Documentation ¶
Index ¶
- Constants
- Variables
- func FormatOpenGraphLocale(locale string) string
- func Initialize(file, webHost, staticHost, apiHost, applicationTimezone string, ...)
- type AccessRight
- type Alternate
- type Async
- type Configuration
- func (conf *Configuration) AsyncURL(key, locale string) string
- func (conf *Configuration) IsPartial(key, locale string) bool
- func (conf *Configuration) Page(c *gin.Context) *Page
- func (conf *Configuration) PageByKey(c *gin.Context, key string) *Page
- func (conf *Configuration) URL(key, locale string) string
- type Error
- type FacebookConfiguration
- type GoogleConfiguration
- type HrefLang
- type Icon
- type Info
- type Meta
- type OpenGraph
- type Page
- func (page *Page) AsyncURL(key string, vars ...map[string]string) string
- func (page *Page) Copy() (copied *Page)
- func (page *Page) Div(a, b int) int
- func (page *Page) FormattedTime(s uint) string
- func (page *Page) HTMLEscape(text string) string
- func (page *Page) HTMLEscapeWithNl(text string) template.HTML
- func (page *Page) HTMLSafe(text string) template.HTML
- func (page *Page) IncludeMainTemplate() template.HTML
- func (page *Page) InitializeData(c *gin.Context)
- func (page *Page) LocaleVar(name, locale string) interface{}
- func (page *Page) Localize(key string, args ...interface{}) string
- func (page *Page) LocalizeDate(t time.Time) string
- func (page *Page) LocalizeDateTime(t time.Time) string
- func (page *Page) LocalizeTime(t time.Time) string
- func (page *Page) Merge(toMerge Page)
- func (page *Page) Minus(a, b int) int
- func (page *Page) Mult(a, b int) int
- func (page *Page) Nl2br(text string) string
- func (page *Page) Plus(a, b int) int
- func (page *Page) PreparePaths(webHost string, applicationLocales []string, fallbackLocales map[string]string)
- func (page *Page) PrepareWithLocale(currentLocale, currentTimezone, webHost, staticHost, apiHost string, ...)
- func (page *Page) Process()
- func (page *Page) RenderError(c *gin.Context)
- func (page *Page) RenderNotFound(c *gin.Context)
- func (page *Page) RenderOk(c *gin.Context)
- func (page *Page) RenderUnauthorized(c *gin.Context)
- func (page *Page) SetError(err response.Error)
- func (page *Page) SetHrefLangParam(locale string, params map[string]string)
- func (page *Page) SetInfo(info Info)
- func (page *Page) SetLocaleVar(name, locale string, value interface{})
- func (page *Page) SetLocalizedVar(name, value string)
- func (page *Page) SetVar(name string, value interface{})
- func (page *Page) StaticURL(path string) string
- func (page *Page) URL(key string, vars ...map[string]string) string
- func (page *Page) UpdateMetaRobots()
- func (page *Page) Var(name string) interface{}
- type PageConfiguration
- type PageContent
- type PageTemplate
- type Script
- type Sitemap
- type SitemapUpdateFrequency
- type SocialNetworksConfiguration
- type Stylesheet
- type Twitter
- type User
Constants ¶
const ( // AccessRightAll concerns all the users. AccessRightAll = "all" // AccessRightSignedIn concerns only the signed in users. AccessRightSignedIn = "signedin" // AccessRightNotSignedIn concerns only the non-signed in users. AccessRightNotSignedIn = "notsignedin" // AccessRightAttributes concerns only the users with some attributes. AccessRightAttributes = "attributes" )
const ( // SitemapUpdateFrequencyAlways always frequency SitemapUpdateFrequencyAlways = "always" // SitemapUpdateFrequencyHourly hourly frequency SitemapUpdateFrequencyHourly = "hourly" // SitemapUpdateFrequencyDaily daily frequency SitemapUpdateFrequencyDaily = "daily" // SitemapUpdateFrequencyWeekly weekly frequency SitemapUpdateFrequencyWeekly = "weekly" // SitemapUpdateFrequencyMonthly monthly frequency SitemapUpdateFrequencyMonthly = "monthly" // SitemapUpdateFrequencyYearly yearly frequency SitemapUpdateFrequencyYearly = "yearly" // SitemapUpdateFrequencyNever never frequency SitemapUpdateFrequencyNever = "never" )
Variables ¶
var ( // LocaleKeyword key of the variable locale. LocaleKeyword = "Locale" // WebHostKeyword key of the variable webhost. WebHostKeyword = "WebHost" // StaticHostKeyword key of the variable statichost. StaticHostKeyword = "StaticHost" // APIHostKeyword key of the variable apihost. APIHostKeyword = "ApiHost" )
Functions ¶
func FormatOpenGraphLocale ¶
FormatOpenGraphLocale : returns a locale in the open graph format.
func Initialize ¶
func Initialize(file, webHost, staticHost, apiHost, applicationTimezone string, applicationLocales []string, fallbackLocales map[string]string, JWTCookieName, JWTSecret string, facebookConfiguration FacebookConfiguration, googleConfiguration GoogleConfiguration, socialNetworksConfiguration SocialNetworksConfiguration, betaVersion, isProduction bool)
Initialize : initialize the configuration of the routes.
Types ¶
type Configuration ¶
type Configuration struct { Default *Page Routes map[string]*Page Async map[string]*Async // contains filtered or unexported fields }
Configuration : struct of the configuration of the routes.
var Main *Configuration
Main : configuration of the routes: singleton.
func (*Configuration) AsyncURL ¶
func (conf *Configuration) AsyncURL(key, locale string) string
AsyncURL : returns the URL of a async url.
func (*Configuration) IsPartial ¶
func (conf *Configuration) IsPartial(key, locale string) bool
IsPartial : returns true if the page is a partial page.
func (*Configuration) Page ¶
func (conf *Configuration) Page(c *gin.Context) *Page
Page : returns the standard page struct with the key and locale.
func (*Configuration) PageByKey ¶
func (conf *Configuration) PageByKey(c *gin.Context, key string) *Page
PageByKey : returns the standard page struct with the key.
func (*Configuration) URL ¶
func (conf *Configuration) URL(key, locale string) string
URL : returns the URL of a page with its locale and some vars.
type FacebookConfiguration ¶
FacebookConfiguration : configuration of the Facebook developer application.
type GoogleConfiguration ¶
GoogleConfiguration : configuration of the Google developer application.
type Meta ¶
type Meta struct { Charset string Title string Description string Keywords []string CanonicalURL string `yaml:"-"` // Defined by the constructor Icons []Icon ImageSource string `yaml:"image_source"` Robots string ViewPort string HrefLang []HrefLang `yaml:"-"` // Defined by the constructor Alternates []Alternate Stylesheets []Stylesheet OpenGraph OpenGraph Twitter Twitter }
Meta struct of a HTML meta data.
func (*Meta) JoinedKeywords ¶
JoinedKeywords returns a string containing the keywords separated by a comma.
type OpenGraph ¶
type OpenGraph struct { Title string Description string Image string URL string SiteName string `yaml:"site_name"` Type string Locale string AlternateLocales []string }
OpenGraph : struct of OpenGraph Meta properties.
type Page ¶
type Page struct { Locale string `yaml:"-"` // Defined by the constructor Timezone string `yaml:"-"` // Defined by the constructor Paths map[string]string Template PageTemplate AccessRight AccessRight `yaml:"access"` ScriptFiles []Script `yaml:"scripts"` Meta Meta Title string Sitemap Sitemap Configuration PageConfiguration `yaml:"-"` // Defined by the constructor Content PageContent `yaml:"-"` // Defined by the each script Partial bool `yaml:"partial"` // true if this page is a partial page (loaded by an ajax call), false if it is a full page. Key string // The key defining the route in the 'routes' file. BetaVersion bool Production bool Vars map[string]interface{} // Common variables to all the pages. }
Page struct of a HTML page.
func (*Page) FormattedTime ¶
FormattedTime : returns a formatted time (used into the templates).
func (*Page) HTMLEscape ¶
HTMLEscape : returns a HTML escaped string (used into the templates).
func (*Page) HTMLEscapeWithNl ¶
HTMLEscapeWithNl : replaces the \n to a <br>.
func (*Page) IncludeMainTemplate ¶
IncludeMainTemplate : returns the content of the page, used to include the parsed Main template to the Decorator template.
func (*Page) InitializeData ¶
InitializeData : initializes the data into the page struct before added some keywords.
func (*Page) LocalizeDate ¶
LocalizeDate : returns a localized date (used into the templates).
func (*Page) LocalizeDateTime ¶
LocalizeDateTime : returns a localized date and time (used into the templates).
func (*Page) LocalizeTime ¶
LocalizeTime : returns a localized time (used into the templates).
func (*Page) PreparePaths ¶
func (page *Page) PreparePaths(webHost string, applicationLocales []string, fallbackLocales map[string]string)
PreparePaths : sets up the global page struct.
func (*Page) PrepareWithLocale ¶
func (page *Page) PrepareWithLocale(currentLocale, currentTimezone, webHost, staticHost, apiHost string, supportedLocales []string)
PrepareWithLocale : sets up a specific page struct before added some keywords.
func (*Page) Process ¶
func (page *Page) Process()
Process : replaces the variables into the target properties before processing the templates.
func (*Page) RenderError ¶
RenderError : renders a HTML page with a HTTP code 500.
func (*Page) RenderNotFound ¶
RenderNotFound : renders a HTML page with a HTTP code 404.
func (*Page) RenderUnauthorized ¶
RenderUnauthorized : renders a HTML page with a HTTP code 401.
func (*Page) SetHrefLangParam ¶
SetHrefLangParam :
func (*Page) SetLocaleVar ¶
SetLocaleVar : sets up a variable to the list of the variables of the page with the locale.
func (*Page) SetLocalizedVar ¶
SetLocalizedVar : sets up a localized variable to the list of the variables of the page.
func (*Page) UpdateMetaRobots ¶
func (page *Page) UpdateMetaRobots()
UpdateMetaRobots : updates the meta 'robots' accordingl to the sitemap's properties.
type PageConfiguration ¶
type PageConfiguration struct { Facebook FacebookConfiguration Google GoogleConfiguration SocialNetworks SocialNetworksConfiguration }
PageConfiguration : set of configurations.
type PageContent ¶
type PageContent struct { CurrentUser User Title string Error Error Info Info Vars map[string]interface{} // contains filtered or unexported fields }
PageContent struct of the content of a HTML page containing some variables.
func (*PageContent) HasError ¶
func (content *PageContent) HasError() bool
HasError : returns true if an error is defined.
func (*PageContent) HasInfo ¶
func (content *PageContent) HasInfo() bool
HasInfo : returns true if an info is defined.
func (*PageContent) HasTitle ¶
func (content *PageContent) HasTitle() bool
HasTitle : returns true if a title is defined.
func (*PageContent) IsUserAuthenticated ¶
func (content *PageContent) IsUserAuthenticated() bool
IsUserAuthenticated : returns true if the userID is defined.
type PageTemplate ¶
PageTemplate struct containing the properties of templates.
func (*PageTemplate) Merge ¶
func (templates *PageTemplate) Merge(toMerge PageTemplate)
Merge merges two PageTemplate structs.
type Sitemap ¶
type Sitemap struct { Included bool Priority float32 UpdateFrequency SitemapUpdateFrequency `yaml:"update_frequency"` }
Sitemap : struct of the sitemap properties.
type SitemapUpdateFrequency ¶
type SitemapUpdateFrequency string
SitemapUpdateFrequency : update frequencies of a sitemap
func (SitemapUpdateFrequency) String ¶
func (frequency SitemapUpdateFrequency) String() string
String : returns the string value of the frequency.
type SocialNetworksConfiguration ¶
SocialNetworksConfiguration : configuration of the social network pages.
type Stylesheet ¶
Stylesheet struct of a stylesheet.
Source Files ¶
- config.go
- type_async.go
- type_meta.go
- type_meta_alternate.go
- type_meta_hreflang.go
- type_meta_icon.go
- type_meta_opengraph.go
- type_meta_private.go
- type_meta_stylesheet.go
- type_meta_twitter.go
- type_page.go
- type_page_access_rights.go
- type_page_configuration.go
- type_page_content.go
- type_page_facebook_configuration.go
- type_page_google_configuration.go
- type_page_private.go
- type_page_script.go
- type_page_sitemap.go
- type_page_social_networks_configuration.go
- type_page_template.go
- type_page_template_functions.go
- type_page_vars.go