From f2991be276f2f6d3b85a401821de85cc187e2b45 Mon Sep 17 00:00:00 2001 From: Kilu Date: Wed, 26 Jun 2024 15:23:23 +0800 Subject: [PATCH] fix: modified web server --- .github/workflows/deploy_test_web.yaml | 2 +- frontend/appflowy_web_app/Dockerfile | 2 +- frontend/appflowy_web_app/package.json | 5 +- frontend/appflowy_web_app/pnpm-lock.yaml | 216 +++++++++++++++++- frontend/appflowy_web_app/server.cjs | 67 ++++-- .../src/assets/arrow_right.svg | 5 + .../src/assets/settings/discord.png | Bin 1533 -> 0 bytes .../src/assets/settings/github.png | Bin 1105 -> 0 bytes .../src/assets/settings/google.png | Bin 1744 -> 0 bytes .../src/components/document/Document.tsx | 4 +- .../src/components/publish/CollabView.tsx | 5 +- .../src/components/publish/PublishView.tsx | 1 + .../components/publish/header/Breadcrumb.tsx | 8 +- .../publish/header/BreadcrumbItem.tsx | 2 +- .../publish/header/PublishViewHeader.tsx | 11 +- .../src/components/publish/useViewMeta.ts | 12 +- .../components/view-meta/ViewMetaPreview.tsx | 2 +- frontend/appflowy_web_app/src/styles/app.scss | 3 + 18 files changed, 303 insertions(+), 42 deletions(-) create mode 100644 frontend/appflowy_web_app/src/assets/arrow_right.svg delete mode 100644 frontend/appflowy_web_app/src/assets/settings/discord.png delete mode 100644 frontend/appflowy_web_app/src/assets/settings/github.png delete mode 100644 frontend/appflowy_web_app/src/assets/settings/google.png diff --git a/.github/workflows/deploy_test_web.yaml b/.github/workflows/deploy_test_web.yaml index f7d3339d77..bd5bd353ca 100644 --- a/.github/workflows/deploy_test_web.yaml +++ b/.github/workflows/deploy_test_web.yaml @@ -69,4 +69,4 @@ jobs: SCRIPT_AFTER: | docker build -t appflowy-web-app . docker rm -f appflowy-web-app || true - docker run -d -p 80:80 -p 443:443 --name appflowy-web-app appflowy-web-app + docker run -d -p 80:80 -p 443:443 --env-file .env --name appflowy-web-app appflowy-web-app diff --git a/frontend/appflowy_web_app/Dockerfile b/frontend/appflowy_web_app/Dockerfile index 97e3a85559..b6e4be2e23 100644 --- a/frontend/appflowy_web_app/Dockerfile +++ b/frontend/appflowy_web_app/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app RUN apt-get update && \ apt-get install -y nginx -RUN bun install cheerio pino axios pino-pretty +RUN bun install cheerio pino pino-pretty COPY . . diff --git a/frontend/appflowy_web_app/package.json b/frontend/appflowy_web_app/package.json index 21ba02a625..b5b4f60e9d 100644 --- a/frontend/appflowy_web_app/package.json +++ b/frontend/appflowy_web_app/package.json @@ -24,7 +24,7 @@ "coverage": "pnpm run test:unit && pnpm run test:components" }, "dependencies": { - "@appflowyinc/client-api-wasm": "0.0.3", + "@appflowyinc/client-api-wasm": "0.0.4", "@atlaskit/primitives": "^5.5.3", "@emoji-mart/data": "^1.1.2", "@emoji-mart/react": "^1.1.1", @@ -139,6 +139,7 @@ "autoprefixer": "^10.4.13", "babel-jest": "^29.6.2", "chalk": "^4.1.2", + "cheerio": "1.0.0-rc.12", "cross-env": "^7.0.3", "cypress": "^13.7.2", "eslint": "^8.57.0", @@ -148,6 +149,8 @@ "istanbul-lib-coverage": "^3.2.2", "jest-environment-jsdom": "^29.6.2", "nyc": "^15.1.0", + "pino": "^9.2.0", + "pino-pretty": "^11.2.1", "postcss": "^8.4.21", "prettier": "2.8.4", "prettier-plugin-tailwindcss": "^0.2.2", diff --git a/frontend/appflowy_web_app/pnpm-lock.yaml b/frontend/appflowy_web_app/pnpm-lock.yaml index 9d8de3d4d6..0a98d3a716 100644 --- a/frontend/appflowy_web_app/pnpm-lock.yaml +++ b/frontend/appflowy_web_app/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@appflowyinc/client-api-wasm': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@atlaskit/primitives': specifier: ^5.5.3 version: 5.7.0(@types/react@18.2.66)(react@18.2.0) @@ -346,6 +346,9 @@ devDependencies: chalk: specifier: ^4.1.2 version: 4.1.2 + cheerio: + specifier: 1.0.0-rc.12 + version: 1.0.0-rc.12 cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -373,6 +376,12 @@ devDependencies: nyc: specifier: ^15.1.0 version: 15.1.0 + pino: + specifier: ^9.2.0 + version: 9.2.0 + pino-pretty: + specifier: ^11.2.1 + version: 11.2.1 postcss: specifier: ^8.4.21 version: 8.4.21 @@ -442,8 +451,8 @@ packages: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 - /@appflowyinc/client-api-wasm@0.0.3: - resolution: {integrity: sha512-ARjLhiDZ8MiZ9egWDbAX9VAdXXS30av+InCPLrS/iqCMYrhuuU9rxS9jQeNEB7jucFrj158gBRusimFN7P/lyw==} + /@appflowyinc/client-api-wasm@0.0.4: + resolution: {integrity: sha512-R8nm811vmh4oJU7LDFV7TJP89Y+WZKYrwpR1xrfL9m+PtyA/c21HvNJrvT+NssHfuz+IKj4L1cH2uXQcggnybA==} dev: false /@atlaskit/analytics-next-stable-react-context@1.0.1(react@18.2.0): @@ -4593,6 +4602,13 @@ packages: deprecated: Use your platform's native atob() and btoa() methods instead dev: true + /abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + dependencies: + event-target-shim: 5.0.1 + dev: true + /acorn-globals@7.0.1: resolution: {integrity: sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==} dependencies: @@ -4899,6 +4915,11 @@ packages: engines: {node: '>= 4.0.0'} dev: true + /atomic-sleep@1.0.0: + resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} + engines: {node: '>=8.0.0'} + dev: true + /autoprefixer@10.4.13(postcss@8.4.21): resolution: {integrity: sha512-49vKpMqcZYsJjwotvt4+h/BCjJVnhGwcLpDt5xkcaOG3eLrG/HUYLagrihYsQ+qrIBgIzX1Rw7a6L8I/ZA1Atg==} engines: {node: ^10 || ^12 || >=14} @@ -5193,6 +5214,13 @@ packages: ieee754: 1.2.1 dev: true + /buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + dev: true + /cachedir@2.4.0: resolution: {integrity: sha512-9EtFOZR8g22CL7BWjJ9BUx1+A/djkofnyW3aOXZORNW2kxoUpx2h+uN2cOqwPmFhnpVmxg+KW2OjOSgChTEvsQ==} engines: {node: '>=6'} @@ -5302,6 +5330,30 @@ packages: engines: {node: '>= 0.8.0'} dev: true + /cheerio-select@2.1.0: + resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==} + dependencies: + boolbase: 1.0.0 + css-select: 5.1.0 + css-what: 6.1.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.1.0 + dev: true + + /cheerio@1.0.0-rc.12: + resolution: {integrity: sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==} + engines: {node: '>= 6'} + dependencies: + cheerio-select: 2.1.0 + dom-serializer: 2.0.0 + domhandler: 5.0.3 + domutils: 3.1.0 + htmlparser2: 8.0.2 + parse5: 7.1.2 + parse5-htmlparser2-tree-adapter: 7.0.0 + dev: true + /chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -5752,6 +5804,10 @@ packages: dependencies: '@babel/runtime': 7.24.1 + /dateformat@4.6.3: + resolution: {integrity: sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==} + dev: true + /dayjs@1.11.10: resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} dev: true @@ -6401,6 +6457,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + dev: true + /eventemitter2@6.4.7: resolution: {integrity: sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==} dev: true @@ -6484,6 +6545,10 @@ packages: resolution: {integrity: sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==} engines: {'0': node >=0.6.0} + /fast-copy@3.0.2: + resolution: {integrity: sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==} + dev: true + /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -6521,6 +6586,15 @@ packages: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} dev: true + /fast-redact@3.5.0: + resolution: {integrity: sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==} + engines: {node: '>=6'} + dev: true + + /fast-safe-stringify@2.1.1: + resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} + dev: true + /fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} dependencies: @@ -6990,6 +7064,10 @@ packages: tslib: 2.6.2 dev: true + /help-me@5.0.0: + resolution: {integrity: sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==} + dev: true + /hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} dependencies: @@ -7012,6 +7090,15 @@ packages: void-elements: 3.1.0 dev: false + /htmlparser2@8.0.2: + resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==} + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.1.0 + entities: 4.5.0 + dev: true + /http-proxy-agent@5.0.0: resolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==} engines: {node: '>= 6'} @@ -7910,6 +7997,11 @@ packages: - supports-color - ts-node + /joycon@3.1.1: + resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} + engines: {node: '>=10'} + dev: true + /jpeg-js@0.4.4: resolution: {integrity: sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==} dev: false @@ -8620,6 +8712,11 @@ packages: resolution: {integrity: sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==} dev: false + /on-exit-leak-free@2.1.2: + resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==} + engines: {node: '>=14.0.0'} + dev: true + /once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: @@ -8765,6 +8862,13 @@ packages: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + /parse5-htmlparser2-tree-adapter@7.0.0: + resolution: {integrity: sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==} + dependencies: + domhandler: 5.0.3 + parse5: 7.1.2 + dev: true + /parse5@7.1.2: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} dependencies: @@ -8854,6 +8958,54 @@ packages: engines: {node: '>=6'} dev: true + /pino-abstract-transport@1.2.0: + resolution: {integrity: sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==} + dependencies: + readable-stream: 4.5.2 + split2: 4.2.0 + dev: true + + /pino-pretty@11.2.1: + resolution: {integrity: sha512-O05NuD9tkRasFRWVaF/uHLOvoRDFD7tb5VMertr78rbsYFjYp48Vg3477EshVAF5eZaEw+OpDl/tu+B0R5o+7g==} + hasBin: true + dependencies: + colorette: 2.0.20 + dateformat: 4.6.3 + fast-copy: 3.0.2 + fast-safe-stringify: 2.1.1 + help-me: 5.0.0 + joycon: 3.1.1 + minimist: 1.2.8 + on-exit-leak-free: 2.1.2 + pino-abstract-transport: 1.2.0 + pump: 3.0.0 + readable-stream: 4.5.2 + secure-json-parse: 2.7.0 + sonic-boom: 4.0.1 + strip-json-comments: 3.1.1 + dev: true + + /pino-std-serializers@7.0.0: + resolution: {integrity: sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==} + dev: true + + /pino@9.2.0: + resolution: {integrity: sha512-g3/hpwfujK5a4oVbaefoJxezLzsDgLcNJeITvC6yrfwYeT9la+edCK42j5QpEQSQCZgTKapXvnQIdgZwvRaZug==} + hasBin: true + dependencies: + atomic-sleep: 1.0.0 + fast-redact: 3.5.0 + on-exit-leak-free: 2.1.2 + pino-abstract-transport: 1.2.0 + pino-std-serializers: 7.0.0 + process-warning: 3.0.0 + quick-format-unescaped: 4.0.4 + real-require: 0.2.0 + safe-stable-stringify: 2.4.3 + sonic-boom: 4.0.1 + thread-stream: 3.1.0 + dev: true + /pirates@4.0.6: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} @@ -9071,6 +9223,10 @@ packages: fromentries: 1.3.2 dev: true + /process-warning@3.0.0: + resolution: {integrity: sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==} + dev: true + /process@0.11.10: resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} engines: {node: '>= 0.6.0'} @@ -9159,6 +9315,10 @@ packages: resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==} dev: true + /quick-format-unescaped@4.0.4: + resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} + dev: true + /quick-lru@5.1.1: resolution: {integrity: sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==} engines: {node: '>=10'} @@ -9679,12 +9839,28 @@ packages: util-deprecate: 1.0.2 dev: true + /readable-stream@4.5.2: + resolution: {integrity: sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + abort-controller: 3.0.0 + buffer: 6.0.3 + events: 3.3.0 + process: 0.11.10 + string_decoder: 1.3.0 + dev: true + /readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} dependencies: picomatch: 2.3.1 + /real-require@0.2.0: + resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} + engines: {node: '>= 12.13.0'} + dev: true + /redux-thunk@3.1.0(redux@5.0.1): resolution: {integrity: sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==} peerDependencies: @@ -9968,6 +10144,11 @@ packages: is-regex: 1.1.4 dev: true + /safe-stable-stringify@2.4.3: + resolution: {integrity: sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==} + engines: {node: '>=10'} + dev: true + /safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} @@ -10017,6 +10198,10 @@ packages: compute-scroll-into-view: 3.1.0 dev: false + /secure-json-parse@2.7.0: + resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} + dev: true + /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -10195,6 +10380,12 @@ packages: tslib: 2.6.2 dev: true + /sonic-boom@4.0.1: + resolution: {integrity: sha512-hTSD/6JMLyT4r9zeof6UtuBDpjJ9sO08/nmS5djaA9eozT9oOlNdpXSnzcgj4FTqpk3nkLrs61l4gip9r1HCrQ==} + dependencies: + atomic-sleep: 1.0.0 + dev: true + /source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} @@ -10238,6 +10429,11 @@ packages: which: 2.0.2 dev: true + /split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + dev: true + /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} @@ -10350,6 +10546,12 @@ packages: safe-buffer: 5.1.2 dev: true + /string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + dependencies: + safe-buffer: 5.2.1 + dev: true + /strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -10543,6 +10745,12 @@ packages: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true + /thread-stream@3.1.0: + resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==} + dependencies: + real-require: 0.2.0 + dev: true + /throttleit@1.0.1: resolution: {integrity: sha512-vDZpf9Chs9mAdfY046mcPt8fg5QSZr37hEH4TXYBnDF+izxgrbRGUAAaBvIk/fJm9aOFCGFd1EsNg5AZCbnQCQ==} dev: true diff --git a/frontend/appflowy_web_app/server.cjs b/frontend/appflowy_web_app/server.cjs index e13c337faa..adff9bce6b 100644 --- a/frontend/appflowy_web_app/server.cjs +++ b/frontend/appflowy_web_app/server.cjs @@ -2,8 +2,7 @@ const path = require('path'); const fs = require('fs'); const pino = require('pino'); const cheerio = require('cheerio'); -const axios = require('axios'); - +const { fetch } = require('bun'); const distDir = path.join(__dirname, 'dist'); const indexPath = path.join(distDir, 'index.html'); @@ -38,38 +37,74 @@ const logRequestTimer = (req) => { }; const fetchMetaData = async (url) => { + logger.info(`Fetching meta data from ${url}`); try { - const response = await axios.get(url); - return response.data; + const response = await fetch(url, { + verbose: true, + }); + + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); + } + + const data = await response.json(); + + return data; } catch (error) { - logger.error('Error fetching meta data', error); + logger.error(`Error fetching meta data ${error}`); return null; } }; +const BASE_URL = process.env.AF_BASE_URL || 'https://test.appflowy.cloud'; const createServer = async (req) => { const timer = logRequestTimer(req); + const reqUrl = new URL(req.url); + logger.info(`Request URL: ${reqUrl.pathname}`); + const [ + namespace, + publishName, + ] = reqUrl.pathname.slice(1).split('/'); + + logger.info(`Namespace: ${namespace}, Publish Name: ${publishName}`); + if (namespace === '' || !publishName) { + timer(); + return new Response(null, { + status: 302, + headers: { + 'Location': 'https://appflowy.io', + }, + }); + } if (req.method === 'GET') { - const pageId = req.url.split('/').pop(); + let metaData; + try { + metaData = await fetchMetaData(`${BASE_URL}/api/workspace/published/${namespace}/${publishName}`); + } catch (error) { + logger.error(`Error fetching meta data: ${error}`); + } + let htmlData = fs.readFileSync(indexPath, 'utf8'); const $ = cheerio.load(htmlData); - if (!pageId) { - timer(); - return new Response($.html(), { - headers: { 'Content-Type': 'text/html' }, - }); - } const description = 'Write, share, comment, react, and publish docs quickly and securely on AppFlowy.'; let title = 'AppFlowy'; const url = 'https://appflowy.com'; let image = 'https://d3uafhn8yrvdfn.cloudfront.net/website/production/_next/static/media/og-image.e347bfb5.png'; // Inject meta data into the HTML to support SEO and social sharing - // if (metaData) { - // title = metaData.title; - // image = metaData.image; - // } + if (metaData) { + title = metaData.view.name; + + try { + const cover = metaData.view.extra ? JSON.parse(metaData.view.extra)?.cover : null; + if (cover && ['unsplash', 'custom'].includes(cover.type)) { + image = cover.value; + } + } catch (_) { + // Do nothing + } + } $('title').text(title); setOrUpdateMetaTag($, 'meta[name="description"]', 'name', description); diff --git a/frontend/appflowy_web_app/src/assets/arrow_right.svg b/frontend/appflowy_web_app/src/assets/arrow_right.svg new file mode 100644 index 0000000000..eba9ea9591 --- /dev/null +++ b/frontend/appflowy_web_app/src/assets/arrow_right.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/appflowy_web_app/src/assets/settings/discord.png b/frontend/appflowy_web_app/src/assets/settings/discord.png deleted file mode 100644 index f71e68c6ed8195eb09608280657f09298d9275ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1533 zcmVSxy$R`ZhcB*#8)UGq!5d?ZV3LYirDy8TYXx|?3GeBprjD( z9v9|V`DIF`pCwr(CV-I*kpaA{sIL{V8l}sMtO&?yC{buX%=}M;aHB+#fLFn7z#S1| z1uI4Yiy|-~U`L?RhK|cg^!BB6+fS-?z+GlRBAG$^#RP7Y5sR=|1%mZunBU~Zc)uNI z|BB<-nSR6*L*%gq%H0-NEFzl{&@U;oKhank-JujFRN2uqqXKJI)#7wp6ertaXgL$b zNKpG&zxk{z=BB1u6$*Ff1(DBwN4yt=~Fwsk7m*u?Os%Uog%3aPKy+Zp)cr;E{@8*l)YUl99Zso(cREJLFWAU5r!|(TuP=2aQ8Uhg z#}@_g<#(N??l(P(N{|IwOs#j3IgLt4DGDz+jLEew!*-@b%$sxT%IxO5jr%qw zf`i(v;@%m?W^5>;uG(oT4y4J~N1|z%Aw}^e7B?3IT;v6-0}kCbhNEkoV8>I8pp$$3-;})Pt=-4?_`tpZ+YJ zJQvTq7N3ONc!_inD#jNn9&Jp)Tz)qope0#1Q;C<9jhXQ>hAeG8? zS6|~)odU0{797dH-`|6MN5asGIY3pnJ zKN7ZOLdbTEbp*(2#NsU*g9o#3hq3m}(^XEz_KXynRkSe8)Z*r!Bx^tq&O#EhRY>{G jV43p%d#?nq9-aIPF|y-&XIdO-00000NkvXXu0mjf(m&a} diff --git a/frontend/appflowy_web_app/src/assets/settings/github.png b/frontend/appflowy_web_app/src/assets/settings/github.png deleted file mode 100644 index 597883b7a3e241064e71aa57130d4053bf551577..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1105 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 mOXU0&V(tBgay-zAH|KxYWKKc diff --git a/frontend/appflowy_web_app/src/components/document/Document.tsx b/frontend/appflowy_web_app/src/components/document/Document.tsx index cb21e8ede7..79cf106649 100644 --- a/frontend/appflowy_web_app/src/components/document/Document.tsx +++ b/frontend/appflowy_web_app/src/components/document/Document.tsx @@ -23,10 +23,10 @@ export const Document = ({ ...viewMeta }: DocumentProps) => { return ( -
+
}> -
+
{ switch (layout) { @@ -42,7 +42,7 @@ function CollabView({ doc }: CollabViewProps) { const getViewRowsMap = usePublishContext()?.getViewRowsMap; const loadView = usePublishContext()?.loadView; - if (!doc) { + if (!doc || !View) { return ; } @@ -57,6 +57,7 @@ function CollabView({ doc }: CollabViewProps) { icon={icon} cover={cover} viewId={viewId} + name={name} />
); diff --git a/frontend/appflowy_web_app/src/components/publish/PublishView.tsx b/frontend/appflowy_web_app/src/components/publish/PublishView.tsx index 4cb45e2c1c..a52c2efdd9 100644 --- a/frontend/appflowy_web_app/src/components/publish/PublishView.tsx +++ b/frontend/appflowy_web_app/src/components/publish/PublishView.tsx @@ -18,6 +18,7 @@ export function PublishView({ namespace, publishName }: PublishViewProps) { const openPublishView = useCallback(async () => { let doc; + setNotFound(false); try { doc = await service?.getPublishView(namespace, publishName); } catch (e) { diff --git a/frontend/appflowy_web_app/src/components/publish/header/Breadcrumb.tsx b/frontend/appflowy_web_app/src/components/publish/header/Breadcrumb.tsx index 840a202289..77685a4a9a 100644 --- a/frontend/appflowy_web_app/src/components/publish/header/Breadcrumb.tsx +++ b/frontend/appflowy_web_app/src/components/publish/header/Breadcrumb.tsx @@ -1,6 +1,6 @@ -import BreadcrumbItem, { Crumb } from 'src/components/publish/header/BreadcrumbItem'; +import BreadcrumbItem, { Crumb } from '@/components/publish/header/BreadcrumbItem'; import React, { useMemo } from 'react'; -import { ReactComponent as RightIcon } from '$icons/16x/right.svg'; +import { ReactComponent as RightIcon } from '@/assets/arrow_right.svg'; export function Breadcrumb({ crumbs }: { crumbs: Crumb[] }) { const renderCrumb = useMemo(() => { @@ -9,10 +9,10 @@ export function Breadcrumb({ crumbs }: { crumbs: Crumb[] }) { const key = crumb.rowId ? `${crumb.viewId}-${crumb.rowId}` : `${crumb.viewId}`; return ( - +
{!isLast && } - +
); }); }, [crumbs]); diff --git a/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx b/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx index d3b5770221..9d07ece56e 100644 --- a/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx +++ b/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx @@ -55,7 +55,7 @@ function BreadcrumbItem({ crumb, disableClick = false }: { crumb: Crumb; disable > {renderCrumbIcon(icon)} {name || t('menuAppHeader.defaultNewPageName')} diff --git a/frontend/appflowy_web_app/src/components/publish/header/PublishViewHeader.tsx b/frontend/appflowy_web_app/src/components/publish/header/PublishViewHeader.tsx index a5b8eafd33..2d3187f27c 100644 --- a/frontend/appflowy_web_app/src/components/publish/header/PublishViewHeader.tsx +++ b/frontend/appflowy_web_app/src/components/publish/header/PublishViewHeader.tsx @@ -6,11 +6,20 @@ export function PublishViewHeader() { const viewMeta = usePublishContext()?.viewMeta; const crumbs = useMemo(() => { const ancestors = viewMeta?.ancestor_views || []; + let icon = viewMeta?.icon; + + try { + const extra = viewMeta?.extra ? JSON.parse(viewMeta.extra) : {}; + + icon = extra.icon || icon; + } catch (e) { + // ignore + } return ancestors.map((ancestor) => ({ viewId: ancestor.view_id, name: ancestor.name, - icon: ancestor.icon || String(viewMeta?.layout), + icon: icon || String(viewMeta?.layout), })); }, [viewMeta]); diff --git a/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts b/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts index adcbf57b03..e3f37749a0 100644 --- a/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts +++ b/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts @@ -22,13 +22,7 @@ export function useViewMeta() { }; }, [extra]); - const layout = useMemo(() => { - if (viewMeta?.layout) { - return viewMeta.layout; - } - - return; - }, [viewMeta?.layout]); + const layout = viewMeta?.layout; const style = useMemo(() => { const fontSizeMap = { small: '14px', @@ -96,7 +90,8 @@ export function useViewMeta() { }, [extra]); const viewId = viewMeta?.view_id; - + const name = viewMeta?.name; + return { icon, cover, @@ -104,5 +99,6 @@ export function useViewMeta() { layoutClassName, layout, viewId, + name, }; } diff --git a/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx b/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx index 60716a4454..2fb3882b9b 100644 --- a/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx +++ b/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx @@ -57,7 +57,7 @@ export function ViewMetaPreview({ icon, cover, name }: ViewMetaProps) { const { t } = useTranslation(); return ( -
+
{cover && }