Compare commits

..

No commits in common. "3d5aa298c9ccdbadef9d1c4baa7016d12aa3136b" and "84d05ac06e1c8ac6f9100edf97aa636ee83a1bed" have entirely different histories.

2 changed files with 24 additions and 43 deletions

View File

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

View File

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