Documentation ¶
Index ¶
- Constants
- func EscapeHTML(in string) string
- func MarkdownToHTML(md []byte) []byte
- func NewlineToBr(in string) string
- type Action
- type AdminCriteria
- type Article
- type ArticleDatasourceService
- type ArticleService
- func (as ArticleService) Count(u *User, c *Category, pc PublishedCriteria) (int, error)
- func (as ArticleService) Create(a *Article) (int, error)
- func (as ArticleService) Delete(id int, u *User) error
- func (as ArticleService) GetByID(id int, u *User, pc PublishedCriteria) (*Article, error)
- func (as ArticleService) GetBySlug(s string, u *User, pc PublishedCriteria) (*Article, error)
- func (as ArticleService) Index(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]IndexArticle, error)
- func (as ArticleService) List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error)
- func (as ArticleService) Publish(id int, u *User) error
- func (as ArticleService) RSSFeed(p *Pagination, pc PublishedCriteria) (RSS, error)
- func (as ArticleService) Update(a *Article, u *User, updateSlug bool) error
- type Category
- type CategoryDatasourceService
- type CategoryService
- func (cs CategoryService) Count(fc FilterCriteria) (int, error)
- func (cs CategoryService) Create(c *Category) (int, error)
- func (cs CategoryService) Delete(id int) error
- func (cs CategoryService) GetByID(id int, fc FilterCriteria) (*Category, error)
- func (cs CategoryService) GetBySlug(s string, fc FilterCriteria) (*Category, error)
- func (cs CategoryService) List(fc FilterCriteria) ([]Category, error)
- func (cs CategoryService) Update(c *Category) error
- type Direction
- type File
- type FileDatasourceService
- type FileInfo
- type FileService
- func (fs FileService) Count(u *User) (int, error)
- func (fs FileService) Delete(fileID int, u *User) error
- func (fs FileService) GetByID(fileID int, u *User) (*File, error)
- func (fs FileService) GetByUniqueName(uniqueName string, u *User) (*File, error)
- func (fs FileService) List(u *User, p *Pagination) ([]File, error)
- func (fs FileService) ToggleInline(fileID int, u *User) error
- func (fs FileService) Upload(f *File) (int, error)
- type FilterCriteria
- type IndexArticle
- type JSONData
- type Mailer
- type NullTime
- type Pagination
- type PublishedCriteria
- type RSS
- type RSSChannel
- type RSSItem
- type RSSTime
- type SQLiteArticleDatasource
- func (rdb SQLiteArticleDatasource) Count(u *User, c *Category, pc PublishedCriteria) (int, error)
- func (rdb SQLiteArticleDatasource) Create(a *Article) (int, error)
- func (rdb SQLiteArticleDatasource) Delete(articleID int) error
- func (rdb SQLiteArticleDatasource) Get(articleID int, u *User, pc PublishedCriteria) (*Article, error)
- func (rdb SQLiteArticleDatasource) GetBySlug(slug string, u *User, pc PublishedCriteria) (*Article, error)
- func (rdb SQLiteArticleDatasource) List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error)
- func (rdb SQLiteArticleDatasource) Publish(a *Article) error
- func (rdb SQLiteArticleDatasource) Update(a *Article) error
- type SQLiteCategoryDatasource
- func (rdb SQLiteCategoryDatasource) Count(fc FilterCriteria) (int, error)
- func (rdb SQLiteCategoryDatasource) Create(c *Category) (int, error)
- func (rdb SQLiteCategoryDatasource) Delete(categoryID int) error
- func (rdb SQLiteCategoryDatasource) Get(categoryID int, fc FilterCriteria) (*Category, error)
- func (rdb SQLiteCategoryDatasource) GetBySlug(slug string, fc FilterCriteria) (*Category, error)
- func (rdb SQLiteCategoryDatasource) List(fc FilterCriteria) ([]Category, error)
- func (rdb SQLiteCategoryDatasource) Update(c *Category) error
- type SQLiteFileDatasource
- func (rdb SQLiteFileDatasource) Count(u *User) (int, error)
- func (rdb SQLiteFileDatasource) Create(f *File) (int, error)
- func (rdb SQLiteFileDatasource) Delete(fileID int) error
- func (rdb SQLiteFileDatasource) Get(fileID int, u *User) (*File, error)
- func (rdb SQLiteFileDatasource) GetByUniqueName(uniqueName string, u *User) (*File, error)
- func (rdb SQLiteFileDatasource) List(u *User, p *Pagination) ([]File, error)
- func (rdb SQLiteFileDatasource) Update(f *File) error
- type SQLiteSiteDatasource
- func (rdb SQLiteSiteDatasource) Count(pc PublishedCriteria) (int, error)
- func (rdb SQLiteSiteDatasource) Create(s *Site) (int, error)
- func (rdb SQLiteSiteDatasource) Delete(s *Site) error
- func (rdb SQLiteSiteDatasource) Get(siteID int, pc PublishedCriteria) (*Site, error)
- func (rdb SQLiteSiteDatasource) GetByLink(link string, pc PublishedCriteria) (*Site, error)
- func (rdb SQLiteSiteDatasource) List(pc PublishedCriteria, p *Pagination) ([]Site, error)
- func (rdb SQLiteSiteDatasource) Max() (int, error)
- func (rdb SQLiteSiteDatasource) Order(id int, d Direction) error
- func (rdb SQLiteSiteDatasource) Publish(s *Site) error
- func (rdb SQLiteSiteDatasource) Update(s *Site) error
- type SQLiteTokenDatasource
- func (rdb SQLiteTokenDatasource) Create(t *Token) (int, error)
- func (rdb SQLiteTokenDatasource) Get(hash string, tt TokenType) (*Token, error)
- func (rdb SQLiteTokenDatasource) ListByUser(userID int, tt TokenType) ([]Token, error)
- func (rdb SQLiteTokenDatasource) Remove(hash string, tt TokenType) error
- type SQLiteUserDatasource
- func (rdb SQLiteUserDatasource) Count(ac AdminCriteria) (int, error)
- func (rdb SQLiteUserDatasource) Create(u *User) (int, error)
- func (rdb SQLiteUserDatasource) Get(userID int) (*User, error)
- func (rdb SQLiteUserDatasource) GetByMail(mail string) (*User, error)
- func (rdb SQLiteUserDatasource) GetByUsername(username string) (*User, error)
- func (rdb SQLiteUserDatasource) List(p *Pagination) ([]User, error)
- func (rdb SQLiteUserDatasource) Remove(userID int) error
- func (rdb SQLiteUserDatasource) Update(u *User, changePassword bool) error
- type SQLiteUserInviteDatasource
- func (rdb SQLiteUserInviteDatasource) Count() (int, error)
- func (rdb SQLiteUserInviteDatasource) Create(ui *UserInvite) (int, error)
- func (rdb SQLiteUserInviteDatasource) Get(inviteID int) (*UserInvite, error)
- func (rdb SQLiteUserInviteDatasource) GetByHash(hash string) (*UserInvite, error)
- func (rdb SQLiteUserInviteDatasource) List() ([]UserInvite, error)
- func (rdb SQLiteUserInviteDatasource) Remove(inviteID int) error
- func (rdb SQLiteUserInviteDatasource) Update(ui *UserInvite) error
- type Site
- type SiteDatasourceService
- type SiteService
- func (ss SiteService) Count(pc PublishedCriteria) (int, error)
- func (ss SiteService) Create(s *Site) (int, error)
- func (ss SiteService) Delete(siteID int) error
- func (ss SiteService) GetByID(siteID int, pc PublishedCriteria) (*Site, error)
- func (ss SiteService) GetByLink(link string, pc PublishedCriteria) (*Site, error)
- func (ss SiteService) List(pc PublishedCriteria, p *Pagination) ([]Site, error)
- func (ss SiteService) Order(siteID int, dir Direction) error
- func (ss SiteService) Publish(siteID int) error
- func (ss SiteService) Update(s *Site) error
- type Token
- type TokenDatasourceService
- type TokenService
- type TokenType
- type User
- type UserDatasourceService
- type UserInterceptor
- type UserInvite
- type UserInviteDatasourceService
- type UserInviteService
- func (uis UserInviteService) Create(ui *UserInvite) (int, error)
- func (uis UserInviteService) Get(inviteID int) (*UserInvite, error)
- func (uis UserInviteService) GetByHash(hash string) (*UserInvite, error)
- func (uis UserInviteService) List() ([]UserInvite, error)
- func (uis UserInviteService) Remove(inviteID int) error
- func (uis UserInviteService) Update(ui *UserInvite) error
- type UserService
- func (us UserService) Authenticate(u *User, loginMethod settings.LoginMethod) (*User, error)
- func (us UserService) Count(a AdminCriteria) (int, error)
- func (us UserService) Create(u *User) (int, error)
- func (us UserService) GetByID(userID int) (*User, error)
- func (us UserService) GetByMail(mail string) (*User, error)
- func (us UserService) GetByUsername(username string) (*User, error)
- func (us UserService) List(p *Pagination) ([]User, error)
- func (us UserService) OneAdmin() (bool, error)
- func (us UserService) Remove(u *User) error
- func (us UserService) Update(u *User, changePassword bool) error
- type Validations
- type XMLData
Constants ¶
const ( CategoriesWithPublishedArticles = iota CategoriesWithoutArticles AllCategories )
const ( //Up for moving the site one up Up = iota //Down for moving the site one down Down )
const ( //OnlyAdmins conider only published OnlyAdmins = iota //NoAdmins conider no admins NoAdmins //AllUser conider all users AllUser )
const ( // OnlyPublished conider only published OnlyPublished = iota // NotPublished conider only not published NotPublished // All conider both published and not published All )
const ( VDupEmail = 1 << iota VDupUsername VPassword )
const ( //PasswordReset token generated for resetting passwords PasswordReset = iota )
Variables ¶
This section is empty.
Functions ¶
func MarkdownToHTML ¶
MarkdownToHTML sanitizes and parses markdown to HTML
Types ¶
type Action ¶
type Action struct { ID string Title string ActionURL string BackLinkURL string WarnMsg string Description string }
Action this type is used for YES/NO actions see template/admin/action.html Title is shown in the headline ActionURL defines where the form should be sent BackLinkURL defines where to go back (if clicking on cancel) WarnMsg defines an optional warning which is shown above the description Description describes what action the user has to decide
type AdminCriteria ¶
type AdminCriteria int
AdminCriteria specifies which type of users should be considered
type Article ¶
type Article struct { ID int Headline string PublishedOn NullTime Published bool Content string Slug string LastModified time.Time Author *User //duplicate category struct to support left joins with nulls //TODO: find a better solution CID sql.NullInt64 CName sql.NullString }
Article represents an article
type ArticleDatasourceService ¶
type ArticleDatasourceService interface { Create(a *Article) (int, error) List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error) Count(u *User, c *Category, pc PublishedCriteria) (int, error) Get(articleID int, u *User, pc PublishedCriteria) (*Article, error) GetBySlug(slug string, u *User, pc PublishedCriteria) (*Article, error) Publish(a *Article) error Update(a *Article) error Delete(articleID int) error }
ArticleDatasourceService defines an interface for CRUD operations of articles
type ArticleService ¶
type ArticleService struct { Datasource ArticleDatasourceService AppConfig settings.Application }
ArticleService containing the service to access articles
func (ArticleService) Count ¶
func (as ArticleService) Count(u *User, c *Category, pc PublishedCriteria) (int, error)
Count returns the number of articles. The publishedCriteria defines whether the published and/or unpublished articles should be considered
func (ArticleService) Create ¶
func (as ArticleService) Create(a *Article) (int, error)
Create creates an article
func (ArticleService) Delete ¶
func (as ArticleService) Delete(id int, u *User) error
Delete deletes an article
func (ArticleService) GetByID ¶
func (as ArticleService) GetByID(id int, u *User, pc PublishedCriteria) (*Article, error)
GetByID get a article by the id. The publishedCriteria defines whether the published and/or unpublished articles should be considered
func (ArticleService) GetBySlug ¶
func (as ArticleService) GetBySlug(s string, u *User, pc PublishedCriteria) (*Article, error)
GetBySlug gets a article by the slug. The publishedCriteria defines whether the published and/or unpublished articles should be considered
func (ArticleService) Index ¶
func (as ArticleService) Index(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]IndexArticle, error)
func (ArticleService) List ¶
func (as ArticleService) List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error)
List returns all article by the slug. The publishedCriteria defines whether the published and/or unpublished articles should be considered
func (ArticleService) Publish ¶
func (as ArticleService) Publish(id int, u *User) error
Publish publishes or 'unpublishes' an article
func (ArticleService) RSSFeed ¶
func (as ArticleService) RSSFeed(p *Pagination, pc PublishedCriteria) (RSS, error)
RSSFeed receives a specified number of articles in RSS
type Category ¶
type CategoryDatasourceService ¶
type CategoryDatasourceService interface { Create(c *Category) (int, error) List(fc FilterCriteria) ([]Category, error) Count(fc FilterCriteria) (int, error) Get(categoryID int, fc FilterCriteria) (*Category, error) GetBySlug(slug string, fc FilterCriteria) (*Category, error) Update(c *Category) error Delete(categoryID int) error }
type CategoryService ¶
type CategoryService struct {
Datasource CategoryDatasourceService
}
CategoryService containing the service to access categories
func (CategoryService) Count ¶
func (cs CategoryService) Count(fc FilterCriteria) (int, error)
func (CategoryService) Create ¶
func (cs CategoryService) Create(c *Category) (int, error)
Create creates a category
func (CategoryService) Delete ¶
func (cs CategoryService) Delete(id int) error
Delete removes a category
func (CategoryService) GetByID ¶
func (cs CategoryService) GetByID(id int, fc FilterCriteria) (*Category, error)
func (CategoryService) GetBySlug ¶
func (cs CategoryService) GetBySlug(s string, fc FilterCriteria) (*Category, error)
func (CategoryService) List ¶
func (cs CategoryService) List(fc FilterCriteria) ([]Category, error)
func (CategoryService) Update ¶
func (cs CategoryService) Update(c *Category) error
Update updates a category
type File ¶
type File struct { ID int UniqueName string `json:"unique_name"` FullFilename string `json:"full_name"` Link string `json:"link"` ContentType string `json:"content_type"` Inline bool `json:"inline"` Size int64 `json:"size"` LastModified time.Time `json:"last_modified"` Data []byte `json:"-"` FileInfo FileInfo Author *User }
File represents a file
type FileDatasourceService ¶
type FileDatasourceService interface { Create(f *File) (int, error) Get(fileID int, u *User) (*File, error) GetByUniqueName(uniqueName string, u *User) (*File, error) List(u *User, p *Pagination) ([]File, error) Count(u *User) (int, error) Update(f *File) error Delete(fileID int) error }
FileDatasourceService defines an interface for CRUD operations of files
type FileInfo ¶ added in v0.3.1
FileInfo contains Path, Name and Extension of a file. Use SplitFilename to split the information from a filename
type FileService ¶
type FileService struct { Datasource FileDatasourceService Config settings.File }
FileService containing the service to interact with files
func (FileService) Count ¶
func (fs FileService) Count(u *User) (int, error)
Count returns a number of files based on the filename; it the user is given and it is a non admin only files specific to this user are counted
func (FileService) Delete ¶
func (fs FileService) Delete(fileID int, u *User) error
Delete deletes a file based on fileID; users which are not the owner are not allowed to remove files; except admins
func (FileService) GetByID ¶
func (fs FileService) GetByID(fileID int, u *User) (*File, error)
GetByID returns the file based on the fileID; it the user is given and it is a non admin only file specific to this user is returned
func (FileService) GetByUniqueName ¶ added in v0.3.1
func (fs FileService) GetByUniqueName(uniqueName string, u *User) (*File, error)
GetByUniqueName returns the file based on the unique name; it the user is given and it is a non admin only file specific to this user is returned
func (FileService) List ¶
func (fs FileService) List(u *User, p *Pagination) ([]File, error)
List returns a list of files based on the filename; it the user is given and it is a non admin only files specific to this user are returned
func (FileService) ToggleInline ¶ added in v0.6.1
func (fs FileService) ToggleInline(fileID int, u *User) error
func (FileService) Upload ¶
func (fs FileService) Upload(f *File) (int, error)
Upload uploaded files will be saved at the configured file location, filename is saved in the database
type JSONData ¶
type JSONData struct {
Data interface{} `json:"data,-" xml:"data,-"`
}
JSONData represents arbritary JSON data
type Mailer ¶
type Mailer struct { AppConfig *settings.Application Sender mail.Sender }
func (Mailer) SendActivationLink ¶
func (m Mailer) SendActivationLink(ui *UserInvite)
func (Mailer) SendPasswordChangeConfirmation ¶
type NullTime ¶
NullTime reprensents a time which may not valid if time is null
func (*NullTime) Scan ¶
Scan implements the Scanner interface.
type Pagination ¶
Pagination type is used to provide a page selector
func (Pagination) Offset ¶
func (p Pagination) Offset() int
Offset returns the offset where to start
func (Pagination) PaginationBar ¶
func (p Pagination) PaginationBar() template.HTML
PaginationBar returns the HTML for the pagination bar which can be embedded
type PublishedCriteria ¶
type PublishedCriteria int
PublishedCriteria specifies which entries should be shown
type RSS ¶
type RSS struct { XMLName xml.Name `xml:"rss"` Version string `xml:"version,attr"` Channel RSSChannel `xml:"channel"` }
type RSSChannel ¶
type RSSItem ¶
type RSSTime ¶
type SQLiteArticleDatasource ¶
SQLiteArticleDatasource providing an implementation of ArticleDatasourceService for SQLite
func (SQLiteArticleDatasource) Count ¶
func (rdb SQLiteArticleDatasource) Count(u *User, c *Category, pc PublishedCriteria) (int, error)
Count returns the number of article found; if the user is not nil the number of articles for this explcit user is returned the PublishedCritera specifies which articles should be considered
func (SQLiteArticleDatasource) Create ¶
func (rdb SQLiteArticleDatasource) Create(a *Article) (int, error)
Create creates an article
func (SQLiteArticleDatasource) Delete ¶
func (rdb SQLiteArticleDatasource) Delete(articleID int) error
Delete deletes the article specified by the articleID
func (SQLiteArticleDatasource) Get ¶
func (rdb SQLiteArticleDatasource) Get(articleID int, u *User, pc PublishedCriteria) (*Article, error)
Get returns a article by its id; if the user is not nil the article for this explcit user is returned the PublishedCritera specifies which articles should be considered
func (SQLiteArticleDatasource) GetBySlug ¶
func (rdb SQLiteArticleDatasource) GetBySlug(slug string, u *User, pc PublishedCriteria) (*Article, error)
GetBySlug returns a article by its slug; if the user is not nil the article for this explcit user is returned the PublishedCritera specifies which articles should be considered
func (SQLiteArticleDatasource) List ¶
func (rdb SQLiteArticleDatasource) List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error)
List returns a slice of articles; if the user is not nil the number of articles for this explcit user is returned the PublishedCritera specifies which articles should be considered
func (SQLiteArticleDatasource) Publish ¶
func (rdb SQLiteArticleDatasource) Publish(a *Article) error
Publish checks if the article is published or not - switches the appropriate status
func (SQLiteArticleDatasource) Update ¶
func (rdb SQLiteArticleDatasource) Update(a *Article) error
Update updates an aricle
type SQLiteCategoryDatasource ¶
SQLiteArticleDatasource providing an implementation of ArticleDatasourceService for SQLite
func (SQLiteCategoryDatasource) Count ¶
func (rdb SQLiteCategoryDatasource) Count(fc FilterCriteria) (int, error)
func (SQLiteCategoryDatasource) Create ¶
func (rdb SQLiteCategoryDatasource) Create(c *Category) (int, error)
func (SQLiteCategoryDatasource) Delete ¶
func (rdb SQLiteCategoryDatasource) Delete(categoryID int) error
func (SQLiteCategoryDatasource) Get ¶
func (rdb SQLiteCategoryDatasource) Get(categoryID int, fc FilterCriteria) (*Category, error)
func (SQLiteCategoryDatasource) GetBySlug ¶
func (rdb SQLiteCategoryDatasource) GetBySlug(slug string, fc FilterCriteria) (*Category, error)
func (SQLiteCategoryDatasource) List ¶
func (rdb SQLiteCategoryDatasource) List(fc FilterCriteria) ([]Category, error)
func (SQLiteCategoryDatasource) Update ¶
func (rdb SQLiteCategoryDatasource) Update(c *Category) error
type SQLiteFileDatasource ¶
SQLiteFileDatasource providing an implementation of FileDatasourceService using MariaDB
func (SQLiteFileDatasource) Count ¶
func (rdb SQLiteFileDatasource) Count(u *User) (int, error)
Count returns a number of files based on the filename; it the user is given and it is a non admin only files specific to this user are counted
func (SQLiteFileDatasource) Create ¶
func (rdb SQLiteFileDatasource) Create(f *File) (int, error)
Create inserts some file meta information into the database
func (SQLiteFileDatasource) Delete ¶
func (rdb SQLiteFileDatasource) Delete(fileID int) error
Delete deletes a file based on fileID; users which are not the owner are not allowed to remove files; except admins
func (SQLiteFileDatasource) Get ¶
func (rdb SQLiteFileDatasource) Get(fileID int, u *User) (*File, error)
Get returns the file based on the filename; it the user is given and it is a non admin only file specific to this user is returned
func (SQLiteFileDatasource) GetByUniqueName ¶ added in v0.3.1
func (rdb SQLiteFileDatasource) GetByUniqueName(uniqueName string, u *User) (*File, error)
GetByFilename returns the file based on the filename; it the user is given and it is a non admin only file specific to this user is returned
func (SQLiteFileDatasource) List ¶
func (rdb SQLiteFileDatasource) List(u *User, p *Pagination) ([]File, error)
List returns a list of files based on the filename; it the user is given and it is a non admin only files specific to this user are returned
func (SQLiteFileDatasource) Update ¶ added in v0.6.1
func (rdb SQLiteFileDatasource) Update(f *File) error
type SQLiteSiteDatasource ¶
SQLiteSiteDatasource providing an implementation of SiteDatasourceService for sqlite
func (SQLiteSiteDatasource) Count ¶
func (rdb SQLiteSiteDatasource) Count(pc PublishedCriteria) (int, error)
Count returns the amount of sites
func (SQLiteSiteDatasource) Create ¶
func (rdb SQLiteSiteDatasource) Create(s *Site) (int, error)
Create creates a site
func (SQLiteSiteDatasource) Delete ¶
func (rdb SQLiteSiteDatasource) Delete(s *Site) error
Delete deletes a site and updates the order numbers
func (SQLiteSiteDatasource) Get ¶
func (rdb SQLiteSiteDatasource) Get(siteID int, pc PublishedCriteria) (*Site, error)
Get returns a site based on the site id
func (SQLiteSiteDatasource) GetByLink ¶
func (rdb SQLiteSiteDatasource) GetByLink(link string, pc PublishedCriteria) (*Site, error)
GetByLink returns a site based on the provided link
func (SQLiteSiteDatasource) List ¶
func (rdb SQLiteSiteDatasource) List(pc PublishedCriteria, p *Pagination) ([]Site, error)
List returns a array of sites
func (SQLiteSiteDatasource) Max ¶
func (rdb SQLiteSiteDatasource) Max() (int, error)
Max returns the maximum order number
func (SQLiteSiteDatasource) Order ¶
func (rdb SQLiteSiteDatasource) Order(id int, d Direction) error
Order moves a site up or down
func (SQLiteSiteDatasource) Publish ¶
func (rdb SQLiteSiteDatasource) Publish(s *Site) error
Publish publishes or unpublishes a site
func (SQLiteSiteDatasource) Update ¶
func (rdb SQLiteSiteDatasource) Update(s *Site) error
Update updates a site
type SQLiteTokenDatasource ¶
SQLiteTokenDatasource providing an implementation of TokenDatasourceService using MariaDB
func (SQLiteTokenDatasource) Create ¶
func (rdb SQLiteTokenDatasource) Create(t *Token) (int, error)
Create creates a new token
func (SQLiteTokenDatasource) Get ¶
func (rdb SQLiteTokenDatasource) Get(hash string, tt TokenType) (*Token, error)
Get gets a token based on the hash and the token type
func (SQLiteTokenDatasource) ListByUser ¶ added in v0.5.3
func (rdb SQLiteTokenDatasource) ListByUser(userID int, tt TokenType) ([]Token, error)
ListByUser receives all tokens based on the user id and the token type ordered by requested
func (SQLiteTokenDatasource) Remove ¶
func (rdb SQLiteTokenDatasource) Remove(hash string, tt TokenType) error
Remove removes a token based on the hash
type SQLiteUserDatasource ¶
SQLiteUserDatasource providing an implementation of UserDatasourceService using SQLite
func (SQLiteUserDatasource) Count ¶
func (rdb SQLiteUserDatasource) Count(ac AdminCriteria) (int, error)
Count retuns the amount of users matches the AdminCriteria
func (SQLiteUserDatasource) Create ¶
func (rdb SQLiteUserDatasource) Create(u *User) (int, error)
Create creates an new user
func (SQLiteUserDatasource) Get ¶
func (rdb SQLiteUserDatasource) Get(userID int) (*User, error)
Get gets an user by his userID
func (SQLiteUserDatasource) GetByMail ¶
func (rdb SQLiteUserDatasource) GetByMail(mail string) (*User, error)
GetByMail gets an user by his mail, includes the password and salt
func (SQLiteUserDatasource) GetByUsername ¶
func (rdb SQLiteUserDatasource) GetByUsername(username string) (*User, error)
GetByUsername gets an user by his username, includes the password and salt
func (SQLiteUserDatasource) List ¶
func (rdb SQLiteUserDatasource) List(p *Pagination) ([]User, error)
List returns a list of user
func (SQLiteUserDatasource) Remove ¶
func (rdb SQLiteUserDatasource) Remove(userID int) error
Removes an user
func (SQLiteUserDatasource) Update ¶
func (rdb SQLiteUserDatasource) Update(u *User, changePassword bool) error
Update updates an user
type SQLiteUserInviteDatasource ¶
SQLiteUserInviteDatasource
func (SQLiteUserInviteDatasource) Count ¶
func (rdb SQLiteUserInviteDatasource) Count() (int, error)
Count retuns the amount of users invitations
func (SQLiteUserInviteDatasource) Create ¶
func (rdb SQLiteUserInviteDatasource) Create(ui *UserInvite) (int, error)
Create creates an new user invitation
func (SQLiteUserInviteDatasource) Get ¶
func (rdb SQLiteUserInviteDatasource) Get(inviteID int) (*UserInvite, error)
func (SQLiteUserInviteDatasource) GetByHash ¶
func (rdb SQLiteUserInviteDatasource) GetByHash(hash string) (*UserInvite, error)
func (SQLiteUserInviteDatasource) List ¶
func (rdb SQLiteUserInviteDatasource) List() ([]UserInvite, error)
func (SQLiteUserInviteDatasource) Remove ¶
func (rdb SQLiteUserInviteDatasource) Remove(inviteID int) error
Removes an user invitation
func (SQLiteUserInviteDatasource) Update ¶
func (rdb SQLiteUserInviteDatasource) Update(ui *UserInvite) error
type Site ¶
type Site struct { ID int Title string Link string Section string Content string Published bool PublishedOn NullTime LastModified time.Time OrderNo int Author *User }
Site represents a site
type SiteDatasourceService ¶
type SiteDatasourceService interface { Create(s *Site) (int, error) List(pc PublishedCriteria, p *Pagination) ([]Site, error) Get(siteID int, pc PublishedCriteria) (*Site, error) GetByLink(link string, pc PublishedCriteria) (*Site, error) Publish(s *Site) error Update(s *Site) error Delete(s *Site) error Order(siteID int, dir Direction) error Max() (int, error) Count(pc PublishedCriteria) (int, error) }
SiteDatasourceService defines an interface for CRUD operations on sites
type SiteService ¶
type SiteService struct {
Datasource SiteDatasourceService
}
SiteService containing the service to access site
func (SiteService) Count ¶
func (ss SiteService) Count(pc PublishedCriteria) (int, error)
Count returns the number of sites
func (SiteService) Create ¶
func (ss SiteService) Create(s *Site) (int, error)
Create creates a site
func (SiteService) GetByID ¶
func (ss SiteService) GetByID(siteID int, pc PublishedCriteria) (*Site, error)
GetByID Get a site by the id.
func (SiteService) GetByLink ¶
func (ss SiteService) GetByLink(link string, pc PublishedCriteria) (*Site, error)
GetByLink Get a site by the link.
func (SiteService) List ¶
func (ss SiteService) List(pc PublishedCriteria, p *Pagination) ([]Site, error)
List returns all sites
func (SiteService) Order ¶
func (ss SiteService) Order(siteID int, dir Direction) error
Order reorder the site
func (SiteService) Publish ¶
func (ss SiteService) Publish(siteID int) error
Publish switches the publish state of the site
type Token ¶
Token represents a token
type TokenDatasourceService ¶
type TokenDatasourceService interface { Create(t *Token) (int, error) Get(hash string, tt TokenType) (*Token, error) ListByUser(userID int, tt TokenType) ([]Token, error) Remove(hash string, tt TokenType) error }
TokenDatasourceService defines an interface for CRUD operations for tokens
type TokenService ¶
type TokenService struct {
Datasource TokenDatasourceService
}
TokenService containing the service to access tokens
func (TokenService) Create ¶
func (ts TokenService) Create(t *Token) error
Create creates a new token
func (TokenService) Get ¶
Get token for a defined token type expires after a defined time Expired token will be removed
func (TokenService) RateLimit ¶ added in v0.5.3
func (ts TokenService) RateLimit(userID int, tt TokenType) error
RateLimit returns an error if a token is requested greater three times in a time span of 15 minutes
func (TokenService) Remove ¶
func (ts TokenService) Remove(hash string, tt TokenType) error
Remove removes a token
type TokenType ¶
type TokenType int
TokenType specifies the type where token can be used
func (*TokenType) Scan ¶
Scan implements the Scanner interface.
type User ¶
type User struct { ID int Username string Email string DisplayName string Password []byte PlainPassword []byte Salt []byte LastModified time.Time Active bool IsAdmin bool }
User represents a user
type UserDatasourceService ¶
type UserDatasourceService interface { Create(u *User) (int, error) List(p *Pagination) ([]User, error) Get(userID int) (*User, error) Update(u *User, changePassword bool) error Count(ac AdminCriteria) (int, error) GetByMail(mail string) (*User, error) GetByUsername(username string) (*User, error) Remove(userID int) error }
UserDatasourceService defines an interface for CRUD operations for users
type UserInterceptor ¶
type UserInterceptor interface { PreCreate(user *User) error PostCreate(user *User) error PreUpdate(oldUser *User, user *User) error PostUpdate(oldUser *User, user *User) error PreRemove(user *User) error PostRemove(user *User) error }
UserInterceptor will be executed before and after updating/creating users
type UserInvite ¶
type UserInvite struct { ID int Hash string Username string Email string DisplayName string CreatedAt time.Time IsAdmin bool CreatedBy *User }
User represents a user
func (UserInvite) Copy ¶
func (ui UserInvite) Copy() *User
type UserInviteDatasourceService ¶
type UserInviteDatasourceService interface { List() ([]UserInvite, error) Get(inviteID int) (*UserInvite, error) GetByHash(hash string) (*UserInvite, error) Create(ui *UserInvite) (int, error) Update(ui *UserInvite) error Remove(inviteID int) error }
UserInviteDatasourceService defines an interface for CRUD operations for users
type UserInviteService ¶
type UserInviteService struct { Datasource UserInviteDatasourceService UserService UserService MailService mail.Service }
UserInviteService
func (UserInviteService) Create ¶
func (uis UserInviteService) Create(ui *UserInvite) (int, error)
func (UserInviteService) Get ¶
func (uis UserInviteService) Get(inviteID int) (*UserInvite, error)
func (UserInviteService) GetByHash ¶
func (uis UserInviteService) GetByHash(hash string) (*UserInvite, error)
func (UserInviteService) List ¶
func (uis UserInviteService) List() ([]UserInvite, error)
func (UserInviteService) Remove ¶
func (uis UserInviteService) Remove(inviteID int) error
func (UserInviteService) Update ¶
func (uis UserInviteService) Update(ui *UserInvite) error
type UserService ¶
type UserService struct { Datasource UserDatasourceService Config settings.User UserInterceptor UserInterceptor }
UserService containing the service to access users
func (UserService) Authenticate ¶
func (us UserService) Authenticate(u *User, loginMethod settings.LoginMethod) (*User, error)
Authenticate authenticates the user by the given login method (email or username) if the user was found but the password is wrong the found user and an error will be returned
func (UserService) Count ¶
func (us UserService) Count(a AdminCriteria) (int, error)
Count returns the amount of users
func (UserService) Create ¶
func (us UserService) Create(u *User) (int, error)
Create creates the user If an UserInterceptor is available the action PreCreate is executed before creating and PostCreate after creating the user
func (UserService) GetByID ¶
func (us UserService) GetByID(userID int) (*User, error)
GetByID gets the user based on the given id; will not contain the user password
func (UserService) GetByMail ¶
func (us UserService) GetByMail(mail string) (*User, error)
GetByMail gets the user based on the given mail; will contain the user password
func (UserService) GetByUsername ¶
func (us UserService) GetByUsername(username string) (*User, error)
GetByUsername gets the user based on the given username; will contain the user password
func (UserService) List ¶
func (us UserService) List(p *Pagination) ([]User, error)
List returns a list of users. Limits the amount based on the defined pagination
func (UserService) OneAdmin ¶ added in v0.2.4
func (us UserService) OneAdmin() (bool, error)
OneAdmin returns true if there is only one admin
func (UserService) Remove ¶
func (us UserService) Remove(u *User) error
Remove removes the user returns an error if no administrator would remain
func (UserService) Update ¶
func (us UserService) Update(u *User, changePassword bool) error
Update updates the user If an UserInterceptor is available the action PreUpdate is executed before updating and PostUpdate after updating the user