A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

48 righe
1.2 KiB

  1. /*
  2. * Copyright © 2018-2019, 2021 A Bunch Tell 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. // Request values
  22. Path string
  23. Username string
  24. Values map[string]string
  25. Flashes []string
  26. CanViewReader bool
  27. IsAdmin bool
  28. CanInvite bool
  29. }
  30. // SanitizeHost alters the StaticPage to contain a real hostname. This is
  31. // especially important for the Tor hidden service, as it can be served over
  32. // proxies, messing up the apparent hostname.
  33. func (sp *StaticPage) SanitizeHost(cfg *config.Config) {
  34. if cfg.Server.HiddenHost != "" && strings.HasPrefix(sp.Host, cfg.Server.HiddenHost) {
  35. sp.Host = cfg.Server.HiddenHost
  36. }
  37. }
  38. func (sp StaticPage) OfficialVersion() string {
  39. p := strings.Split(sp.Version, "-")
  40. return p[0]
  41. }