diff options
| author | nytpu <alex@nytpu.com> | 2021-03-18 15:01:25 -0600 |
|---|---|---|
| committer | nytpu <alex@nytpu.com> | 2021-03-18 15:01:25 -0600 |
| commit | 77982cb60eaee33593446be6985c2aaa771ce0a9 (patch) | |
| tree | 8a8dfc35169efb96cf43378c0fca6d127de1ab2d | |
| parent | d0a71b360d034fb0005f5552b3875a55061161f4 (diff) | |
add Export function to core.FullData
| -rw-r--r-- | core/core.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/core.go b/core/core.go index 513c84c..6b68f3f 100644 --- a/core/core.go +++ b/core/core.go @@ -15,6 +15,7 @@ package core import ( "encoding/json" "fmt" + "io" "io/ioutil" "os" "path/filepath" @@ -81,3 +82,23 @@ func (d *FullData) WriteJSON(dataPath string) error { err = os.Rename(path, filepath.Join(dataPath, "comitium.json")) return err } + +func (d *FullData) Export(w io.Writer) { + fmt.Fprint(w, "# comitium subscribed feeds\n## Feeds\n\n") + d.FeedsMu.RLock() + for _, v := range d.Feeds { + fmt.Fprintf(w, "=> %v %v\n", v.FeedLink, v.Title) + } + d.FeedsMu.RUnlock() + + fmt.Fprint(w, "\n\n## Pages\n\n") + d.PagesMu.RLock() + for _, v := range d.Pages { + fmt.Fprintf(w, "=> %v", v.Link) + if v.Title != "" { + fmt.Fprintf(w, " %v", v.Title) + } + fmt.Fprint(w, "\n") + } + d.PagesMu.RUnlock() +} |
