summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-31 18:24:03 +0200
committerPaul Buetow <paul@buetow.org>2024-12-31 18:24:03 +0200
commitec523bdd63bd23cfec465e2cc45d0c17198ef4c4 (patch)
tree38e29cdf9030f615dc6753d07e1601bfb3a26ce7
parente40995f28834ffffdea5343b1526a85c7268d202 (diff)
refine summary, add gemtexter tags
-rw-r--r--cmd/gos/main.go2
-rw-r--r--internal/config/args.go1
-rw-r--r--internal/summary/summary.go21
3 files changed, 15 insertions, 9 deletions
diff --git a/cmd/gos/main.go b/cmd/gos/main.go
index 8c286ff..c8e94e8 100644
--- a/cmd/gos/main.go
+++ b/cmd/gos/main.go
@@ -31,6 +31,7 @@ func main() {
pauseDays := flag.Int("pauseDays", 3, "How many days until next post can be posted?")
lookback := flag.Int("lookback", 30, "How many days look back in time for posting history")
summaryFor := flag.String("summaryFor", "", "Generate a summary in Gemtext format, format is coma separated string of months, e.g. 202410,202411")
+ gemtexterEnable := flag.Bool("gemtexterEnable", true, "Add special Gemtexter tags to the Gemtext summary")
flag.Parse()
secrets, err := config.NewSecrets(secretsConfigPath)
@@ -50,6 +51,7 @@ func main() {
CacheDir: *cacheDir,
Secrets: secrets,
OAuth2Browser: *browser,
+ GemtexterEnable: *gemtexterEnable,
}
if *summaryFor != "" {
args.SummaryFor = strings.Split(*summaryFor, ",")
diff --git a/internal/config/args.go b/internal/config/args.go
index 615c607..43687ac 100644
--- a/internal/config/args.go
+++ b/internal/config/args.go
@@ -23,6 +23,7 @@ type Args struct {
Secrets Secrets
OAuth2Browser string
SummaryFor []string
+ GemtexterEnable bool
}
func (a *Args) ParsePlatforms(platformStrs string) error {
diff --git a/internal/summary/summary.go b/internal/summary/summary.go
index 9a6c96e..b2a8fde 100644
--- a/internal/summary/summary.go
+++ b/internal/summary/summary.go
@@ -9,14 +9,11 @@ import (
"sort"
"strings"
- "codeberg.org/snonux/gos/internal/colour"
"codeberg.org/snonux/gos/internal/config"
"codeberg.org/snonux/gos/internal/entry"
)
func Run(ctx context.Context, args config.Args) error {
- colour.Infoln("Generating summary for", args.SummaryFor)
-
entries, err := deduppedEntries(args)
if err != nil {
return err
@@ -26,8 +23,8 @@ func Run(ctx context.Context, args config.Args) error {
return entries[i].Time.Before(entries[j].Time)
})
- title := fmt.Sprintf("Summary for %s", strings.Join(args.SummaryFor, " "))
- gemtext, err := fmt.Print(generateGemtext(entries, title))
+ title := fmt.Sprintf("Posts for %s", strings.Join(args.SummaryFor, " "))
+ gemtext, err := fmt.Print(generateGemtext(entries, title, args.GemtexterEnable))
if err != nil {
return err
}
@@ -37,7 +34,7 @@ func Run(ctx context.Context, args config.Args) error {
}
// TODO: Fix the Gemtexter inline toc when there are tags in it
-func generateGemtext(entries []entry.Entry, title string) (string, error) {
+func generateGemtext(entries []entry.Entry, title string, gemtexterEnable bool) (string, error) {
var (
sb strings.Builder
currentDateStr string
@@ -45,9 +42,9 @@ func generateGemtext(entries []entry.Entry, title string) (string, error) {
sb.WriteString("# ")
sb.WriteString(title)
- // TODO: Make this configurable
- // TODO: Also add gemtexter index to previous posts like this
- sb.WriteString("\n\n<< template::inline::toc")
+ if gemtexterEnable {
+ sb.WriteString("\n\n<< template::inline::toc")
+ }
for _, en := range entries {
dateStr := en.Time.Format("January 2006")
@@ -81,6 +78,12 @@ func generateGemtext(entries []entry.Entry, title string) (string, error) {
}
}
+ if gemtexterEnable {
+ sb.WriteString("\n\nOther related posts:")
+ sb.WriteString("\n\n<< template::inline::index posts-for")
+ sb.WriteString("\n\n")
+ }
+
return sb.String(), nil
}