"github.com/vorlif/spreak"
"go.stargrave.org/sgblog"
"go.stargrave.org/sgblog/cmd/sgblog/atom"
- "golang.org/x/crypto/blake2b"
+ "lukechampine.com/blake3"
)
const (
makeErr(err, http.StatusBadRequest)
}
- etagHash, err := blake2b.New256(nil)
- if err != nil {
- panic(err)
- }
+ etagHash := blake3.New(32, nil)
for _, s := range []string{
"SGBLOG",
sgblog.Version,
cfg.CommentsNotesRef,
cfg.CommentsEmail,
}
- for _, gitURL := range cfg.GitURLs {
- etagHashForWeb = append(etagHashForWeb, gitURL)
- }
+ etagHashForWeb = append(etagHashForWeb, cfg.GitURLs...)
headHash, err := initRepo(cfg)
if err != nil {
} else {
title = fmt.Sprintf("%s (topic: %s)", cfg.Title, topic)
}
- idHasher, err := blake2b.New256(nil)
- if err != nil {
- panic(err)
- }
+ idHasher := blake3.New(32, nil)
idHasher.Write([]byte("ATOM POSTS"))
idHasher.Write([]byte(cfg.AtomId))
idHasher.Write([]byte(topic))
htmlized = append(htmlized, lineURLize(cfg.AtomBaseURL+cfg.URLPrefix, l))
}
htmlized = append(htmlized, "</pre>")
+ links := []atom.Link{{
+ Rel: "alternate",
+ Href: cfg.AtomBaseURL + cfg.URLPrefix + "/" + commit.Hash.String(),
+ }}
+ for _, img := range listImgs(cfg, commit.Hash) {
+ links = append(links, atom.Link{
+ Rel: "enclosure",
+ Href: "http://" + cfg.ImgDomain + "/" + img.Path,
+ Type: img.Typ,
+ Length: uint(img.Size),
+ })
+ }
feed.Entry = append(feed.Entry, &atom.Entry{
- Title: lines[0],
- ID: "urn:uuid:" + bytes2uuid(commit.Hash[:]),
- Link: []atom.Link{{
- Rel: "alternate",
- Href: cfg.AtomBaseURL + cfg.URLPrefix + "/" + commit.Hash.String(),
- }},
+ Title: lines[0],
+ ID: "urn:uuid:" + bytes2uuid(commit.Hash[:]),
+ Link: links,
Published: atom.Time(commit.Author.When),
Updated: atom.Time(commit.Author.When),
Summary: &atom.Text{Type: "text", Body: lines[0]},
etagHash.Write([]byte("ATOM COMMENTS"))
etagHash.Write(commit.Hash[:])
checkETag(etagHash)
- idHasher, err := blake2b.New256(nil)
- if err != nil {
- panic(err)
- }
+ idHasher := blake3.New(32, nil)
idHasher.Write([]byte("ATOM COMMENTS"))
idHasher.Write([]byte(cfg.AtomId))
feed := atom.Feed{
body: lines[3:],
})
}
- idHasher, err := blake2b.New256(nil)
- if err != nil {
- panic(err)
- }
+ idHasher := blake3.New(32, nil)
idHasher.Write([]byte("ATOM COMMENTS"))
idHasher.Write(commit.Hash[:])
feed := atom.Feed{
NoteLines []string
Comments []CommentEntry
Topics []string
+ Imgs []Img
}{
T: localizer,
Version: sgblog.Version,
NoteLines: notesLines,
Comments: comments,
Topics: sgblog.ParseTopics(topicsRaw),
+ Imgs: listImgs(cfg, commit.Hash),
})
if err != nil {
makeErr(err, http.StatusInternalServerError)