diff --git a/.gitignore b/.gitignore index 4c49bd7..1408b1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .env +.venv + diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..d9506ce --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.5 diff --git a/__pycache__/octomode.cpython-312.pyc b/__pycache__/octomode.cpython-312.pyc new file mode 100644 index 0000000..398f02b Binary files /dev/null and b/__pycache__/octomode.cpython-312.pyc differ diff --git a/octomode.py b/octomode.py index e4af7b2..33b1f36 100755 --- a/octomode.py +++ b/octomode.py @@ -118,12 +118,12 @@ def main(name): @APP.route('//pad/') def pad(name): - url = f"{ APP.config['PAD_URL'] }/{ name }.md" + url = f"{ APP.config['PAD_URL'] }/p/{ name }.md" return render_template('iframe.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL']) @APP.route('//stylesheet/') def stylesheet(name): - url = f"{ APP.config['PAD_URL'] }/{ name }.css" + url = f"{ APP.config['PAD_URL'] }/p/{ name }.css" return render_template('iframe.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL']) @APP.route('//html/') @@ -175,7 +175,16 @@ def preview(name): lang = "en" title = "No title" - return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang, title=title) + # only here we need application root to make all the URLs work..... + if APP.config['APPLICATION_ROOT'] == '/': + app_root = '' + elif APP.config['APPLICATION_ROOT'].endswith('/'): + app_root = APP.config['APPLICATION_ROOT'][:-1] + else: + app_root = APP.config['APPLICATION_ROOT'] + urn = f"{ app_root }/{ name }" + + return render_template('preview.html', urn=urn, name=name.strip(), pad_content=html, lang=lang, title=title) @APP.route('//pagedjs.html') def pagedjs(name): @@ -186,7 +195,16 @@ def pagedjs(name): lang = metadata['language'][0] title = metadata['title'][0] - return render_template('pagedjs.html', name=name.strip(), pad_content=html, lang=lang, title=title) + # only here we need application root to make all the URLs work..... + if APP.config['APPLICATION_ROOT'] == '/': + app_root = '' + elif APP.config['APPLICATION_ROOT'].endswith('/'): + app_root = APP.config['APPLICATION_ROOT'][:-1] + else: + app_root = APP.config['APPLICATION_ROOT'] + urn = f"{ app_root }/{ name }" + + return render_template('pagedjs.html', urn=urn, name=name.strip(), pad_content=html, lang=lang, title=title) # ////////////////// diff --git a/templates/pagedjs.html b/templates/pagedjs.html index 4375168..5a630b2 100644 --- a/templates/pagedjs.html +++ b/templates/pagedjs.html @@ -5,7 +5,7 @@ - + {{ title }} diff --git a/templates/preview.html b/templates/preview.html index 4e23ea4..83e79d1 100644 --- a/templates/preview.html +++ b/templates/preview.html @@ -3,7 +3,7 @@ - + {{ title }}