package yatwiki import ( "fmt" "html/template" "time" ) var subresourceNonce = time.Now().Unix() type pageTemplateOptions struct { CurrentPageIsArticle bool CurrentPageName string WikiTitle string Content template.HTML BaseURL string LoadCodeResources bool DefaultPage string AllowDownload bool SessionMessage string PageNotExistsError bool PageNotExistsTarget string } func DefaultPageTemplateOptions(opts *ServerOptions) *pageTemplateOptions { return &pageTemplateOptions{ WikiTitle: opts.PageTitle, BaseURL: opts.ExpectBaseURL, DefaultPage: opts.DefaultPage, AllowDownload: opts.AllowDBDownload, } } func (this *pageTemplateOptions) NewArticleTitle() string { return fmt.Sprintf("untitled-%d", time.Now().Unix()) } func (this *pageTemplateOptions) SubresourceNonce() int64 { return subresourceNonce } const pageTemplate string = ` {{.CurrentPageName}}{{ if len .CurrentPageName }} - {{end}}{{.WikiTitle}} {{if .LoadCodeResources}} {{end}}
{{if .CurrentPageIsArticle }}
{{end}}
{{if .PageNotExistsError}}
No such article exists. Click here to create it.
{{end}} {{if len .SessionMessage}}
{{.SessionMessage}}
{{end}} {{.Content}}
`