From c894b1a250509468f165bc0ad07d392b57221244 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 6 Apr 2023 17:23:05 +0100 Subject: [PATCH 1/4] CI: Publish to GitHub pages. --- .github/workflows/pages.yml | 35 +++++++++++++++++++++++++++++++++++ Makefile | 3 +++ generate-html.py | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pages.yml diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..743cab8d --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,35 @@ +name: Pages + +on: + pull_request: + push: + branches: + - main + +jobs: + test: + name: GitHub Pages (en) + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: 3.11 + + - name: Install Dependencies + run: | + make deps + + - name: Build Packages + run: | + make LANG=en + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./output/en + cname: pinout.xyz diff --git a/Makefile b/Makefile index 0d51f539..5e6ac32a 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ LANG := $(firstword $(LANG)) all: html resources +deps: + python3 -m pip install -r requirements.txt + css: scss resources/pinout.scss > resources/pinout.scss.css diff --git a/generate-html.py b/generate-html.py index 59e0683a..fdbc47d7 100755 --- a/generate-html.py +++ b/generate-html.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import re From 605a51f5ad23160746e254d89cd848f5c9d48ce2 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 31 Jul 2023 17:51:13 +0100 Subject: [PATCH 2/4] CI: GitHub pages compatible vanity URLs. --- generate-html.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/generate-html.py b/generate-html.py index fdbc47d7..03c4ac2d 100755 --- a/generate-html.py +++ b/generate-html.py @@ -787,9 +787,14 @@ def interfaces_menu(current): crumbtrail=crumbtrail ) - debug(0, '>> Saving: pinout/{}.html'.format(pin_url)) + debug(0, '>> Saving: pinout/{}/index.html'.format(pin_url)) - with open(os.path.join('output', lang, 'pinout', '{}.html'.format(pin_url)), 'w') as f: + try: + os.mkdir(os.path.join('output', lang, 'pinout', '{}'.format(pin_url))) + except FileExistsError: + pass + + with open(os.path.join('output', lang, 'pinout', '{}/index.html'.format(pin_url)), 'w') as f: f.write(pin_html) @@ -876,10 +881,21 @@ def interfaces_menu(current): if url not in ['index', '404', 'boards']: url = os.path.join('pinout', url) + output_path = os.path.join('output', lang, f'{url}.html') + output_url = f'{url}.html' + + if url == 'boards': + output_path = os.path.join('output', lang, f'{url}/index.html') + output_url = f'{url}/index.html' + try: + os.mkdir(os.path.join('output', lang, url)) + except FileExistsError: + pass + if 'source' in pages[key]: - debug(0, '>> Saving: {src} => {url}.html'.format(url=url, src=pages[key]['source'])) + debug(0, '>> Saving: {src} => {url}'.format(url=output_url, src=pages[key]['source'])) - with open(os.path.join('output', lang, '{}.html'.format(url)), 'w') as f: + with open(output_path, 'w') as f: f.write(html) print('\nAll done!') From 02140940f2d714ec9bce389db181f9a21676d7df Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 31 Jul 2023 18:09:54 +0100 Subject: [PATCH 3/4] Footer: Change defunct pi link. --- src/en/template/footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/en/template/footer.html b/src/en/template/footer.html index 2208b730..6e4dd92f 100644 --- a/src/en/template/footer.html +++ b/src/en/template/footer.html @@ -1,3 +1,3 @@

Spotted an error, want to add your board's pinout? Contribute to Pinout.xyz at GitHub

-

Originally part of pi.gadgetoid.com. Maintained by @Gadgetoid@fosstodon.org.

+

Part of gadgetoid.com. Maintained by @Gadgetoid@fosstodon.org.

Help make Pinout.xyz better- please sponsor me at Ko-Fi, GitHub or Patreon

\ No newline at end of file From a72893ed68910a1c9cee6083d5c651a5a937f80d Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 13 Oct 2023 15:26:58 +0100 Subject: [PATCH 4/4] CI: Target master branch for GH pages build. --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 743cab8d..d672d4a4 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - main + - master jobs: test: