diff --git a/.github/workflows/dev_branch.yaml b/.github/workflows/dev_branch.yaml new file mode 100644 index 0000000..e8fd607 --- /dev/null +++ b/.github/workflows/dev_branch.yaml @@ -0,0 +1,30 @@ +name: Dev Branch + +on: + push: + branches: + - 'dev' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install necessary Python packages + run: | + pip install -r requirements.txt + - name: Update submodules + run: | + git submodule update --remote + + # Custom script + - name: Run custom prechecking + run: python prechecker.py \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..b00a665 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,29 @@ +name: Pull Request + +on: + pull_request: + types: [opened, reopened] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install necessary Python packages + run: | + pip install -r requirements.txt + - name: Update submodules + run: | + git submodule update --remote + + # Custom script + - name: Run custom prechecking + run: python prechecker.py \ No newline at end of file diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 6f03393..b8d88cc 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -2,6 +2,8 @@ name: Push on: push: + branches: + - 'main' workflow_dispatch: repository_dispatch: types: [ost-data-export-update-event] diff --git a/_main_config.py b/_main_config.py new file mode 100644 index 0000000..2a7f7cb --- /dev/null +++ b/_main_config.py @@ -0,0 +1,11 @@ +ALL_LANGS = ["en", "zh_cn"] +LANG_OTHER_PAGE = { + "page/{lang}/main_all.html": "main/index.html", + "page/{lang}/_index.html": "index.html", + "page/{lang}/_about.html": "about.html" +} +OTHER_STATIC_PAGE = { + "page/index.html": "index.html", + "page/404.html": "404.html", + "page/zh_cn/_zhcn_technical.html": "zh_cn/zhcn_technical.html" +} \ No newline at end of file diff --git a/main_prod.py b/main_prod.py index 4dcec73..ba5253e 100644 --- a/main_prod.py +++ b/main_prod.py @@ -1,16 +1,5 @@ from _main import * - -ALL_LANGS = ["en", "zh_cn"] -LANG_OTHER_PAGE = { - "page/{lang}/main_all.html": "main/index.html", - "page/{lang}/_index.html": "index.html", - "page/{lang}/_about.html": "about.html" -} -OTHER_STATIC_PAGE = { - "page/index.html": "index.html", - "page/404.html": "404.html", - "page/zh_cn/_zhcn_technical.html": "zh_cn/zhcn_technical.html" -} +from _main_config import * delete_old_page() copy_static_file(True) diff --git a/main_test.py b/main_test.py index d8dbbc5..991afd6 100644 --- a/main_test.py +++ b/main_test.py @@ -1,16 +1,6 @@ from _main import * +from _main_config import * -ALL_LANGS = ["zh_cn"] -LANG_OTHER_PAGE = { - "page/{lang}/main_all.html": "main/index.html", - "page/{lang}/_index.html": "index.html", - "page/{lang}/_about.html": "about.html" -} -OTHER_STATIC_PAGE = { - "page/index.html": "index.html", - "page/404.html": "404.html", - "page/zh_cn/_zhcn_technical.html": "zh_cn/zhcn_technical.html" -} ALL_FOLDERS = ["character"] delete_old_page() diff --git a/main_tool.py b/main_tool.py index 9c70e19..7a77abe 100644 --- a/main_tool.py +++ b/main_tool.py @@ -1,5 +1,5 @@ -import datetime -import minify_html +import time +import htmlmin import os import json import urllib.parse @@ -17,8 +17,8 @@ class JinjaTool: @staticmethod - def get_current_utc(fmt="%Y-%m-%d %H:%M:%S"): - return datetime.datetime.utcnow().strftime(fmt) + def get_current_utc(): + return time.time() @staticmethod def generate_tooltip_id(): @@ -31,7 +31,10 @@ def generate_tooltip_id(): @staticmethod def js_string_safe(value): - return value.replace("&", "&").replace("'", "\'") + return (value.replace("&", "&"). + replace("'", "\'"). + replace("[", "["). + replace("]", "]")) @staticmethod def js_html_string_safe(value): @@ -39,11 +42,10 @@ def js_html_string_safe(value): @staticmethod def page_minify_html(value): - return minify_html.minify(value, keep_closing_tags=True, - remove_processing_instructions=True). \ - replace("'", "'"). \ - replace(" ", ""). \ - replace(" ", " ") + return htmlmin.minify(value, + remove_empty_space=True, + remove_optional_attribute_quotes=False). \ + replace("'", "'") @staticmethod def get_outer_json(instance_id: str, instance_type: str): @@ -154,7 +156,6 @@ def py_tooltip_background(background, instance_id, instance_type, extra_data): # if GenerationCache.check_for_cache("all", cache_id): # return GenerationCache.get_from_cache("all", cache_id) - for story in extra_data.values(): story = story[0] story_parts = [] @@ -342,4 +343,3 @@ def py_output_usedby_story(data_story: dict, instance_uuid, instance_key): # GenerationCache.add_to_cache("all", cache_id, [story for (i, j) in all_story_with_filetype.items() for story in j]) return all_story_with_filetype - diff --git a/page/en/battle.html b/page/en/battle.html index 2d01a79..d94cdf3 100644 --- a/page/en/battle.html +++ b/page/en/battle.html @@ -2,7 +2,7 @@ {% block title %}Battle/{% if battle.filetype == 21 %}{{ battle.chapter }}-{{ battle.no[:2] }} {% endif %}{{ battle.name.en }}{% endblock title %} {% block article_content %} - {% from "template/en/_macro.html" import get_social_for_composer %} + {% from "template/en/_macro.html" import get_social_for_composer, generate_track_anchor %}
{{ video.name.en }} is a video related to Blue Archive.