From 96b297f6170dca1b49fddce5dccd10428457581d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=85=83=E7=9A=93?= Date: Wed, 14 May 2025 18:52:14 +0800 Subject: [PATCH] Refactor API endpoints to use cached data and update Code of Conduct to Contributor Covenant --- CODE_OF_CONDUCT.md.md | 129 +++++++++++++++++- bun.lock | 10 ++ components/app/windows/aboutNewsOrg.vue | 2 +- components/app/windows/chatbot.vue | 28 ++-- components/app/windows/hotnews.vue | 2 +- components/app/windows/sources.vue | 2 +- components/app/windows/tty.vue | 9 +- createDatabase.ts | 7 +- nuxt.config.ts | 2 +- package.json | 2 + pages/app/desktop/index.vue | 38 +++++- scraping/hotnews_data.json | 2 +- .../{ => cached}/getData/fetchNewsOrgInfo.ts | 0 .../{ => cached}/getData/fetchSidebarData.ts | 0 .../api/{ => cached}/getData/fetchSources.ts | 0 server/api/{ => cached}/rss/google.ts | 0 tailwind.config.js | 5 +- 17 files changed, 207 insertions(+), 31 deletions(-) rename server/api/{ => cached}/getData/fetchNewsOrgInfo.ts (100%) rename server/api/{ => cached}/getData/fetchSidebarData.ts (100%) rename server/api/{ => cached}/getData/fetchSources.ts (100%) rename server/api/{ => cached}/rss/google.ts (100%) diff --git a/CODE_OF_CONDUCT.md.md b/CODE_OF_CONDUCT.md.md index 2fe822c..edcc30b 100644 --- a/CODE_OF_CONDUCT.md.md +++ b/CODE_OF_CONDUCT.md.md @@ -1 +1,128 @@ -# Code of conduct +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +report@yuanhau.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. \ No newline at end of file diff --git a/bun.lock b/bun.lock index 5457278..e4c958d 100644 --- a/bun.lock +++ b/bun.lock @@ -37,10 +37,12 @@ "rss-parser": "^3.13.0", "shadcn-nuxt": "2.1.0", "tailwind-merge": "^3.2.0", + "tailwind-scrollbar": "^4.0.2", "tailwindcss": "3", "tailwindcss-animate": "^1.0.7", "tailwindcss-animatecss": "^3.0.5", "uploadthing": "^7.6.0", + "uuid": "^11.1.0", "vue": "^3.5.13", "vue-router": "^4.5.1", }, @@ -684,6 +686,8 @@ "@types/pg-pool": ["@types/pg-pool@2.0.6", "", { "dependencies": { "@types/pg": "*" } }, "sha512-TaAUE5rq2VQYxab5Ts7WZhKNmuN78Q6PiFonTDdpbx8a1H0M1vhy3rhiMjl+e2iHmogyMw7jZF4FrE6eJUy5HQ=="], + "@types/prismjs": ["@types/prismjs@1.26.5", "", {}, "sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ=="], + "@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="], "@types/shimmer": ["@types/shimmer@1.2.0", "", {}, "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg=="], @@ -1944,6 +1948,8 @@ "pretty-ms": ["pretty-ms@9.2.0", "", { "dependencies": { "parse-ms": "^4.0.0" } }, "sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg=="], + "prism-react-renderer": ["prism-react-renderer@2.4.1", "", { "dependencies": { "@types/prismjs": "^1.26.0", "clsx": "^2.0.0" }, "peerDependencies": { "react": ">=16.0.0" } }, "sha512-ey8Ls/+Di31eqzUxC46h8MksNuGx/n0AAC8uKpwFau4RPDYLuE3EXTp8N8G2vX2N7UC/+IXeNUnlWBGGcAG+Ig=="], + "process": ["process@0.11.10", "", {}, "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="], "process-nextick-args": ["process-nextick-args@2.0.1", "", {}, "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="], @@ -1984,6 +1990,8 @@ "rc9": ["rc9@2.1.2", "", { "dependencies": { "defu": "^6.1.4", "destr": "^2.0.3" } }, "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg=="], + "react": ["react@19.1.0", "", {}, "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg=="], + "read-cache": ["read-cache@1.0.0", "", { "dependencies": { "pify": "^2.3.0" } }, "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA=="], "read-package-up": ["read-package-up@11.0.0", "", { "dependencies": { "find-up-simple": "^1.0.0", "read-pkg": "^9.0.0", "type-fest": "^4.6.0" } }, "sha512-MbgfoNPANMdb4oRBNg5eqLbB2t2r+o5Ua1pNt8BqGp4I0FJZhuVSOj3PaBPni4azWuSzEdNn2evevzVmEk1ohQ=="], @@ -2168,6 +2176,8 @@ "tailwind-merge": ["tailwind-merge@3.3.0", "", {}, "sha512-fyW/pEfcQSiigd5SNn0nApUOxx0zB/dm6UDU/rEwc2c3sX2smWUNbapHv+QRqLGVp9GWX3THIa7MUGPo+YkDzQ=="], + "tailwind-scrollbar": ["tailwind-scrollbar@4.0.2", "", { "dependencies": { "prism-react-renderer": "^2.4.1" }, "peerDependencies": { "tailwindcss": "4.x" } }, "sha512-wAQiIxAPqk0MNTPptVe/xoyWi27y+NRGnTwvn4PQnbvB9kp8QUBiGl/wsfoVBHnQxTmhXJSNt9NHTmcz9EivFA=="], + "tailwindcss": ["tailwindcss@3.4.17", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", "chokidar": "^3.6.0", "didyoumean": "^1.2.2", "dlv": "^1.1.3", "fast-glob": "^3.3.2", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", "jiti": "^1.21.6", "lilconfig": "^3.1.3", "micromatch": "^4.0.8", "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.1.1", "postcss": "^8.4.47", "postcss-import": "^15.1.0", "postcss-js": "^4.0.1", "postcss-load-config": "^4.0.2", "postcss-nested": "^6.2.0", "postcss-selector-parser": "^6.1.2", "resolve": "^1.22.8", "sucrase": "^3.35.0" }, "bin": { "tailwind": "lib/cli.js", "tailwindcss": "lib/cli.js" } }, "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og=="], "tailwindcss-animate": ["tailwindcss-animate@1.0.7", "", { "peerDependencies": { "tailwindcss": ">=3.0.0 || insiders" } }, "sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA=="], diff --git a/components/app/windows/aboutNewsOrg.vue b/components/app/windows/aboutNewsOrg.vue index d85bcf5..ce24194 100644 --- a/components/app/windows/aboutNewsOrg.vue +++ b/components/app/windows/aboutNewsOrg.vue @@ -17,7 +17,7 @@ const { data: fetchNewsOrgInfo, pending, error, -} = useFetch("/api/getData/fetchNewsOrgInfo", { +} = useFetch("/api/cached/getData/fetchNewsOrgInfo", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/components/app/windows/chatbot.vue b/components/app/windows/chatbot.vue index 5d77ef7..9c6e372 100644 --- a/components/app/windows/chatbot.vue +++ b/components/app/windows/chatbot.vue @@ -37,23 +37,27 @@ onMounted(() => {
-
-
+
+
-
-
- + diff --git a/components/app/windows/hotnews.vue b/components/app/windows/hotnews.vue index 5bfab7a..50a0a2e 100644 --- a/components/app/windows/hotnews.vue +++ b/components/app/windows/hotnews.vue @@ -6,7 +6,7 @@ import Button from "~/components/ui/button/Button.vue"; const pending = ref(); try { - const { data, pending } = await useFetch("/api/rss/google"); + const { data, pending } = await useFetch("/api/cached/rss/google"); ffeed.value = data.value; } catch (error) { console.error("Error:", error); diff --git a/components/app/windows/sources.vue b/components/app/windows/sources.vue index 0179b86..16cfaba 100644 --- a/components/app/windows/sources.vue +++ b/components/app/windows/sources.vue @@ -13,7 +13,7 @@ const { data: source, pending, error, -} = await useFetch("/api/getData/fetchSources", { +} = await useFetch("/api/cached/getData/fetchSources", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/components/app/windows/tty.vue b/components/app/windows/tty.vue index cc340bc..8fc1c40 100644 --- a/components/app/windows/tty.vue +++ b/components/app/windows/tty.vue @@ -1 +1,8 @@ - + + diff --git a/createDatabase.ts b/createDatabase.ts index ee25053..0d0b673 100644 --- a/createDatabase.ts +++ b/createDatabase.ts @@ -46,7 +46,7 @@ create table if not exists news_articles ( author text, related_uuid text not null ) -` +`; const hotNews = await sql` create table if not exists hot_news ( @@ -57,10 +57,9 @@ create table if not exists hot_news ( related_uuid text not null, created_at timestamptz default current_timestamp ) -` - +`; console.log("Creation Complete"); await sql.end(); -process.exit(0) \ No newline at end of file +process.exit(0); diff --git a/nuxt.config.ts b/nuxt.config.ts index 7b4eeff..b16a169 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -5,7 +5,6 @@ export default defineNuxtConfig({ routeRules: { "/": { redirect: "/home" }, "/zh_tw": { redirect: "/zh_tw/home" }, - "/api/rss/**": { swr: 3600 }, "/go/**": { ssr: true }, "/find/**": { ssr: true }, // Send ZIP bombs to troll bots @@ -18,6 +17,7 @@ export default defineNuxtConfig({ "/wp-login.php": { redirect: "https://s3.yhw.tw/data/def-zip-bomb/wp-login.php.zip", }, + "/api/cached/**": { swr: 3600 }, }, css: ["~/styles/main.css"], diff --git a/package.json b/package.json index 092c734..15cdbcc 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,12 @@ "rss-parser": "^3.13.0", "shadcn-nuxt": "2.1.0", "tailwind-merge": "^3.2.0", + "tailwind-scrollbar": "^4.0.2", "tailwindcss": "3", "tailwindcss-animate": "^1.0.7", "tailwindcss-animatecss": "^3.0.5", "uploadthing": "^7.6.0", + "uuid": "^11.1.0", "vue": "^3.5.13", "vue-router": "^4.5.1" }, diff --git a/pages/app/desktop/index.vue b/pages/app/desktop/index.vue index 418292f..6c62770 100644 --- a/pages/app/desktop/index.vue +++ b/pages/app/desktop/index.vue @@ -11,6 +11,7 @@ interface currentNavBarInterface { action: any; flash: boolean; windowAssociated: string; + minimized: boolean; } interface associAppWindowInterface { @@ -21,6 +22,7 @@ interface associAppWindowInterface { } // Import plugins +import { v4 as uuidv4 } from "uuid"; import { gsap } from "gsap"; import { TextPlugin } from "gsap/TextPlugin"; gsap.registerPlugin(TextPlugin); @@ -160,6 +162,17 @@ const associAppWindow = [ }, ]; +currentNavBar.value = [ + { + name: "anything", + icon: "anything", + action: "s", + flash: true, + windowAssociated: "322", + minimized: true, + }, +]; + /* const keyboardShortcuts = { 'Meta+k': { @@ -291,6 +304,7 @@ const findAndOpenWindow = (windowName: string) => { activeWindows.value.push({ id: currentOpenAppId.value, + absoluteId: uuidv4(), component: windowComponent, name: windowName, title: app.title, @@ -298,6 +312,15 @@ const findAndOpenWindow = (windowName: string) => { height: app.height || "300px", }); currentOpenAppId.value++; + // Add to navbar + currentNavBar.value.push({ + name: "anything", + icon: "anything", + action: "s", + flash: true, + windowAssociated: "322", + minimized: true, + }); } }; @@ -399,23 +422,24 @@ watchEffect((cleanupFn) => { -
+
+
+ +
+