diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 00000000..3e89a98e --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,86 @@ +name: Build and deploy vim help + +# This is an experimental. +# +# gh-pagesブランチを経由せず、actions/upload-pages-artifactを使って直接GitHub Pagesにデプロイする試み +# pushのたびにいったん artifacts まで作る(HTML生成+Jekyll実行) +# masterへのpushかcronでの実行であればGitHub Pagesへアップロードする +# …という計画 + +on: + push: + + schedule: + - cron: '5 12 * * *' + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: Setup Vim + uses: thinca/action-setup-vim@v2 + with: + vim_version: 'v9.1.0065' + vim_type: 'Vim' + + - name: Checkout + uses: actions/checkout@v4 + + # + # Generate HTML from Vim documents and upload it as an artifact. + # + + - name: Generate new HTML documents + run: | + make html + + - name: Check commit IDs + id: commitid + run: | + echo "vim=$(git -C vim rev-parse HEAD)" >> $GITHUB_OUTPUT + echo "vim_faq=$(git -C vim_faq rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Upload vim generated HTML files as an artifact + uses: actions/upload-artifact@v4 + with: + name: vim-generated-html + path: target/html/doc/*.html + + # + # Generate GitHub Page site and upload it as an artifact. + # + + - name: Prepare for building GitHub Page (Jekyll) + run: + make jekyll-build-prepare + + - name: Build GitHub Page site + uses: actions/jekyll-build-pages@v1 + with: + source: target/jekyll-work + verbose: true + + - name: Upload a site as an artifact + uses: actions/upload-pages-artifact@v3 + with: + path: _site/ + retention-days: 7 + + # Upload a site to GitHub Pages + deploy: + needs: + - build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-22.04 + permissions: + contents: read + pages: write + id-token: write + # Run only when updating the master branch or when started by cron. + if: github.ref == 'refs/heads/master' || github.event_name == 'schedule' + steps: + - name: Deploy to Github Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 02ec45a2..b0321a02 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -44,7 +44,7 @@ jobs: run: | echo "vim=$(git -C work/vim rev-parse HEAD)" >> $GITHUB_OUTPUT echo "vim_faq=$(git -C work/vim_faq rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Commit updated master branch + - name: Commit updated gh-pages branch uses: EndBug/add-and-commit@v9 with: cwd: './target' diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml index 6372947a..b67c7908 100644 --- a/.github/workflows/trigger.yml +++ b/.github/workflows/trigger.yml @@ -17,3 +17,7 @@ jobs: -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ -H "Accept: application/vnd.github.v3+json" \ 'https://api.github.com/repos/vim-jp/vimdoc-en/actions/workflows/trigger.yml/enable' + curl -i -X PUT \ + -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ + -H "Accept: application/vnd.github.v3+json" \ + 'https://api.github.com/repos/vim-jp/vimdoc-en/actions/workflows/build-and-deploy.yml/enable' diff --git a/.gitignore b/.gitignore index 670d5b37..74103605 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /target/ /vim/ /vim_faq/ +/tmp/ diff --git a/Makefile b/Makefile index 7bead814..898f1d36 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,48 @@ .PHONY: all html clean +JEKYLL_WORKDIR=target/jekyll-work +JEKYLL_OUTDIR=target/_site + all: + $(MAKE) html + $(MAKE) jekyl-build-by-docker + +html-prepare: vim/runtime/doc vim_faq/doc target/html/doc + rm -f target/html/doc/*.txt + cp vim/runtime/doc/*.txt target/html/doc + cp vim_faq/doc/*.txt target/html/doc -html: - rm -rf target/html - mkdir -p target/html/doc - if [ ! -d vim/runtime/doc ]; then git clone --depth=1 https://github.com/vim/vim.git; fi - if [ ! -d vim_faq/doc ]; then git clone --depth=1 https://github.com/chrisbra/vim_faq.git; fi - cd vim; git apply ../tools/add-vimfaq-link.diff; cd .. - cp vim/runtime/doc/*.txt vim_faq/doc/*.txt target/html/doc +html: html-prepare -cd target/html/doc ; vim -eu ../../../tools/buildhtml.vim -c "qall!" +vim/runtime/doc: + git clone --depth=1 https://github.com/vim/vim.git + cd vim && git apply ../tools/add-vimfaq-link.diff + +vim_faq/doc: + git clone --depth=1 https://github.com/chrisbra/vim_faq.git + +target/html/doc: + mkdir -p $@ + clean: rm -rf target + +distclean: clean + rm -rf vim vim_faq + +jekyll-build-prepare: + mkdir -p $(JEKYLL_WORKDIR) + cp target/html/doc/*.html $(JEKYLL_WORKDIR) + cp -Ru src/* $(JEKYLL_WORKDIR) + +jekyll-build: jekyll-build-prepare + jekyll build -s $(JEKYLL_WORKDIR) -d $(JEKYLL_OUTDIR) + +jekyll-build-by-docker: jekyll-build-prepare + ./tools/docker_jekyll jekyll build -s $(JEKYLL_WORKDIR) -d $(JEKYLL_OUTDIR) + +jekyll-clean: + rm -rf $(JEKYLL_WORKDIR) $(JEKYLL_OUTDIR) + +.PHONY: jekyll-build-prepare jekyll-build jekyll-build-by-docker jekyll-clean diff --git a/README.md b/README.md index e8b5331c..908c0ed0 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,16 @@ There is already another similar site: . The main purpose of the vimdoc-en project is to provide a handy way to see both Japanese and English versions of the help pages. The help pages are automatically updated everyday (if there are any changes). + +## for Developers + +First of all, to generate everything, just run `make`. +This requires Docker, so prepare it in advance. + +Here's what's happening: + +1. Run `make html` to generate HTML files before GitHub Pages (Jekyll) processing + 1. Download vim and vim\_faq + 2. Collect the necessary \*.txt files + 3. Convert the \*.txt files to \*.html +2. Run `make jekyll-build-by-docker` to output all HTML files for the vimdoc-en site using GitHub Pages (Jekyll) diff --git a/src/_config.yml b/src/_config.yml new file mode 100644 index 00000000..e9820d7b --- /dev/null +++ b/src/_config.yml @@ -0,0 +1,25 @@ +############################################################################ +# 原則 http://jekyllrb.com/docs/configuration/#default-configuration からの +# 差分のみ記述している。記述順序も前述に従う。 + +### Handling Reading +# デフォルトと同じだが「utf-8で記事を書こう」という宣言的な意味合で残した。 +encoding: utf-8 + +### Filtering Content +future: true + +### Outputting +# デフォルトと同じだが、万が一デフォルトが変わってしまうと記事のURLが変わってし +# まいクリティカルなので、明示的に指定した。 +permalink: date + +### Markdown Processors +kramdown: + input: GFM + +############################################################################ +# 以下はvim-jp固有の設定項目 + +# baseurl と紛らわしいが別物なので要注意 +base-url: http://vim-jp.org/vimdoc-en diff --git a/src/_includes/google-analytics.html b/src/_includes/google-analytics.html new file mode 100644 index 00000000..afb5d106 --- /dev/null +++ b/src/_includes/google-analytics.html @@ -0,0 +1,10 @@ + diff --git a/src/_layouts/vimdoc.html b/src/_layouts/vimdoc.html new file mode 100644 index 00000000..210a6ef2 --- /dev/null +++ b/src/_layouts/vimdoc.html @@ -0,0 +1,314 @@ + + + + +{{ page.helpname }} - Vim Documentation + + + + + + + + + + + + + + +
+ + + + + +
+ vim-jp + / vimdoc-en + / {{ page.helpname }}
+

{{ page.helpname }} - Vim Documentation

+ Return to main + + + English + | 日本語 + +
+
+ + + +
+{{ content }} +
+ + + + + + + + + + diff --git a/src/background-white.png b/src/background-white.png new file mode 100644 index 00000000..c981fb8b Binary files /dev/null and b/src/background-white.png differ diff --git a/src/js/check-referrer.js b/src/js/check-referrer.js new file mode 100644 index 00000000..d79fde65 --- /dev/null +++ b/src/js/check-referrer.js @@ -0,0 +1,15 @@ +$(function() { + 'use strict'; + var REDIRECTS = { + '//vim-jp.org/vimdoc-ja/hebrew.html': true, + '//vim-jp.org/vimdoc-ja/todo.html': true, + '//vim-jp.org/vimdoc-ja/version5.html': true, + '//vim-jp.org/vimdoc-ja/version6.html': true, + '//vim-jp.org/vimdoc-ja/version7.html': true, + }; + var CLS = 'redirected-by-notranslation'; + var MSG = 'このページには日本語訳が存在しないために英語版に転送されました。'; + if (REDIRECTS[document.referrer.replace(/^https?:/, '')]) { + $('.header').append('
' + MSG + '
'); + } +}) diff --git a/src/mark-current-page.js b/src/mark-current-page.js new file mode 100644 index 00000000..6d521849 --- /dev/null +++ b/src/mark-current-page.js @@ -0,0 +1,10 @@ +$(function() { + // Mark an item of current page in