Documentation
¶
Index ¶
- Constants
- func EnsurePostMiddleware() negroni.Handler
- func ListPage() http.Handler
- func LoadEntity(r *http.Request) (interface{}, error)
- func LoadEntityFromUrl(r *http.Request, param string) (interface{}, error)
- func NewPostForm(filter func(string) string) form.Delegate
- func NewRevisionsForm() form.Delegate
- func Pages(store keyvalue.Store, filter func(string) string) []server.Route
- func PostEditAccessMiddleware() negroni.Handler
- func RevisionDiffPage() http.Handler
- type Post
- type PostRecord
- type PostRevision
Constants ¶
const ( // PermissionCreatePost is the permission for creating posts. PermissionCreatePost = "create-post" // PermissionEditOwnPost is the permission for editing own posts. PermissionEditOwnPost = "edit-own-post" // PermissionEditAnyPost is the permission for editing any posts. PermissionEditAnyPost = "edit-any-post" // PageSize is the default page size for post listing pages. PageSize = 15 )
Variables ¶
This section is empty.
Functions ¶
func EnsurePostMiddleware ¶
EnsurePostMiddleware loads the post record object from the URL.
func LoadEntity ¶
LoadEntity loads an entity from the URL with the default parameter name 'id'.
func LoadEntityFromUrl ¶
LoadEntityFromUrl loads a post from the URL.
The 'param' tells the name of the parameter where the post's uuid is.
func NewPostForm ¶
NewPostForm creates the delegate for the post form.
This form handles the creating and editing of a post.
func NewRevisionsForm ¶
NewRevisionsForm creates the delegate for the post revision form page.
func PostEditAccessMiddleware ¶
PostEditAccessMiddleware is a middleware that makes sure that the current account has edit access on the post in the URL.
func RevisionDiffPage ¶
RevisionDiffPage is a http handler that shows a diff page between two revisions of a post.
Types ¶
type Post ¶
type Post struct { ID uuid.UUID `json:"id"` Title string `json:"title"` Revision uuid.UUID `json:"revision"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
Post represents the post entity.
type PostRecord ¶
type PostRecord struct { Post *Post Revision *PostRevision }
PostRecord represents a post and its current revision.
func GetPostRecord ¶
func GetPostRecord(r *http.Request) *PostRecord
GetPostRecord returns the loaded PostRecord from the request context.
type PostRevision ¶
type PostRevision struct { ID uuid.UUID `json:"id"` Post uuid.UUID `json:"post"` Content string `json:"content"` Filtered template.HTML `json:"filtered"` Author uuid.UUID `json:"author"` Created time.Time `json:"created"` }
PostRevision represents a post's revision.
func ListRevisions ¶
ListRevisions lists revisions for a given post.
func (*PostRevision) Save ¶
func (r *PostRevision) Save(conn database.DB) error
Save inserts a new revision.
func (PostRevision) SchemaSQL ¶
func (r PostRevision) SchemaSQL() string
SchemaSQL returns the schema of the PostRevision.