1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-04 18:19:54 +00:00

Implement /today and /edit-today

Implements #205
This commit is contained in:
Timur Ismagilov 2024-06-01 22:44:27 +03:00
parent b691ea04ce
commit 5547cb153d
4 changed files with 19 additions and 1 deletions

2
go.mod
View File

@ -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

4
help/en/today.myco Normal file
View File

@ -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]].

View File

@ -33,6 +33,7 @@
<li><a href="/help/en/recent_changes">{{block "recent_changes" .}}Recent changes{{end}}</a></li>
<li><a href="/help/en/feeds">{{block "feeds" .}}Feeds{{end}}</a></li>
<li><a href="/help/en/orphans">{{block "orphans" .}}Orphaned hyphae{{end}}</a></li>
<li><a href="/help/en/today">Today links</a></li>
</ul>
</li>
<li>{{block "configuration" .}}Configuration (for administrators){{end}}

View File

@ -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) {