mirror of
https://github.com/onionshare/onionshare.git
synced 2025-08-02 11:26:16 -04:00
adding html files to Resources, loading them from the correct path, and make sure to include jinja2 extension in py2app (#151)
This commit is contained in:
parent
a86cda4549
commit
ad553146c7
3 changed files with 14 additions and 4 deletions
|
@ -47,6 +47,15 @@ def get_osx_resources_dir():
|
||||||
return os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
|
return os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
|
||||||
|
|
||||||
|
|
||||||
|
def get_html_path(filename):
|
||||||
|
p = platform.system()
|
||||||
|
if p == 'Darwin':
|
||||||
|
prefix = os.path.join(get_osx_resources_dir(), 'html')
|
||||||
|
else:
|
||||||
|
prefix = get_onionshare_dir()
|
||||||
|
return os.path.join(prefix, filename)
|
||||||
|
|
||||||
|
|
||||||
def constant_time_compare(val1, val2):
|
def constant_time_compare(val1, val2):
|
||||||
_builtin_constant_time_compare = getattr(hmac, 'compare_digest', None)
|
_builtin_constant_time_compare = getattr(hmac, 'compare_digest', None)
|
||||||
if _builtin_constant_time_compare is not None:
|
if _builtin_constant_time_compare is not None:
|
||||||
|
|
|
@ -114,7 +114,7 @@ def index(slug_candidate):
|
||||||
|
|
||||||
add_request(REQUEST_LOAD, request.path)
|
add_request(REQUEST_LOAD, request.path)
|
||||||
return render_template_string(
|
return render_template_string(
|
||||||
open('{0:s}/index.html'.format(helpers.get_onionshare_dir())).read(),
|
open(helpers.get_html_path('index.html')).read(),
|
||||||
slug=slug,
|
slug=slug,
|
||||||
file_info=file_info,
|
file_info=file_info,
|
||||||
filename=os.path.basename(zip_filename).decode("utf-8"),
|
filename=os.path.basename(zip_filename).decode("utf-8"),
|
||||||
|
@ -198,7 +198,7 @@ def download(slug_candidate):
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def page_not_found(e):
|
def page_not_found(e):
|
||||||
add_request(REQUEST_OTHER, request.path)
|
add_request(REQUEST_OTHER, request.path)
|
||||||
return render_template_string(open('{0:s}/404.html'.format(helpers.get_onionshare_dir())).read())
|
return render_template_string(open(helpers.get_html_path('404.html')).read())
|
||||||
|
|
||||||
# shutting down the server only works within the context of flask, so the easiest way to do it is over http
|
# shutting down the server only works within the context of flask, so the easiest way to do it is over http
|
||||||
shutdown_slug = helpers.random_string(16)
|
shutdown_slug = helpers.random_string(16)
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -101,13 +101,14 @@ elif system == 'Darwin':
|
||||||
app=['install/onionshare-launcher.py'],
|
app=['install/onionshare-launcher.py'],
|
||||||
data_files=[
|
data_files=[
|
||||||
('images', images),
|
('images', images),
|
||||||
('locale', locale)
|
('locale', locale),
|
||||||
|
('html', ['onionshare/index.html', 'onionshare/404.html'])
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'py2app': {
|
'py2app': {
|
||||||
'argv_emulation': True,
|
'argv_emulation': True,
|
||||||
'iconfile':'install/onionshare.icns',
|
'iconfile':'install/onionshare.icns',
|
||||||
'includes': ['pip', 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui'],
|
'includes': ['pip', 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui', 'jinja2', 'jinja2.ext', 'jinja2.ext.autoescape'],
|
||||||
'excludes': ['PyQt4.QtDesigner', 'PyQt4.QtNetwork', 'PyQt4.QtOpenGL', 'PyQt4.QtScript', 'PyQt4.QtSql', 'PyQt4.QtTest', 'PyQt4.QtWebKit', 'PyQt4.QtXml', 'PyQt4.phonon']
|
'excludes': ['PyQt4.QtDesigner', 'PyQt4.QtNetwork', 'PyQt4.QtOpenGL', 'PyQt4.QtScript', 'PyQt4.QtSql', 'PyQt4.QtTest', 'PyQt4.QtWebKit', 'PyQt4.QtXml', 'PyQt4.phonon']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue