cmd/sgblog-comment-add/main.go | 2 +- cmd/sgblog-topics/main.go | 2 +- cmd/sgblog/gemini.go | 2 +- cmd/sgblog/gopher.go | 2 +- cmd/sgblog/http.go | 2 +- cmd/sgblog/topics.go | 2 +- common.go => internal/note.go | 47 +---------------------------------------------- internal/comments.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ internal/topics.go | 33 +++++++++++++++++++++++++++++++++ internal/version.go | 3 +++ internal/when.go | 3 +++ diff --git a/cmd/sgblog-comment-add/main.go b/cmd/sgblog-comment-add/main.go index 27d3c74f3af915af13a4e8109317881ed07a9fa93a59216b8776f9f5ca7d1ddc..d559b63eb6a3b7eebe40e5be56f8d8741740020a87168da6f77f679de5e9bda1 100644 --- a/cmd/sgblog-comment-add/main.go +++ b/cmd/sgblog-comment-add/main.go @@ -35,7 +35,7 @@ "syscall" "time" "go.cypherpunks.su/recfile/v3" - "go.stargrave.org/sgblog" + sgblog "go.stargrave.org/sgblog/internal" ) var hashFinder = regexp.MustCompile("([0-9a-f]{40})") diff --git a/cmd/sgblog-topics/main.go b/cmd/sgblog-topics/main.go index 8674a4ecb9f84321e84ffda29268907df12a7ecc370e1e7684377e0d97018743..e0703d476984642fcf7a51a3d7668fe7aae33c7f64352e1343de41411ce49db1 100644 --- a/cmd/sgblog-topics/main.go +++ b/cmd/sgblog-topics/main.go @@ -26,7 +26,7 @@ "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/go-git/go-git/v5/plumbing/storer" - "go.stargrave.org/sgblog" + sgblog "go.stargrave.org/sgblog/internal" ) func main() { diff --git a/cmd/sgblog/gemini.go b/cmd/sgblog/gemini.go index 10a4334c24ebb696f087aaa8ae1bff30f9408bcd3e4f11db42d695747eff1ca4..0f77301115d7650260383f0614c799e9a5b04577aa2334467284d9a644a06cab 100644 --- a/cmd/sgblog/gemini.go +++ b/cmd/sgblog/gemini.go @@ -33,7 +33,7 @@ "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" + sgblog "go.stargrave.org/sgblog/internal" ) var ( diff --git a/cmd/sgblog/gopher.go b/cmd/sgblog/gopher.go index 5dcd996e92a7d22fb89fd650cec9c1c7b2b1685235df66662b1a3f30554452c1..1877625f5580d0b25455dc5c4fd8a994e47c6608fa86c00b4f7e6059b45546d3 100644 --- a/cmd/sgblog/gopher.go +++ b/cmd/sgblog/gopher.go @@ -31,7 +31,7 @@ "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" + sgblog "go.stargrave.org/sgblog/internal" ) var ( diff --git a/cmd/sgblog/http.go b/cmd/sgblog/http.go index 78e56745084080b6b314eabc06175d3f3db9cf9b245e81561bdfed9fe78a1ea4..8f3b3dcc7aa15c178e84bef3ebd54dc9999ff310c3f9b8a94f27361589cd6bf1 100644 --- a/cmd/sgblog/http.go +++ b/cmd/sgblog/http.go @@ -41,8 +41,8 @@ "github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/storer" "github.com/klauspost/compress/zstd" "github.com/vorlif/spreak" - "go.stargrave.org/sgblog" "go.stargrave.org/sgblog/cmd/sgblog/atom" + sgblog "go.stargrave.org/sgblog/internal" "lukechampine.com/blake3" ) diff --git a/cmd/sgblog/topics.go b/cmd/sgblog/topics.go index e665486286d7a7e5f50ccb5a0373dff1779e1964d9e3af6f5f3f7fa18a587785..2a62aeab1a5ee85ceabeaca5e63bbc4d1bc34bac64be5b79cdaaffec4b92ec90 100644 --- a/cmd/sgblog/topics.go +++ b/cmd/sgblog/topics.go @@ -25,7 +25,7 @@ "time" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" - "go.stargrave.org/sgblog" + sgblog "go.stargrave.org/sgblog/internal" ) type TopicsCache map[string][]plumbing.Hash diff --git a/common.go b/internal/note.go rename from common.go rename to internal/note.go index f61a02bbca28ed40c33d375a48d6d356608048b2caaadc9d9166a9a5d8a95fd3..0f37fc614a980c813e7c5d272b9659130c74c9b0e4b243de8489204fc8508f15 100644 --- a/common.go +++ b/internal/note.go @@ -13,61 +13,16 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -// SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine -package sgblog +package internal import ( "bytes" - "fmt" "io" - "sort" - "text/scanner" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" - "go.cypherpunks.su/recfile/v3" -) - -const ( - Version = "0.36.0" - WhenFmt = "2006-01-02 15:04:05Z07:00" ) - -func ParseComments(data []byte) []string { - comments := []string{} - r := recfile.NewReader(bytes.NewReader(data)) - for { - fields, err := r.Next() - if err != nil { - break - } - if len(fields) != 3 || - fields[0].F != "From" || - fields[1].F != "Date" || - fields[2].F != "Body" { - continue - } - comments = append(comments, fmt.Sprintf( - "%s: %s\n%s: %s\n%s", - fields[0].F, fields[0].V, - fields[1].F, fields[1].V, - fields[2].V, - )) - } - return comments -} - -func ParseTopics(data []byte) []string { - var s scanner.Scanner - s.Init(bytes.NewBuffer(data)) - topics := []string{} - for tok := s.Scan(); tok != scanner.EOF; tok = s.Scan() { - topics = append(topics, s.TokenText()) - } - sort.Strings(topics) - return topics -} func GetNote(repo *git.Repository, tree *object.Tree, what plumbing.Hash) []byte { if tree == nil { diff --git a/internal/comments.go b/internal/comments.go new file mode 100644 index 0000000000000000000000000000000000000000..c43dcdf290053af9753a3ac3d13836618976419972c64f3c0dd921db47994206 --- /dev/null +++ b/internal/comments.go @@ -0,0 +1,47 @@ +// SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine +// Copyright (C) 2020-2025 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package internal + +import ( + "bytes" + "fmt" + + "go.cypherpunks.su/recfile/v3" +) + +func ParseComments(data []byte) []string { + comments := []string{} + r := recfile.NewReader(bytes.NewReader(data)) + for { + fields, err := r.Next() + if err != nil { + break + } + if len(fields) != 3 || + fields[0].F != "From" || + fields[1].F != "Date" || + fields[2].F != "Body" { + continue + } + comments = append(comments, fmt.Sprintf( + "%s: %s\n%s: %s\n%s", + fields[0].F, fields[0].V, + fields[1].F, fields[1].V, + fields[2].V, + )) + } + return comments +} diff --git a/internal/topics.go b/internal/topics.go new file mode 100644 index 0000000000000000000000000000000000000000..20c211c3fd687aaa851033a64c87f798f8f206b0ccd4301040df7bdb6d1befae --- /dev/null +++ b/internal/topics.go @@ -0,0 +1,33 @@ +// SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine +// Copyright (C) 2020-2025 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package internal + +import ( + "bytes" + "sort" + "text/scanner" +) + +func ParseTopics(data []byte) []string { + var s scanner.Scanner + s.Init(bytes.NewBuffer(data)) + topics := []string{} + for tok := s.Scan(); tok != scanner.EOF; tok = s.Scan() { + topics = append(topics, s.TokenText()) + } + sort.Strings(topics) + return topics +} diff --git a/internal/version.go b/internal/version.go new file mode 100644 index 0000000000000000000000000000000000000000..94fcc5e55490a33c1356d13d16f44ae7aabf8dae7db72332ead3a7ffaf983ad4 --- /dev/null +++ b/internal/version.go @@ -0,0 +1,3 @@ +package internal + +const Version = "0.37.0" diff --git a/internal/when.go b/internal/when.go new file mode 100644 index 0000000000000000000000000000000000000000..f57151616d63a37a6450a8ed653e3b3bb319b5bc8d10ce5a6504436cfe7e64fe --- /dev/null +++ b/internal/when.go @@ -0,0 +1,3 @@ +package internal + +const WhenFmt = "2006-01-02 15:04:05Z07:00"