func ShowIndexRss(writer http.ResponseWriter) error { // Read lock global blog methods.Blog.RLock() defer methods.Blog.RUnlock() // 15 posts in rss for now posts, err := database.RetrievePostsForIndex(15, 0) if err != nil { return err } blogData := &structure.RequestData{Posts: posts, Blog: methods.Blog} feed := createFeed(blogData) err = feed.WriteRss(writer) return err }
func ShowIndexTemplate(w http.ResponseWriter, r *http.Request, page int) error { // Read lock templates and global blog compiledTemplates.RLock() defer compiledTemplates.RUnlock() methods.Blog.RLock() defer methods.Blog.RUnlock() postIndex := int64(page - 1) if postIndex < 0 { postIndex = 0 } posts, err := database.RetrievePostsForIndex(methods.Blog.PostsPerPage, (methods.Blog.PostsPerPage * postIndex)) if err != nil { return err } requestData := structure.RequestData{Posts: posts, Blog: methods.Blog, CurrentIndexPage: page, CurrentTemplate: 0, CurrentPath: r.URL.Path} // CurrentTemplate = index _, err = w.Write(executeHelper(compiledTemplates.m["index"], &requestData, 0)) // context = index if requestData.PluginVMs != nil { // Put the lua state map back into the pool plugins.LuaPool.Put(requestData.PluginVMs) } return err }