delete button works, server returns 302 over 301 so browser cache is less bad, ui sorts filetree alpha by title

master
Bel LaPointe 2022-02-16 08:49:45 -07:00
parent e025f3835a
commit 51bd874063
4 changed files with 24 additions and 11 deletions

View File

@ -312,7 +312,7 @@ func (server *Server) uiSubTemplates() (*template.Template, error) {
} }
func (server *Server) rootHandler(w http.ResponseWriter, r *http.Request) error { func (server *Server) rootHandler(w http.ResponseWriter, r *http.Request) error {
http.Redirect(w, r, "/ui/files/"+uuid.New().String()[:5], 301) http.Redirect(w, r, "/ui/files/"+uuid.New().String()[:5], 302)
return nil return nil
} }

View File

@ -1,12 +1,9 @@
todo: todo:
- hide checkbox for tree
- delete button does nothing
- do not rewrite .md title vs. link cause hrefs to ./gobs.md wont work - do not rewrite .md title vs. link cause hrefs to ./gobs.md wont work
- https://codepen.io/bisserof/pen/nrMveb
- alert box; https://concisecss.com/documentation/ui - alert box; https://concisecss.com/documentation/ui
- scrape odo - scrape odo
- only one scroll bar
- scrape gdoc - scrape gdoc
- hide checkbox for tree
- scrape gsheet - scrape gsheet
- scrape gslide - scrape gslide
- anchor links work - anchor links work
@ -14,6 +11,9 @@ todo:
- ui; last updated; 2022.02.01T12:34:56 - ui; last updated; 2022.02.01T12:34:56
- mark generated via meta so other files in the dir can be created, deleted, replaced safely - mark generated via meta so other files in the dir can be created, deleted, replaced safely
done: done:
- only one scroll bar
- https://codepen.io/bisserof/pen/nrMveb
- delete button does nothing
- search page tree is empty - search page tree is empty
- highlight current page - highlight current page
- fix links - fix links

View File

@ -43,7 +43,7 @@
function pushFile() { function pushFile() {
const title = document.getElementById("title").innerHTML ? document.getElementById("title").innerHTML : "" const title = document.getElementById("title").innerHTML ? document.getElementById("title").innerHTML : ""
const body = easyMDE.value() ? easyMDE.value() : "" const body = easyMDE.value() ? easyMDE.value() : ""
const id = window.location.pathname.includes("/ui/files/") ? window.location.pathname.split("/ui/files/")[1] : "" const id = {{ js .This.ID }}
headers = {} headers = {}
if (title) if (title)
headers["Title"] = title headers["Title"] = title
@ -59,6 +59,17 @@
saveFeedbackInterval = setTimeout(() => {document.getElementById("saveFeedback").innerHTML = ""}, 5000) saveFeedbackInterval = setTimeout(() => {document.getElementById("saveFeedback").innerHTML = ""}, 5000)
}, body, headers) }, body, headers)
} }
function deleteFile() {
const id = {{ js .This.ID }}
const pid = {{ js .This.PID }}
http("DELETE", "/api/v0/files/" + id, (body, status) => {
if (status != 200) {
alert(`failed to delete file ${id}: ${status}: ${body}`)
throw `failed to delete file ${id}: ${status}: ${body}`
}
window.location.href = `${window.location.protocol}\/\/${window.location.host}/ui/files/${pid}`
})
}
</script> </script>
<div class="fullscreen tb_fullscreen"> <div class="fullscreen tb_fullscreen">
<article id="article"> <article id="article">
@ -76,8 +87,8 @@
</span> </span>
<span id="title" class="thic_flex" contenteditable>{{ .This.Title }}</span> <span id="title" class="thic_flex" contenteditable>{{ .This.Title }}</span>
<span class="l_buffer"> <span class="l_buffer">
<form action="" method="delete" onsubmit="return confirm('are you sure?');"> <!-- TODO --> <form onsubmit="deleteFile(); return false;"> <!-- TODO -->
<input class="button-error lil_btn" type="submit" value="DELETE"/> <input class="button-error lil_btn" type="submit" onclick="confirm('are you sure?');" value="DELETE"/>
</form> </form>
</span> </span>
</div> </div>

View File

@ -52,12 +52,14 @@
function branchesHTML(id, branches) { function branchesHTML(id, branches) {
if (!branchesHaveContent(branches)) if (!branchesHaveContent(branches))
return "" return ""
var html = []
var out = `` var out = ``
for(var i in branches) { for(var i in branches) {
out += `<details open>` html.push([branches[i].Leaf.Title, `<details open>` + branchHTML(i, branches[i]) + `</details>`])
out += branchHTML(i, branches[i])
out += `</details>`
} }
html.sort()
for(var i in html)
out += html[i][1]
return out return out
} }
function branchesHaveContent(branches) { function branchesHaveContent(branches) {