Exemplo n.º 1
0
func GetPost(key string) (*storage.Result, error) { /*{{{*/
	result, err := storage.Get(postKey(key))
	if err != nil {
		return nil, err
	}
	return result, nil
} /*}}}*/
Exemplo n.º 2
0
func GetStaticReader(key, path string) (io.Reader, error) { /*{{{*/
	results, err := storage.Get(postKey(key))
	if err != nil {
		return nil, err
	}
	return results.Content[0].Static(path), nil
} /*}}}*/
Exemplo n.º 3
0
//GetFullList get entire posts list
func GetFullList() (*storage.Result, error) { /*{{{*/
	results, err := storage.Get()
	if err != nil {
		return nil, err
	}
	//sorted by date
	sort.Sort(results)
	return results, nil
} /*}}}*/
Exemplo n.º 4
0
//GetRSS get rss object in atom format
func GetRSS() (interface{}, error) {
	r, err := storage.Get()
	if err != nil {
		return nil, err
	}
	if len(r.Content) == 0 {
		return nil, waitErr
	}

	//sorted by time
	sort.Sort(r)

	//Init a common infos
	feed := &atom.Feed{
		Title: "Tw's blog",
		Link:  []atom.Link{atom.Link{Href: "/rss"}},
		ID:    "/rss",
		Author: &atom.Person{
			Name:  "Tw",
			Email: "*****@*****.**",
		},
		//use the newest post time
		Updated: atom.Time(r.Content[0].Date()),
	}

	//fill the entries
	feed.Entry = make([]*atom.Entry, len(r.Content))
	for i := range feed.Entry {
		p := r.Content[i]
		feed.Entry[i] = &atom.Entry{
			Title:   string(p.Title()),
			ID:      p.Key(),
			Updated: atom.Time(p.Date()),
			Link:    []atom.Link{atom.Link{Href: "/posts/" + p.Key()}},
			Content: &atom.Text{Body: string(p.Content()), Type: "html"},
		}
	}
	return feed, nil
}