mirror of
https://github.com/davegallant/rfd-fyi.git
synced 2026-03-03 17:46:35 +00:00
Compare commits
45 Commits
davegallan
...
faf27839e7
| Author | SHA1 | Date | |
|---|---|---|---|
| faf27839e7 | |||
| 54c5a7f7c5 | |||
| 20f294b8d7 | |||
| b6d6c23eeb | |||
| fb9f52cfc6 | |||
| 816438430e | |||
| c13bd92c2b | |||
| ea871e3fb4 | |||
| d523c31953 | |||
| 928ee46b9d | |||
| ca58af6a57 | |||
| 640feea592 | |||
| 45dfa503aa | |||
| 87f98fa8c0 | |||
| e8dc79f981 | |||
| 985519f850 | |||
| 8c58cd466d | |||
| 61492157c3 | |||
| 2176a49ce2 | |||
| fe616c06c3 | |||
| a091f0ef0e | |||
| 1e69b2b57e | |||
|
|
3c93910723 | ||
|
|
e2882c2e3a | ||
|
|
73ea77e935 | ||
|
|
6bf5cd8e19 | ||
|
|
ba0d5c592a | ||
| 7a3ff92e06 | |||
|
|
6c0109684c | ||
|
|
8436524f67 | ||
|
|
f268097e89 | ||
|
|
f68acccc06 | ||
|
|
210898bbc4 | ||
|
|
dfab73666a | ||
|
|
8184d1746f | ||
|
|
f78d9d4eda | ||
|
|
777b0b02dc | ||
|
|
f270e0ebfa | ||
|
|
15d8223278 | ||
|
|
94d5e44768 | ||
|
|
c0cfeb7897 | ||
|
|
ecfe0b35c2 | ||
|
|
0d9e05b296 | ||
|
|
d4bd76f89b | ||
| 76ca6fe575 |
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
dist/
|
||||||
|
node_modules/
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@ backend/bin/
|
|||||||
.vscode
|
.vscode
|
||||||
*.pem
|
*.pem
|
||||||
.env
|
.env
|
||||||
|
.direnv
|
||||||
|
.envrc.local
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
{
|
||||||
|
auto_https off
|
||||||
|
}
|
||||||
|
|
||||||
:80 {
|
:80 {
|
||||||
file_server
|
file_server
|
||||||
reverse_proxy /api/* backend:8080
|
reverse_proxy /api/* rfd-fyi-backend:8080
|
||||||
}
|
}
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -15,7 +15,7 @@ help:
|
|||||||
|
|
||||||
## backend: Build and run the backend from source
|
## backend: Build and run the backend from source
|
||||||
backend:
|
backend:
|
||||||
@cd backend && go run .
|
@cd backend && CGO_ENABLED=0 go run .
|
||||||
.PHONY: backend
|
.PHONY: backend
|
||||||
|
|
||||||
## frontend: Build and run the frontend from source
|
## frontend: Build and run the frontend from source
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# syntax=docker/dockerfile:1.20
|
# syntax=docker/dockerfile:1.21
|
||||||
FROM cgr.dev/chainguard/go:latest as build
|
FROM cgr.dev/chainguard/go:latest AS build
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
|
|||||||
102
backend/app.go
102
backend/app.go
@@ -63,6 +63,7 @@ func (a *App) Run(httpPort string) {
|
|||||||
|
|
||||||
func (a *App) initializeRoutes() {
|
func (a *App) initializeRoutes() {
|
||||||
a.Router.HandleFunc("/topics", a.listTopics).Methods("GET")
|
a.Router.HandleFunc("/topics", a.listTopics).Methods("GET")
|
||||||
|
a.Router.HandleFunc("/topics/{id}", a.getTopicDetails).Methods("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
// func respondWithError(w http.ResponseWriter, code int, message string) {
|
// func respondWithError(w http.ResponseWriter, code int, message string) {
|
||||||
@@ -87,12 +88,97 @@ func (a *App) listTopics(w http.ResponseWriter, r *http.Request) {
|
|||||||
respondWithJSON(w, http.StatusOK, a.CurrentTopics)
|
respondWithJSON(w, http.StatusOK, a.CurrentTopics)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getTopicDetails godoc
|
||||||
|
// @Summary Get detailed information about a specific topic
|
||||||
|
// @Description Fetches full details including recent comments for a topic by ID
|
||||||
|
// @ID get-topic-details
|
||||||
|
// @Param id path int true "Topic ID"
|
||||||
|
// @Router /topics/{id} [get]
|
||||||
|
// @Success 200 {object} TopicDetails
|
||||||
|
func (a *App) getTopicDetails(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
topicID := vars["id"]
|
||||||
|
|
||||||
|
// Find topic in current topics
|
||||||
|
var topic *Topic
|
||||||
|
for i := range a.CurrentTopics {
|
||||||
|
if fmt.Sprintf("%d", a.CurrentTopics[i].TopicID) == topicID {
|
||||||
|
topic = &a.CurrentTopics[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if topic == nil {
|
||||||
|
respondWithJSON(w, http.StatusNotFound, map[string]string{"error": "Topic not found"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch detailed info from RFD API
|
||||||
|
requestURL := fmt.Sprintf("https://forums.redflagdeals.com/api/topics/%s", topicID)
|
||||||
|
res, err := http.Get(requestURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("error fetching topic details: %s\n", err)
|
||||||
|
respondWithJSON(w, http.StatusInternalServerError, map[string]string{"error": "Failed to fetch details"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("could not read response body: %s\n", err)
|
||||||
|
respondWithJSON(w, http.StatusInternalServerError, map[string]string{"error": "Failed to read response"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var rfdResponse map[string]interface{}
|
||||||
|
err = json.Unmarshal([]byte(body), &rfdResponse)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("could not unmarshal response body: %s", err)
|
||||||
|
respondWithJSON(w, http.StatusInternalServerError, map[string]string{"error": "Failed to parse response"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract relevant fields for tooltip
|
||||||
|
details := TopicDetails{
|
||||||
|
Topic: *topic,
|
||||||
|
Description: extractDescription(rfdResponse),
|
||||||
|
FirstPost: extractFirstPost(rfdResponse),
|
||||||
|
}
|
||||||
|
|
||||||
|
respondWithJSON(w, http.StatusOK, details)
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractDescription(data map[string]interface{}) string {
|
||||||
|
if topic, ok := data["topic"].(map[string]interface{}); ok {
|
||||||
|
if description, ok := topic["description"].(string); ok {
|
||||||
|
return description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractFirstPost(data map[string]interface{}) string {
|
||||||
|
if posts, ok := data["posts"].([]interface{}); ok && len(posts) > 0 {
|
||||||
|
if firstPost, ok := posts[0].(map[string]interface{}); ok {
|
||||||
|
if body, ok := firstPost["body"].(string); ok {
|
||||||
|
// Truncate to first 200 characters
|
||||||
|
if len(body) > 200 {
|
||||||
|
return body[:200] + "..."
|
||||||
|
}
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) refreshTopics() {
|
func (a *App) refreshTopics() {
|
||||||
for {
|
for {
|
||||||
log.Info().Msg("Refreshing topics")
|
log.Info().Msg("Refreshing topics")
|
||||||
latestTopics := a.getDeals(9, 1, 6)
|
latestTopics := a.getDeals(9, 1, 6)
|
||||||
|
|
||||||
if len(latestTopics) > 0 {
|
if len(latestTopics) > 0 {
|
||||||
|
latestTopics = a.deduplicateTopics(latestTopics)
|
||||||
latestTopics = a.updateScores(latestTopics)
|
latestTopics = a.updateScores(latestTopics)
|
||||||
|
|
||||||
log.Info().Msg("Refreshing redirects")
|
log.Info().Msg("Refreshing redirects")
|
||||||
@@ -146,6 +232,22 @@ func (a *App) stripRedirects(t []Topic) []Topic {
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) deduplicateTopics(topics []Topic) []Topic {
|
||||||
|
seen := make(map[uint]bool)
|
||||||
|
var deduplicated []Topic
|
||||||
|
|
||||||
|
for _, topic := range topics {
|
||||||
|
if !seen[topic.TopicID] {
|
||||||
|
seen[topic.TopicID] = true
|
||||||
|
deduplicated = append(deduplicated, topic)
|
||||||
|
} else {
|
||||||
|
log.Debug().Msgf("Removing duplicate topic: %d", topic.TopicID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deduplicated
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) isSponsor(t Topic) bool {
|
func (a *App) isSponsor(t Topic) bool {
|
||||||
return strings.HasPrefix(t.Title, "[Sponsored]")
|
return strings.HasPrefix(t.Title, "[Sponsored]")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/davegallant/rfd-fyi
|
module github.com/davegallant/rfd-fyi
|
||||||
|
|
||||||
go 1.18
|
go 1.26
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/dlclark/regexp2 v1.11.5
|
github.com/dlclark/regexp2 v1.11.5
|
||||||
|
|||||||
@@ -27,3 +27,9 @@ type Offer struct {
|
|||||||
DealerName string `json:"dealer_name"`
|
DealerName string `json:"dealer_name"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
} // @name Offer
|
} // @name Offer
|
||||||
|
|
||||||
|
type TopicDetails struct {
|
||||||
|
Topic Topic `json:"topic"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
FirstPost string `json:"first_post"`
|
||||||
|
} // @name TopicDetails
|
||||||
|
|||||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1771008912,
|
||||||
|
"narHash": "sha256-gf2AmWVTs8lEq7z/3ZAsgnZDhWIckkb+ZnAo5RzSxJg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "a82ccc39b39b621151d6732718e3e250109076fa",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
51
flake.nix
Normal file
51
flake.nix
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
description = "rfd-fyi development environment";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# Node.js LTS with npm
|
||||||
|
nodejs_20
|
||||||
|
|
||||||
|
# Go for backend
|
||||||
|
go
|
||||||
|
|
||||||
|
# Build tools
|
||||||
|
pkg-config
|
||||||
|
|
||||||
|
# Development utilities
|
||||||
|
git
|
||||||
|
curl
|
||||||
|
jq
|
||||||
|
|
||||||
|
# Optional: for better development experience
|
||||||
|
gnumake
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
echo "🚀 rfd-fyi development environment loaded"
|
||||||
|
echo "Available commands:"
|
||||||
|
echo " Frontend: npm install, npm run build, npm run serve"
|
||||||
|
echo " Backend: cd backend && CGO_ENABLED=0 go run ."
|
||||||
|
echo ""
|
||||||
|
echo "Node version: $(node --version)"
|
||||||
|
echo "npm version: $(npm --version)"
|
||||||
|
echo "Go version: $(go version)"
|
||||||
|
echo ""
|
||||||
|
echo "Tip: Run 'npm install' to install frontend dependencies"
|
||||||
|
echo "Tip: Vite is available via 'npx vite' or 'npm run build'"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
59
index.html
59
index.html
@@ -1,21 +1,69 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="" data-bs-theme="dark">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||||
<meta name="description" content="An overlay of rfd deals" />
|
<meta name="description" content="An alternative frontend for hot deals" />
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.png" />
|
|
||||||
|
<!-- DNS prefetch for faster Google Fonts resolution -->
|
||||||
|
<link rel="dns-prefetch" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="dns-prefetch" href="https://fonts.gstatic.com" />
|
||||||
|
|
||||||
|
<!-- Preconnect for faster font loading -->
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
|
||||||
|
<link rel="icon" href="/favicon.png" />
|
||||||
|
|
||||||
|
<!-- Load Material Symbols font with optimal display settings -->
|
||||||
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block"
|
||||||
/>
|
/>
|
||||||
<title>rfd-fyi - An overlay of hot deals</title>
|
|
||||||
|
<title>rfd-fyi - An alternative frontend for hot deals</title>
|
||||||
|
|
||||||
|
<!-- Analytics - loaded async/defer so it doesn't block page -->
|
||||||
<script
|
<script
|
||||||
|
async
|
||||||
defer
|
defer
|
||||||
src="https://umami.davegallant.ca/script.js"
|
src="https://umami.davegallant.ca/script.js"
|
||||||
data-website-id="59ffe8be-509a-471e-8cd6-a63c5b35b7aa"
|
data-website-id="59ffe8be-509a-471e-8cd6-a63c5b35b7aa"
|
||||||
></script>
|
></script>
|
||||||
|
|
||||||
|
<!-- Theme detection script - runs before Vue loads to prevent flash of unstyled content -->
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
// Check for saved theme preference only
|
||||||
|
const savedTheme = localStorage.getItem('theme');
|
||||||
|
if (!savedTheme) {
|
||||||
|
return; // Let Vue handle default theme
|
||||||
|
}
|
||||||
|
|
||||||
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
let theme = savedTheme;
|
||||||
|
|
||||||
|
// Handle 'auto' theme preference
|
||||||
|
if (theme === 'auto') {
|
||||||
|
theme = prefersDark ? 'dark' : 'light';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply theme to html element
|
||||||
|
document.documentElement.setAttribute('data-bs-theme', theme);
|
||||||
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
|
|
||||||
|
// Apply theme classes
|
||||||
|
if (theme === 'dark') {
|
||||||
|
document.documentElement.classList.add('dark-theme');
|
||||||
|
document.documentElement.classList.remove('light-theme');
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.add('light-theme');
|
||||||
|
document.documentElement.classList.remove('dark-theme');
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>
|
<noscript>
|
||||||
@@ -26,6 +74,5 @@
|
|||||||
</noscript>
|
</noscript>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.js"></script>
|
<script type="module" src="/src/main.js"></script>
|
||||||
<!-- built files will be auto injected -->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
1183
package-lock.json
generated
1183
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -16,13 +16,10 @@
|
|||||||
"axios": "^1.12.0",
|
"axios": "^1.12.0",
|
||||||
"core-js": "^3.32.1",
|
"core-js": "^3.32.1",
|
||||||
"cssnano": "^7.0.0",
|
"cssnano": "^7.0.0",
|
||||||
"jquery": "^3.7.0",
|
"dayjs": "^1.11.10",
|
||||||
"moment": "^2.29.4",
|
|
||||||
"vue": "^3.5.17",
|
"vue": "^3.5.17",
|
||||||
"vue-github-button": "^3.0.3",
|
|
||||||
"vue-loading-overlay": "^6.0.3",
|
"vue-loading-overlay": "^6.0.3",
|
||||||
"vue-router": "^4.5.1",
|
"vue-router": "^5.0.0"
|
||||||
"vuetify": "^3.9.6"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.22.10",
|
"@babel/core": "^7.22.10",
|
||||||
@@ -35,10 +32,8 @@
|
|||||||
"eslint-plugin-vue": "^9.17.0",
|
"eslint-plugin-vue": "^9.17.0",
|
||||||
"postcss-cli": "^11.0.0",
|
"postcss-cli": "^11.0.0",
|
||||||
"sass-embedded": "^1.89.2",
|
"sass-embedded": "^1.89.2",
|
||||||
"unplugin-fonts": "^1.3.1",
|
"unplugin-vue-components": "^31.0.0",
|
||||||
"unplugin-vue-components": "^30.0.0",
|
"vite": "^6.3.6"
|
||||||
"vite": "^6.3.6",
|
|
||||||
"vite-plugin-vuetify": "^2.1.1"
|
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
351
src/App.vue
351
src/App.vue
@@ -1,46 +1,180 @@
|
|||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import moment from "moment";
|
import dayjs from "dayjs";
|
||||||
import Loading from "vue-loading-overlay";
|
import utc from "dayjs/plugin/utc";
|
||||||
import { install } from "@github/hotkey";
|
|
||||||
|
|
||||||
import "vue-loading-overlay/dist/css/index.css";
|
import "./theme.css";
|
||||||
import { ref } from "vue";
|
|
||||||
|
dayjs.extend(utc);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
ascending: this.ascending,
|
filter: decodeURIComponent(window.location.href.split("filter=")[1] || ""),
|
||||||
filter: window.location.href.split("filter=")[1] || "",
|
sortMethod: "score",
|
||||||
sortColumn: this.sortColumn,
|
|
||||||
topics: [],
|
topics: [],
|
||||||
|
isMobile: false,
|
||||||
|
currentTheme: "auto",
|
||||||
|
darkModeQuery: null,
|
||||||
|
themeChangeHandler: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
window.addEventListener("keydown", this.handleKeyDown);
|
window.addEventListener("keydown", this.handleKeyDown);
|
||||||
|
window.addEventListener("resize", this.handleResize);
|
||||||
|
this.detectMobile();
|
||||||
this.fetchDeals();
|
this.fetchDeals();
|
||||||
|
this.initializeSortMethod();
|
||||||
|
this.initializeTheme();
|
||||||
|
this.setupThemeListener();
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
window.removeEventListener("keydown", this.handleKeyDown);
|
window.removeEventListener("keydown", this.handleKeyDown);
|
||||||
|
window.removeEventListener("resize", this.handleResize);
|
||||||
|
if (this.darkModeQuery && this.themeChangeHandler) {
|
||||||
|
this.darkModeQuery.removeEventListener("change", this.themeChangeHandler);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
filteredTopics() {
|
||||||
|
const filterTerm = this.filter.toLowerCase();
|
||||||
|
|
||||||
|
const filtered = this.topics.filter((row) => {
|
||||||
|
const searchText = `${row.title} [${row.Offer.dealer_name}]`.toLowerCase();
|
||||||
|
return searchText.includes(filterTerm);
|
||||||
|
});
|
||||||
|
|
||||||
|
const sortFns = {
|
||||||
|
score: (a, b) => b.score - a.score,
|
||||||
|
views: (a, b) => b.total_views - a.total_views,
|
||||||
|
recency: (a, b) => new Date(b.last_post_time) - new Date(a.last_post_time),
|
||||||
|
};
|
||||||
|
|
||||||
|
return filtered.sort(sortFns[this.sortMethod] || sortFns.score);
|
||||||
|
},
|
||||||
|
|
||||||
|
themeIcon() {
|
||||||
|
const icons = { auto: "brightness_auto", dark: "dark_mode", light: "light_mode" };
|
||||||
|
return icons[this.currentTheme];
|
||||||
|
},
|
||||||
|
|
||||||
|
themeTitle() {
|
||||||
|
const titles = {
|
||||||
|
auto: "Theme: Auto (click for Light)",
|
||||||
|
light: "Theme: Light (click for Dark)",
|
||||||
|
dark: "Theme: Dark (click for Auto)",
|
||||||
|
};
|
||||||
|
return titles[this.currentTheme];
|
||||||
|
},
|
||||||
|
|
||||||
|
sortIcon() {
|
||||||
|
const icons = { score: "trending_up", views: "visibility", recency: "schedule" };
|
||||||
|
return icons[this.sortMethod];
|
||||||
|
},
|
||||||
|
|
||||||
|
sortTitle() {
|
||||||
|
const titles = {
|
||||||
|
score: "Sort by Score (click for Views)",
|
||||||
|
views: "Sort by Views (click for Recency)",
|
||||||
|
recency: "Sort by Recency (click for Score)",
|
||||||
|
};
|
||||||
|
return titles[this.sortMethod];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
formatDate(dateString) {
|
||||||
|
return dayjs(String(dateString)).format("YYYY-MM-DD hh:mm A");
|
||||||
|
},
|
||||||
|
|
||||||
|
highlightText(text) {
|
||||||
|
if (!this.filter) return text;
|
||||||
|
|
||||||
|
const lowerText = text.toLowerCase();
|
||||||
|
const lowerFilter = this.filter.toLowerCase();
|
||||||
|
|
||||||
|
if (!lowerText.includes(lowerFilter)) return text;
|
||||||
|
|
||||||
|
const regex = new RegExp(this.filter, "ig");
|
||||||
|
return text.replace(regex, (match) => `<mark>${match}</mark>`);
|
||||||
|
},
|
||||||
|
|
||||||
|
initializeTheme() {
|
||||||
|
const savedTheme = localStorage.getItem("theme") || "auto";
|
||||||
|
this.currentTheme = savedTheme;
|
||||||
|
this.applyTheme(savedTheme, true);
|
||||||
|
},
|
||||||
|
|
||||||
|
setupThemeListener() {
|
||||||
|
this.darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
|
||||||
|
this.themeChangeHandler = (e) => {
|
||||||
|
const savedTheme = localStorage.getItem("theme");
|
||||||
|
if (savedTheme === "auto" || !savedTheme) {
|
||||||
|
this.applyThemeActual(e.matches ? "dark" : "light");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.darkModeQuery.addEventListener("change", this.themeChangeHandler);
|
||||||
|
},
|
||||||
|
|
||||||
|
applyTheme(theme, skipSave = false) {
|
||||||
|
this.currentTheme = theme;
|
||||||
|
|
||||||
|
if (!skipSave) {
|
||||||
|
localStorage.setItem("theme", theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
let actualTheme = theme;
|
||||||
|
if (theme === "auto") {
|
||||||
|
actualTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.applyThemeActual(actualTheme);
|
||||||
|
},
|
||||||
|
|
||||||
|
applyThemeActual(theme) {
|
||||||
|
document.documentElement.setAttribute("data-bs-theme", theme);
|
||||||
|
document.documentElement.classList.toggle("dark-theme", theme === "dark");
|
||||||
|
document.documentElement.classList.toggle("light-theme", theme === "light");
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleTheme() {
|
||||||
|
const cycle = { auto: "light", light: "dark", dark: "auto" };
|
||||||
|
this.applyTheme(cycle[this.currentTheme]);
|
||||||
|
},
|
||||||
|
|
||||||
|
detectMobile() {
|
||||||
|
const hasTouch =
|
||||||
|
"ontouchstart" in window ||
|
||||||
|
navigator.maxTouchPoints > 0 ||
|
||||||
|
navigator.msMaxTouchPoints > 0;
|
||||||
|
|
||||||
|
const isMobileScreen = window.innerWidth <= 1024;
|
||||||
|
this.isMobile = hasTouch || isMobileScreen;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleResize() {
|
||||||
|
this.detectMobile();
|
||||||
|
},
|
||||||
|
|
||||||
handleKeyDown(event) {
|
handleKeyDown(event) {
|
||||||
const isInput = ["INPUT", "TEXTAREA"].includes(
|
const isInput = ["INPUT", "TEXTAREA"].includes(document.activeElement.tagName);
|
||||||
document.activeElement.tagName
|
|
||||||
);
|
|
||||||
if (event.key === "/" && !isInput) {
|
if (event.key === "/" && !isInput) {
|
||||||
event.preventDefault(); // prevent typing `/` into whatever is focused
|
event.preventDefault();
|
||||||
this.$refs.filter.focus();
|
this.$refs.filter.focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createFilterRoute(params) {
|
createFilterRoute(params) {
|
||||||
this.$refs.filter.blur();
|
this.$refs.filter.blur();
|
||||||
history.pushState(
|
history.pushState({}, null, `${window.location.origin}#/filter=${encodeURIComponent(params)}`);
|
||||||
{},
|
|
||||||
null,
|
|
||||||
`${window.location.origin}#/filter=${encodeURIComponent(params)}`
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchDeals() {
|
fetchDeals() {
|
||||||
axios
|
axios
|
||||||
.get("api/v1/topics")
|
.get("api/v1/topics")
|
||||||
@@ -48,127 +182,102 @@ export default {
|
|||||||
this.topics = response.data;
|
this.topics = response.data;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err.response);
|
console.error("Failed to fetch deals:", err.response || err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
formatDate() {
|
|
||||||
return (v) => {
|
|
||||||
return moment(String(v)).format("hh:mm A z (MM/DD)");
|
|
||||||
};
|
|
||||||
},
|
|
||||||
filteredTopics() {
|
|
||||||
return this.topics.filter((row) => {
|
|
||||||
const titles = (
|
|
||||||
row.title.toString() +
|
|
||||||
" [" +
|
|
||||||
row.Offer.dealer_name +
|
|
||||||
"]"
|
|
||||||
).toLowerCase();
|
|
||||||
const filterTerm = this.filter.toLowerCase();
|
|
||||||
return titles.includes(filterTerm);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
highlightMatches() {
|
|
||||||
return (v) => {
|
|
||||||
if (this.filter == "") return v;
|
|
||||||
const matchExists = v.toLowerCase().includes(this.filter.toLowerCase());
|
|
||||||
if (!matchExists) return v;
|
|
||||||
|
|
||||||
const re = new RegExp(this.filter, "ig");
|
initializeSortMethod() {
|
||||||
return v.replace(re, (matchedText) => `<mark>${matchedText}</mark>`);
|
const saved = localStorage.getItem("sortMethod");
|
||||||
};
|
if (saved) {
|
||||||
|
this.sortMethod = saved;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleSort() {
|
||||||
|
const cycle = { score: "views", views: "recency", recency: "score" };
|
||||||
|
this.sortMethod = cycle[this.sortMethod];
|
||||||
|
localStorage.setItem("sortMethod", this.sortMethod);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const headers = [
|
|
||||||
{ title: "Deal", value: "title", align: "center" },
|
|
||||||
{ title: "Score", value: "score", align: "center", sortable: true },
|
|
||||||
{ title: "Views", value: "total_views", align: "center", sortable: true },
|
|
||||||
{
|
|
||||||
title: "Last Post",
|
|
||||||
value: "last_post_time",
|
|
||||||
align: "center",
|
|
||||||
sortable: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const sortBy = ref([{ key: "score", order: "desc" }]); // Vuetify 3 format
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<v-app>
|
<div id="app">
|
||||||
<v-main>
|
<div class="container">
|
||||||
<link rel="shortcut icon" type="image/png" href="/favicon.png" />
|
<div class="header">
|
||||||
<body>
|
<div class="header-controls">
|
||||||
<v-text-field
|
<input
|
||||||
v-model="filter"
|
|
||||||
label="Filter"
|
|
||||||
ref="filter"
|
ref="filter"
|
||||||
|
v-model="filter"
|
||||||
|
type="text"
|
||||||
|
placeholder="Filter deals"
|
||||||
|
class="search-input"
|
||||||
@keyup.enter="createFilterRoute(filter.toString())"
|
@keyup.enter="createFilterRoute(filter.toString())"
|
||||||
@keyup.esc="$refs.filter.blur()"
|
@keyup.esc="$refs.filter.blur()"
|
||||||
hide-details="true"
|
|
||||||
/>
|
/>
|
||||||
<v-data-table
|
<button class="icon-button" :title="sortTitle" @click="toggleSort">
|
||||||
:headers="headers"
|
<span class="material-symbols-outlined">{{ sortIcon }}</span>
|
||||||
:items="filteredTopics"
|
</button>
|
||||||
:sort-by="sortColumn"
|
<button class="icon-button" :title="themeTitle" @click="toggleTheme">
|
||||||
v-model:sortBy="sortBy"
|
<span class="material-symbols-outlined">{{ themeIcon }}</span>
|
||||||
:items-per-page="25"
|
</button>
|
||||||
>
|
</div>
|
||||||
<template #item.title="{ item }">
|
</div>
|
||||||
|
|
||||||
|
<div class="cards-grid">
|
||||||
|
<div v-for="topic in filteredTopics" :key="topic.topic_id" class="deal-card">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="title-with-link">
|
||||||
<a
|
<a
|
||||||
:href="`https://forums.redflagdeals.com${item.web_path}`"
|
:href="`https://forums.redflagdeals.com${topic.web_path}`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
v-html="
|
class="deal-title"
|
||||||
highlightMatches(
|
v-html="highlightText(topic.title)"
|
||||||
item.title + ' [' + item.Offer.dealer_name + '] '
|
|
||||||
)
|
|
||||||
"
|
|
||||||
></a>
|
></a>
|
||||||
<a :href="item.Offer.url" target="_blank" v-if="item.Offer.url">
|
<a
|
||||||
<span class="material-symbols-outlined"> link </span>
|
v-if="topic.Offer.url"
|
||||||
</a>
|
:href="topic.Offer.url"
|
||||||
<span v-else class="material-symbols-outlined"> link_off </span>
|
target="_blank"
|
||||||
</template>
|
class="card-link"
|
||||||
|
title="Open deal"
|
||||||
<template #item.score="{ item }">
|
|
||||||
<span v-if="item.score > 0" class="green-score"
|
|
||||||
>+{{ item.score }}</span
|
|
||||||
>
|
>
|
||||||
<span v-else-if="item.score < 0" class="red-score">{{
|
<span class="material-symbols-outlined">open_in_new</span>
|
||||||
item.score
|
</a>
|
||||||
}}</span>
|
</div>
|
||||||
<span v-else>{{ item.score }}</span>
|
<div
|
||||||
</template>
|
class="score-bubble"
|
||||||
|
:class="{
|
||||||
|
positive: topic.score > 0,
|
||||||
|
negative: topic.score < 0,
|
||||||
|
neutral: topic.score === 0,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<span v-if="topic.score > 0">+{{ topic.score }}</span>
|
||||||
|
<span v-else>{{ topic.score }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template #item.last_post_time="{ item }">
|
<div class="card-meta">
|
||||||
{{ formatDate(item.last_post_time) }}
|
<span class="dealer-name" v-html="highlightText(topic.Offer.dealer_name)"></span>
|
||||||
</template>
|
</div>
|
||||||
|
|
||||||
<template #loading>
|
<div class="card-details">
|
||||||
<v-progress-linear indeterminate color="grey" />
|
<div class="details-stats">
|
||||||
</template>
|
<div class="stat">
|
||||||
</v-data-table>
|
<span class="material-symbols-outlined">visibility</span>
|
||||||
</body>
|
<span class="stat-value">{{ topic.total_views }} views</span>
|
||||||
</v-main>
|
</div>
|
||||||
</v-app>
|
<div class="stat">
|
||||||
|
<span class="material-symbols-outlined">chat</span>
|
||||||
|
<span class="stat-value">{{ topic.total_replies }} replies</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-timestamp">Last post: {{ formatDate(topic.last_post_time) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
|
||||||
#app {
|
|
||||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
text-align: center;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fixed-bottom {
|
|
||||||
background: #ffc;
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
13
src/main.js
13
src/main.js
@@ -2,11 +2,12 @@ import { createApp } from "vue";
|
|||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import { createRouter, createWebHashHistory } from "vue-router";
|
import { createRouter, createWebHashHistory } from "vue-router";
|
||||||
|
|
||||||
import "./theme.css";
|
const routes = [
|
||||||
|
{
|
||||||
import { registerPlugins } from "@/plugins";
|
path: '/:pathMatch(.*)*',
|
||||||
|
component: App,
|
||||||
const routes = [];
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHashHistory(),
|
history: createWebHashHistory(),
|
||||||
@@ -15,7 +16,5 @@ const router = createRouter({
|
|||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
registerPlugins(app);
|
|
||||||
|
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Plugins
|
|
||||||
|
|
||||||
Plugins are a way to extend the functionality of your Vue application. Use this folder for registering plugins that you want to use globally.
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/**
|
|
||||||
* plugins/index.js
|
|
||||||
*
|
|
||||||
* Automatically included in `./src/main.js`
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Plugins
|
|
||||||
import vuetify from './vuetify'
|
|
||||||
|
|
||||||
export function registerPlugins (app) {
|
|
||||||
app.use(vuetify)
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* plugins/vuetify.js
|
|
||||||
*
|
|
||||||
* Framework documentation: https://vuetifyjs.com`
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Styles
|
|
||||||
import "@mdi/font/css/materialdesignicons.css";
|
|
||||||
import "vuetify/styles";
|
|
||||||
|
|
||||||
const tokyoNight = {
|
|
||||||
dark: true,
|
|
||||||
colors: {
|
|
||||||
background: "#1a1b26",
|
|
||||||
surface: "#24283b",
|
|
||||||
primary: "#7aa2f7",
|
|
||||||
secondary: "#b4f9f8",
|
|
||||||
accent: "#ff9e64",
|
|
||||||
error: "#f7768e",
|
|
||||||
info: "#2ac3de",
|
|
||||||
success: "#9ece6a",
|
|
||||||
warning: "#e0af68",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Composables
|
|
||||||
import { createVuetify } from "vuetify";
|
|
||||||
|
|
||||||
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
|
|
||||||
export default createVuetify({
|
|
||||||
theme: {
|
|
||||||
defaultTheme: "tokyoNight",
|
|
||||||
themes: { tokyoNight },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
458
src/theme.css
458
src/theme.css
@@ -1,54 +1,440 @@
|
|||||||
body {
|
/* Material Symbols Icon Font */
|
||||||
max-width: 100%;
|
.material-symbols-outlined {
|
||||||
|
font-family: 'Material Symbols Outlined';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 1;
|
||||||
|
letter-spacing: normal;
|
||||||
|
text-transform: none;
|
||||||
|
display: inline-block;
|
||||||
|
white-space: nowrap;
|
||||||
|
word-wrap: normal;
|
||||||
|
direction: ltr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Theme Variables
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* Light theme (default) */
|
||||||
|
--bg-primary: #dddddd;
|
||||||
|
--bg-secondary: #e8e8e8;
|
||||||
|
--bg-input: #f5f5f5;
|
||||||
|
--bg-input-focus: #ffffff;
|
||||||
|
--text-primary: #212529;
|
||||||
|
--text-secondary: #6c757d;
|
||||||
|
--border-color: #d0d0d0;
|
||||||
|
--border-color-light: #cccccc;
|
||||||
|
--border-color-hover: #999999;
|
||||||
|
--link-color: #212529;
|
||||||
|
--score-positive-bg: rgb(34, 139, 34);
|
||||||
|
--score-positive-text: white;
|
||||||
|
--score-negative-bg: rgb(247, 118, 142);
|
||||||
|
--score-negative-text: white;
|
||||||
|
--mark-bg: rgba(255, 193, 7, 0.3);
|
||||||
|
--shadow-light: rgba(0, 0, 0, 0.05);
|
||||||
|
--shadow-medium: rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dark theme via media query */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-bs-theme="light"]):not(.light-theme) {
|
||||||
|
--bg-primary: #1a1a1a;
|
||||||
|
--bg-secondary: #2a2a2a;
|
||||||
|
--bg-input: #1a1a1a;
|
||||||
|
--bg-input-focus: #2a2a2a;
|
||||||
|
--text-primary: #e0e0e0;
|
||||||
|
--text-secondary: #a0a0a0;
|
||||||
|
--border-color: #3a3a3a;
|
||||||
|
--border-color-light: #555555;
|
||||||
|
--border-color-hover: #777777;
|
||||||
|
--link-color: #e0e0e0;
|
||||||
|
--score-positive-bg: rgb(158, 206, 106);
|
||||||
|
--score-positive-text: #1a1a1a;
|
||||||
|
--mark-bg: rgba(255, 193, 7, 0.4);
|
||||||
|
--shadow-light: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Explicit dark theme */
|
||||||
|
html[data-bs-theme="dark"],
|
||||||
|
html.dark-theme {
|
||||||
|
--bg-primary: #1a1a1a;
|
||||||
|
--bg-secondary: #2a2a2a;
|
||||||
|
--bg-input: #1a1a1a;
|
||||||
|
--bg-input-focus: #2a2a2a;
|
||||||
|
--text-primary: #e0e0e0;
|
||||||
|
--text-secondary: #a0a0a0;
|
||||||
|
--border-color: #3a3a3a;
|
||||||
|
--border-color-light: #555555;
|
||||||
|
--border-color-hover: #777777;
|
||||||
|
--link-color: #e0e0e0;
|
||||||
|
--score-positive-bg: rgb(158, 206, 106);
|
||||||
|
--score-positive-text: #1a1a1a;
|
||||||
|
--mark-bg: rgba(255, 193, 7, 0.4);
|
||||||
|
--shadow-light: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Explicit light theme */
|
||||||
|
html[data-bs-theme="light"],
|
||||||
|
html.light-theme {
|
||||||
|
--bg-primary: #dddddd;
|
||||||
|
--bg-secondary: #e8e8e8;
|
||||||
|
--bg-input: #f5f5f5;
|
||||||
|
--bg-input-focus: #ffffff;
|
||||||
|
--text-primary: #212529;
|
||||||
|
--text-secondary: #6c757d;
|
||||||
|
--border-color: #d0d0d0;
|
||||||
|
--border-color-light: #cccccc;
|
||||||
|
--border-color-hover: #999999;
|
||||||
|
--link-color: #212529;
|
||||||
|
--score-positive-bg: rgb(34, 139, 34);
|
||||||
|
--score-positive-text: white;
|
||||||
|
--mark-bg: rgba(255, 193, 7, 0.3);
|
||||||
|
--shadow-light: rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Base Styles
|
||||||
|
============================================ */
|
||||||
|
|
||||||
html {
|
html {
|
||||||
font-family: sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
-ms-text-size-adjust: 100%;
|
-ms-text-size-adjust: 100%;
|
||||||
|
background-color: var(--bg-primary);
|
||||||
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
body {
|
||||||
background: #212529;
|
max-width: 100%;
|
||||||
color: white;
|
background-color: var(--bg-primary);
|
||||||
padding: 3px;
|
color: var(--text-primary);
|
||||||
padding-right: 10px;
|
transition: background-color 0.3s ease, color 0.3s ease;
|
||||||
padding-left: 10px;
|
margin: 0;
|
||||||
}
|
padding: 0;
|
||||||
|
|
||||||
.footer-left {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-right {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.green-score {
|
|
||||||
color: rgb(158, 206, 106) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.red-score {
|
|
||||||
color: rgb(247, 118, 142) !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--v-theme-primary);
|
color: var(--link-color);
|
||||||
}
|
transition: color 0.2s ease;
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: #d65d03;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a:visited {
|
a:visited {
|
||||||
color: #53514f;
|
color: var(--link-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 769px) {
|
/* ============================================
|
||||||
.v-data-table-header th,
|
Layout
|
||||||
.v-data-table__td,
|
============================================ */
|
||||||
.v-data-footer {
|
|
||||||
font-size: 1.2rem;
|
.container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: var(--bg-primary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-controls {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Search Input
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
flex: 1;
|
||||||
|
max-width: 500px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
border: 1px solid var(--border-color-light);
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: var(--bg-input);
|
||||||
|
color: var(--text-primary);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
background-color: var(--bg-input-focus);
|
||||||
|
box-shadow: 0 0 0 2px var(--shadow-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input::placeholder {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Icon Buttons (Theme & Sort Toggle)
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.icon-button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border: 1px solid var(--border-color-light);
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: var(--bg-input);
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
font-size: 18px;
|
||||||
|
padding: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-button:hover {
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-button:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Legacy class names for compatibility */
|
||||||
|
.sort-toggle,
|
||||||
|
.theme-toggle {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border: 1px solid var(--border-color-light);
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: var(--bg-input);
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
font-size: 18px;
|
||||||
|
padding: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sort-toggle:hover,
|
||||||
|
.theme-toggle:hover {
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sort-toggle:active,
|
||||||
|
.theme-toggle:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Cards Grid
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.cards-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
||||||
|
gap: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deal-card {
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
border: 1.5px solid #aaaaaa;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
min-height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deal-card:hover {
|
||||||
|
box-shadow: 0 4px 8px var(--shadow-medium);
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Card Header
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-with-link {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 6px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deal-title {
|
||||||
|
color: var(--link-color);
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1.4;
|
||||||
|
flex: 1;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deal-title:visited {
|
||||||
|
color: var(--link-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deal-title:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--link-color);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-link:hover {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-link .material-symbols-outlined {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Score Bubble
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.score-bubble {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 50px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 12px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
padding: 0 8px;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-bubble.positive {
|
||||||
|
background-color: var(--score-positive-bg);
|
||||||
|
color: var(--score-positive-text);
|
||||||
|
box-shadow: 0 1px 3px rgba(34, 139, 34, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-bubble.negative {
|
||||||
|
background-color: var(--score-negative-bg);
|
||||||
|
color: var(--score-negative-text);
|
||||||
|
box-shadow: 0 1px 3px rgba(247, 118, 142, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-bubble.neutral {
|
||||||
|
background-color: var(--text-secondary);
|
||||||
|
color: var(--bg-primary);
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Card Meta & Details
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.card-meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dealer-name {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-details {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-stats {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat .material-symbols-outlined {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-timestamp {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Mark Highlighting
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
mark {
|
||||||
|
background-color: var(--mark-bg);
|
||||||
|
color: inherit;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
Mobile Responsive
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.cards-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
// Plugins
|
// Plugins
|
||||||
import Components from "unplugin-vue-components/vite";
|
import Components from "unplugin-vue-components/vite";
|
||||||
import Vue from "@vitejs/plugin-vue";
|
import Vue from "@vitejs/plugin-vue";
|
||||||
import Vuetify, { transformAssetUrls } from "vite-plugin-vuetify";
|
|
||||||
import Fonts from "unplugin-fonts/vite";
|
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
@@ -11,27 +9,9 @@ import { fileURLToPath, URL } from "node:url";
|
|||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
Vue({
|
Vue(),
|
||||||
template: { transformAssetUrls },
|
|
||||||
}),
|
|
||||||
// https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme
|
|
||||||
Vuetify(),
|
|
||||||
Components(),
|
Components(),
|
||||||
Fonts({
|
|
||||||
fontsource: {
|
|
||||||
families: [
|
|
||||||
{
|
|
||||||
name: "Roboto",
|
|
||||||
weights: [100, 300, 400, 500, 700, 900],
|
|
||||||
styles: ["normal", "italic"],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
optimizeDeps: {
|
|
||||||
exclude: ["vuetify"],
|
|
||||||
},
|
|
||||||
define: { "process.env": {} },
|
define: { "process.env": {} },
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
@@ -55,4 +35,36 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
build: {
|
||||||
|
target: "esnext",
|
||||||
|
minify: "terser",
|
||||||
|
terserOptions: {
|
||||||
|
compress: {
|
||||||
|
drop_console: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
manualChunks: {
|
||||||
|
"vendor": ["axios", "dayjs", "vue-router", "vue-loading-overlay"],
|
||||||
|
},
|
||||||
|
chunkFileNames: "js/[name].[hash].js",
|
||||||
|
entryFileNames: "js/[name].[hash].js",
|
||||||
|
assetFileNames: (assetInfo) => {
|
||||||
|
const info = assetInfo.name.split(".");
|
||||||
|
const ext = info[info.length - 1];
|
||||||
|
if (/png|jpe?g|gif|tiff|bmp|ico/i.test(ext)) {
|
||||||
|
return `images/[name].[hash][extname]`;
|
||||||
|
} else if (/woff|woff2|eot|ttf|otf/i.test(ext)) {
|
||||||
|
return `fonts/[name].[hash][extname]`;
|
||||||
|
} else if (ext === "css") {
|
||||||
|
return `css/[name].[hash][extname]`;
|
||||||
|
}
|
||||||
|
return `[name].[hash][extname]`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
chunkSizeWarningLimit: 1000,
|
||||||
|
reportCompressedSize: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user