aboutsummaryrefslogtreecommitdiff
path: root/page
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@x230.my.domain>2021-07-11 11:55:47 -0400
committerMitchell Riedstra <mitch@x230.my.domain>2021-07-11 11:55:47 -0400
commit1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d (patch)
tree023701c9d033269d83be8415809b292ae1f3cee0 /page
parente6d53f71c9718ecdb9fde16a924d75a71aadd2d2 (diff)
downloadgo-website-1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d.tar.gz
go-website-1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d.tar.xz
Initial banging away at adding an Atom feed to the site
Diffstat (limited to 'page')
-rw-r--r--page/atom.go31
-rw-r--r--page/page.go9
-rw-r--r--page/time.go5
3 files changed, 45 insertions, 0 deletions
diff --git a/page/atom.go b/page/atom.go
new file mode 100644
index 0000000..4a89117
--- /dev/null
+++ b/page/atom.go
@@ -0,0 +1,31 @@
+package page
+
+/*
+
+import (
+ "github.com/gorilla/feeds"
+ "io"
+)
+
+// Atom returns an Atom feed for all of the articles with the specified tag
+func (p *Page) Atom(wr io.Writer, tag string) error {
+ index, err := p.Index()
+ if err != nil {
+ return err
+ }
+
+ pages, ok := index[tag]
+ if !ok {
+ pages = PageList{}
+ }
+
+ feed := &feeds.Feed{
+ Title: "",
+ Link: &feeds.Link{Href: "http://jmoiron.net/blog"},
+ Description: "discussion about tech, footie, photos",
+ Author: &feeds.Author{Name: "Jason Moiron", Email: "jmoiron@jmoiron.net"},
+ Created: now,
+ }
+
+}
+*/
diff --git a/page/page.go b/page/page.go
index 82f46f2..ecd2268 100644
--- a/page/page.go
+++ b/page/page.go
@@ -25,6 +25,7 @@ package page
import (
"bufio"
"bytes"
+ "encoding/json"
"fmt"
"io"
"log"
@@ -45,6 +46,8 @@ type Page struct {
Title string
Head string
Description string
+ AuthorName string
+ AuthorEmail string
// Tags to apply to the page in question. Useful for Index()
Tags map[string]interface{}
Date *PageTime
@@ -209,3 +212,9 @@ func (p *Page) RenderBody() (string, error) {
func (p Page) String() string {
return fmt.Sprintf("Page: %s", p.path)
}
+
+// StringDetail prints a detailed string of the page
+func (p Page) StringDetail() string {
+ b, _ := json.MarshalIndent(p, "", " ")
+ return fmt.Sprintf("Page: %s\n%s\n", p.path, b)
+}
diff --git a/page/time.go b/page/time.go
index 958dc38..0374490 100644
--- a/page/time.go
+++ b/page/time.go
@@ -21,3 +21,8 @@ func (pt *PageTime) UnmarshalYAML(n *yaml.Node) error {
pt.Time = t
return nil
}
+
+func (pt PageTime) MarshalYAML() (interface{}, error) {
+ s := pt.Time.Format(TimeFormat)
+ return s, nil
+}