Compare commits
No commits in common. "3de1b8b7141632cff7f099b9f5de2647aa068edc" and "a90859e151be149a87fa69c5590740295126e56c" have entirely different histories.
3de1b8b714
...
a90859e151
2 changed files with 6 additions and 28 deletions
|
|
@ -37,7 +37,7 @@ var commandBar = new TinyMDE.CommandBar({
|
|||
'|',
|
||||
'h1', 'h2',
|
||||
'|',
|
||||
'ul', 'ol',
|
||||
'ul', 'ol', {name: "checklist", title: "Check List", action: makeChecklist},
|
||||
'|',
|
||||
'blockquote', 'hr',
|
||||
'|',
|
||||
|
|
@ -45,23 +45,9 @@ var commandBar = new TinyMDE.CommandBar({
|
|||
],
|
||||
});
|
||||
|
||||
let editTimeout;
|
||||
let autoSaveDelay = 2000;
|
||||
|
||||
tinyMDE.addEventListener("change", function() {
|
||||
clearTimeout(editTimeout);
|
||||
editTimeout = setTimeout(() => {
|
||||
let form = document.querySelector("form");
|
||||
let formData = new FormData(form);
|
||||
|
||||
fetch("{{.urlSave}}", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((data) => {
|
||||
console.log("Saved Note")
|
||||
});
|
||||
}, autoSaveDelay);
|
||||
});
|
||||
|
||||
function makeChecklist(editor) {
|
||||
editor.wrapSelection("* [ ] ", "")
|
||||
};
|
||||
</script>
|
||||
{{end}}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"forgejo.gwairfelin.com/max/gonotes/internal/conf"
|
||||
markdown "github.com/teekennedy/goldmark-markdown"
|
||||
|
|
@ -37,7 +36,6 @@ type Note struct {
|
|||
Owner string
|
||||
Viewers map[string]struct{}
|
||||
Uid string
|
||||
LastModified time.Time
|
||||
}
|
||||
|
||||
type NoteStore struct {
|
||||
|
|
@ -65,7 +63,7 @@ func Init() error {
|
|||
files, err := os.ReadDir(notesDir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
os.MkdirAll(notesDir, os.FileMode(0o750))
|
||||
os.MkdirAll(notesDir, os.FileMode(0750))
|
||||
} else {
|
||||
log.Print(err.Error())
|
||||
return err
|
||||
|
|
@ -167,7 +165,7 @@ func (n *Note) Save() error {
|
|||
return os.WriteFile(
|
||||
filename,
|
||||
[]byte(fmt.Sprintf("---\n%s---\n%s", frontmatter, n.Body)),
|
||||
0o600,
|
||||
0600,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -192,11 +190,6 @@ func loadNote(uid string) (*Note, error) {
|
|||
}
|
||||
defer f.Close()
|
||||
|
||||
stat, err := os.Stat(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bodyScanner := bufio.NewScanner(f)
|
||||
body := make([]byte, 0, 10)
|
||||
fullBody := make([]byte, 0, 10)
|
||||
|
|
@ -243,7 +236,6 @@ func loadNote(uid string) (*Note, error) {
|
|||
note := NewNoteNoSave(title, owner)
|
||||
note.Uid = uid
|
||||
note.Body = body
|
||||
note.LastModified = stat.ModTime()
|
||||
|
||||
viewers := metaData["viewers"].([]interface{})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue