Documentation ¶
Index ¶
- func CreatePage(db *gorm.DB, title string, slug string, tags []Tag, template string, ...) bool
- func CreateRole(db *gorm.DB, name string) bool
- func CreateSetting(db *gorm.DB, key string, value string) bool
- func CreateUser(db *gorm.DB, email string, password string, roles []*Role, sites []*Site) bool
- func UpdatePage(db *gorm.DB, id int, title string, slug string, tags []Tag, template string, ...) bool
- func UpdateRole(db *gorm.DB, id int, name string, features []*Feature) bool
- func UpdateSetting(db *gorm.DB, id int, key string, value string) bool
- func UpdateSite(db *gorm.DB, id int, title string, domain string, siteType int, themeID int, ...) bool
- func UpdateUser(db *gorm.DB, id int, email string, password string, roles []*Role, ...) bool
- type Comment
- type Config
- type Feature
- type JSONTag
- type Page
- type PageData
- type Role
- type Session
- type Setting
- type Site
- type Tag
- type Theme
- type User
- type UserActivation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePage ¶
func CreatePage(db *gorm.DB, title string, slug string, tags []Tag, template string, content string, siteID int) bool
CreatePage is a method which creates a page using gorm
func CreateRole ¶
CreateRole is a method which creates a role using gorm
func CreateSetting ¶
CreateSetting is a method which creates a setting using gorm
func CreateUser ¶
CreateUser is a method which creates a user using gorm
func UpdatePage ¶
func UpdatePage(db *gorm.DB, id int, title string, slug string, tags []Tag, template string, content string, siteID int) bool
UpdatePage is a method which updates a page in the database with relevant data
func UpdateRole ¶
UpdateRole updates the role struct with the provided details
func UpdateSetting ¶
UpdateSetting updates a setting key value pair using gorm
Types ¶
type Comment ¶
type Comment struct { gorm.Model User User UserID int Email string Website string Text string Page Page PageID int }
Comment can be related to a post created by a user
type Config ¶
type Config struct { gorm.Model Key string `gorm:"size:255;unique_index"` Value string `sql:"type:text"` }
Config is a key value store for various settings and configurations
type Feature ¶
type Feature struct { gorm.Model Key string `gorm:"size:255"` Roles []*Role `gorm:"many2many:role_features;"` }
Feature contains a key referencing features in the application
type JSONTag ¶
type JSONTag struct {
Value string `json:"value"`
}
JSONTag is used for responses where tags are shown TODO is this redundant if we can use Tag?
type Page ¶
type Page struct { gorm.Model Title string `gorm:"size:255"` Content string `sql:"type:text"` Description string `sql:"type:text"` Excerpt string `sql:"type:text"` Slug string `gorm:"size:255;unique_index:idx_slug_site_id"` Template string `gorm:"size:255"` Site Site SiteID int `gorm:"unique_index:idx_slug_site_id"` Tags []Tag `gorm:"many2many:page_tags;"` }
Page represents the content of a page, I wanted to go with the concept of having everything be a post even if it's a page, contact form or product
func DeletePage ¶
DeletePage deletes a page with the provided id from the database
type PageData ¶
type PageData struct { Theme string Template string Templates map[string]string Themes map[string]string Title string WebsiteName string URL string Error string Warning string Message string Year string Stylesheets []string Scripts []string Favicon string Extra interface{} Components []page.Component Menus []page.Menu }
PageData is a general structure that holds all data that can be displayed on a page using go html templates
type Role ¶
type Role struct { gorm.Model Name string `gorm:"size:255"` Users []*User `gorm:"many2many:user_roles;"` Features []*Feature `gorm:"many2many:role_features;"` }
Role has one or more users and one or more features. A user belonging to a role which also has a feature will allow that user to use the feature
func FetchRoleByName ¶
FetchRoleByName retrieves a role from the database using the provided name
func (Role) HasFeature ¶
HasFeature checks if a role has the specified feature
type Session ¶
Session represents an authenticated user session, there can be multiple sessions for one user
type Setting ¶
Setting represents a key value setting for Beubo usually used for global config values
func DeleteSetting ¶
DeleteSetting removes a setting with the matching id from the database
func FetchSetting ¶
FetchSetting gets a setting from the database via the provided id
func FetchSettingByKey ¶
FetchSettingByKey gets a setting from the database via the provided key
func FetchSettings ¶
FetchSettings gets all settings from the database
type Site ¶
type Site struct { gorm.Model Title string `gorm:"size:255"` Domain string `gorm:"size:255;unique_index"` DestinationDomain string Type int Theme Theme ThemeID int Users []*User `gorm:"many2many:user_sites;"` }
Site represents one website, the idea is that Beubo handles many websites at the same time, you could then have 100s of sites all on the same platform
func CreateSite ¶
func CreateSite(db *gorm.DB, title string, domain string, siteType int, themeID int, destinationDomain string) Site
CreateSite is a method which creates a site using gorm
func DeleteSite ¶
DeleteSite removes a site from the database based on the provided id
func FetchSiteByHost ¶
FetchSiteByHost retrieves a site from the database based on the provided host string TODO what if one site can have many hosts? For now a redirect can be added for other hosts
func FetchSites ¶
FetchSites gets a site from the database using the provided id
type Tag ¶
Tag of a post can be used for post categories or things like meta tag keywords for example
type Theme ¶
type Theme struct { gorm.Model Title string `gorm:"size:255;unique_index"` Slug string `gorm:"size:255;unique_index"` }
Theme is the template or html files that a site uses, theme files are found under the web directory
func FetchTheme ¶
FetchTheme gets a theme from the database using the provided id
type User ¶
type User struct { gorm.Model Email string `gorm:"size:255"` Password string `gorm:"size:255"` Activations []UserActivation Roles []*Role `gorm:"many2many:user_roles;"` Sites []*Site `gorm:"many2many:user_sites;"` }
User is a user who can authenticate with Beubo
func FetchUserByEmail ¶
FetchUserByEmail retrieves a user from the database using the provided email
func FetchUserFromSession ¶
FetchUserFromSession takes a provided token string and fetches the user for the session matching the provided token
func (User) CanAccessSite ¶
CanAccessSite checks if a user is allowed to access the specified site