diff --git a/go.mod b/go.mod index f037e3c..0b8b31c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/bouncepaw/mycorrhiza -go 1.19 +go 1.22 require ( git.sr.ht/~bouncepaw/mycomarkup/v5 v5.5.0 diff --git a/help/en/today.myco b/help/en/today.myco new file mode 100644 index 0000000..33df377 --- /dev/null +++ b/help/en/today.myco @@ -0,0 +1,4 @@ += Today links +Some people use Mycorrhiza to keep their diaries. They put each day's notes into separate hyphae, usually named in the ISO format, for example, `2024-06-01` for the 1st of June, 2024. This date format is especially handy because it aligns with the way Mycorrhiza sorts hyphae, so the days are in order. + +Links [[/today]] and [[/edit-today]] are special links that redirect to or edit the “today” hypha. Put them on your home hypha or on [[/help/en/top_bar | the top bar]]. diff --git a/help/view_help.html b/help/view_help.html index 5797ffa..2f7a97f 100644 --- a/help/view_help.html +++ b/help/view_help.html @@ -33,6 +33,7 @@
  • {{block "recent_changes" .}}Recent changes{{end}}
  • {{block "feeds" .}}Feeds{{end}}
  • {{block "orphans" .}}Orphaned hyphae{{end}}
  • +
  • Today links
  • {{block "configuration" .}}Configuration (for administrators){{end}} diff --git a/web/readers.go b/web/readers.go index 53f7576..0482a9a 100644 --- a/web/readers.go +++ b/web/readers.go @@ -14,6 +14,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/gorilla/mux" @@ -35,6 +36,18 @@ func initReaders(r *mux.Router) { r.PathPrefix("/rev/").HandlerFunc(handlerRevision) r.PathPrefix("/rev-text/").HandlerFunc(handlerRevisionText) r.PathPrefix("/media/").HandlerFunc(handlerMedia) + r.Path("/today").HandlerFunc(handlerToday) + r.Path("/edit-today").HandlerFunc(handlerEditToday) +} + +func handlerEditToday(w http.ResponseWriter, rq *http.Request) { + today := time.Now().Format(time.DateOnly) + http.Redirect(w, rq, "/edit/"+today, http.StatusSeeOther) +} + +func handlerToday(w http.ResponseWriter, rq *http.Request) { + today := time.Now().Format(time.DateOnly) + http.Redirect(w, rq, "/hypha/"+today, http.StatusSeeOther) } func handlerMedia(w http.ResponseWriter, rq *http.Request) {