A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

49 lines
1.2 KiB

  1. /*
  2. * Copyright © 2018-2019, 2021 Musing Studio LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. // package page provides mechanisms and data for generating a WriteFreely page.
  11. package page
  12. import (
  13. "github.com/writefreely/writefreely/config"
  14. "strings"
  15. )
  16. type StaticPage struct {
  17. // App configuration
  18. config.AppCfg
  19. Version string
  20. HeaderNav bool
  21. CustomCSS bool
  22. // Request values
  23. Path string
  24. Username string
  25. Values map[string]string
  26. Flashes []string
  27. CanViewReader bool
  28. IsAdmin bool
  29. CanInvite bool
  30. }
  31. // SanitizeHost alters the StaticPage to contain a real hostname. This is
  32. // especially important for the Tor hidden service, as it can be served over
  33. // proxies, messing up the apparent hostname.
  34. func (sp *StaticPage) SanitizeHost(cfg *config.Config) {
  35. if cfg.Server.HiddenHost != "" && strings.HasPrefix(sp.Host, cfg.Server.HiddenHost) {
  36. sp.Host = cfg.Server.HiddenHost
  37. }
  38. }
  39. func (sp StaticPage) OfficialVersion() string {
  40. p := strings.Split(sp.Version, "-")
  41. return p[0]
  42. }