master
bel 2022-02-16 07:57:47 -07:00
parent 24acc02dc7
commit 09532849d4
3 changed files with 72 additions and 57 deletions

View File

@ -200,7 +200,6 @@ func (server *Server) putContentHandler(filePath string, w http.ResponseWriter,
}
func (server *Server) uiSearchHandler(w http.ResponseWriter, r *http.Request) error {
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/ui/files")
t, err := server.uiSubTemplates()
if err != nil {
return err
@ -261,11 +260,11 @@ func (server *Server) uiFilesHandler(w http.ResponseWriter, r *http.Request) err
leaf.Title = "My New File"
}
data := map[string]interface{}{
"This": map[string]string{
"This": map[string]interface{}{
"Title": leaf.Title,
"Content": leaf.Content,
"ID": r.URL.Path,
"PID": strings.TrimPrefix(path.Dir(r.URL.Path), "/"),
"ID": id,
"PID": id.Pop(),
"PTitle": parent.Title,
},
"Tree": string(branchesJSON),

View File

@ -45,7 +45,7 @@
return `
<div style="margin: 0; padding: 0; height: 0; width: 0;" id="${name}"></div>
<a style="flex-grow: 1;" href="${href}#${parentname}"><button style="width: 100%; text-align: left; outline: none;">${title}</button></a>
<a href="${href}/${crypto.randomUUID().split("-")[0]}#${parentname}"><button>+</button></a>
<a href="${href}/${generateUUID().split("-")[0]}#${parentname}"><button>+</button></a>
`
}
function branchesHTML(id, branches) {
@ -54,7 +54,7 @@
var out = ``
for(var i in branches) {
out += `<details open>`
out += branchHTML((id ? id + "/" : "") + i, branches[i])
out += branchHTML(i, branches[i])
out += `</details>`
}
return out
@ -65,6 +65,6 @@
n += 1
return n > 0
}
drawTree(JSON.parse(`{{ .Tree }}`))
drawTree(JSON.parse({{ .Tree }}))
</script>
{{ end }}

View File

@ -15,48 +15,48 @@
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
-->
<style>
html, body {
background-color: #f8f8f8;
}
.columns {
display: flex;
flex-direction: row;
}
.rows {
width: 100%;
display: flex;
flex-direction: column;
}
.thic_flex {
text-align: left;
flex-grow: 1;
}
.mia {
display: none;
}
.align_left {
text-align: left;
}
.tb_buffer {
margin-top: 1em;
margin-bottom: 1em;
}
.r_buffer {
margin-right: 1em;
}
.l_buffer {
margin-left: 1em;
}
.monospace {
font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
}
.lil_btn {
width: initial;
display: inline-block;
}
input, label, textarea {
margin: initial;
}
html, body {
background-color: #f8f8f8;
}
.columns {
display: flex;
flex-direction: row;
}
.rows {
width: 100%;
display: flex;
flex-direction: column;
}
.thic_flex {
text-align: left;
flex-grow: 1;
}
.mia {
display: none;
}
.align_left {
text-align: left;
}
.tb_buffer {
margin-top: 1em;
margin-bottom: 1em;
}
.r_buffer {
margin-right: 1em;
}
.l_buffer {
margin-left: 1em;
}
.monospace {
font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
}
.lil_btn {
width: initial;
display: inline-block;
}
input, label, textarea {
margin: initial;
}
.fullscreen {
position: relative;
top: 0;
@ -66,15 +66,15 @@
padding: 5px;
overflow: scroll;
}
.lr_fullscreen {
width: 100%;
/*max-width: 1024px;*/
margin-right: auto;
margin-left: auto;
}
.tb_fullscreen {
.lr_fullscreen {
width: 100%;
/*max-width: 1024px;*/
margin-right: auto;
margin-left: auto;
}
.tb_fullscreen {
height: 100%;
}
}
</style>
<script>
function http(method, remote, callback, body, headers) {
@ -94,5 +94,21 @@
}
xmlhttp.send(body);
}
function generateUUID() { // Public Domain/MIT // https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid
var d = new Date().getTime();//Timestamp
var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16;//random number between 0 and 16
if(d > 0){//Use timestamp until depleted
r = (d + r)%16 | 0;
d = Math.floor(d/16);
} else {//Use microseconds since page-load if supported
r = (d2 + r)%16 | 0;
d2 = Math.floor(d2/16);
}
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
}
);
}
</script>
{{ end }}