From: Sergey Matveev Date: Wed, 19 Feb 2025 07:16:39 +0000 (+0300) Subject: Denser gopher/gemini output X-Git-Tag: v0.35.0 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=e73b8959ddb9eacb31e0f7369eea347be91b224d;p=sgblog.git Denser gopher/gemini output --- diff --git a/cmd/sgblog/gemini-entry.tmpl b/cmd/sgblog/gemini-entry.tmpl index abbca9e..02dc3e5 100644 --- a/cmd/sgblog/gemini-entry.tmpl +++ b/cmd/sgblog/gemini-entry.tmpl @@ -15,12 +15,9 @@ {{range $idx, $img := .Images}}=> /img/{{$img.Path}} {{$img.Alt}} {{end}} {{end -}} -{{- if .Cfg.CommentsEmail}} -=> mailto:{{.Cfg.CommentsEmail}}?subject={{.TitleEscaped}} {{$.T.Get "leave a comment"}} -{{end}}{{range $idx, $comment := .Comments}} +{{range $idx, $comment := .Comments}} ## {{$.T.Get "comment"}} {{$idx}}: ``` {{$comment}} ``` {{end}} -{{$.T.Get "Generated by"}}: SGBlog {{.Version}} diff --git a/cmd/sgblog/gemini-menu.tmpl b/cmd/sgblog/gemini-menu.tmpl index eead365..c6a294e 100644 --- a/cmd/sgblog/gemini-menu.tmpl +++ b/cmd/sgblog/gemini-menu.tmpl @@ -9,9 +9,8 @@ {{- $dateCur := .Commit.Author.When.Format "2006-01-02" -}} {{- if ne $dateCur $datePrev}}{{$datePrev = $dateCur}}## {{$dateCur}} {{end -}} -=> /{{.Commit.Hash.String}} {{.Commit.Author.When.Format "2006-01-02"}} [{{.Commit.Author.When.Format "15:04"}}] {{.Title}} ({{.LinesNum}}L){{with .ImagesNum}} ({{.}}I){{end}}{{with .CommentsNum}} ({{.}}C){{end}}{{if .Topics}}{{range .Topics}} {{.}}{{end}}{{end}} +=> /{{.Commit.Hash.String}} {{.Commit.Author.When.Format "2006-01-02"}} {{.Title}} {{end}} {{range .Topics -}}=> /?topic={{.}} Topic: {{.}} {{end}} -{{$.T.Get "Generated by"}}: SGBlog {{.Version}} diff --git a/cmd/sgblog/gemini.go b/cmd/sgblog/gemini.go index 1517117..d7a654e 100644 --- a/cmd/sgblog/gemini.go +++ b/cmd/sgblog/gemini.go @@ -132,16 +132,8 @@ func serveGemini(cfgPath string) { } lines := msgSplit(commit.Message) entries = append(entries, TableMenuEntry{ - Commit: commit, - Title: lines[0], - LinesNum: len(lines) - 2, - ImagesNum: len(listImgs(cfg, commit.Hash)), - CommentsNum: len(sgblog.ParseComments(sgblog.GetNote( - repo, commentsTree, commit.Hash, - ))), - Topics: sgblog.ParseTopics(sgblog.GetNote( - repo, topicsTree, commit.Hash, - )), + Commit: commit, + Title: lines[0], }) } offsetPrev := max(offset-PageEntries, 0) @@ -178,17 +170,16 @@ func serveGemini(cfgPath string) { } title := msgSplit(commit.Message)[0] err = TmplGemEntry.Execute(os.Stdout, struct { - T *spreak.Localizer - Title string - Commit *object.Commit - When string - Cfg *Cfg - Note string - Images []Img - Comments []string - Topics []string - Version string - TitleEscaped string + T *spreak.Localizer + Title string + Commit *object.Commit + When string + Cfg *Cfg + Note string + Images []Img + Comments []string + Topics []string + Version string }{ T: localizer, Title: title, @@ -200,9 +191,6 @@ func serveGemini(cfgPath string) { Comments: sgblog.ParseComments(sgblog.GetNote(repo, commentsTree, commit.Hash)), Topics: sgblog.ParseTopics(sgblog.GetNote(repo, topicsTree, commit.Hash)), Version: sgblog.Version, - TitleEscaped: url.PathEscape(fmt.Sprintf( - "Re: %s (%s)", title, commit.Hash, - )), }) if err != nil { log.Fatalln(err) diff --git a/cmd/sgblog/gopher-entry.tmpl b/cmd/sgblog/gopher-entry.tmpl index 3235123..aface6a 100644 --- a/cmd/sgblog/gopher-entry.tmpl +++ b/cmd/sgblog/gopher-entry.tmpl @@ -12,13 +12,8 @@ ------------------------------------------------------------------------ {{$.T.Get "Note"}}: {{.Note}}{{end -}} -{{- if .Cfg.CommentsEmail}} ------------------------------------------------------------------------- -{{$.T.Get "leave a comment"}}: mailto:{{.Cfg.CommentsEmail}}?subject={{.TitleEscaped}} -{{end}}{{range $idx, $comment := .Comments}} +{{range $idx, $comment := .Comments}} ------------------------------------------------------------------------ {{$.T.Get "comment"}} {{$idx}}: {{$comment}} {{end}} ------------------------------------------------------------------------- -{{$.T.Get "Generated by"}}: SGBlog {{.Version}} diff --git a/cmd/sgblog/gopher-menu.tmpl b/cmd/sgblog/gopher-menu.tmpl index ad89756..df39c82 100644 --- a/cmd/sgblog/gopher-menu.tmpl +++ b/cmd/sgblog/gopher-menu.tmpl @@ -9,8 +9,7 @@ i{{.Cfg.Title}} {{if .Topic}}({{$.T.Get "topic"}}: {{.Topic}}) {{end}}({{.Offset {{- $dateCur := .Commit.Author.When.Format "2006-01-02" -}} {{- if ne $dateCur $datePrev}}{{$datePrev = $dateCur}} i{{$dateCur}} err{{template "domainPort" $Cfg}}{{$CR}}{{end}} -0[{{.Commit.Author.When.Format "15:04"}}] {{.Title}} ({{.LinesNum}}L){{with .ImagesNum}} ({{.}}I){{end}}{{with .CommentsNum}} ({{.}}C){{end}}{{if .Topics}}{{range .Topics}} {{.}}{{end}}{{end}} /{{.Commit.Hash.String}}{{template "domainPort" $Cfg}}{{$CR}}{{end}} +0{{.Title}} /{{.Commit.Hash.String}}{{template "domainPort" $Cfg}}{{$CR}}{{end}} {{range .Topics}} 1{{$.T.Get "topic"}}: {{.}} {{.}}/offset/0{{template "domainPort" $Cfg}}{{$CR}}{{end}} -i{{$.T.Get "Generated by"}}: SGBlog {{.Version}} err{{template "domainPort" .Cfg}}{{$CR}} .{{$CRLF}} diff --git a/cmd/sgblog/gopher.go b/cmd/sgblog/gopher.go index 1944ae0..e9173eb 100644 --- a/cmd/sgblog/gopher.go +++ b/cmd/sgblog/gopher.go @@ -22,7 +22,6 @@ import ( "fmt" "io" "log" - "net/url" "os" "strconv" "strings" @@ -46,12 +45,8 @@ var ( ) type TableMenuEntry struct { - Commit *object.Commit - Title string - Topics []string - LinesNum int - ImagesNum int - CommentsNum int + Commit *object.Commit + Title string } func serveGopher(cfgPath string) { @@ -97,16 +92,14 @@ Redirecting to %s... log.Fatalln(err) } err = TmplGopherEntry.Execute(os.Stdout, struct { - T *spreak.Localizer - Commit *object.Commit - When string - Cfg *Cfg - Note string - Images []Img - Comments []string - Topics []string - Version string - TitleEscaped string + T *spreak.Localizer + Commit *object.Commit + When string + Cfg *Cfg + Note string + Images []Img + Comments []string + Topics []string }{ T: localizer, Commit: commit, @@ -116,10 +109,6 @@ Redirecting to %s... Images: listImgs(cfg, commit.Hash), Comments: sgblog.ParseComments(sgblog.GetNote(repo, commentsTree, commit.Hash)), Topics: sgblog.ParseTopics(sgblog.GetNote(repo, topicsTree, commit.Hash)), - Version: sgblog.Version, - TitleEscaped: url.PathEscape(fmt.Sprintf( - "Re: %s (%s)", msgSplit(commit.Message)[0], commit.Hash, - )), }) if err != nil { log.Fatalln(err) @@ -177,16 +166,8 @@ Redirecting to %s... } lines := msgSplit(commit.Message) entries = append(entries, TableMenuEntry{ - Commit: commit, - Title: lines[0], - LinesNum: len(lines) - 2, - ImagesNum: len(listImgs(cfg, commit.Hash)), - CommentsNum: len(sgblog.ParseComments(sgblog.GetNote( - repo, commentsTree, commit.Hash, - ))), - Topics: sgblog.ParseTopics(sgblog.GetNote( - repo, topicsTree, commit.Hash, - )), + Commit: commit, + Title: lines[0], }) } offsetPrev := max(offset-PageEntries, 0) @@ -200,7 +181,6 @@ Redirecting to %s... LogEnded bool Entries []TableMenuEntry Topics []string - Version string }{ T: localizer, Cfg: cfg, @@ -211,7 +191,6 @@ Redirecting to %s... LogEnded: logEnded, Entries: entries, Topics: topicsCache.Topics(), - Version: sgblog.Version, }) if err != nil { log.Fatalln(err) diff --git a/common.go b/common.go index 9ab5c7f..67675a3 100644 --- a/common.go +++ b/common.go @@ -30,7 +30,7 @@ import ( ) const ( - Version = "0.34.0" + Version = "0.35.0" WhenFmt = "2006-01-02 15:04:05Z07:00" )