diff --git a/core/entries.go b/core/entries.go index f1bb092..74fb241 100644 --- a/core/entries.go +++ b/core/entries.go @@ -72,10 +72,31 @@ func toLocalDay(t time.Time) time.Time { return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) } +// genDay returns a string with the current date and time +func genDay() string { + return fmt.Sprintf("Generated on %s\n", time.Now().Format("2006-01-02 at 15:04 MST")) +} + +// agplCompliance returns a string containing a footer linking to the source code +func agplCompilance() string { + return fmt.Sprintf(` + +--- + +=> https://git.nytpu.com/comitium/about/ aggregated using comitium v%s +`, + Version, + ) + +} + func (d *FullData) WriteSubs(dataPath string) error { path := filepath.Join(dataPath, "subscriptions.gmi.new") - rawPage := `# subscribed feeds + rawPage := "# subscribed feeds\n\n" + rawPage += genDay() + rawPage += ` + ## Feeds Gemini, Atom, RSS, and JSON feeds from all over. @@ -110,12 +131,7 @@ Watching these pages for any changes that occur. } d.PagesMu.RUnlock() - rawPage += ` - ---- - -=> https://git.nytpu.com/comitium/about/ aggregated using comitium -` + rawPage += agplCompilance() err := ioutil.WriteFile(path, []byte(rawPage), 0666) if err != nil { @@ -135,7 +151,7 @@ func (d *FullData) WriteFeed(dataPath string) error { pe := d.getPageEntries() rawPage += fmt.Sprintf("\n=> subscriptions.gmi Currently aggregating %d capsules, gopherholes, and websites.\n\n", len(d.Feeds)+len(d.Pages)) d.RUnlock() - rawPage += fmt.Sprintf("Generated on %s\n", time.Now().Format("2006-01-02 at 15:04 MST")) + rawPage += genDay() if len(pe.Entries) > 0 { curDay := toLocalDay(pe.Entries[0].Published) @@ -156,15 +172,7 @@ func (d *FullData) WriteFeed(dataPath string) error { } } - rawPage += fmt.Sprintf(` - ---- - -=> https://git.nytpu.com/comitium/about/ aggregated using comitium v%s -`, - Version, - ) - + rawPage += agplCompilance() err := ioutil.WriteFile(path, []byte(rawPage), 0666) if err != nil { return err