Skip to content

Commit

Permalink
native app setup
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzapanther committed Aug 31, 2023
1 parent 4530bfa commit db52d56
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 41 deletions.
30 changes: 0 additions & 30 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,6 @@ function showContent() {
}

showContent();

function registerServiceWorker () {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js")
.then((reg) => {
if (reg.installing) {
console.log("Service worker installing");
} else if (reg.waiting) {
console.log("Service worker installed");
} else if (reg.active) {
console.log("Service worker active");
}
})
.catch((e) => {
console.error('Registration failed');
console.error(e);
});
}
}

window.addEventListener("load", (event) => {
if (window.Capacitor) {
console.log("Native Platform SW");
registerServiceWorker();
} else {
console.log("Web Platform");
// todo: show app download buttons
}

});
</script>
<img alt="Cross" src="/img/cross.jpg" style="width: 40%; float: right; border-radius: 10px;">

Expand Down
1 change: 0 additions & 1 deletion layouts/partials/head/custom.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<link rel="manifest" href="/icons/site.webmanifest">
<link rel="stylesheet" href="/overrides.css" />
<script src="/app.js"></script>
29 changes: 20 additions & 9 deletions prepare_native_app.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#!/usr/bin/env python3

import os

import re

def run():
base = "public"
index_paths = [
'/about/',
'/events/',
'/watch/',
'/donate/',
'/contact/'
html = [
[r'href="/(.*)/"', r'href="/\1/index.html"'],
[r"href='/(.*)/'", r"href='/\1/index.html'"],
]

json = [
[r'"permalink":\s*"/(.*?)/"', r'"permalink":"/\1/index.html"'],
]

path = "public/search/index.json"
with open(path, 'r') as fh:
text = fh.read()

for s in json:
text = re.sub(s[0], s[1], text, flags=re.I)

with open(path, 'w') as fh:
fh.write(text)

for root, dirs, files in os.walk(base):
for f in files:
if f.endswith(".html"):
Expand All @@ -21,8 +32,8 @@ def run():
with open(path, 'r') as fh:
text = fh.read()

for i in index_paths:
text = text.replace(i, f"{i}index.html")
for s in html:
text = re.sub(s[0], s[1], text, flags=re.I)

with open(path, 'w') as fh:
fh.write(text)
Expand Down
Empty file removed static/app.js
Empty file.
1 change: 0 additions & 1 deletion static/service-worker.js

This file was deleted.

0 comments on commit db52d56

Please sign in to comment.