Merge pull request #15 from hpware/beta

Merge Beta Branch
This commit is contained in:
元皓 2025-07-02 22:52:34 +08:00 committed by GitHub
commit f120b8a9ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 503 additions and 290 deletions

BIN
.github/README/error1.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

1
.github/funding.yml vendored
View File

@ -1 +0,0 @@
ko_fi: howard00

1
.gitignore vendored
View File

@ -37,3 +37,4 @@ _dt_*.py
# Testing files
test.vue
100106_lt_test.html
dump.txt

View File

@ -1,36 +1,36 @@
# If you have customized your output directory, please just remove it. :)
FROM oven/bun:latest as builder
FROM oven/bun:latest as builder
WORKDIR /app
WORKDIR /app
# Copy package files
COPY package.json ./
COPY bun.lock* package-lock.json* yarn.lock* ./
# Copy package files
COPY package.json ./
COPY bun.lock* package-lock.json* yarn.lock* ./
# Install dependencies
RUN bun pm untrusted
RUN bun install
# Install dependencies
RUN bun pm untrusted
RUN bun install
# Copy source files
COPY . .
RUN bun run generateVersionTag
# Build the application
RUN bun run build
# Copy source files
COPY . .
RUN bun run generateVersionTag
# Build the application
RUN bun run build
# Production stage
FROM oven/bun:latest
# Production stage
FROM oven/bun:latest
WORKDIR /app
WORKDIR /app
# Copy package files for production
COPY --from=builder /app/package.json ./
# Copy package files for production
COPY --from=builder /app/package.json ./
# Copy build outputs from builder
COPY --from=builder /app/.output /app/.output
# Copy build outputs from builder
COPY --from=builder /app/.output /app/.output
RUN bun install --production
RUN bun install --production
EXPOSE 3000
EXPOSE 3000
CMD ["bun", "run", "start"]
CMD ["bun", "run", "start"]

View File

@ -46,9 +46,6 @@ Chatbot, which is chatbot for chatting about news articles, is currently not ava
### Server Downtime
Use https://status.yhw.tw/ for checking down time, most of the time it will be up, but sometimes it just won't updated to the latest feature & update.
#### Archive:
I fixed most issues of the server, including the nameserver stuff, if you want to know how I fixed it, you can view how I fixed it [here](/server_fixes.md) or on [My broken blog](https://4-1-2.yuanhau.com/posts/)
### Scraping restrictions:
As LINE Today only loads & put the image file via JS in the browser, node-fetch is not working (yes, this platform uses node-fetch as the only way to scrape stuff). If LINE today became more problematic of this platform, those APIs will no longer work & most of the things will just not work, as it requires LINE Today to NOT patch these node-fetch things.
@ -64,6 +61,14 @@ This code is absolutly NOT designed to be spinned up at Vercel or Netlify, it ha
### The API returning outdated data from more than 5+ years:
Here is the GitHub Issue: https://github.com/hpware/news-analyze/issues/2
### Groq API not loading to .env for some reasons.
If the user did not load a GROQ api, the summerizing system will just fail outright. Fixing this rn.
### When using the desktop in the dev env it pops up an error
![](/.github/README/error1.png)
For some reasons, Nuxt's dev env prev does not display this error, but with the newer ones, it started displaying this error, please run `./wipedev.sh` or `./wipedev.bat` and restart the dev server. (And this is only a temp fix, I have no idea how can I fix this, if you have a fix, please submit a PR thx.)
## Why?
We'll use this news article from May 7th 2025 as an example:

587
bun.lock

File diff suppressed because it is too large Load Diff

View File

@ -125,12 +125,13 @@ const stopDrag = () => {
>
<LanguagesIcon />
</button>
<button
<!-- TODO !!!-->
<!--<button
@click="emit('min')"
class="p-1 hover:bg-gray-300 dark:hover:bg-gray-600 rounded transition duration-200"
>
<MinusIcon />
</button>
</button>-->
<button
@click="emit('close')"
class="p-1 rounded bg-red-500 text-white hover:bg-red-600 transition duration-200"

View File

@ -284,7 +284,32 @@ const translateFunction = () => {
};
</script>
<template>
<div v-if="translateLoading">Loading...</div>
<div v-if="translateLoading">
<div
class="flex flex-col bg-gray-200/50 text-black w-full h-full absolute inset-0 justify-center align-middle text-center z-[20] backdrop-blur-sm"
>
<!--Spinner from https://flowbite.com/docs/components/spinner/-->
<div role="status" class="justify-center self-center text-center">
<svg
aria-hidden="true"
class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
</div>
<div>Translating...</div>
</div>
</div>
<div class="justify-center align-center text-center">
<!--Tabs-->
<div

View File

@ -135,8 +135,31 @@ onMounted(async () => {
<button></button>
</div>
</div>
<!--TODO: Get a better animation later.-->
<div v-if="loadingTranslations">Loading...</div>
<div
v-if="loadingTranslations"
class="flex flex-col bg-gray-200/50 text-black w-full h-full fixed inset-0 justify-center align-middle text-center z-[20] backdrop-blur-sm"
>
<!--Spinner from https://flowbite.com/docs/components/spinner/-->
<div role="status">
<svg
aria-hidden="true"
class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
</div>
<div>Translating...</div>
</div>
<div
class="justify-center align-center text-center flex flex-col md:flex-row flex-wrap"
>

View File

@ -56,6 +56,7 @@ const logoutAction = async () => {
const req = await fetch("/api/user/logout");
const res = await req.json();
console.log(res);
await validateUserInfo();
showLogoutDialog.value = false;
};

View File

@ -80,7 +80,7 @@ onMounted(async () => {
</div>
<div class="flex flex-row flex-wrap justify-center gap-2">
<div
class="flex flex-col group bg-gray-900/30 rounded-xl p-3 transition-all shadow-lg hover:translate-y-[-2px] ransition-all duration-500 max-w-1/2"
class="flex flex-col group bg-gray-900/30 rounded-xl p-3 transition-all shadow-lg hover:translate-y-[-2px] ransition-all duration-500 max-w-1/2 min-w-1/3"
v-for="item in source?.data"
:key="item.id"
>

View File

@ -21,6 +21,8 @@ sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```
4. Download the docker-compose.yml and .env.example file to an dir & change the .env.example file to .env:
psst: You can change the docker-compose file to different systems, these are available: `docker-compose.yml`, `docker-compose-no-traefik.yml`, `docker-compose-beta.yml`, `docker-compose-beta-no-traefik.yml`
```bash
# Chahnge your_dir to your dir in your server!
mkdir ./your_dir

View File

@ -0,0 +1,14 @@
services:
service:
image: ghcr.io/hpware/news-analyze:beta
ports:
- 36695:3000 # CHANGE YOUR PORT HERE
restart: unless-stopped
# Use only one node to ease development, as this is not for prod use.
env_file:
- path: ./.env
required: true
networks:
- n3abetaweb
networks:
n3abetaweb: null

View File

@ -2,32 +2,28 @@ services:
reverse-proxy:
image: traefik:v3.1
command:
- "--providers.docker"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- --providers.docker
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
ports:
- 127.0.0.1:36694:80
- 127.0.0.1:36695:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- web
newsanalyze-service:
- n3abetaweb
service:
image: ghcr.io/hpware/news-analyze:beta
networks:
- web
- n3abetaweb
labels:
- "traefik.enable=true"
- "traefik.http.routers.newsanalyze.rule=Host(`news.yuanhau.com`)"
- "traefik.http.services.newsanalyze.loadbalancer.server.port=3000"
- "com.centurylinklabs.watchtower.enable=true"
- traefik.enable=true
- traefik.http.routers.newsanalyzebeat.rule=Host(`YOUR_HOSTNAME_HERE`) # YOUR HOSTNAME HERE
- traefik.http.services.newsanalyzebeta.loadbalancer.server.port=3000
- com.centurylinklabs.watchtower.enable=true
restart: unless-stopped
# Use only one node to ease development, as this is not for prod use.
env_file:
- path: ./.env
required: true
deploy:
mode: replicated
replicas: 2
networks:
web:
n3abetaweb: null

14
docker-compose-no-traefik.yml Executable file
View File

@ -0,0 +1,14 @@
services:
newsanalyze-service:
image: ghcr.io/hpware/news-analyze:latest
ports:
- 36694:80 # CHANGE YOUR PORT HERE
networks:
- web
restart: unless-stopped
env_file:
- path: ./.env
required: true
networks:
web:

View File

@ -18,7 +18,7 @@ services:
- web
labels:
- "traefik.enable=true"
- "traefik.http.routers.newsanalyze.rule=Host(`news.yuanhau.com`)"
- "traefik.http.routers.newsanalyze.rule=Host(`YOUR_HOSTNAME_HERE`)" # CHANGE TO YOUR HOSTNAME
- "traefik.http.services.newsanalyze.loadbalancer.server.port=3000"
- "com.centurylinklabs.watchtower.enable=true"
restart: unless-stopped

View File

@ -14,7 +14,7 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"wipedev": "./clean-dev-env.sh",
"wipedev": "./wipedev.sh",
"generateVersionTag": "bun run versionTagGenerate.ts"
},
"dependencies": {
@ -41,6 +41,7 @@
"js-confetti": "^0.12.0",
"lucide-vue-next": "^0.511.0",
"nuxt": "^3.17.5",
"pg-backup": "^0.0.2",
"postgres": "^3.4.7",
"prettier": "^3.5.3",
"reka-ui": "^2.3.1",

View File

@ -500,7 +500,7 @@ const toggleMinWindow = (windowUUId: string) => {
component: activeWindow.component,
name: activeWindow.name,
title: activeWindow.title,
width: activeWindow.width,
width: activeWindow.width, // HUH THIS IS CAUSING THE ERROR????
height: activeWindow.height,
black: activeWindow.black || false,
translatable: activeWindow.translatable || false,
@ -631,6 +631,7 @@ setInterval(async () => {
newUpdate.value = await checkAppVersion();
}, newUpdateTimer);
</script>
<template>
<div v-if="changeLangAnimation">
<div
@ -710,9 +711,10 @@ setInterval(async () => {
leave-active-class="animate__animated animate__fadeOutUp animate_fast03"
>
<div
class="m-2 p-2 bg-gray-800 shadow-lg w-fit rounded-[10px] v-9998 selection:opacity-0"
class="m-2 p-2 bg-gray-800 shadow-lg w-fit rounded-[10px] z-[99999] selection:opacity-0 fixed top-[3em]"
v-if="menuOpen"
>
<!--Wait, I'm not using z-9998 this entire time? What?-->
<div v-for="item in menuItems" :key="item.name" class="">
<button
@click="openWindow(item.windowName)"

View File

@ -2,10 +2,6 @@ import { Groq } from "groq-sdk";
import sql from "~/server/components/postgres";
import { checkIfUserHasCustomGroqKey } from "~/server/components/customgroqsystem";
const groq = new Groq({
apiKey: process.env.GROQ_API_KEY,
});
export default defineEventHandler(async (event) => {
const host = getRequestHost(event);
const protocol = getRequestProtocol(event);
@ -14,7 +10,7 @@ export default defineEventHandler(async (event) => {
console.log("Token: ", userToken);
const doesTheUserHasACustomGroqApiAndWhatIsIt =
await checkIfUserHasCustomGroqKey(userToken);
let groqClient = groq;
let groqClient;
if (doesTheUserHasACustomGroqApiAndWhatIsIt.status === true) {
groqClient = new Groq({
apiKey: doesTheUserHasACustomGroqApiAndWhatIsIt.customApi,

View File

@ -15,7 +15,7 @@ export default defineEventHandler(async (event) => {
// Use Static values for now.
const requestChange = body.action || "";
const apiKeyqq = body.value.match(clearBadDataRegex);
console.log(apiKeyqq);
console.log(apiKeyqq);
const allowedColumns = ["firstname", "email"];
if (!allowedColumns.includes(requestChange)) {

6
wipedev.bat Normal file
View File

@ -0,0 +1,6 @@
@REM THis file is AI generated
rmdir /s /q node_modules
del /f /q bun.lock
rmdir /s /q .nuxt
rmdir /s /q .output
bun install