aboutsummaryrefslogtreecommitdiffstats
path: root/archive/archive.go
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-02-09 19:40:44 -0800
committerAdam Mathes <adam@trenchant.org>2017-02-09 19:40:44 -0800
commitded6e3b25bca083cabe21bda6f4d01f6766587bc (patch)
tree2855fa24e8b2f939bdf091f5faca411e7884ac83 /archive/archive.go
downloadsnkt-ded6e3b25bca083cabe21bda6f4d01f6766587bc.tar.gz
snkt-ded6e3b25bca083cabe21bda6f4d01f6766587bc.tar.bz2
snkt-ded6e3b25bca083cabe21bda6f4d01f6766587bc.zip
initial commit (fmstatic -> snkt)
Diffstat (limited to 'archive/archive.go')
-rw-r--r--archive/archive.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/archive/archive.go b/archive/archive.go
new file mode 100644
index 0000000..ce1b45e
--- /dev/null
+++ b/archive/archive.go
@@ -0,0 +1,51 @@
+package archive
+
+import (
+ "snkt/config"
+ "snkt/post"
+ "snkt/render"
+ "path"
+)
+
+var archiveTmplName = "archive"
+var archiveName = "archive.html"
+
+/*
+ListArchive
+*/
+type ListArchive struct {
+ Posts post.Posts
+ Tgt string
+ Template string
+
+ Site interface{}
+}
+
+func NewListArchive(posts post.Posts) *ListArchive {
+ la := ListArchive{ Posts: posts }
+ return &la
+}
+
+func (a ListArchive) Target() string {
+ if a.Tgt == "" {
+ a.Tgt = path.Join(config.Config.HtmlDir, archiveName)
+ }
+ return a.Tgt
+}
+
+func (a ListArchive) Render() []byte {
+ if a.Template == "" {
+ a.Template = archiveTmplName
+ }
+ return render.Render(a.Template, a)
+}
+
+
+/*
+NewRssArchive takes posts and returns an archive ready for RSS output
+*/
+func NewRssArchive(posts post.Posts) *ListArchive {
+ ra := ListArchive{ Posts: posts, Template: "rss" }
+ ra.Tgt = path.Join(config.Config.HtmlDir, "rss.xml")
+ return &ra
+}