diff --git a/.github/workflows/generate-ebooks.yml b/.github/workflows/generate-ebooks.yml new file mode 100644 index 00000000000..38053001241 --- /dev/null +++ b/.github/workflows/generate-ebooks.yml @@ -0,0 +1,63 @@ +###################################### +## Custom Web Almanac GitHub action ## +###################################### +# +# A script that must be run in GitHub Actions to generate the ebooks. +# Useful for those that don't have prince installed locally. +# +name: Generate ebooks + +env: + # Update periodically from https://www.princexml.com/latest/ + PRINCE_PACKAGE: 'prince_16.1-1_ubuntu24.04_amd64.deb' + +on: + workflow_dispatch: + +jobs: + build: + name: Generate Ebooks + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v7 + - name: Setup Node.js for use with actions + uses: actions/setup-node@v7 + with: + node-version: '24' + - name: Set up Python 3.12 + uses: actions/setup-python@v7 + with: + python-version: '3.12' + - name: Install Asian Fonts + if: ${{ github.event.inputs.ebooks == 'true' }} + run: | + # Install Japanese san-serif font + sudo apt-get install -y fonts-ipafont-gothic + # Install Chinese san-serif font + sudo apt-get install -y fonts-arphic-uming + # Install Korean san-serif font + sudo apt-get install -y fonts-unfonts-core + - name: Install PrinceXML + if: ${{ github.event.inputs.ebooks == 'true' }} + run: | + wget https://www.princexml.com/download/${{ env.PRINCE_PACKAGE }} --directory-prefix=/tmp + DEBIAN_FRONTEND=noninteractive sudo apt install -y /tmp/${{ env.PRINCE_PACKAGE }} + - name: Install pdftk + if: ${{ github.event.inputs.ebooks == 'true' }} + run: sudo apt install pdftk + - name: Run the website + run: ./src/tools/scripts/run_and_test_website.sh + - name: Generating Ebooks + run: | + cd src + mkdir static/pdfs/ + npm run ebooks + - name: Upload PDF artifact + if: ${{ github.event.inputs.ebooks == 'true' }} + uses: actions/upload-artifact@v7 + with: + name: pdfs + path: ./src/static/pdfs/*.pdf + if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn` + retention-days: 5 # defaults to 90 diff --git a/src/config/2025.json b/src/config/2025.json index fa147a2a2c7..241112a95fc 100644 --- a/src/config/2025.json +++ b/src/config/2025.json @@ -3,7 +3,7 @@ { "is_live": true, "supported_languages": ["de","en","es","fr","hi","it","ja","nl","pt","ru","tr","uk","zh-CN","zh-TW"], - "ebook_languages": ["en"] + "ebook_languages": ["en","ja"] } ], "outline": [ diff --git a/src/config/last_updated.json b/src/config/last_updated.json index d1fd0dcac49..0d5a88b9219 100644 --- a/src/config/last_updated.json +++ b/src/config/last_updated.json @@ -235,6 +235,23 @@ "date_modified": "2026-06-09T00:00:00.000Z", "hash": "1b4f831fe700d22363fcf6a84fffd009", "size": 12 + }, + "/static/pdfs/web_almanac_2025_ja.pdf": { + "date_published": "2026-08-10T00:00:00.000Z", + "date_modified": "2026-08-10T00:00:00.000Z", + "hash": "84fd8a59f723beed0e3f93dba2135542", + "size": 12 + }, + "/static/pdfs/web_almanac_2025_ja_cover_A5.pdf": { + "date_published": "2026-08-10T00:00:00.000Z", + "date_modified": "2026-08-10T00:00:00.000Z", + "hash": "b73962b439e73aadf6f22554e597adfc" + }, + "/static/pdfs/web_almanac_2025_ja_print_A5.pdf": { + "date_published": "2026-08-10T00:00:00.000Z", + "date_modified": "2026-08-10T00:00:00.000Z", + "hash": "05c36794e850f494d862825794301586", + "size": 12 }, "en/2019/chapters/accessibility.html": { "date_published": "2019-11-11T00:00:00.000Z", diff --git a/src/templates/base/base_ebook.html b/src/templates/base/base_ebook.html index 3e65f05f45a..1bd451dfe0c 100644 --- a/src/templates/base/base_ebook.html +++ b/src/templates/base/base_ebook.html @@ -119,11 +119,15 @@ {% set unit = 'mm' %} {% set spine = 25 %} +{% if year == '2019' and lang == 'ja' %}{% set spine = 26.0 %}{% endif %} {% if year == '2020' and lang == 'en' %}{% set spine = 36.0 %}{% endif %} {% if year == '2020' and lang == 'ja' %}{% set spine = 37.0 %}{% endif %} -{% if year == '2021' %}{% set spine = 46.5 %}{% endif %} -{% if year == '2022' %}{% set spine = 42.5 %}{% endif %} -{% if year == '2024' %}{% set spine = 42.5 %}{% endif %} +{% if year == '2021' and lang == 'en' %}{% set spine = 46.5 %}{% endif %} +{% if year == '2022' and lang == 'ja' %}{% set spine = 43.5 %}{% endif %} +{% if year == '2024' and lang == 'en' %}{% set spine = 44.5 %}{% endif %} +{% if year == '2024' and lang == 'ha' %}{% set spine = 46.0 %}{% endif %} +{% if year == '2025' and lang == 'en' %}{% set spine = 33.5 %}{% endif %} +{% if year == '2025' and lang == 'ja' %}{% set spine = 34.5 %}{% endif %} {% set pageWidth = 148 %} {% set pageHeight = 210 %} {% if request.args.get('unit') != None %}{% set unit = request.args.get('unit') %}{% endif %}