-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,018 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Compile host-redirect.min.js | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "firebase.json" | ||
- "tool/host-redirect/**" | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
NODE_VERSION: 20 | ||
|
||
jobs: | ||
compile_host_redirect_js: | ||
if: ${{ github.actor.login != 'cfug-dev' && | ||
github.repository == 'cfug/flutter.cn' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
- name: Build JS | ||
run: bash ./tool/host-redirect/build.sh | ||
shell: bash |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules/ | ||
build/ | ||
report/ | ||
coverage/ | ||
.AppleDouble | ||
.vscode/ | ||
/.development | ||
/.developmentx | ||
/.xdevelopment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Amos<[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## 临时的重定向方案 | ||
|
||
由于 OSS 部分限制的问题, | ||
无法将大量重定向逻辑在服务端直接使用(类似 Nginx、Apache 等), | ||
|
||
所有无法访问的链接会被重定向至 404 页, | ||
该方案利用 404 页, | ||
将 firebase.json 内的重定向逻辑运行在 404 页面。 | ||
|
||
关于 firebase.json 内重定向的相关资料: | ||
> https://firebase.google.cn/docs/hosting/full-config?hl=zh-cn#redirects | ||
### 环境 | ||
|
||
- node v20.11.0 | ||
- npm v10.2.4 | ||
|
||
### 使用 | ||
|
||
```sh | ||
npm install | ||
|
||
npm run build # ./build/host-redirect.min.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/bash | ||
|
||
cd tool/host-redirect | ||
npm install | ||
npm run build | ||
|
||
cd - | ||
cp ./tool/host-redirect/build/host-redirect.min.js ./src/content/assets/js/host-redirect.min.js | ||
|
||
git init | ||
git config --global user.name "cfug-dev" | ||
git config --global user.email "[email protected]" | ||
|
||
git add ./src/content/assets/js/host-redirect.min.js | ||
git commit -m "[sync] Update: host-redirect.min.js" | ||
git push -u -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "host_redirect", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "./src/index.js", | ||
"scripts": { | ||
"build": "node ./src/generate_firebase_data.js && webpack" | ||
}, | ||
"author": "AmosHuKe", | ||
"homepage": "https://github.com/cfug/flutter.cn/tree/main/tool/host-redirect", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"webpack": "^5.91.0", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"dependencies": { | ||
"minimatch": "^9.0.4", | ||
"path-to-regexp": "^6.2.2", | ||
"re2js": "^0.4.1" | ||
} | ||
} |
Oops, something went wrong.