diff --git a/octomode.py b/octomode.py index 889913d..9acac31 100755 --- a/octomode.py +++ b/octomode.py @@ -120,23 +120,23 @@ def main(name): def pad(name): pad_name = f'{ name }.md' url = os.path.join(APP.config['PAD_URL'], pad_name) - return render_template('iframe.html', url=url, name=name.strip()) + return render_template('iframe.html', url=url, name=name.strip(), application_root=APP.config["APPLICATION_ROOT"]) @APP.route('//stylesheet/') def stylesheet(name): pad_name = f'{ name }.css' url = os.path.join(APP.config['PAD_URL'], pad_name) - return render_template('iframe.html', url=url, name=name.strip()) + return render_template('iframe.html', url=url, name=name.strip(), application_root=APP.config["APPLICATION_ROOT"]) @APP.route('//html/') def html(name): path = os.path.join(f'/{ name }/', 'preview.html') - return render_template('iframe.html', url=path, name=name.strip()) + return render_template('iframe.html', url=path, name=name.strip(), application_root=APP.config["APPLICATION_ROOT"]) @APP.route('//pdf/') def pdf(name): path = os.path.join(f'/{ name }/', 'pagedjs.html') - return render_template('pdf.html', url=path, name=name.strip()) + return render_template('pdf.html', url=path, name=name.strip(), application_root=APP.config["APPLICATION_ROOT"]) # ////////////////// # RENDERED RESOURCES @@ -156,10 +156,14 @@ def preview(name): md_pad_content = get_pad_content(name, ext='.md') html = md_to_html(md_pad_content) metadata = get_md_metadata(md_pad_content) - lang = metadata['language'][0] - title = metadata['title'][0] + if metadata: + lang = metadata['language'][0] + title = metadata['title'][0] + else: + lang = "en" + title = "No title" - return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang, title=title) + return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang, title=title, application_root=APP.config["APPLICATION_ROOT"]) @APP.route('//pagedjs.html') def pagedjs(name): @@ -170,7 +174,7 @@ 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) + return render_template('pagedjs.html', name=name.strip(), pad_content=html, lang=lang, title=title, application_root=APP.config["APPLICATION_ROOT"]) # ////////////////// diff --git a/templates/base.html b/templates/base.html index d8b349b..3d1585e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,14 +20,15 @@ window.addEventListener('load', function () { const nav = document.createElement('div'); nav.id = 'nav'; const name = '{{ name }}'; + const application_root = '{{ application_root }}'; nav.innerHTML = `

${ name } in octomode

- : - : - - + : + : + +
`; document.body.insertBefore(nav, document.body.firstChild); diff --git a/templates/pagedjs.html b/templates/pagedjs.html index 1623a86..af3a551 100644 --- a/templates/pagedjs.html +++ b/templates/pagedjs.html @@ -3,9 +3,9 @@ - - - + + + {{ title }} diff --git a/templates/pdf.html b/templates/pdf.html index c3648c3..36e1ef1 100644 --- a/templates/pdf.html +++ b/templates/pdf.html @@ -16,7 +16,7 @@ window.addEventListener('load', function () { // Load the main.css again, to load the stylesheet for the nav var cssLink = document.createElement('link'); cssLink.rel = 'stylesheet'; - cssLink.href = '/static/main.css'; + cssLink.href = '{{ application_root }}/static/main.css'; var head = document.getElementsByTagName('head')[0]; head.insertBefore(cssLink, head.firstChild); diff --git a/templates/preview.html b/templates/preview.html index 4e23ea4..17910f0 100644 --- a/templates/preview.html +++ b/templates/preview.html @@ -3,7 +3,7 @@ - + {{ title }}