]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/http.go
sgblog-topics helper command
[sgblog.git] / cmd / sgblog / http.go
index d039ed38ec6b27b2964cc8811ac7904a6fce895f..7ed1ea6e33219ded65715e5f8524d166a8f6d3c8 100644 (file)
@@ -401,9 +401,9 @@ func serveHTTP() {
                                break
                        }
                        etagHash.Write(commit.Hash[:])
-                       commentsRaw := getNote(commentsTree, commit.Hash)
+                       commentsRaw := sgblog.GetNote(repo, commentsTree, commit.Hash)
                        etagHash.Write(commentsRaw)
-                       topicsRaw := getNote(topicsTree, commit.Hash)
+                       topicsRaw := sgblog.GetNote(repo, topicsTree, commit.Hash)
                        etagHash.Write(topicsRaw)
                        entries = append(entries, TableEntry{
                                Commit:      commit,
@@ -426,8 +426,8 @@ func serveHTTP() {
                                }
                                entry.DomainURLs = append(entry.DomainURLs, makeA(line, u.Host))
                        }
-                       entry.CommentsNum = len(parseComments(entry.CommentsRaw))
-                       entry.Topics = parseTopics(entry.TopicsRaw)
+                       entry.CommentsNum = len(sgblog.ParseComments(entry.CommentsRaw))
+                       entry.Topics = sgblog.ParseTopics(entry.TopicsRaw)
                        entries[i] = entry
                }
                offsetPrev := offset - PageEntries
@@ -533,7 +533,7 @@ func serveHTTP() {
                        }
                        lines := msgSplit(commit.Message)
                        var categories []atom.Category
-                       for _, topic := range parseTopics(getNote(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))
@@ -613,7 +613,7 @@ func serveHTTP() {
                        if err != nil {
                                continue
                        }
-                       comments := parseComments(getNote(t, commentedHash))
+                       comments := sgblog.ParseComments(sgblog.GetNote(repo, t, commentedHash))
                        if len(comments) == 0 {
                                continue
                        }
@@ -673,9 +673,9 @@ func serveHTTP() {
                        cfg.AtomBaseURL, cfg.URLPrefix, "/",
                        commit.Hash.String(), "/", AtomCommentsFeed,
                }, "")
-               commentsRaw := getNote(commentsTree, commit.Hash)
+               commentsRaw := sgblog.GetNote(repo, commentsTree, commit.Hash)
                etagHash.Write(commentsRaw)
-               topicsRaw := getNote(topicsTree, commit.Hash)
+               topicsRaw := sgblog.GetNote(repo, topicsTree, commit.Hash)
                etagHash.Write(topicsRaw)
                if strings.HasSuffix(pathInfo, AtomCommentsFeed) {
                        etagHash.Write([]byte("ATOM COMMENTS"))
@@ -686,7 +686,7 @@ func serveHTTP() {
                                date string
                                body []string
                        }
-                       commentsRaw := parseComments(commentsRaw)
+                       commentsRaw := sgblog.ParseComments(commentsRaw)
                        var toSkip int
                        if len(commentsRaw) > PageEntries {
                                toSkip = len(commentsRaw) - PageEntries
@@ -762,7 +762,7 @@ func serveHTTP() {
                        out.Write(data)
                        goto AtomFinish
                }
-               notesRaw := getNote(notesTree, commit.Hash)
+               notesRaw := sgblog.GetNote(repo, notesTree, commit.Hash)
                etagHash.Write(notesRaw)
                checkETag(etagHash)
 
@@ -773,7 +773,7 @@ func serveHTTP() {
                if len(commit.ParentHashes) > 0 {
                        parent = commit.ParentHashes[0].String()
                }
-               commentsParsed := parseComments(commentsRaw)
+               commentsParsed := sgblog.ParseComments(commentsRaw)
                comments := make([]CommentEntry, 0, len(commentsParsed))
                for _, comment := range commentsParsed {
                        lines := strings.Split(comment, "\n")
@@ -813,7 +813,7 @@ func serveHTTP() {
                        Lines:           lines[2:],
                        NoteLines:       notesLines,
                        Comments:        comments,
-                       Topics:          parseTopics(topicsRaw),
+                       Topics:          sgblog.ParseTopics(topicsRaw),
                })
                if err != nil {
                        makeErr(err)