diff --git a/config/config.go b/config/config.go index 3e91447..1963587 100755 --- a/config/config.go +++ b/config/config.go @@ -166,6 +166,14 @@ const defaultWrapper = ` .comment:focus-within { display: inline-flex; } + .attachments > details > form { + display: flex; + flex-direction: row; + width: 100%; + } + .attachments > details > form > input:first-of-type { + flex-grow: 2; + } diff --git a/server/notes.go b/server/notes.go index ccf6fc9..3edd14b 100755 --- a/server/notes.go +++ b/server/notes.go @@ -6,6 +6,7 @@ import ( "local/notes-server/filetree" "net/http" "path" + "strings" ) func (s *Server) notes(w http.ResponseWriter, r *http.Request) { @@ -49,13 +50,15 @@ func (s *Server) file(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusBadRequest) return } - fileHead(w, filetree.NewPathFromURL(r.URL.Path).BaseHREF) + s.fileHead(w, r.URL.Path) fmt.Fprintln(w, file) } -func fileHead(w http.ResponseWriter, baseHREF string) { +func (s *Server) fileHead(w http.ResponseWriter, path string) { + baseHREF := filetree.NewPathFromURL(path).BaseHREF htmlEdit(w, baseHREF) htmlDelete(w, baseHREF) + s.htmlAttachments(w, path) } func htmlEdit(w http.ResponseWriter, baseHREF string) { @@ -76,6 +79,32 @@ func htmlDelete(w http.ResponseWriter, baseHREF string) {
`, path.Join("/delete/", baseHREF)) } +func (s *Server) htmlAttachments(w http.ResponseWriter, urlPath string) { + dir := path.Dir(urlPath) + f := "." + path.Base(urlPath) + ".attachments" + _, files, _ := s.Notes.Dir(path.Join(dir, f)) + // + //style="min-width: 2em; text-align: center; padding: 0; margin-top: 0; margin-bottom: 0;"/> + form := fmt.Sprintf(` +
+ + +
+ `, strings.TrimPrefix(urlPath, "/")) + if config.ReadOnly { + form = "" + } + fmt.Fprintf(w, `
+
+ + Attachments + + %s + %s +
+

`, form, files) +} + func htmlCreate(w http.ResponseWriter, baseHREF string) { if config.ReadOnly { return