README.texi | 8 +++++--- cmd/sgblog/http.go | 33 +++++++++++++++++++++++++++++++++ common.go | 2 +- diff --git a/README.texi b/README.texi index 65f808a5d893c03d7edc1d82ffc6cedc82a82e60786e9eab0ff7be50febc0677..c8310dbbd1d3fce99092d6a65974c80f1dc39a3ac54f8ccc137dd298cc159f02 100644 --- a/README.texi +++ b/README.texi @@ -11,9 +11,11 @@ @top SGBlog SGBlog is minimalistic and simple Git-backed CGI/UCSPI @url{https://en.wikipedia.org/wiki/Blog, blogging} (@code{http://}/@code{https://}), -@url{https://en.wikipedia.org/wiki/Phlog, phlogging} (@code{gopher://}) and -gemlogging (@code{gemini://}) engine -with email-backed comments support, written on @url{https://golang.org/, Go}. +@url{https://en.wikipedia.org/wiki/Phlog, phlogging} (@code{gopher://}), +@url{https://twtxt.readthedocs.io/en/latest/index.html, twtxting}, and +@url{https://en.wikipedia.org/wiki/Gemini_(protocol), gemlogging} (@code{gemini://}) +engine with email-backed comments support, +written on @url{https://golang.org/, Go}. Its main competitive features: diff --git a/cmd/sgblog/http.go b/cmd/sgblog/http.go index 995fbd855506bceb627fae3d5880e8f6c698ee405f77af9dd37de5193ff967a2..e2620951e2b3527f61fff2b716642d8e1c08b296a784ddf07a13e6763cfe0876 100644 --- a/cmd/sgblog/http.go +++ b/cmd/sgblog/http.go @@ -36,6 +36,7 @@ "os" "strconv" "strings" "text/template" + "time" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" @@ -379,6 +380,38 @@ }) if err != nil { makeErr(err, http.StatusInternalServerError) } + } else if pathInfo == "/twtxt.txt" { + commit, err := repo.CommitObject(*headHash) + if err != nil { + makeErr(err, http.StatusInternalServerError) + } + etagHash.Write([]byte("TWTXT POSTS")) + etagHash.Write(commit.Hash[:]) + checkETag(etagHash) + repoLog, err := repo.Log(&git.LogOptions{From: *headHash}) + if err != nil { + makeErr(err, http.StatusInternalServerError) + } + for i := 0; i < PageEntries; i++ { + commit, err = repoLog.Next() + if err != nil { + break + } + fmt.Fprintf( + out, "%s\t%s\n", + commit.Author.When.Format(time.RFC3339), + msgSplit(commit.Message)[0], + ) + } + os.Stdout.WriteString("Content-Type: text/plain; charset=utf-8\n") + os.Stdout.WriteString("ETag: " + etagString(etagHash) + "\n") + if gzipWriter != nil { + os.Stdout.WriteString("Content-Encoding: gzip\n") + gzipWriter.Close() + } + os.Stdout.WriteString("\n") + os.Stdout.Write(outBuf.Bytes()) + return } else if pathInfo == "/"+AtomPostsFeed { commit, err := repo.CommitObject(*headHash) if err != nil { diff --git a/common.go b/common.go index 02fb7206fc0e202a007b1eb752850df0583186f00032ecdb9ec7c7b29ab46c64..9c214bd2e1256b5a5d40d62136e742ca5e667f0d316ccd28b6895ad316ec70ec 100644 --- a/common.go +++ b/common.go @@ -15,7 +15,7 @@ "go.cypherpunks.ru/recfile" ) const ( - Version = "0.24.0" + Version = "0.25.0" WhenFmt = "2006-01-02 15:04:05Z07:00" )