]> Sergey Matveev's repositories - sgblog.git/commitdiff
Denser gopher/gemini output v0.35.0
authorSergey Matveev <stargrave@stargrave.org>
Wed, 19 Feb 2025 07:16:39 +0000 (10:16 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 19 Feb 2025 07:16:39 +0000 (10:16 +0300)
cmd/sgblog/gemini-entry.tmpl
cmd/sgblog/gemini-menu.tmpl
cmd/sgblog/gemini.go
cmd/sgblog/gopher-entry.tmpl
cmd/sgblog/gopher-menu.tmpl
cmd/sgblog/gopher.go
common.go

index abbca9e7d2f57c4e98c3049776adab940005bace..02dc3e55b87ae2cc58b50637bbe4158ac8b8298c 100644 (file)
 {{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}}
index eead36527d391108f24065b4c5682fc11131d71d..c6a294e54698d11572e2f8a306c7312fa574a807 100644 (file)
@@ -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}}
index 1517117714d0d9d13433ba31a1588c65cd91683c..d7a654ebcbfaa4cbda01a5cde20930438de1d460 100644 (file)
@@ -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)
index 3235123507637a24828b647c5fa9a8cfb3c44fbb..aface6af33a997b4a413ee7f58f72de895cd193d 100644 (file)
 ------------------------------------------------------------------------
 {{$.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}}
index ad897560766b2309d58ad89c65bcd4a66aa67cbe..df39c820cbc45129aad2e7771885864408579fde 100644 (file)
@@ -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}}
index 1944ae0362fbff5e471f2f3cb44afac161e1a973..e9173eba91de15081d21a0d15d98f67afcd274b0 100644 (file)
@@ -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 <a href="%s">%s</a>...
                        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 <a href="%s">%s</a>...
                        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 <a href="%s">%s</a>...
                        }
                        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 <a href="%s">%s</a>...
                        LogEnded   bool
                        Entries    []TableMenuEntry
                        Topics     []string
-                       Version    string
                }{
                        T:          localizer,
                        Cfg:        cfg,
@@ -211,7 +191,6 @@ Redirecting to <a href="%s">%s</a>...
                        LogEnded:   logEnded,
                        Entries:    entries,
                        Topics:     topicsCache.Topics(),
-                       Version:    sgblog.Version,
                })
                if err != nil {
                        log.Fatalln(err)
index 9ab5c7f1719636b3f5cc904e2fa7fd25c8f440cd..67675a38f3b0002d7ecdd7770340e584eb40080a 100644 (file)
--- 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"
 )