forked from Xkeeper0/deltarune-viewer
-
Notifications
You must be signed in to change notification settings - Fork 4
syntax highlighting, better layout, build automation improvements! #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4c7cc23
syntax highlighting, better layout, build automation improvements!
RedstoneWizard08 e5bfd10
ah yes, typo.
RedstoneWizard08 56b2efc
Merge branch 'utdrwiki:master' into master
RedstoneWizard08 569831a
Fix text highlight & padding
RedstoneWizard08 cf8e522
Hopefully fix formatting?
RedstoneWizard08 a96f844
fix fmt
RedstoneWizard08 a0751e4
Switch to python script in actions
RedstoneWizard08 0512840
Update readme
RedstoneWizard08 2b879c0
Fix disambig
RedstoneWizard08 09f1849
Font via download, fix broken action lol
RedstoneWizard08 e793900
CSS
RedstoneWizard08 894c13e
style
RedstoneWizard08 adc3de2
remove ignore
RedstoneWizard08 dfc030b
remove script
RedstoneWizard08 8b41d2e
oi
RedstoneWizard08 16d5e77
WTF GIT
RedstoneWizard08 a09e632
fmt & uv
RedstoneWizard08 eb639d9
add contrib
RedstoneWizard08 37bda2c
bold & regular
RedstoneWizard08 36b45aa
fix lints
RedstoneWizard08 4cd4b96
style stuff
RedstoneWizard08 1299ad9
style
RedstoneWizard08 6ebaeda
highlightjs
RedstoneWizard08 36c3989
fix flake8, add ruff.toml
RedstoneWizard08 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
KockaAdmiralac marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
KockaAdmiralac marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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,158 @@ | ||
| import argparse | ||
| import os | ||
| import zipfile | ||
| from io import BytesIO | ||
| from os.path import dirname, exists, join, relpath | ||
| from shutil import copyfile, rmtree | ||
| from typing import Optional | ||
|
|
||
| import requests | ||
| from loguru import logger | ||
| from tqdm import tqdm | ||
|
|
||
| from data import Data | ||
| from generate import generate | ||
|
|
||
| DIR = dirname(__file__) | ||
| STATIC = join(DIR, 'static') | ||
|
|
||
|
|
||
| def download(url: str, file: str): | ||
| data = requests.get(url).content | ||
| parent = dirname(file) | ||
|
|
||
| if not exists(parent): | ||
| os.makedirs(parent) | ||
|
|
||
| with open(file, 'wb') as f: | ||
| f.write(data) | ||
|
|
||
|
|
||
| def build(game: str, chapter: Optional[str]): | ||
| out = join(DIR, 'out', game) | ||
|
|
||
| raw = ( | ||
| join(out, 'raw', chapter) if chapter is not None else join(out, 'raw') | ||
| ) | ||
|
|
||
| input_dir = ( | ||
| join(DIR, f'decompiled-{game}', chapter) | ||
| if chapter is not None | ||
| else join(DIR, f'decompiled-{game}') | ||
| ) | ||
|
|
||
| logger.info(f'Building chapter: {chapter}') | ||
| logger.info('Finding script files...') | ||
|
|
||
| scripts: list[str] = [] | ||
|
|
||
| for root, _, files in os.walk(input_dir): | ||
| for name in files: | ||
| if name.lower().endswith('.gml'): | ||
| scripts.append(join(root, name)) | ||
|
|
||
| logger.info('Copying script files...') | ||
|
|
||
| for file in tqdm(scripts): | ||
| rel = relpath(file, input_dir) | ||
| target = join(raw, rel) | ||
| txt = join(raw, '.'.join(rel.split('.')[:-1]) + '.txt') | ||
| parent = dirname(target) | ||
|
|
||
| if not exists(parent): | ||
| os.makedirs(parent) | ||
|
|
||
| copyfile(file, target) | ||
| copyfile(file, txt) | ||
|
|
||
|
|
||
| def run(game: str): | ||
| data = Data(game) | ||
| out = join(DIR, 'out', game) | ||
| static_out = join(out, 'static') | ||
|
|
||
| if exists(out): | ||
| logger.info('Clearing existing output...') | ||
| rmtree(out) | ||
|
|
||
| os.makedirs(out) | ||
|
|
||
| chapters = data.get_chapters() | ||
|
|
||
| if chapters is not None and len(chapters) > 0: | ||
| logger.info('Building chapters...') | ||
|
|
||
| for chapter in chapters.keys(): | ||
| build(game, chapter) | ||
| else: | ||
| build(game, None) | ||
|
|
||
| logger.info('Copying static files...') | ||
|
|
||
| static_files: list[str] = [] | ||
|
|
||
| for root, _, files in os.walk(STATIC): | ||
| for file in files: | ||
| static_files.append(relpath(join(root, file), STATIC)) | ||
|
|
||
| os.makedirs(static_out) | ||
|
|
||
| for file in tqdm(static_files): | ||
| out_path = join(static_out, file) | ||
| parent = dirname(out_path) | ||
|
|
||
| if not exists(parent): | ||
| os.makedirs(parent) | ||
|
|
||
| copyfile(join(STATIC, file), out_path) | ||
|
|
||
| copyfile(join(DIR, '_headers'), join(out, '_headers')) | ||
|
|
||
| logger.info('Downloading font...') | ||
|
|
||
| font_url = ( | ||
| 'https://download-cdn.jetbrains.com/fonts/JetBrainsMono-2.304.zip' | ||
| ) | ||
| data = requests.get(font_url).content | ||
|
|
||
| with zipfile.ZipFile(BytesIO(data), 'r') as z: | ||
| z.extractall(static_out) | ||
|
|
||
| logger.info('Downloading highlight.js...') | ||
|
|
||
| hjs_base = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1' | ||
|
|
||
| download( | ||
| f'{hjs_base}/highlight.min.js', | ||
| join(static_out, 'highlight', 'highlight.min.js'), | ||
| ) | ||
|
|
||
| download( | ||
| f'{hjs_base}/languages/gml.min.js', | ||
| join(static_out, 'highlight', 'gml.min.js'), | ||
| ) | ||
|
|
||
| download( | ||
| f'{hjs_base}/styles/github-dark.min.css', | ||
| join(static_out, 'highlight', 'github-dark.min.css'), | ||
| ) | ||
|
|
||
| logger.info('Generating website...') | ||
|
|
||
| generate(game) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| parser = argparse.ArgumentParser( | ||
| description='Generates the code viewer website.' | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| 'game', | ||
| type=str, | ||
| help='game for which to generate the website', | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| run(args.game) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,3 +1,3 @@ | ||
| #!/bin/bash | ||
| cd "${0%/*}" | ||
| python -m http.server -d out | ||
| python -m http.server -d out/"$1" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.