diff --git a/blog/blog.go b/blog/blog.go
index 817e97a..4e53c16 100644
--- a/blog/blog.go
+++ b/blog/blog.go
@@ -21,8 +21,8 @@ const postsPerPage int = 5
var blogname string
var folder string
var style string
-var templateString string
var t *template.Template
+var rssTemplate *template.Template
var categories map[string][]Post
func linkToPost(filename string) string {
@@ -208,6 +208,13 @@ func makeTimeline(posts []Post) {
goutil.WriteFile(filepath.Join("stage2", folder, "timeline.html"), buf.String())
}
+func makeRSS(posts []Post) {
+ sort.Sort(byDateDesc(posts))
+ buf := new(bytes.Buffer)
+ rssTemplate.Execute(buf, posts)
+ goutil.WriteFile(filepath.Join("stage2", folder, "feed.rss"), buf.String())
+}
+
type byDate []Post
func (p byDate) Len() int { return len(p) }
@@ -246,6 +253,7 @@ func makeBlog() {
os.Link(indexFilename(n), filepath.Join("stage2", folder, "index.html"))
makeCategories()
makeTimeline(posts)
+ makeRSS(posts)
}
func Generate(dir string) {
@@ -259,8 +267,10 @@ func Generate(dir string) {
var err error
var err2 error
style, err = goutil.ReadFile("style.css")
- templateString, err2 = goutil.ReadFile("template")
+ templateString, err2 := goutil.ReadFile("template")
t = template.Must(template.New("page").Parse(templateString))
+ rssTemplateString, _ := goutil.ReadFile("rssTemplate")
+ rssTemplate = template.Must(template.New("rss").Parse(rssTemplateString))
if err == nil && err2 == nil {
makeBlog()
} else {
diff --git a/initer/initer.go b/initer/initer.go
index 7bf642d..fda8b2d 100644
--- a/initer/initer.go
+++ b/initer/initer.go
@@ -41,6 +41,10 @@ func dumpInitFiles(style Style) error {
if err != nil {
return err
}
+ err = goutil.WriteFile("rssTemplate", rssTemplate)
+ if err != nil {
+ return err
+ }
err = goutil.WriteFile("style.css", css)
if err != nil {
return err
diff --git a/initer/templates.go b/initer/templates.go
index 91c2888..1cc3686 100644
--- a/initer/templates.go
+++ b/initer/templates.go
@@ -1,5 +1,27 @@
package initer
+var rssTemplate string = `
+