forked from jonacruz89/SAWARATSUKI.ServiceLogos
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SAWARATSUKI:main' into main
- Loading branch information
Showing
25 changed files
with
783 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
...REQUEST_TEMPLATE/pull_request_template.md → .github/pull_request_template.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# Pull Request | ||
|
||
## Description | ||
|
||
[Please include a brief description of the changes or features you are proposing.] | ||
|
||
## Related Issues | ||
|
||
[If this pull request is related to any GitHub issue(s), please reference them here.] | ||
|
||
## Pictures (if applicable) | ||
|
||
[Include any pictures that help demonstrate the changes.] | ||
|
||
## Checklist | ||
- [ ] I have added/updated tests to cover my changes. | ||
- [ ] All new and existing tests passed. | ||
|
||
- [ ] I have tested the changes/updates before submitting this pull request. | ||
|
||
## Additional Notes | ||
|
||
[Add any additional notes or context about the changes here.] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Update Image List | ||
|
||
permissions: write-all | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.png" | ||
- "docs/README*" | ||
- "docs/scripts/**" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
submodules: true | ||
|
||
- uses: pnpm/action-setup@v3 | ||
with: | ||
version: latest | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: pnpm | ||
|
||
- uses: pdm-project/setup-pdm@v3 | ||
|
||
- name: Run Job | ||
run: |- | ||
# pdm install # no 3rd lib used | ||
pdm run generate | ||
pnpm i | ||
pnpm format | ||
if [[ -n "$(git status -s)" ]]; then | ||
git add . | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git commit -m "Update Image List" | ||
git push | ||
else | ||
echo "No changes detected." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.venv | ||
.pdm-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
singleQuote: false |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Replace Rider Startup Image | ||
|
||
--- | ||
|
||
## Version 2024.1 | ||
|
||
--- | ||
|
||
- Open the `%userprofile%\AppData\Local\Programs\Rider\lib` folder | ||
- Copy `app.jar` to an empty folder and make sure to back it up | ||
- Create a new folder in this directory and move `app.jar` into it | ||
- Go into this folder, right-click, choose `Open in Terminal`, and enter `jar -xvf app.jar` to extract. After extraction, delete `app.jar` | ||
- Then go to the `rider\artwork\release` directory within this folder | ||
- Rename the downloaded images to `splash.png` and `[email protected]` to replace the original images | ||
- Return to the extracted folder, then run `jar -cfM0 ../app.jar ./` to compress the current folder, and save it to the parent directory | ||
- Put the new `app.jar` into `%userprofile%\AppData\Local\Programs\Rider\lib` to replace the original | ||
- Finally, delete all files in `%userprofile%\AppData\Local\JetBrains\Rider2024.1\splash` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Rider のスタートアップ画像の交換 | ||
|
||
--- | ||
|
||
## 2024.1 バージョン | ||
|
||
--- | ||
|
||
- `%userprofile%\AppData\Local\Programs\Rider\lib` フォルダを開く | ||
- `app.jar` を空のフォルダにコピーし、バックアップを取る | ||
- 同じディレクトリに新しいフォルダを作成し、`app.jar` を移動する | ||
- このフォルダに入り、右クリックして「ターミナルで開く」を選択し、`jar -xvf app.jar` と入力して解凍する。解凍後、`app.jar` を削除する | ||
- このフォルダ内の `rider\artwork\release` ディレクトリに移動 | ||
- ダウンロードした画像を `splash.png` と `[email protected]` にリネームして、元の画像を置き換える | ||
- 解凍されたフォルダに戻り、`jar -cfM0 ../app.jar ./` を実行して、現在のフォルダを圧縮し、上のディレクトリに保存する | ||
- 新しい `app.jar` を `%userprofile%\AppData\Local\Programs\Rider\lib` に配置して、元のファイルと交換する | ||
- 最後に、`%userprofile%\AppData\Local\JetBrains\Rider2024.1\splash` のすべてのファイルを削除する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 替换 Rider 启动图片 | ||
|
||
--- | ||
|
||
## 2024.1 版本 | ||
|
||
--- | ||
|
||
- 打开 `%userprofile%\AppData\Local\Programs\Rider\lib` 文件夹 | ||
- 将 `app.jar` 复制到一个空的文件夹,并注意备份该文件 | ||
- 在此目录下再创建一个新的文件夹,并将 `app.jar` 移动进去 | ||
- 进入此文件夹,右键选择 `在终端中打开` ,输入 `jar -xvf app.jar` 解压,解压完后删除 `app.jar` | ||
- 然后进入此文件夹中的 `rider\artwork\release` 目录 | ||
- 将下载好的图片重命名为 `splash.png` 和 `[email protected]` 替换原来的图片 | ||
- 回到解压后的目录,通过终端执行 `jar -cfM0 ../app.jar ./` 来压缩当前目录,并将结果保存到上层目录 | ||
- 将新的 `app.jar` 放到 `%userprofile%\AppData\Local\Programs\Rider\lib` 进行替换 | ||
- 最后将 `%userprofile%\AppData\Local\JetBrains\Rider2024.1\splash` 内的文件全部删除 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import re | ||
from contextlib import suppress | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import TypeAlias | ||
from urllib.parse import quote | ||
|
||
FolderDict: TypeAlias = dict[str, list[Path]] | ||
|
||
|
||
@dataclass | ||
class ReadMeInfo: | ||
path: Path | ||
locale: str | ||
|
||
|
||
DOCS_FOLDER = Path(__file__).parent.parent | ||
ROOT_FOLDER = DOCS_FOLDER.parent | ||
|
||
START = "<!-- image-list: start -->" | ||
END = "<!-- image-list: end -->" | ||
|
||
|
||
LOCALE: dict[str, dict[str, str]] = { | ||
"en": {"name": "Name", "image": "Image"}, | ||
"ja": {"name": "名前", "image": "画像"}, | ||
"zhHans": {"name": "名称", "image": "图片"}, | ||
"zhHant": {"name": "名稱", "image": "圖片"}, | ||
} | ||
|
||
|
||
def l5(n: str | None, k: str) -> str: | ||
if n: | ||
with suppress(KeyError): | ||
return LOCALE[n][k] | ||
with suppress(KeyError): | ||
return LOCALE["en"][k] | ||
return k | ||
|
||
|
||
def find_image_folders() -> FolderDict: | ||
return { | ||
x.name: images | ||
for x in ROOT_FOLDER.iterdir() | ||
if x.is_dir() and (images := list(x.glob("*.png"))) | ||
} | ||
|
||
|
||
def find_readme() -> list[ReadMeInfo]: | ||
return [ | ||
ReadMeInfo( | ||
path=x, | ||
locale=( | ||
res["loc"] | ||
if (res := re.search(r"README-(?P<loc>.+)", x.stem)) | ||
else "en" | ||
), | ||
) | ||
for x in DOCS_FOLDER.glob("README*.md") | ||
] | ||
|
||
|
||
def generate_markdown(folders: FolderDict, locale: str | None = None) -> str: | ||
def get_image_tags(images: list[Path]) -> str: | ||
return " ".join( | ||
( | ||
f'<img src="../{quote(x.relative_to(ROOT_FOLDER).as_posix())}" ' | ||
f'alt="{quote(x.stem)}" width="100" />' | ||
) | ||
for x in images | ||
) | ||
|
||
item_list = [ | ||
( | ||
folder, | ||
sorted( # move exact match to first | ||
images, | ||
key=lambda x: "\0" if x.stem == folder else x.stem.lower(), | ||
), | ||
) | ||
for folder, images in sorted(folders.items(), key=lambda x: x[0].lower()) | ||
] | ||
lines = [ | ||
f"| {l5(locale, 'name')} | {l5(locale, 'image')} |", | ||
"| --- | --- |", | ||
*(f"| {folder} | {get_image_tags(images)} |" for folder, images in item_list), | ||
] | ||
return "\n".join(lines) | ||
|
||
|
||
def replace_file(content: str, inner: str) -> str: | ||
start_index = content.find(START) | ||
end_index = content.find(END) | ||
if start_index == -1 or end_index == -1 or start_index >= end_index: | ||
raise ValueError("Invalid table start or end mark") | ||
|
||
pfx = content[: content.index(START) + len(START)] | ||
sfx = content[content.index(END) :] | ||
return f"{pfx}\n\n{inner}\n\n{sfx}" | ||
|
||
|
||
def process_file(info: ReadMeInfo, image_folders: FolderDict): | ||
md_table = generate_markdown(image_folders, info.locale) | ||
content = info.path.read_text("u8") | ||
try: | ||
replaced = replace_file(content, md_table) | ||
except ValueError as e: | ||
raise ValueError(f"Error replacing {info.path.name}") from e | ||
info.path.write_text(replaced, "u8") | ||
|
||
|
||
def main(): | ||
image_folders = find_image_folders() | ||
print(f"Found {len(image_folders)} image folders") | ||
readme_files = find_readme() | ||
for info in readme_files: | ||
print(f"Processing {info.path.name}, locale: {info.locale}") | ||
process_file(info, image_folders) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"format": "prettier -cw ." | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.2.5" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.