Documentation
¶
Overview ¶
Package fedwiki provides tooling for Federated Wiki
See https://github.com/fedwiki for more information
Code here based on mgo/bson
Index ¶
- Variables
- func ErrorResponse(ecode int, format string, args ...interface{}) (code int, template string, data interface{})
- func NewID() string
- func ValidateSlug(slug Slug) error
- type Action
- type Date
- type Handler
- type HandlerFunc
- type Item
- type Journal
- type Meta
- type Page
- type PageHeader
- type PageStore
- type Server
- type Slug
- type Story
- func (s *Story) Append(item Item)
- func (s Story) IndexOf(id string) (index int, ok bool)
- func (s *Story) InsertAfter(id string, item Item) error
- func (ps *Story) Move(id string, afterId string) error
- func (s *Story) Prepend(item Item)
- func (s *Story) RemoveByID(id string) (item Item, err error)
- func (s Story) SetByID(id string, item Item) error
- type Template
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ErrorResponse ¶
func ErrorResponse(ecode int, format string, args ...interface{}) (code int, template string, data interface{})
ErrorResponse creates a response based on http Error code
func ValidateSlug ¶
ValidateSlug verifies whether a `slug` is valid
Types ¶
type Action ¶
type Action map[string]interface{}
Action represents a operation that can be applied to a fedwiki.Page
type Date ¶
Date represents a federated wiki time it's represented by unix time in JSON
func (Date) MarshalJSON ¶
MarshalJSON marshals Date as unix timestamp
func (*Date) UnmarshalJSON ¶
UnmarshalJSON unmarshals Date from an unix timestamp
type HandlerFunc ¶
HandlerFunc type adapts a function to be used as a regular handler
type Meta ¶
type Meta map[string]interface{}
Meta is used for additional page properties not in fedwiki spec
type Page ¶
type Page struct {
PageHeader `bson:",inline"`
Story Story `json:"story,omitempty"`
Journal Journal `json:"journal,omitempty"`
}
Page represents a federated wiki page
func (*Page) LastModified ¶
LastModified returns the date when the page was last modified if there is no such date it will return a zero time
type PageHeader ¶
type PageHeader struct {
Slug Slug `json:"slug" bson:"_id"`
Title string `json:"title"`
Date Date `json:"date"`
Synopsis string `json:"synopsis,omitempty"`
// may contain extra information specific to client/server
Meta Meta `json:"meta,omitempty"`
}
PageHeader represents minimal useful information about the page
type PageStore ¶
type PageStore interface {
// Exists checks whether a page with `slug` exists
Exists(slug Slug) bool
// Create adds a new `page` with `slug`
Create(slug Slug, page *Page) error
// Load loads the page with identified by `slug`
Load(slug Slug) (*Page, error)
// Save saves the new page to `slug`
Save(slug Slug, page *Page) error
// List lists all the page headers
List() ([]*PageHeader, error)
}
type Slug ¶
type Slug string
Slug is a string where Slugify(string(slug)) == slug
func Slugify ¶
Slugify converts text to a slug
- numbers and '/' are left intact
- letters will be lowercased (if possible)
- '-', ',', '.', ' ', '_' will be converted to '-'
- other symbols or punctuations will be converted to html entity reference name (if there exists such reference name)
- everything else will be converted to '-'
Example:
"&Hello_世界/+!" ==> "amp-hello-世界/plus-excl" "Hello World / Test" ==> "hello-world/test"
type Story ¶
type Story []Item
Story is the viewable content of the page
func (Story) IndexOf ¶
IndexOf returns the index of an item with `id` ok = false, if that item doesn't exist
func (*Story) InsertAfter ¶
InsertAfter adds the `item` after the item with `id`
func (*Story) RemoveByID ¶
Removes item with `id`
type Template ¶
type Template interface {
// RenderHTML renders data as HTML with the appropriate template
// template = "" means that it should be rendered as a regular page
RenderHTML(w io.Writer, template string, data interface{}) error
}
Template is the interface that is used to render pages as HTML
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
example-time
command
This is an example service for fedwiki
|
This is an example service for fedwiki |
|
fedwiki
command
|
|
|
internal
|
|
|
runetable
command
|
|
|
This package implements common federated wiki types
|
This package implements common federated wiki types |
|
pagestore contains default handler for a fedwiki.PageStore
|
pagestore contains default handler for a fedwiki.PageStore |
|
folderstore
This package implements PageStore for a folder
|
This package implements PageStore for a folder |
|
globstore
This package implements PageStore over a glob
|
This package implements PageStore over a glob |
|
mongostore
This package implements PageStore for MongoDB
|
This package implements PageStore for MongoDB |
|
multistore
This package implements dispatching PageStore
|
This package implements dispatching PageStore |
|
This package implements federated wiki Plugin handling
|
This package implements federated wiki Plugin handling |
|
This package implements sitemap and slugs Handler for a PageStore
|
This package implements sitemap and slugs Handler for a PageStore |
|
This package implements simple HTML rendering for federated wiki
|
This package implements simple HTML rendering for federated wiki |