diff --git a/.gitignore b/.gitignore index b2d6de30..3b2beea2 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +.tmp/ +docs/ +versioned_docs/ \ No newline at end of file diff --git a/Makefile b/Makefile index 3c2ecda0..68f79782 100644 --- a/Makefile +++ b/Makefile @@ -7,43 +7,76 @@ endif .PHONY: all all: build -.PHONY: prepare-latest -prepare-latest: - mkdir -p .tmp docs +.PHONY: create_dir +create_dir: + mkdir -p .tmp docs versioned_docs + +.PHONY: clone_main +clone_main: create_dir git clone --depth=1 --branch=main https://github.com/go-gitea/gitea.git .tmp/upstream-docs-latest + cur_path=`pwd` + cd .tmp/upstream-docs-latest/docs && make trans-copy + cd $(cur_path) + +.PHONY: prepare-latest +prepare-latest: clone_main cp -r .tmp/upstream-docs-latest/docs/static/* static/ rsync -avz --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/doc/ docs/ cp .tmp/upstream-docs-latest/docs/content/page/index.en-us.md docs/intro.md cp .tmp/upstream-docs-latest/templates/swagger/v1_json.tmpl static/latest-swagger.json bash loop_docs.sh rm docs/help/search.en-us.md - rm -rf .tmp/upstream-docs-latest + +.PHONY: prepare-latest-zh-cn +prepare-latest-zh-cn: clone_main + cp -r .tmp/upstream-docs-latest/docs/static/* static/ + rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/doc/ docs/zh-cn/ + cp .tmp/upstream-docs-latest/docs/content/page/index.zh-cn.md docs/zh-cn/intro.md + cp .tmp/upstream-docs-latest/templates/swagger/v1_json.tmpl static/latest-swagger.json + bash loop_docs-zh-cn.sh + rm docs/zh-cn/help/search.zh-cn.md + +.PHONY: clone_\#% +clone_\#%: create_dir + git clone --depth=1 --branch=release/v1.$* https://github.com/go-gitea/gitea.git .tmp/upstream-docs-$* + cur_path=`pwd` + cd .tmp/upstream-docs-$*/docs && make trans-copy + cd $(cur_path) .PHONY: prepare\#% -prepare\#%: - mkdir -p versioned_docs - git clone --depth=1 --branch=release/v1.$* https://github.com/go-gitea/gitea.git .tmp/upstream-docs-$* +prepare\#%: clone_\#% cp -r .tmp/upstream-docs-$*/docs/static/* static/ rsync -a --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/doc/ versioned_docs/version-1.$*/ cp .tmp/upstream-docs-$*/docs/content/page/index.en-us.md versioned_docs/version-1.$*/intro.md cp .tmp/upstream-docs-$*/templates/swagger/v1_json.tmpl static/$*-swagger.json bash loop_docs-$*.sh rm versioned_docs/version-1.$*/help/search.en-us.md - rm -rf .tmp/upstream-docs-$* + +.PHONY: prepare-zh-cn\#% +prepare-zh-cn\#%: clone_\#% + cp -r .tmp/upstream-docs-$*/docs/static/* static/ + rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/doc/ versioned_docs/version-1.$*/zh-cn/ + cp .tmp/upstream-docs-19/docs/content/page/index.zh-cn.md versioned_docs/version-1.$*/zh-cn/intro.md + cp .tmp/upstream-docs-19/templates/swagger/v1_json.tmpl static/$*-swagger.json + bash loop_docs-$*-zh-cn.sh + rm versioned_docs/version-1.$*/zh-cn/help/search.zh-cn.md + +.PHONY: install +install: + npm install .PHONY: build -build: prepare-latest prepare\#19 +build: install prepare-latest prepare\#19 prepare-latest-zh-cn prepare-zh-cn\#19 npm ci npm run build .PHONY: serve -serve: prepare-latest - npm run serve +serve: install prepare-latest prepare\#19 prepare-latest-zh-cn prepare-zh-cn\#19 + npm run start .PHONY: clean clean: rm -rf .tmp - rm -rf node_modules rm -rf docs rm -rf versioned_docs/ rm -rf static/_* diff --git a/docusaurus.config.js b/docusaurus.config.js index bbb05e83..0158ead6 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -16,7 +16,7 @@ const config = { i18n: { defaultLocale: 'en', - locales: ['en'/*, 'fr-fr', 'zh-cn', 'zh-tw'*/], // temporarily disable other locales + locales: ['en'/*, 'zh-cn', 'fr-fr', 'zh-tw'*/], // temporarily disable other locales }, presets: [ @@ -94,6 +94,10 @@ const config = { type: 'search', position: 'right', }, + { + type: 'localeDropdown', + position: 'right', + }, { type: 'docsVersionDropdown', position: 'right', diff --git a/loop_docs-19-zh-cn.sh b/loop_docs-19-zh-cn.sh new file mode 100644 index 00000000..bc4087d5 --- /dev/null +++ b/loop_docs-19-zh-cn.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +set -xe + +if sed --version 2>/dev/null | grep -q GNU; then + SED_INPLACE="sed -i" +else + SED_INPLACE="sed -i ''" +fi + +$SED_INPLACE 's/}}//' $file + $SED_INPLACE 's/{{< version >}}/1.19.0/g' $file + $SED_INPLACE 's/{{< relref "doc/\/docs/g' $file + $SED_INPLACE 's/" >}}//g' $file + $SED_INPLACE 's/\*\*Table of Contents\*\*//' $file +done + +for file in `find ./versioned_docs/version-1.19/zh-cn/usage/ -name "*.md"`; do + # note only works on linux, forget about it when attempting to run on macos + # hide hugo toc + $SED_INPLACE 's/title:.*//' $file +done + +for file in versioned_docs/version-1.19/zh-cn/*; do + if [ -d $file ]; then + continue + fi + if [ "$file" == "versioned_docs/version-1.19/zh-cn/intro.md" ]; then + continue + fi + rm $file +done + +# for file in `find ./versioned_docs/version-1.19/zh-cn/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done +# for file in `find ./i18n/zh-tw/docusaurus-plugin-content-docs/version-1.19/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done +# for file in `find ./i18n/fr-fr/docusaurus-plugin-content-docs/version-1.19/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done +# for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done diff --git a/loop_docs-zh-cn.sh b/loop_docs-zh-cn.sh new file mode 100644 index 00000000..2e34b8ed --- /dev/null +++ b/loop_docs-zh-cn.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -xe + +if sed --version 2>/dev/null | grep -q GNU; then + SED_INPLACE="sed -i" +else + SED_INPLACE="sed -i ''" +fi + +$SED_INPLACE 's/}}//' $file + $SED_INPLACE 's/{{< version >}}/1.18.2/g' $file + $SED_INPLACE 's/{{< relref "doc/\/docs/g' $file + $SED_INPLACE 's/" >}}//g' $file + $SED_INPLACE 's/\*\*Table of Contents\*\*//' $file +done + +for file in `find ./docs/zh-cn/usage/ -name "*.md"`; do + # note only works on linux, forget about it when attempting to run on macos + # hide hugo toc + $SED_INPLACE 's/title:.*//' $file +done + +for file in docs/zh-cn/*; do + if [ -d $file ]; then + continue + fi + if [ "$file" == "docs/zh-cn/intro.md" ]; then + continue + fi + rm $file +done + + +# for file in `find ./docs/zh-cn/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done + +# for file in `find ./i18n/zh-tw/docusaurus-plugin-content-docs/zh-cn/current/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done +# for file in `find ./i18n/fr-fr/docusaurus-plugin-content-docs/zh-cn/current/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done +# for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/zh-cn/current/ -name "*.md"`; do +# trimmed=$(echo $file | cut -f 2 -d '.') +# mv $file .$trimmed.md +# done diff --git a/versioned_sidebars/version-sidebars-1.19.json b/versioned_sidebars/version-sidebars-1.19.json new file mode 100644 index 00000000..bd400751 --- /dev/null +++ b/versioned_sidebars/version-sidebars-1.19.json @@ -0,0 +1,79 @@ +{ + "mySidebar": [ + { + "type": "link", + "label": "What is Gitea?", + "href": "/" + }, + { + "type": "category", + "label": "Installation", + "items": [ + { + "type": "autogenerated", + "dirName": "installation" + } + ] + }, + { + "type": "category", + "label": "Administration", + "items": [ + { + "type": "autogenerated", + "dirName": "administration" + } + ] + }, + { + "type": "category", + "label": "Usage", + "items": [ + { + "type": "category", + "label": "Packages", + "items": [ + { + "type": "autogenerated", + "dirName": "packages" + } + ] + }, + { + "type": "autogenerated", + "dirName": "usage" + } + ] + }, + { + "type": "category", + "label": "Development", + "items": [ + { + "type": "autogenerated", + "dirName": "development" + } + ] + }, + { + "type": "category", + "label": "Contributing", + "items": [ + { + "type": "autogenerated", + "dirName": "contributing" + } + ] + }, + { + "type": "category", + "label": "Help", + "items": [ + { + "type": "autogenerated", + "dirName": "help" + } + ] + } + ] +} diff --git a/versioned_sidebars/version-sidebars-zh-cn-1.19.json b/versioned_sidebars/version-sidebars-zh-cn-1.19.json new file mode 100644 index 00000000..bd400751 --- /dev/null +++ b/versioned_sidebars/version-sidebars-zh-cn-1.19.json @@ -0,0 +1,79 @@ +{ + "mySidebar": [ + { + "type": "link", + "label": "What is Gitea?", + "href": "/" + }, + { + "type": "category", + "label": "Installation", + "items": [ + { + "type": "autogenerated", + "dirName": "installation" + } + ] + }, + { + "type": "category", + "label": "Administration", + "items": [ + { + "type": "autogenerated", + "dirName": "administration" + } + ] + }, + { + "type": "category", + "label": "Usage", + "items": [ + { + "type": "category", + "label": "Packages", + "items": [ + { + "type": "autogenerated", + "dirName": "packages" + } + ] + }, + { + "type": "autogenerated", + "dirName": "usage" + } + ] + }, + { + "type": "category", + "label": "Development", + "items": [ + { + "type": "autogenerated", + "dirName": "development" + } + ] + }, + { + "type": "category", + "label": "Contributing", + "items": [ + { + "type": "autogenerated", + "dirName": "contributing" + } + ] + }, + { + "type": "category", + "label": "Help", + "items": [ + { + "type": "autogenerated", + "dirName": "help" + } + ] + } + ] +} diff --git a/versioned_sidebars/version-sidebars-zh-cn-latest.json b/versioned_sidebars/version-sidebars-zh-cn-latest.json new file mode 100644 index 00000000..bd400751 --- /dev/null +++ b/versioned_sidebars/version-sidebars-zh-cn-latest.json @@ -0,0 +1,79 @@ +{ + "mySidebar": [ + { + "type": "link", + "label": "What is Gitea?", + "href": "/" + }, + { + "type": "category", + "label": "Installation", + "items": [ + { + "type": "autogenerated", + "dirName": "installation" + } + ] + }, + { + "type": "category", + "label": "Administration", + "items": [ + { + "type": "autogenerated", + "dirName": "administration" + } + ] + }, + { + "type": "category", + "label": "Usage", + "items": [ + { + "type": "category", + "label": "Packages", + "items": [ + { + "type": "autogenerated", + "dirName": "packages" + } + ] + }, + { + "type": "autogenerated", + "dirName": "usage" + } + ] + }, + { + "type": "category", + "label": "Development", + "items": [ + { + "type": "autogenerated", + "dirName": "development" + } + ] + }, + { + "type": "category", + "label": "Contributing", + "items": [ + { + "type": "autogenerated", + "dirName": "contributing" + } + ] + }, + { + "type": "category", + "label": "Help", + "items": [ + { + "type": "autogenerated", + "dirName": "help" + } + ] + } + ] +}