diff --git a/Dockerfile b/Dockerfile index 0f03ddd..40477ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apk add nodejs npm WORKDIR /source COPY . . -WORKDIR /source/pkg/view +WORKDIR /source/pkg/views RUN npm install RUN npm run build WORKDIR /source @@ -18,4 +18,4 @@ COPY --from=interactive-server /dist /interactive/server EXPOSE 8445 -CMD ["/interactive/server"] \ No newline at end of file +CMD ["/interactive/server"] diff --git a/pkg/server/startup.go b/pkg/server/startup.go index 0360151..1fdb923 100644 --- a/pkg/server/startup.go +++ b/pkg/server/startup.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "code.smartsheep.studio/hydrogen/interactive/pkg/view" + "code.smartsheep.studio/hydrogen/identity/pkg/views" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cache" "github.com/gofiber/fiber/v2/middleware/cors" @@ -99,7 +99,7 @@ func NewServer() { Expiration: 24 * time.Hour, CacheControl: true, }), filesystem.New(filesystem.Config{ - Root: http.FS(view.FS), + Root: http.FS(views.FS), PathPrefix: "dist", Index: "index.html", NotFoundFile: "dist/index.html", diff --git a/pkg/view/.gitignore b/pkg/view/.gitignore deleted file mode 100644 index 886c090..0000000 --- a/pkg/view/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/dist -/node_modules - -.DS_Store - -package-lock.json -yarn.lock diff --git a/pkg/view/README.md b/pkg/view/README.md deleted file mode 100644 index 99613fc..0000000 --- a/pkg/view/README.md +++ /dev/null @@ -1,28 +0,0 @@ -## Usage - -```bash -$ npm install # or pnpm install or yarn install -``` - -### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs) - -## Available Scripts - -In the project directory, you can run: - -### `npm run dev` - -Runs the app in the development mode.
-Open [http://localhost:5173](http://localhost:5173) to view it in the browser. - -### `npm run build` - -Builds the app for production to the `dist` folder.
-It correctly bundles Solid in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -## Deployment - -Learn more about deploying your application with the [documentations](https://vitejs.dev/guide/static-deploy.html) diff --git a/pkg/view/embed.go b/pkg/view/embed.go deleted file mode 100644 index ec34587..0000000 --- a/pkg/view/embed.go +++ /dev/null @@ -1,6 +0,0 @@ -package view - -import "embed" - -//go:embed all:dist -var FS embed.FS diff --git a/pkg/view/embed.html b/pkg/view/embed.html deleted file mode 100644 index 18963b3..0000000 --- a/pkg/view/embed.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - Embedded Interactive - - - - - - - \ No newline at end of file diff --git a/pkg/view/index.html b/pkg/view/index.html deleted file mode 100644 index 731eaea..0000000 --- a/pkg/view/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Goatplaza - - -
- - - diff --git a/pkg/view/package.json b/pkg/view/package.json deleted file mode 100644 index 112e107..0000000 --- a/pkg/view/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "@hydrogen/interactive-web", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc && vite build", - "preview": "vite preview" - }, - "dependencies": { - "@fortawesome/fontawesome-free": "^6.5.1", - "@solidjs/router": "^0.10.10", - "artplayer": "^5.1.1", - "cherry-markdown": "^0.8.38", - "dompurify": "^3.0.8", - "flv.js": "^1.6.2", - "hls.js": "^1.5.3", - "marked": "^12.0.0", - "medium-zoom": "^1.1.0", - "solid-js": "^1.8.7", - "universal-cookie": "^7.0.2" - }, - "devDependencies": { - "@tailwindcss/typography": "^0.5.10", - "@types/dompurify": "^3.0.5", - "autoprefixer": "^10.4.17", - "daisyui": "^4.6.1", - "postcss": "^8.4.33", - "solid-devtools": "^0.29.3", - "tailwindcss": "^3.4.1", - "typescript": "^5.2.2", - "vite": "^5.0.8", - "vite-plugin-solid": "^2.8.0" - } -} diff --git a/pkg/view/postcss.config.js b/pkg/view/postcss.config.js deleted file mode 100644 index 2e7af2b..0000000 --- a/pkg/view/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -} diff --git a/pkg/view/public/favicon.svg b/pkg/view/public/favicon.svg deleted file mode 100644 index 3edea9a..0000000 --- a/pkg/view/public/favicon.svg +++ /dev/null @@ -1,21 +0,0 @@ - - Logo - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pkg/view/src/.prettierrc b/pkg/view/src/.prettierrc deleted file mode 100644 index 78bd232..0000000 --- a/pkg/view/src/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "printWidth": 120, - "tabWidth": 2, - "singleQuote": false -} \ No newline at end of file diff --git a/pkg/view/src/assets/fonts/fonts.css b/pkg/view/src/assets/fonts/fonts.css deleted file mode 100644 index 3688303..0000000 --- a/pkg/view/src/assets/fonts/fonts.css +++ /dev/null @@ -1,184 +0,0 @@ -:root { - --bs-body-font-family: "IBM Plex Sans", "Noto Serif SC", sans-serif !important; -} - -html, -body { - font-family: var(--bs-body-font-family); -} - -/* ibm-plex-sans-100 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 100; - src: url('./ibm-plex-sans-v19-latin-100.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-100italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 100; - src: url('./ibm-plex-sans-v19-latin-100italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-200 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 200; - src: url('./ibm-plex-sans-v19-latin-200.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-200italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 200; - src: url('./ibm-plex-sans-v19-latin-200italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-300 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 300; - src: url('./ibm-plex-sans-v19-latin-300.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-300italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 300; - src: url('./ibm-plex-sans-v19-latin-300italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-regular - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 400; - src: url('./ibm-plex-sans-v19-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 400; - src: url('./ibm-plex-sans-v19-latin-italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-500 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 500; - src: url('./ibm-plex-sans-v19-latin-500.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-500italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 500; - src: url('./ibm-plex-sans-v19-latin-500italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-600 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 600; - src: url('./ibm-plex-sans-v19-latin-600.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-600italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 600; - src: url('./ibm-plex-sans-v19-latin-600italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-700 - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: normal; - font-weight: 700; - src: url('./ibm-plex-sans-v19-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} -/* ibm-plex-sans-700italic - latin */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: 'IBM Plex Sans'; - font-style: italic; - font-weight: 700; - src: url('./ibm-plex-sans-v19-latin-700italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-200 - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 200; - src: url("./noto-serif-sc-v22-chinese-simplified-200.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-300 - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 300; - src: url("./noto-serif-sc-v22-chinese-simplified-300.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-regular - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 400; - src: url("./noto-serif-sc-v22-chinese-simplified-regular.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-500 - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 500; - src: url("./noto-serif-sc-v22-chinese-simplified-500.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-600 - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 600; - src: url("./noto-serif-sc-v22-chinese-simplified-600.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-700 - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 700; - src: url("./noto-serif-sc-v22-chinese-simplified-700.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} - -/* noto-serif-sc-900 - chinese-simplified */ -@font-face { - font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */ - font-family: "Noto Serif SC"; - font-style: normal; - font-weight: 900; - src: url("./noto-serif-sc-v22-chinese-simplified-900.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ -} diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-100.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-100.woff2 deleted file mode 100755 index bbe5a8b..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-100.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-100italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-100italic.woff2 deleted file mode 100755 index 075d1c8..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-100italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-200.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-200.woff2 deleted file mode 100755 index 13e9069..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-200.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-200italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-200italic.woff2 deleted file mode 100755 index 0947013..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-200italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-300.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-300.woff2 deleted file mode 100755 index 8737b6b..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-300.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-300italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-300italic.woff2 deleted file mode 100755 index a5f9f4c..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-300italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-500.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-500.woff2 deleted file mode 100755 index adbbd4c..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-500.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-500italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-500italic.woff2 deleted file mode 100755 index 6d6a9b1..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-500italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-600.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-600.woff2 deleted file mode 100755 index 0ac91d6..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-600.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-600italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-600italic.woff2 deleted file mode 100755 index c71f94c..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-600italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-700.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-700.woff2 deleted file mode 100755 index da7d57f..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-700.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-700italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-700italic.woff2 deleted file mode 100755 index 9cd1838..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-700italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-italic.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-italic.woff2 deleted file mode 100755 index eea1618..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-italic.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-regular.woff2 b/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-regular.woff2 deleted file mode 100755 index 93bcd64..0000000 Binary files a/pkg/view/src/assets/fonts/ibm-plex-sans-v19-latin-regular.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-200.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-200.woff2 deleted file mode 100755 index d90173a..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-200.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-300.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-300.woff2 deleted file mode 100755 index 385e4f8..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-300.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-500.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-500.woff2 deleted file mode 100755 index 9699234..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-500.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-600.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-600.woff2 deleted file mode 100755 index ee418fd..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-600.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-700.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-700.woff2 deleted file mode 100755 index 03494a8..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-700.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-900.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-900.woff2 deleted file mode 100755 index 149b461..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-900.woff2 and /dev/null differ diff --git a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-regular.woff2 b/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-regular.woff2 deleted file mode 100755 index 6c638af..0000000 Binary files a/pkg/view/src/assets/fonts/noto-serif-sc-v22-chinese-simplified-regular.woff2 and /dev/null differ diff --git a/pkg/view/src/components/Avatar.tsx b/pkg/view/src/components/Avatar.tsx deleted file mode 100644 index 4912ced..0000000 --- a/pkg/view/src/components/Avatar.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { Show } from "solid-js"; - -export default function Avatar(props: { user: any }) { - return ( - -
- {props.user?.name?.substring(0, 1)} -
- - } - > -
-
- avatar -
-
-
- ); -} \ No newline at end of file diff --git a/pkg/view/src/components/LoadingAnimation.tsx b/pkg/view/src/components/LoadingAnimation.tsx deleted file mode 100644 index ea2dd8f..0000000 --- a/pkg/view/src/components/LoadingAnimation.tsx +++ /dev/null @@ -1,8 +0,0 @@ -export default function LoadingAnimation() { - return ( -
-

-

Listening to the latest news...

-
- ) -} \ No newline at end of file diff --git a/pkg/view/src/components/NameCard.module.css b/pkg/view/src/components/NameCard.module.css deleted file mode 100644 index 932298a..0000000 --- a/pkg/view/src/components/NameCard.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.description { - color: var(--fallback-bc, oklch(var(--bc)/.8)); -} \ No newline at end of file diff --git a/pkg/view/src/components/NameCard.tsx b/pkg/view/src/components/NameCard.tsx deleted file mode 100644 index f1e870a..0000000 --- a/pkg/view/src/components/NameCard.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { createSignal, Show } from "solid-js"; - -import styles from "./NameCard.module.css"; -import { getAtk } from "../stores/userinfo.tsx"; -import { request } from "../scripts/request.ts"; - -export default function NameCard(props: { accountId: string, onError: (messasge: string | null) => void }) { - const [info, setInfo] = createSignal(null); - const [isFollowing, setIsFollowing] = createSignal(false); - - const [_, setLoading] = createSignal(true); - const [submitting, setSubmitting] = createSignal(false); - - async function readInfo() { - setLoading(true); - const res = await request(`/api/users/${props.accountId}`); - if (res.status !== 200) { - props.onError(await res.text()); - } else { - setInfo(await res.json()); - props.onError(null); - } - setLoading(false); - } - - async function readIsFollowing() { - setLoading(true); - const res = await request(`/api/users/${props.accountId}/follow`, { - method: "GET", - headers: { Authorization: `Bearer ${getAtk()}` } - }); - if (res.status === 200) { - const data = await res.json(); - setIsFollowing(data["is_followed"]); - } - setLoading(false); - } - - async function follow() { - setSubmitting(true); - const res = await request(`/api/users/${props.accountId}/follow`, { - method: "POST", - headers: { "Authorization": `Bearer ${getAtk()}` } - }); - if (res.status !== 201 && res.status !== 204) { - props.onError(await res.text()); - } else { - await readIsFollowing(); - props.onError(null); - } - setSubmitting(false); - } - - readInfo(); - readIsFollowing(); - - return ( -
- - -
-
- avatar -
-
- -
-
- follow()}> - - Follow - - }> - - -
-
- -
-

{info()?.name}

-

{info()?.description}

-
-

- - Joined at {new Date(info()?.created_at).toLocaleString()} -

-
-
-
- ); -} \ No newline at end of file diff --git a/pkg/view/src/components/posts/PostAttachments.module.css b/pkg/view/src/components/posts/PostAttachments.module.css deleted file mode 100644 index 368ec7e..0000000 --- a/pkg/view/src/components/posts/PostAttachments.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.attachmentsControl { - background-color: transparent !important; -} \ No newline at end of file diff --git a/pkg/view/src/components/posts/PostAttachments.tsx b/pkg/view/src/components/posts/PostAttachments.tsx deleted file mode 100644 index 7d95d54..0000000 --- a/pkg/view/src/components/posts/PostAttachments.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import { createEffect, createMemo, createSignal, Match, Switch } from "solid-js"; -import mediumZoom from "medium-zoom"; - -import styles from "./PostAttachments.module.css"; - -import Artplayer from "artplayer"; -import HlsJs from "hls.js"; -import FlvJs from "flv.js"; - -function Video({ url, ...rest }: any) { - let container: any; - - function playM3u8(video: HTMLVideoElement, url: string, art: Artplayer) { - if (HlsJs.isSupported()) { - if (art.hls) art.hls.destroy(); - const hls = new HlsJs(); - hls.loadSource(url); - hls.attachMedia(video); - art.hls = hls; - art.on("destroy", () => hls.destroy()); - } else if (video.canPlayType("application/vnd.apple.mpegurl")) { - video.src = url; - } else { - art.notice.show = "Unsupported playback format: m3u8"; - } - } - - function playFlv(video: HTMLVideoElement, url: string, art: Artplayer) { - if (FlvJs.isSupported()) { - if (art.flv) art.flv.destroy(); - const flv = FlvJs.createPlayer({ type: "flv", url }); - flv.attachMediaElement(video); - flv.load(); - art.flv = flv; - art.on("destroy", () => flv.destroy()); - } else { - art.notice.show = "Unsupported playback format: flv"; - } - } - - createEffect(() => { - new Artplayer({ - container: container as HTMLDivElement, - url: url, - setting: true, - flip: true, - loop: true, - playbackRate: true, - aspectRatio: true, - subtitleOffset: true, - fullscreen: true, - fullscreenWeb: true, - theme: "#49509e", - customType: { - m3u8: playM3u8, - flv: playFlv - } - }); - }); - - return ( -
- ); -} - -function Audio({ url, caption, ...rest }: any) { - - return ( -
-
{caption}
-
- ); -} - - -export default function PostAttachments(props: { attachments: any[] }) { - if (props.attachments.length <= 0) return null; - - const [focus, setFocus] = createSignal(0); - const item = createMemo(() => props.attachments[focus()]); - - function getRenderType(item: any): string { - return item.mimetype.split("/")[0]; - } - - function getUrl(item: any): string { - return item.external_url ? item.external_url : `/api/attachments/o/${item.file_id}`; - } - - createEffect(() => { - mediumZoom(document.querySelectorAll(".attachment-image img"), { - background: "var(--fallback-b1,oklch(var(--b1)/1))" - }); - }, [focus()]); - - return ( - <> -

- - Attached {props.attachments.length} file{props.attachments.length > 1 ? "s" : null} -

-
- -
- -

{item().filename}

- -
-

{item().filesize <= 0 ? "Unknown" : item().filesize} Bytes

-

{item().mimetype}

-
- - -
-
- }> - -
- {item().filename} -
-
- - - - - - -
-
- - -
- -
-
- File {focus() + 1} -
-
-
- - - ); -} \ No newline at end of file diff --git a/pkg/view/src/components/posts/PostEditActions.tsx b/pkg/view/src/components/posts/PostEditActions.tsx deleted file mode 100644 index bd3008c..0000000 --- a/pkg/view/src/components/posts/PostEditActions.tsx +++ /dev/null @@ -1,399 +0,0 @@ -import { closeModel, openModel } from "../../scripts/modals.ts"; -import { createSignal, For, Match, Show, Switch } from "solid-js"; -import { getAtk, useUserinfo } from "../../stores/userinfo.tsx"; -import { request } from "../../scripts/request.ts"; - -import styles from "./PostPublish.module.css"; - -export default function PostEditActions(props: { - editing?: any; - onInputAlias: (value: string) => void; - onInputPublish: (value: string) => void; - onInputAttachments: (value: any[]) => void; - onInputCategories: (categories: any[]) => void; - onInputTags: (tags: any[]) => void; - onError: (message: string | null) => void; -}) { - const userinfo = useUserinfo(); - - const [uploading, setUploading] = createSignal(false); - - const [attachments, setAttachments] = createSignal(props.editing?.attachments ?? []); - const [categories, setCategories] = createSignal<{ alias: string; name: string }[]>(props.editing?.categories ?? []); - const [tags, setTags] = createSignal<{ alias: string; name: string }[]>(props.editing?.tags ?? []); - - const [availableCategories, setAvailableCategories] = createSignal([]); - const [attachmentMode, setAttachmentMode] = createSignal(0); - - async function readCategories() { - const res = await request("/api/categories"); - if (res.status === 200) { - setAvailableCategories(await res.json()); - } - } - - readCategories(); - - async function uploadAttachment(evt: SubmitEvent) { - evt.preventDefault(); - - const form = evt.target as HTMLFormElement; - const data = new FormData(form); - if (!data.get("attachment")) return; - - setUploading(true); - const res = await request("/api/attachments", { - method: "POST", - headers: { Authorization: `Bearer ${getAtk()}` }, - body: data, - }); - if (res.status !== 200) { - props.onError(await res.text()); - } else { - const data = await res.json(); - setAttachments(attachments().concat([data.info])); - props.onInputAttachments(attachments()); - props.onError(null); - form.reset(); - } - setUploading(false); - } - - function addAttachment(evt: SubmitEvent) { - evt.preventDefault(); - - const form = evt.target as HTMLFormElement; - const data = Object.fromEntries(new FormData(form)); - - setAttachments( - attachments().concat([ - { - ...data, - author_id: userinfo?.profiles?.id, - }, - ]), - ); - props.onInputAttachments(attachments()); - form.reset(); - } - - function removeAttachment(idx: number) { - const data = attachments().slice(); - data.splice(idx, 1); - setAttachments(data); - props.onInputAttachments(attachments()); - } - - function addCategory(evt: SubmitEvent) { - evt.preventDefault(); - - const form = evt.target as HTMLFormElement; - const data = Object.fromEntries(new FormData(form)); - if (!data.category) return; - - const item = availableCategories().find((item) => item.alias === data.category); - - setCategories(categories().concat([item])); - props.onInputCategories(categories()); - form.reset(); - } - - function removeCategory(idx: number) { - const data = categories().slice(); - data.splice(idx, 1); - setCategories(data); - props.onInputCategories(categories()); - } - - function addTag(evt: SubmitEvent) { - evt.preventDefault(); - - const form = evt.target as HTMLFormElement; - const data = Object.fromEntries(new FormData(evt.target as HTMLFormElement)); - if (!data.alias) data.alias = crypto.randomUUID().replace(/-/g, ""); - if (!data.name) return; - - setTags(tags().concat([data as any])); - props.onInputTags(tags()); - form.reset(); - } - - function removeTag(idx: number) { - const data = tags().slice(); - data.splice(idx, 1); - setTags(data); - props.onInputTags(tags()); - } - - return ( - <> -
- - - - -
- - - - - - - - - - - - - - - - - - ); -} diff --git a/pkg/view/src/components/posts/PostEditor.tsx b/pkg/view/src/components/posts/PostEditor.tsx deleted file mode 100644 index 61736ca..0000000 --- a/pkg/view/src/components/posts/PostEditor.tsx +++ /dev/null @@ -1,223 +0,0 @@ -import { createEffect, createMemo, createSignal, For, onMount, Show } from "solid-js"; - -import Cherry from "cherry-markdown"; -import "cherry-markdown/dist/cherry-markdown.min.css"; -import { getAtk } from "../../stores/userinfo.tsx"; -import { request } from "../../scripts/request.ts"; -import PostEditActions from "./PostEditActions.tsx"; - -export default function PostEditor(props: { - editing?: any, - onError: (message: string | null) => void, - onPost: () => void -}) { - let editorContainer: any; - const [editor, setEditor] = createSignal(); - const [realmList, setRealmList] = createSignal([]); - - const [submitting, setSubmitting] = createSignal(false); - - const [alias, setAlias] = createSignal(""); - const [publishedAt, setPublishedAt] = createSignal(""); - const [attachments, setAttachments] = createSignal([]); - const [categories, setCategories] = createSignal<{ alias: string, name: string }[]>([]); - const [tags, setTags] = createSignal<{ alias: string, name: string }[]>([]); - - const theme = createMemo(() => { - if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) { - return "dark"; - } else { - return "light"; - } - }); - - createEffect(() => { - editor()?.setTheme(theme()); - }, [editor(), theme()]); - - onMount(() => { - if (editorContainer) { - setEditor(new Cherry({ - el: editorContainer, - value: "Welcome to the creator hub! " + - "We provide a better editor than normal mode for you! " + - "So you can tell us your mind clearly. " + - "Delete this paragraph and getting start!" - })); - } - }); - - createEffect(() => { - setAttachments(props.editing?.attachments ?? []); - setCategories(props.editing?.categories ?? []); - setTags(props.editing?.tags ?? []); - editor()?.setValue(props.editing?.content); - }, [props.editing]); - - async function listRealm() { - const res = await request("/api/realms/me/available", { - headers: { "Authorization": `Bearer ${getAtk()}` } - }); - if (res.status === 200) { - setRealmList(await res.json()); - } - } - - listRealm(); - - async function doPost(evt: SubmitEvent) { - evt.preventDefault(); - - const form = evt.target as HTMLFormElement; - const data = Object.fromEntries(new FormData(form)); - if (!editor()?.getValue()) return; - - setSubmitting(true); - const res = await request("/api/posts", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${getAtk()}` - }, - body: JSON.stringify({ - alias: alias() ? alias() : crypto.randomUUID().replace(/-/g, ""), - title: data.title, - content: editor()?.getValue(), - attachments: attachments(), - categories: categories(), - tags: tags(), - realm_id: parseInt(data.realm as string) !== 0 ? parseInt(data.realm as string) : undefined, - published_at: publishedAt() ? new Date(publishedAt()) : new Date() - }) - }); - if (res.status !== 200) { - props.onError(await res.text()); - } else { - form.reset(); - props.onError(null); - props.onPost(); - } - setSubmitting(false); - } - - async function doEdit(evt: SubmitEvent) { - evt.preventDefault(); - - const form = evt.target as HTMLFormElement; - const data = Object.fromEntries(new FormData(form)); - if (!editor()?.getValue()) return; - - setSubmitting(true); - const res = await request(`/api/posts/${props.editing?.id}`, { - method: "PUT", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${getAtk()}` - }, - body: JSON.stringify({ - alias: alias() ? alias() : crypto.randomUUID().replace(/-/g, ""), - title: data.title, - content: editor()?.getValue(), - attachments: attachments(), - categories: categories(), - tags: tags(), - published_at: publishedAt() ? new Date(publishedAt()) : new Date() - }) - }); - if (res.status !== 200) { - props.onError(await res.text()); - } else { - form.reset(); - props.onError(null); - props.onPost(); - } - setSubmitting(false); - } - - function resetForm() { - setAttachments([]); - setCategories([]); - setTags([]); - } - - return ( -
props.editing ? doEdit(evt) : doPost(evt)}> -
-
-
- -
- -
- -
- -
- Publish region -
- - - }> - -
- - - -