customize: move save button above html textarea, add unsaved changes indicator

This commit is contained in:
blankie 2026-06-14 08:12:10 +00:00
parent bef95fd901
commit 56a53e8b08

View file

@ -127,12 +127,22 @@ def handle_style_form(msg="", gateway_host="", scheme="http"):
f'<a href="/reindex">manage semantic index</a><br><br>'
f"</div>"
f"{forum_section}"
f'<div id="unsaved" style="display:none;color:#888">* unsaved changes</div>'
f'<button type="submit">save</button>'
f'<script>'
f'(function(){{'
f"var f=document.querySelector('form');"
f"var u=document.getElementById('unsaved');"
f"f.addEventListener('change',function(){{u.style.display=''}});"
f"f.addEventListener('submit',function(){{u.style.display='none'}});"
f'}})();'
f'</script>'
f"</form>"
f"<h2>custom html</h2>"
f"<p>Edit the full page template. Use <code>{esc('{{content}}')}</code> "
f"where page content should appear.</p>"
f'<textarea name="template" rows="20" cols="60">{esc(template)}</textarea><br><br>'
f'<button type="submit">save</button>'
f"</form>"
f'<textarea name="template" rows="20" cols="60">{esc(template)}</textarea><br>'
f'<small>Saved with the form above.</small><br><br>'
f"<h2>bookmarklet</h2>"
f"<p>Drag this link to your bookmarks bar. Click it on any page to index it instantly.</p>"
f'<p><a href="javascript:void(fetch(\'{esc(scheme)}://{esc(gateway_host or "localhost:8080")}/bookmark?url=\'+encodeURIComponent(location.href)+\'&token={_get_bookmark_token()}\').then(r=>r.text()).then(t=>alert(t)).catch(()=>alert(\'tinyweb not running\')))">+ save to {esc(name)}</a></p>'