summaryrefslogtreecommitdiff
path: root/browser/gemini.py
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2022-01-19 19:03:01 -0600
committerMatt Singleton <matt@xcolour.net>2022-01-19 19:03:01 -0600
commit616371e01fa96653bd43f4384a6b8ef68b3661b5 (patch)
treef156998b6de2ad66ef72423a309f8df99140892b /browser/gemini.py
parent35a197f5e5263bfb0e7d41717b2153c03e50008d (diff)
get it working with pyinstaller on macos
Diffstat (limited to 'browser/gemini.py')
-rw-r--r--browser/gemini.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/browser/gemini.py b/browser/gemini.py
index 7bedda5..a26f8fc 100644
--- a/browser/gemini.py
+++ b/browser/gemini.py
@@ -6,6 +6,7 @@ import string
import urllib.parse
import fsm
+from util import resource_path
def htmlescape(text: str) -> str:
@@ -16,19 +17,19 @@ def gem2html(gem: dict) -> str:
params = {
'charset': 'utf-8',
'lang': 'en',
- 'css': open('style.css').read()
+ 'css': open(resource_path('resources/style.css')).read()
}
if gem['status'][0] == '2':
- template = string.Template(open('page_template.html').read())
+ template = string.Template(open(resource_path('resources/page_template.html')).read())
body = io.StringIO()
parser = fsm.Parser(gem['body'].split('\n'), body)
parser.parse()
params['body'] = body.getvalue()
elif gem['status'][0] == '1':
- template = string.Template(open('input_template.html').read())
+ template = string.Template(open(resource_path('resources/input_template.html')).read())
params['meta'] = gem['meta']
else:
- template = string.Template(open('error_template.html').read())
+ template = string.Template(open(resource_path('resources/error_template.html')).read())
if gem['status'] == '00':
params['status'] = 'CLIENT ERROR'
elif gem['status'][0] == '4':
@@ -40,8 +41,6 @@ def gem2html(gem: dict) -> str:
params['meta'] = gem['meta']
html = template.substitute(params)
- with open('latest.html', 'w') as fp:
- fp.write(html)
return html