Compare commits

..

2 Commits

Author SHA1 Message Date
3d5aa298c9 Format Linux build script 2024-07-29 08:36:07 -07:00
950c052e3f Use local server instead of temporary file 2024-07-29 08:36:05 -07:00
2 changed files with 43 additions and 24 deletions

View File

@ -6,13 +6,21 @@ distName=navpoint-linux-$arch
rm -rf dist/$distName-bundle
mkdir -p dist/$distName-bundle
pyinstaller -w -F --hidden-import tornado.web --add-data README.md:files --add-data GPL-3.0.txt:files --add-data CC-BY-SA-4.0.txt:files main.py
pyinstaller --windowed --onefile \
--hidden-import tornado.web \
--add-data README.md:files \
--add-data GPL-3.0.txt:files \
--add-data CC-BY-SA-4.0.txt:files \
main.py
cp dist/main dist/$distName-standalone
mv dist/main dist/$distName-bundle/navpoint
cp icon.png dist/$distName-bundle/navpoint.png
cp GPL-3.0.txt CC-BY-SA-4.0.txt dist/$distName-bundle/
pandoc -s --metadata "title=Navpoint Desktop" README.md | grep -v 'h1 id="navpoint-desktop"' > dist/$distName-bundle/README.html
pandoc -s --metadata "title=Navpoint Desktop" README.md |
grep -v 'h1 id="navpoint-desktop"' \
> dist/$distName-bundle/README.html
cat > dist/$distName-bundle/navpoint.desktop << HERE
[Desktop Entry]

View File

@ -1,30 +1,29 @@
import webbrowser
import tempfile
import time
import os
import threading
import markdown
import tornado.ioloop
import tornado.web
import navpoint.fix_path
def about():
with open(navpoint.fix_path.fix_path("README.md")) as f:
readme = markdown.markdown(
f.read()
.replace("https://www.gnu.org/licenses/gpl-3.0.en.html", "#gpl")
.replace("https://creativecommons.org/licenses/by-sa/4.0/", "#cc")
)
class AboutHandler(tornado.web.RequestHandler):
def get(self):
with open(navpoint.fix_path.fix_path("README.md")) as f:
readme = markdown.markdown(
f.read()
.replace("https://www.gnu.org/licenses/gpl-3.0.en.html", "#gpl")
.replace(
"https://creativecommons.org/licenses/by-sa/4.0/", "#cc"
)
)
with open(navpoint.fix_path.fix_path("GPL-3.0.txt")) as f:
gpl = f.read()
with open(navpoint.fix_path.fix_path("GPL-3.0.txt")) as f:
gpl = f.read()
with open(navpoint.fix_path.fix_path("CC-BY-SA-4.0.txt")) as f:
cc = f.read()
with open(navpoint.fix_path.fix_path("CC-BY-SA-4.0.txt")) as f:
cc = f.read()
fd, name = tempfile.mkstemp(suffix=".html")
os.close(fd)
with open(name, "w") as f:
f.write(
self.write(
f"""\
<!DOCTYPE html>
<html>
@ -45,7 +44,19 @@ def about():
</html>
"""
)
tornado.ioloop.IOLoop.instance().stop()
webbrowser.open(name)
time.sleep(5) # Give the browser time to open the file
os.remove(name)
def _run():
app = tornado.web.Application(
[
("/", AboutHandler),
]
)
app.listen(9999, address="127.0.0.1")
tornado.ioloop.IOLoop.instance().start()
def about():
threading.Thread(target=_run).start()
webbrowser.open("http://127.0.0.1:9999/")