]> Sergey Matveev's repositories - sgblog.git/commitdiff
Cleaner internal subpackage
authorSergey Matveev <stargrave@stargrave.org>
Mon, 14 Jul 2025 08:54:16 +0000 (11:54 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 14 Jul 2025 08:54:16 +0000 (11:54 +0300)
cmd/sgblog-comment-add/main.go
cmd/sgblog-topics/main.go
cmd/sgblog/gemini.go
cmd/sgblog/gopher.go
cmd/sgblog/http.go
cmd/sgblog/topics.go
internal/comments.go [new file with mode: 0644]
internal/note.go [moved from common.go with 62% similarity]
internal/topics.go [new file with mode: 0644]
internal/version.go [new file with mode: 0644]
internal/when.go [new file with mode: 0644]

index 47a15efab3aec68f1949825b811cabb2bd9b0148..ccd8abf4b748d9fc50ce08a6482ec678d406fc52 100644 (file)
@@ -35,7 +35,7 @@ import (
        "time"
 
        "go.cypherpunks.su/recfile/v3"
-       "go.stargrave.org/sgblog"
+       sgblog "go.stargrave.org/sgblog/internal"
 )
 
 var hashFinder = regexp.MustCompile("([0-9a-f]{40})")
index a71a2acdd724ef5e15392921c7b3576f31434168..62e1c0d95e884e9eaa9b685995a1d4a9253fb48d 100644 (file)
@@ -26,7 +26,7 @@ import (
        "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() {
index d7a654ebcbfaa4cbda01a5cde20930438de1d460..808fd38700ccb2ed03657016597a48a0ed189123 100644 (file)
@@ -33,7 +33,7 @@ import (
        "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 (
index e9173eba91de15081d21a0d15d98f67afcd274b0..37aef755f1480fdc82ddca00b9f97b94a1b2aa20 100644 (file)
@@ -31,7 +31,7 @@ import (
        "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 (
index 837320bdbf9c8bd291a37aeabf76124bea4c67cb..e8c36f023489dfa2199660970a702d295f2555e8 100644 (file)
@@ -41,8 +41,8 @@ import (
        "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"
 )
 
index d6528c19796d5072eb99dfe097ec840ce48f37d4..7a6285e6b647e9fb9c04eb5c3f64dfec7a6a7fb3 100644 (file)
@@ -25,7 +25,7 @@ import (
 
        "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/internal/comments.go b/internal/comments.go
new file mode 100644 (file)
index 0000000..ec112dc
--- /dev/null
@@ -0,0 +1,47 @@
+// SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine
+// Copyright (C) 2020-2025 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
+// 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 <http://www.gnu.org/licenses/>.
+
+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
+}
similarity index 62%
rename from common.go
rename to internal/note.go
index 128a745c75b2d5ae3f292657fe0d51d34e2393b8..27c6e42cedcab546a9c006e3fbbd57a9f589c374 100644 (file)
--- a/common.go
 // You should have received a copy of the GNU Affero General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-// 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 {
                return nil
diff --git a/internal/topics.go b/internal/topics.go
new file mode 100644 (file)
index 0000000..ade40e6
--- /dev/null
@@ -0,0 +1,33 @@
+// SGBlog -- Git-backed CGI/UCSPI blogging/phlogging/gemlogging engine
+// Copyright (C) 2020-2025 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
+// 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 <http://www.gnu.org/licenses/>.
+
+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 (file)
index 0000000..416ad4b
--- /dev/null
@@ -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 (file)
index 0000000..3cdfb60
--- /dev/null
@@ -0,0 +1,3 @@
+package internal
+
+const WhenFmt = "2006-01-02 15:04:05Z07:00"