Skip to content

Commit

Permalink
chore: use python to build html
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Oct 26, 2023
1 parent 725c35d commit be9ff29
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ jobs:
name: Build project (Makefile)
run: make
-
name: Build page (Makefile)
run: >-
mkdir -p html &&
curl -o html/nes.js "https://cdn.jsdelivr.net/gh/takahirox/[email protected]/build/nes.min.js" &&
sh -c 'awk "{gsub(/{{game}}/, \"Kokobatoru 2\");} /{{rom}}/ {cmd=\"base64 bin/kokobatoru.nes\"; while ((cmd | getline line) > 0) var = var line; close(cmd); gsub(/{{rom}}/, var);} 1" res/index.html' > html/jap.html &&
sh -c 'awk "{gsub(/{{game}}/, \"Coco Battle Royale II\");} /{{rom}}/ {cmd=\"base64 bin/cocobattleroyale.nes\"; while ((cmd | getline line) > 0) var = var line; close(cmd); gsub(/{{rom}}/, var);} 1" res/index.html' > html/usa.html
name: Build page (Python)
run: ./build-pwa.py && ./build-pwa.py --jap
-
name: Setup Pages
uses: actions/configure-pages@v3
Expand Down
19 changes: 19 additions & 0 deletions build-pwa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
from base64 import b64encode as b64
import sys

title = 'Coco Battle Royale II'
input = './bin/cocobattleroyale.nes'
output = './html/usa.html'

if '--jap' in sys.argv:
title = 'Kokobatoru 2'
input = './bin/kokobatoru.nes'
output = './html/jap.html'

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 be9ff29

Please sign in to comment.