forked from jriou/coller
- Remove encryptionKey from URL - Use POST method to pass both password and encryption key - Parse URL fragment to extract the encryption key from the web (using javascript) and from the CLI Fixes #36. Signed-off-by: Julien Riou <julien@riou.xyz>
63 lines
No EOL
2.4 KiB
HTML
63 lines
No EOL
2.4 KiB
HTML
{{define "note"}}
|
|
{{if ne .Err nil}}
|
|
{{block "error" .}}{{end}}
|
|
{{else}}
|
|
<div class="container mb-4">
|
|
<div class="d-flex flex-wrap py-2">
|
|
<span class="fs-4 d-flex mb-3 mb-md-0 me-md-auto text-decoration-none">Note {{.Note.ID}}</span>
|
|
<ul class="nav nav-pills align-items-center">
|
|
<li class="nav-item px-2">
|
|
<a href="" id="rawURL">raw</a>
|
|
<script>document.getElementById("rawURL").href = window.location.href.replace(".html", "");</script>
|
|
</li>
|
|
<li class="nav-item px-2">
|
|
{{.Note.Language}}
|
|
</li>
|
|
{{if eq .Note.DeleteAfterRead false}}
|
|
<li class="nav-item px-2">
|
|
expires in {{HumanDuration (TimeDiff .Note.ExpiresAt)}}
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
</div>
|
|
{{if .DisableEditor}}
|
|
<div class="row">
|
|
<pre class="border px-3 pt-3" style="min-height: 300px; resize: vertical; overflow: auto;">
|
|
{{string .Note.Content}}
|
|
</pre>
|
|
</div>
|
|
{{else}}
|
|
<div class="row">
|
|
<div id="editor" name="editor" class="form-control" style="min-height: 300px; resize: vertical; overflow: auto;">
|
|
</div>
|
|
</div>
|
|
<script
|
|
src="{{if .AceDirectory}}/static/ace-builds{{else}}https://cdn.jsdelivr.net/npm/ace-builds@1.43.3{{end}}/src-noconflict/ace.js"
|
|
type="text/javascript" charset="utf-8"></script>
|
|
<script>
|
|
var editor = ace.edit("editor");
|
|
editor.setValue("{{string .Note.Content}}");
|
|
editor.setReadOnly(true);
|
|
editor.getSession().setMode("ace/mode/{{.Note.Language}}");
|
|
editor.getSession().selection.clearSelection();
|
|
editor.setOptions({ maxLines: Infinity });
|
|
|
|
if (document.documentElement.getAttribute('data-bs-theme') == 'light') {
|
|
editor.setTheme("ace/theme/github_light_default");
|
|
} else {
|
|
editor.setTheme("ace/theme/github_dark");
|
|
}
|
|
|
|
// Dark mode
|
|
document.getElementById("lightSwitch").addEventListener("click", () => {
|
|
if (document.documentElement.getAttribute('data-bs-theme') == 'light') {
|
|
editor.setTheme("ace/theme/github_light_default")
|
|
} else if (document.documentElement.getAttribute('data-bs-theme') == 'dark') {
|
|
editor.setTheme("ace/theme/github_dark")
|
|
}
|
|
});
|
|
</script>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
{{end}} |