Documentation ¶
Overview ¶
Package okinotes contains all the model and business layers for the okinotes application.
Index ¶
- Variables
- func RegisterAPIOnRouter(m *mux.Router, f AppFactory) error
- func RegisterPagesOnRouter(m *mux.Router, f AppFactory) error
- type App
- func (app App) CreateItem(userName, pageName string, i Item) (Item, error)
- func (app App) CreatePage(page Page) error
- func (app App) CreateUser(ident Ident, userName string) error
- func (app App) CurrentIdentity() (Identity, error)
- func (app App) CurrentUser() (User, error)
- func (app App) CurrentUserIsAdmin() bool
- func (app App) CurrentUserName() string
- func (app App) DeleteImage(imgID string) error
- func (app App) DeleteItem(userName, pageName string, itemID string) error
- func (app App) DeletePage(userName, pageName string) error
- func (app App) GetAllTemplates() ([]Template, error)
- func (app App) GetPage(userName string, pageName string) (Page, error)
- func (app App) GetTemplate(templateID string) (Template, error)
- func (app App) ImageURL(img UploadInfo, secure bool, size int) (string, error)
- func (app App) Images(limit int) ([]UploadInfo, error)
- func (app App) ListOwnedPages(limit int) ([]Page, bool, error)
- func (app App) ListPublicPages(limit int) ([]Page, bool, error)
- func (app App) LoginURL(destURL string) (string, error)
- func (app App) LogoutURL(destURL string) (string, error)
- func (app App) PutItem(userName, pageName string, i Item) (Item, error)
- func (app App) RenameImage(imgID string, newName string) error
- func (app App) SetItemTag(userName, pageName string, itemID string, tagKey string, tagValue string) error
- func (app App) StoreImage(r *http.Request, name string) error
- func (app App) StoreTemplate(tpl Template) error
- func (app App) UpdateItem(userName, pageName string, i Item, updateTags bool) (Item, error)
- func (app App) UpdatePage(page Page, pageTags TagDescriptionList) error
- func (app App) UpdateTemplate(userName string, pageName string, newTemplateID string) error
- func (app App) UploadURL(destURL string) (string, error)
- func (app App) Version() string
- type AppFactory
- type DataError
- type Ident
- type Identity
- type Item
- type LogInteractor
- type Membership
- type NotAuthorizedError
- type NotInDatastoreError
- type Page
- type PageQuery
- type Policy
- type Repository
- type Tag
- type TagDescription
- type TagDescriptionList
- type TagList
- type Template
- type UploadInfo
- type UploadInteractor
- type Usage
- type User
- type UserInteractor
- type UserKind
Constants ¶
This section is empty.
Variables ¶
var ( //ErrFirstUserConnection is the errors returned when connecting //for the first time with an identity. ErrFirstUserConnection = errors.New("User not created") )
Functions ¶
func RegisterAPIOnRouter ¶
func RegisterAPIOnRouter(m *mux.Router, f AppFactory) error
RegisterAPIOnRouter initializes the router for the API of the webapp
func RegisterPagesOnRouter ¶
func RegisterPagesOnRouter(m *mux.Router, f AppFactory) error
RegisterPagesOnRouter initializes the router for the pages of the webapp
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the main application.
func NewApp ¶
func NewApp(r Repository, u UserInteractor, l LogInteractor, up UploadInteractor) App
NewApp creates a new App using the given services
func (App) CreateItem ¶
CreateItem stores an item Returns the stored item.
func (App) CreatePage ¶
CreatePage create a new page for the given user Returns the id of the stored page.
func (App) CreateUser ¶
CreateUser creates a user
func (App) CurrentIdentity ¶
CurrentIdentity returns the Identity used to logged in.
func (App) CurrentUser ¶
CurrentUser returns the current user
func (App) CurrentUserIsAdmin ¶
CurrentUserIsAdmin returns true if the current user is an administrator
func (App) CurrentUserName ¶
CurrentUserName returns the name of the current user. Returns an empty string if not logged in.
func (App) DeleteImage ¶
DeleteImage delete an uploaded image
func (App) DeleteItem ¶
DeleteItem removes permanently an item
func (App) DeletePage ¶
DeletePage removes permanently a page and all the associated content (items and permissions)
func (App) GetAllTemplates ¶
GetAllTemplates retrieve all templates from the datastore
func (App) GetTemplate ¶
GetTemplate retrieve a template from the datastore
func (App) Images ¶
func (app App) Images(limit int) ([]UploadInfo, error)
Images retrieves the images associated with the current user
func (App) ListOwnedPages ¶
ListOwnedPages returns the list of pages owned by a given user
func (App) ListPublicPages ¶
ListPublicPages returns the list of public pages for a given user
func (App) PutItem ¶
PutItem stores a fully defined item. Replace the item if it already exists Returns the stored item.
func (App) RenameImage ¶
RenameImage changes the name of an uploaded image
func (App) SetItemTag ¶
func (app App) SetItemTag(userName, pageName string, itemID string, tagKey string, tagValue string) error
SetItemTag stores a new value for an item tag
func (App) StoreImage ¶
StoreImage stores an uplaoded image in the datastore and associate it with the current user
func (App) StoreTemplate ¶
StoreTemplate insert or update a template in database
func (App) UpdateItem ¶
UpdateItem stores an updated item
func (App) UpdatePage ¶
func (app App) UpdatePage(page Page, pageTags TagDescriptionList) error
UpdatePage updates a given page. The description of tags in the current template must be provided.
func (App) UpdateTemplate ¶
UpdateTemplate changes the template of page.
type AppFactory ¶
AppFactory represents the objects able to create an App
type Identity ¶
Identity is the authentication of a user (the link between an external Ident and a User)
type Item ¶
type Item struct { ID string `json:"id"` CreationDate time.Time `json:"creationDate"` LastModificationDate time.Time `json:"lastModificationDate"` Kind string `json:"kind"` Title string `json:"title"` Content string `datastore:",noindex" json:"content"` HTMLContent template.HTML `datastore:",noindex" json:"htmlContent"` Source string `json:"source"` URL string `json:"url"` Tags TagList `json:"tags"` }
Item is an element of a page. It belongs to his parent page.
type LogInteractor ¶
type LogInteractor interface { // Debugf formats its arguments according to the format, analogous to fmt.Printf, // and records the text as a log message at Debug level. Debugf(format string, args ...interface{}) // Infof is like Debugf, but at Info level. Infof(format string, args ...interface{}) // Warningf is like Debugf, but at Warning level. Warningf(format string, args ...interface{}) // Errorf is like Debugf, but at Error level. Errorf(format string, args ...interface{}) // Criticalf is like Debugf, but at Critical level. Criticalf(format string, args ...interface{}) }
LogInteractor allows logging of application messages
type Membership ¶
Membership indicates the membership of a user into an organisation.
type NotAuthorizedError ¶
type NotAuthorizedError struct {
Operation string
}
NotAuthorizedError represents an authorisation error on operation
func (NotAuthorizedError) Error ¶
func (err NotAuthorizedError) Error() string
type NotInDatastoreError ¶
NotInDatastoreError represents an error on data not in datastore
func (NotInDatastoreError) Error ¶
func (err NotInDatastoreError) Error() string
type Page ¶
type Page struct { UserName string `json:"userName"` Name string `json:"name"` CreationDate time.Time `json:"creationDate"` LastModificationDate time.Time `json:"lastModificationDate"` Title string `json:"title"` ContentLicense string `json:"contentLicense"` Policy Policy `json:"policy"` TemplateID string `json:"templateID"` Tags TagList `json:"tags"` }
Page represents a collection of items. It belongs to a user
type PageQuery ¶
type PageQuery interface { User(userName string) PageQuery Filter(filterStr string, value interface{}) PageQuery Order(fieldName string) PageQuery Limit(limit int) PageQuery GetAll() ([]Page, bool, error) }
PageQuery allows querying multiple pages using conditions and ordering
type Repository ¶
type Repository interface { RunInTransaction(func(repo Repository) error) error GetPage(userName string, pageName string) (Page, error) NewPageQuery() PageQuery StorePage(page Page) error DeletePage(userName string, pageName string) error GetItemsFromPage(userName string, pageName string, limit int) ([]Item, error) DeleteItemsFromPage(userName string, pageName string) error FindItem(userName string, pageName string, itemID string) (bool, error) GetItem(userName string, pageName string, itemID string) (Item, error) StoreItem(userName string, pageName string, i Item) error DeleteItem(userName string, pageName string, itemID string) error FindUser(userName string) (bool, error) GetUser(ident Ident) (User, error) GetIdentity(ident Ident) (Identity, error) StoreUser(user User) error StoreIdentity(identity Identity) error GetImages(userName string, limit int) ([]UploadInfo, error) StoreImage(img UploadInfo, userName string) error RenameImage(name string, imgID string, userName string) error DeleteImage(imgID string, userName string) error IsUsed(imgID string) (bool, error) StoreUsage(userName string, pageName string, imgID string) error DeleteUsages(userName string, pageName string) error GetTemplate(templateID string) (Template, error) GetAllTemplates() ([]Template, error) StoreTemplate(tpl Template, generateID func() string) (string, error) DeleteTemplate(templateID string) error }
Repository is the interface allowing usage of any data store for Pages, Items and all other data
type TagDescription ¶
type TagDescription struct { Key string Name string Kind string Description string DefaultValue string }
TagDescription represents metadata on a Tag
type TagDescriptionList ¶
type TagDescriptionList []TagDescription
TagDescriptionList represenets a list of TagDescription
type TagList ¶
type TagList []Tag
TagList represent all the extension information
func (*TagList) DefaultTo ¶
func (l *TagList) DefaultTo(defaultValues TagDescriptionList)
DefaultTo add or replace the values of the current tag list with the one from the new list TagList remains sorted after this operation.
type Template ¶
type Template struct { ID string CreationDate time.Time LastModificationDate time.Time Name string File string PageTags TagDescriptionList ItemTags TagDescriptionList }
Template represents a page schema with optional parameters
type UploadInfo ¶
type UploadInfo struct { Key string ContentType string CreationTime time.Time Filename string Size int64 }
UploadInfo contains all the information of uploaded content
type UploadInteractor ¶
type UploadInteractor interface { UploadURL(destURL string, maxUploadBytes int64) (string, error) UploadInfo(req *http.Request, name string) (UploadInfo, error) ImageURL(key string, secure bool, size int) (string, error) Delete(key string) error }
UploadInteractor allows uploading and serving images
type Usage ¶
type Usage struct {
UploadInfoKey string
}
Usage represents the characteristics of the usage of a ressource in a page.