Skip to content

Commit

Permalink
build: improve python build html
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Oct 27, 2023
1 parent be9ff29 commit 97f26ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: make
-
name: Build page (Python)
run: ./build-pwa.py && ./build-pwa.py --jap
run: ./build-pwa.py --download && ./build-pwa.py --jap
-
name: Setup Pages
uses: actions/configure-pages@v3
Expand Down
10 changes: 9 additions & 1 deletion build-pwa.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from base64 import b64encode as b64
import requests
import sys

title = 'Coco Battle Royale II'
Expand All @@ -11,9 +12,16 @@
input = './bin/kokobatoru.nes'
output = './html/jap.html'

if '--download' in sys.argv:
for file_name in ['nes.min.js']:
cdn = 'https://cdn.jsdelivr.net/gh/takahirox/[email protected]/build'
with requests.get(f'{cdn}/{file_name}', stream=True) as download:
file_name = file_name.replace(r'.min.js', '.js')
open(f'./html/{file_name}', "w").write(download.text)

rom = b64(open(input, "rb").read()).decode()
html = open("./res/index.html", "r").read()
html = html.replace(r'{{game}}', title).replace(r'{{rom}}', rom)

open(output, "w").write(html)

print(title)

0 comments on commit 97f26ec

Please sign in to comment.