/*
SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine
-Copyright (C) 2020-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2023 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
+ "github.com/vorlif/spreak"
"go.stargrave.org/sgblog"
"go.stargrave.org/sgblog/cmd/sgblog/atom"
"golang.org/x/crypto/blake2b"
func startHeader(etag hash.Hash, gziped bool) string {
lines := []string{
- "Content-Type: text/html; charset=UTF-8",
+ "Content-Type: text/html; charset=utf-8",
"ETag: " + etagString(etag),
}
if gziped {
func makeErr(err error, status int) {
fmt.Println("Status:", status)
- fmt.Print("Content-Type: text/plain; charset=UTF-8\n\n")
+ fmt.Print("Content-Type: text/plain; charset=utf-8\n\n")
fmt.Println(err)
log.Fatalln(err)
}
if err != nil {
log.Fatalln(err)
}
+ initLocalizer(cfg.Lang)
pathInfo := os.Getenv("PATH_INFO")
if len(pathInfo) == 0 {
}
os.Stdout.Write([]byte(startHeader(etagHash, gzipWriter != nil)))
err = TmplHTMLIndex.Execute(out, struct {
+ T *spreak.Localizer
Version string
Cfg *Cfg
Topic string
LogEnded bool
Entries []TableEntry
}{
+ T: localizer,
Version: sgblog.Version,
Cfg: cfg,
Topic: topic,
}
lines := msgSplit(commit.Message)
var categories []atom.Category
- for _, topic := range sgblog.ParseTopics(sgblog.GetNote(repo, topicsTree, commit.Hash)) {
+ for _, topic := range sgblog.ParseTopics(sgblog.GetNote(
+ repo, topicsTree, commit.Hash,
+ )) {
categories = append(categories, atom.Category{Term: topic})
}
htmlized := make([]string, 0, len(lines))
if err != nil {
makeErr(err, http.StatusInternalServerError)
}
+ out.Write([]byte(xml.Header))
out.Write(data)
goto AtomFinish
} else if pathInfo == "/"+AtomCommentsFeed {
if err != nil {
makeErr(err, http.StatusInternalServerError)
}
+ out.Write([]byte(xml.Header))
out.Write(data)
goto AtomFinish
} else if sha1DigestRe.MatchString(pathInfo[1:]) {
if err != nil {
makeErr(err, http.StatusInternalServerError)
}
+ out.Write([]byte(xml.Header))
out.Write(data)
goto AtomFinish
}
os.Stdout.Write([]byte(startHeader(etagHash, gzipWriter != nil)))
err = TmplHTMLEntry.Execute(out, struct {
+ T *spreak.Localizer
Version string
Cfg *Cfg
Title string
Comments []CommentEntry
Topics []string
}{
+ T: localizer,
Version: sgblog.Version,
Cfg: cfg,
Title: title,
return
AtomFinish:
- os.Stdout.WriteString("Content-Type: application/atom+xml; charset=UTF-8\n")
+ os.Stdout.WriteString("Content-Type: application/atom+xml; charset=utf-8\n")
os.Stdout.WriteString("ETag: " + etagString(etagHash) + "\n")
if gzipWriter != nil {
os.Stdout.WriteString("Content-Encoding: gzip\n")