blob: 60fb89d801289dcd65b741669a9c2734d024a094 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package archive
import (
"adammathes.com/snkt/config"
"adammathes.com/snkt/post"
"adammathes.com/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
}
func NewGenericListArchive(posts post.Posts, templateName string, target string) *ListArchive {
la := ListArchive{Posts: posts, Template: templateName}
la.Tgt = path.Join(config.Config.HtmlDir, target)
return &la
}
|