Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

blog source pure

Variables 1

var ErrPostTitleMissing, ErrPostSlugMissing, ErrPostBodyMissing, ErrPostSlugExists, ErrPostPubDateExists, ErrPostTitleExists, ErrNoSuchPost

1var (
2	ErrPostTitleMissing  = errors.New("post title is missing")
3	ErrPostSlugMissing   = errors.New("post slug is missing")
4	ErrPostBodyMissing   = errors.New("post body is missing")
5	ErrPostSlugExists    = errors.New("post with specified slug already exists")
6	ErrPostPubDateExists = errors.New("post with specified publication date exists")
7	ErrPostTitleExists   = errors.New("post with specified title already exists")
8	ErrNoSuchPost        = errors.New("no such post")
9)
source

Types 3

type Blog

struct
1type Blog struct {
2	Title             string
3	Prefix            string   // i.e. r/gnoland/blog:
4	Posts             avl.Tree // slug -> *Post
5	PostsPublished    avl.Tree // published-date -> *Post
6	PostsAlphabetical avl.Tree // title -> *Post
7	NoBreadcrumb      bool
8}
source

Methods on Blog

func GetPost

method on Blog
1func (b *Blog) GetPost(slug string) *Post
source

func NewPost

method on Blog
1func (b *Blog) NewPost(publisher address, slug, title, body, pubDate string, authors, tags []string) error
source

func Render

method on Blog
1func (b Blog) Render(path string) string
source

func RenderHome

method on Blog
1func (b Blog) RenderHome(res *mux.ResponseWriter, _ *mux.Request)
source

func RenderPost

method on Blog
1func (b Blog) RenderPost(res *mux.ResponseWriter, req *mux.Request)
source

func RenderTag

method on Blog
1func (b Blog) RenderTag(res *mux.ResponseWriter, req *mux.Request)
source

type Comment

struct
1type Comment struct {
2	Post      *Post
3	CreatedAt time.Time
4	Author    address
5	Comment   string
6}
source

Methods on Comment

type Post

struct
 1type Post struct {
 2	Blog         *Blog
 3	Slug         string // FIXME: save space?
 4	Title        string
 5	Body         string
 6	CreatedAt    time.Time
 7	UpdatedAt    time.Time
 8	Comments     avl.Tree
 9	Authors      []string
10	Publisher    address
11	Tags         []string
12	CommentIndex int
13}
source

Methods on Post

func AddComment

method on Post
1func (p *Post) AddComment(author address, comment string) error
source

func HasTag

method on Post
1func (p *Post) HasTag(tag string) bool
source

func RenderAuthorList

method on Post
1func (p *Post) RenderAuthorList() string
source

Render authors if there are any

func RenderTagList

method on Post
1func (p *Post) RenderTagList() string
source

Render post tags

func Summary

method on Post
1func (p *Post) Summary() string
source

func URL

method on Post
1func (p *Post) URL() string
source

func Update

method on Post
1func (p *Post) Update(title, body, publicationDate string, authors, tags []string) error
source

Imports 7

Source Files 5