2018-12-24 17:45:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2018 A Bunch Tell LLC.
|
|
|
|
*
|
|
|
|
* This file is part of WriteFreely.
|
|
|
|
*
|
|
|
|
* WriteFreely is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, included
|
|
|
|
* in the LICENSE file in this source code package.
|
|
|
|
*/
|
2018-12-31 06:05:26 +00:00
|
|
|
|
2018-11-08 04:50:50 +00:00
|
|
|
// package page provides mechanisms and data for generating a WriteFreely page.
|
|
|
|
package page
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/writeas/writefreely/config"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type StaticPage struct {
|
|
|
|
// App configuration
|
|
|
|
config.AppCfg
|
|
|
|
Version string
|
|
|
|
HeaderNav bool
|
|
|
|
|
|
|
|
// Request values
|
2019-06-17 00:29:31 +00:00
|
|
|
Path string
|
|
|
|
Username string
|
|
|
|
Values map[string]string
|
|
|
|
Flashes []string
|
|
|
|
CanViewReader bool
|
2019-08-07 13:00:16 +00:00
|
|
|
IsAdmin bool
|
|
|
|
CanInvite bool
|
2018-11-08 04:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SanitizeHost alters the StaticPage to contain a real hostname. This is
|
|
|
|
// especially important for the Tor hidden service, as it can be served over
|
|
|
|
// proxies, messing up the apparent hostname.
|
|
|
|
func (sp *StaticPage) SanitizeHost(cfg *config.Config) {
|
|
|
|
if cfg.Server.HiddenHost != "" && strings.HasPrefix(sp.Host, cfg.Server.HiddenHost) {
|
|
|
|
sp.Host = cfg.Server.HiddenHost
|
|
|
|
}
|
|
|
|
}
|
2019-04-10 19:27:31 +00:00
|
|
|
|
|
|
|
func (sp StaticPage) OfficialVersion() string {
|
|
|
|
p := strings.Split(sp.Version, "-")
|
|
|
|
return p[0]
|
|
|
|
}
|