1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-09-12 15:56:07 +00:00

Move config-related stuff to its own module

This commit is contained in:
Timur Ismagilov
2021-05-09 14:36:39 +05:00
parent 9bf5e8e471
commit 662794dd59
29 changed files with 540 additions and 514 deletions

View File

@@ -1,4 +1,4 @@
package util package cfg
import ( import (
"log" "log"
@@ -8,7 +8,31 @@ import (
"github.com/go-ini/ini" "github.com/go-ini/ini"
) )
// See https://mycorrhiza.lesarbr.es/hypha/configuration/fields var (
WikiName string
NaviTitleIcon string
HomeHypha string
UserHypha string
HeaderLinksHypha string
HTTPPort string
URL string
GeminiCertificatePath string
WikiDir string
ConfigFilePath string
UseFixedAuth bool
FixedAuthCredentialsPath string
UseRegistration bool
RegistrationCredentialsPath string
LimitRegistration int
)
// Config represents a Mycorrhiza wiki configuration file.
//
// See https://mycorrhiza.lesarbr.es/hypha/configuration/fields for fields' docs.
type Config struct { type Config struct {
WikiName string WikiName string
NaviTitleIcon string NaviTitleIcon string
@@ -17,18 +41,21 @@ type Config struct {
Authorization Authorization
} }
// Hyphae is a section of Config which has fields related to special hyphae.
type Hyphae struct { type Hyphae struct {
HomeHypha string HomeHypha string
UserHypha string UserHypha string
HeaderLinksHypha string HeaderLinksHypha string
} }
// Network is a section of Config that has fields related to network stuff: HTTP and Gemini.
type Network struct { type Network struct {
HTTPPort uint64 HTTPPort uint64
URL string URL string
GeminiCertificatePath string GeminiCertificatePath string
} }
// Authorization is a section of Config that has fields related to authorization and authentication.
type Authorization struct { type Authorization struct {
UseFixedAuth bool UseFixedAuth bool
FixedAuthCredentialsPath string FixedAuthCredentialsPath string
@@ -38,6 +65,7 @@ type Authorization struct {
LimitRegistration uint64 LimitRegistration uint64
} }
// ReadConfigFile reads a config on the given path and stores the configuration.
func ReadConfigFile(path string) { func ReadConfigFile(path string) {
cfg := &Config{ cfg := &Config{
WikiName: "MycorrhizaWiki", WikiName: "MycorrhizaWiki",
@@ -76,16 +104,16 @@ func ReadConfigFile(path string) {
} }
// Map the struct to the global variables // Map the struct to the global variables
SiteName = cfg.WikiName WikiName = cfg.WikiName
SiteNavIcon = cfg.NaviTitleIcon NaviTitleIcon = cfg.NaviTitleIcon
HomePage = cfg.HomeHypha HomeHypha = cfg.HomeHypha
UserHypha = cfg.UserHypha UserHypha = cfg.UserHypha
HeaderLinksHypha = cfg.HeaderLinksHypha HeaderLinksHypha = cfg.HeaderLinksHypha
ServerPort = strconv.FormatUint(cfg.HTTPPort, 10) HTTPPort = strconv.FormatUint(cfg.HTTPPort, 10)
URL = cfg.URL URL = cfg.URL
GeminiCertPath = cfg.GeminiCertificatePath GeminiCertificatePath = cfg.GeminiCertificatePath
UseFixedAuth = cfg.UseFixedAuth UseFixedAuth = cfg.UseFixedAuth
FixedCredentialsPath = cfg.FixedAuthCredentialsPath FixedAuthCredentialsPath = cfg.FixedAuthCredentialsPath
UseRegistration = cfg.UseRegistration UseRegistration = cfg.UseRegistration
RegistrationCredentialsPath = cfg.RegistrationCredentialsPath RegistrationCredentialsPath = cfg.RegistrationCredentialsPath
LimitRegistration = int(cfg.LimitRegistration) LimitRegistration = int(cfg.LimitRegistration)

View File

@@ -3,11 +3,11 @@ package files
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/adrg/xdg" "github.com/adrg/xdg"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/mitchellh/go-homedir" "github.com/mitchellh/go-homedir"
) )
@@ -49,7 +49,7 @@ func tokenStoragePath() (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
if strings.HasPrefix(dir, util.WikiDir) { if strings.HasPrefix(dir, cfg.WikiDir) {
return "", errors.New("wiki storage directory includes private config files") return "", errors.New("wiki storage directory includes private config files")
} }
return dir, nil return dir, nil
@@ -57,7 +57,7 @@ func tokenStoragePath() (string, error) {
func registrationCredentialsPath() (string, error) { func registrationCredentialsPath() (string, error) {
var err error var err error
path := util.RegistrationCredentialsPath path := cfg.RegistrationCredentialsPath
if len(path) == 0 { if len(path) == 0 {
path, err = xdg.DataFile("mycorrhiza/registration.json") path, err = xdg.DataFile("mycorrhiza/registration.json")
@@ -81,7 +81,7 @@ func registrationCredentialsPath() (string, error) {
func fixedCredentialsPath() (string, error) { func fixedCredentialsPath() (string, error) {
var err error var err error
path := util.FixedCredentialsPath path := cfg.FixedAuthCredentialsPath
if len(path) > 0 { if len(path) > 0 {
path, err = homedir.Expand(path) path, err = homedir.Expand(path)

15
flag.go
View File

@@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@@ -14,7 +15,7 @@ import (
var printExampleConfig bool var printExampleConfig bool
func init() { func init() {
flag.StringVar(&util.ConfigFilePath, "config-path", "", "Path to a configuration file. Leave empty if you don't want to use it.") flag.StringVar(&cfg.ConfigFilePath, "config-path", "", "Path to a configuration file. Leave empty if you don't want to use it.")
flag.BoolVar(&printExampleConfig, "print-example-config", false, "If true, print an example configuration file contents and exit. You can save the output to a file and base your own configuration on it.") flag.BoolVar(&printExampleConfig, "print-example-config", false, "If true, print an example configuration file contents and exit. You can save the output to a file and base your own configuration on it.")
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf( fmt.Fprintf(
@@ -42,16 +43,16 @@ func parseCliArgs() {
var err error var err error
WikiDir, err = filepath.Abs(args[0]) WikiDir, err = filepath.Abs(args[0])
util.WikiDir = WikiDir cfg.WikiDir = WikiDir
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
if util.URL == "" { if cfg.URL == "" {
util.URL = "http://0.0.0.0:" + util.ServerPort cfg.URL = "http://0.0.0.0:" + cfg.HTTPPort
} }
util.HomePage = util.CanonicalName(util.HomePage) cfg.HomeHypha = util.CanonicalName(cfg.HomeHypha)
util.UserHypha = util.CanonicalName(util.UserHypha) cfg.UserHypha = util.CanonicalName(cfg.UserHypha)
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha) cfg.HeaderLinksHypha = util.CanonicalName(cfg.HeaderLinksHypha)
} }

View File

@@ -3,6 +3,7 @@ package main
import ( import (
"crypto/tls" "crypto/tls"
"crypto/x509/pkix" "crypto/x509/pkix"
"github.com/bouncepaw/mycorrhiza/cfg"
"io/ioutil" "io/ioutil"
"log" "log"
"path/filepath" "path/filepath"
@@ -13,7 +14,6 @@ import (
"github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/markup" "github.com/bouncepaw/mycorrhiza/markup"
"github.com/bouncepaw/mycorrhiza/util"
) )
func geminiHomeHypha(w *gemini.ResponseWriter, rq *gemini.Request) { func geminiHomeHypha(w *gemini.ResponseWriter, rq *gemini.Request) {
@@ -23,7 +23,7 @@ func geminiHomeHypha(w *gemini.ResponseWriter, rq *gemini.Request) {
You have successfully served the wiki through Gemini. Currently, support is really work-in-progress; you should resort to using Mycorrhiza through the web protocols. You have successfully served the wiki through Gemini. Currently, support is really work-in-progress; you should resort to using Mycorrhiza through the web protocols.
Visit home hypha: Visit home hypha:
=> /hypha/` + util.HomePage)) => /hypha/` + cfg.HomeHypha))
} }
func geminiHypha(w *gemini.ResponseWriter, rq *gemini.Request) { func geminiHypha(w *gemini.ResponseWriter, rq *gemini.Request) {
@@ -48,10 +48,10 @@ func geminiHypha(w *gemini.ResponseWriter, rq *gemini.Request) {
} }
func handleGemini() { func handleGemini() {
if util.GeminiCertPath == "" { if cfg.GeminiCertificatePath == "" {
return return
} }
certPath, err := filepath.Abs(util.GeminiCertPath) certPath, err := filepath.Abs(cfg.GeminiCertificatePath)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@@ -3,6 +3,7 @@ package history
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"html" "html"
"log" "log"
"os/exec" "os/exec"
@@ -167,7 +168,7 @@ func (rev *Revision) bestLink() string {
func gitsh(args ...string) (out bytes.Buffer, err error) { func gitsh(args ...string) (out bytes.Buffer, err error) {
fmt.Printf("$ %v\n", args) fmt.Printf("$ %v\n", args)
cmd := exec.Command(gitpath, args...) cmd := exec.Command(gitpath, args...)
cmd.Dir = util.WikiDir cmd.Dir = cfg.WikiDir
b, err := cmd.CombinedOutput() b, err := cmd.CombinedOutput()
if err != nil { if err != nil {
@@ -179,7 +180,7 @@ func gitsh(args ...string) (out bytes.Buffer, err error) {
// silentGitsh is like gitsh, except it writes less to the stdout. // silentGitsh is like gitsh, except it writes less to the stdout.
func silentGitsh(args ...string) (out bytes.Buffer, err error) { func silentGitsh(args ...string) (out bytes.Buffer, err error) {
cmd := exec.Command(gitpath, args...) cmd := exec.Command(gitpath, args...)
cmd.Dir = util.WikiDir cmd.Dir = cfg.WikiDir
b, err := cmd.CombinedOutput() b, err := cmd.CombinedOutput()
return *bytes.NewBuffer(b), err return *bytes.NewBuffer(b), err

View File

@@ -4,20 +4,20 @@ package history
import ( import (
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"log" "log"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/gorilla/feeds" "github.com/gorilla/feeds"
) )
func recentChangesFeed() *feeds.Feed { func recentChangesFeed() *feeds.Feed {
feed := &feeds.Feed{ feed := &feeds.Feed{
Title: "Recent changes", Title: "Recent changes",
Link: &feeds.Link{Href: util.URL}, Link: &feeds.Link{Href: cfg.URL},
Description: "List of 30 recent changes on the wiki", Description: "List of 30 recent changes on the wiki",
Author: &feeds.Author{Name: "Wikimind", Email: "wikimind@mycorrhiza"}, Author: &feeds.Author{Name: "Wikimind", Email: "wikimind@mycorrhiza"},
Updated: time.Now(), Updated: time.Now(),
@@ -44,7 +44,7 @@ func recentChangesFeed() *feeds.Feed {
Description: rev.descriptionForFeed(), Description: rev.descriptionForFeed(),
Created: rev.Time, Created: rev.Time,
Updated: rev.Time, Updated: rev.Time,
Link: &feeds.Link{Href: util.URL + rev.bestLink()}, Link: &feeds.Link{Href: cfg.URL + rev.bestLink()},
}) })
} }
return feed return feed
@@ -141,7 +141,7 @@ func (rev *Revision) asHistoryEntry(hyphaName string) (html string) {
author := "" author := ""
if rev.Username != "anon" { if rev.Username != "anon" {
author = fmt.Sprintf(` author = fmt.Sprintf(`
<span class="history-entry__author">by <a href="/page/%[1]s/%[2]s" rel="author">%[2]s</span>`, util.UserHypha, rev.Username) <span class="history-entry__author">by <a href="/page/%[1]s/%[2]s" rel="author">%[2]s</span>`, cfg.UserHypha, rev.Username)
} }
return fmt.Sprintf(` return fmt.Sprintf(`
<li class="history__entry"> <li class="history__entry">
@@ -176,7 +176,7 @@ func parseRevisionLine(line string) Revision {
// See how the file with `filepath` looked at commit with `hash`. // See how the file with `filepath` looked at commit with `hash`.
func FileAtRevision(filepath, hash string) (string, error) { func FileAtRevision(filepath, hash string) (string, error) {
out, err := gitsh("show", hash+":"+strings.TrimPrefix(filepath, util.WikiDir+"/")) out, err := gitsh("show", hash+":"+strings.TrimPrefix(filepath, cfg.WikiDir+"/"))
return out.String(), err return out.String(), err
} }

View File

@@ -1,11 +1,11 @@
package main package main
import ( import (
"github.com/bouncepaw/mycorrhiza/cfg"
"log" "log"
"net/http" "net/http"
"github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views" "github.com/bouncepaw/mycorrhiza/views"
) )
@@ -38,6 +38,6 @@ func handlerAdminReindexUsers(w http.ResponseWriter, rq *http.Request) {
prepareRq(rq) prepareRq(rq)
if user.CanProceed(rq, "admin") && rq.Method == "POST" { if user.CanProceed(rq, "admin") && rq.Method == "POST" {
user.ReadUsersFromFilesystem() user.ReadUsersFromFilesystem()
http.Redirect(w, rq, "/hypha/"+util.UserHypha, http.StatusSeeOther) http.Redirect(w, rq, "/hypha/"+cfg.UserHypha, http.StatusSeeOther)
} }
} }

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"github.com/bouncepaw/mycorrhiza/cfg"
"io" "io"
"log" "log"
"net/http" "net/http"
@@ -20,7 +21,7 @@ func init() {
func handlerRegister(w http.ResponseWriter, rq *http.Request) { func handlerRegister(w http.ResponseWriter, rq *http.Request) {
prepareRq(rq) prepareRq(rq)
if !util.UseRegistration { if !cfg.UseRegistration {
w.WriteHeader(http.StatusForbidden) w.WriteHeader(http.StatusForbidden)
} }
if rq.Method == http.MethodGet { if rq.Method == http.MethodGet {

View File

@@ -2,6 +2,7 @@
package main package main
import ( import (
"github.com/bouncepaw/mycorrhiza/cfg"
"io" "io"
"log" "log"
"math/rand" "math/rand"
@@ -32,7 +33,7 @@ func handlerList(w http.ResponseWriter, rq *http.Request) {
func handlerReindex(w http.ResponseWriter, rq *http.Request) { func handlerReindex(w http.ResponseWriter, rq *http.Request) {
prepareRq(rq) prepareRq(rq)
if ok := user.CanProceed(rq, "reindex"); !ok { if ok := user.CanProceed(rq, "reindex"); !ok {
HttpErr(w, http.StatusForbidden, util.HomePage, "Not enough rights", "You must be an admin to reindex hyphae.") HttpErr(w, http.StatusForbidden, cfg.HomeHypha, "Not enough rights", "You must be an admin to reindex hyphae.")
log.Println("Rejected", rq.URL) log.Println("Rejected", rq.URL)
return return
} }
@@ -50,7 +51,7 @@ func handlerReindex(w http.ResponseWriter, rq *http.Request) {
func handlerUpdateHeaderLinks(w http.ResponseWriter, rq *http.Request) { func handlerUpdateHeaderLinks(w http.ResponseWriter, rq *http.Request) {
prepareRq(rq) prepareRq(rq)
if ok := user.CanProceed(rq, "update-header-links"); !ok { if ok := user.CanProceed(rq, "update-header-links"); !ok {
HttpErr(w, http.StatusForbidden, util.HomePage, "Not enough rights", "You must be a moderator to update header links.") HttpErr(w, http.StatusForbidden, cfg.HomeHypha, "Not enough rights", "You must be a moderator to update header links.")
log.Println("Rejected", rq.URL) log.Println("Rejected", rq.URL)
return return
} }
@@ -66,7 +67,7 @@ func handlerRandom(w http.ResponseWriter, rq *http.Request) {
amountOfHyphae = hyphae.Count() amountOfHyphae = hyphae.Count()
) )
if amountOfHyphae == 0 { if amountOfHyphae == 0 {
HttpErr(w, http.StatusNotFound, util.HomePage, "There are no hyphae", HttpErr(w, http.StatusNotFound, cfg.HomeHypha, "There are no hyphae",
"It is impossible to display a random hypha because the wiki does not contain any hyphae") "It is impossible to display a random hypha because the wiki does not contain any hyphae")
return return
} }
@@ -84,7 +85,7 @@ func handlerRandom(w http.ResponseWriter, rq *http.Request) {
func handlerAbout(w http.ResponseWriter, rq *http.Request) { func handlerAbout(w http.ResponseWriter, rq *http.Request) {
w.Header().Set("Content-Type", "text/html;charset=utf-8") w.Header().Set("Content-Type", "text/html;charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
_, err := io.WriteString(w, base("About "+util.SiteName, views.AboutHTML(), user.FromRequest(rq))) _, err := io.WriteString(w, base("About "+cfg.WikiName, views.AboutHTML(), user.FromRequest(rq)))
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }

14
main.go
View File

@@ -6,6 +6,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
@@ -19,7 +20,6 @@ import (
"github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/shroom" "github.com/bouncepaw/mycorrhiza/shroom"
"github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views" "github.com/bouncepaw/mycorrhiza/views"
) )
@@ -52,13 +52,13 @@ var base = views.BaseHTML
func handlerStyle(w http.ResponseWriter, rq *http.Request) { func handlerStyle(w http.ResponseWriter, rq *http.Request) {
prepareRq(rq) prepareRq(rq)
if _, err := os.Stat(util.WikiDir + "/static/common.css"); err == nil { if _, err := os.Stat(cfg.WikiDir + "/static/common.css"); err == nil {
http.ServeFile(w, rq, util.WikiDir+"/static/common.css") http.ServeFile(w, rq, cfg.WikiDir+"/static/common.css")
} else { } else {
w.Header().Set("Content-Type", "text/css;charset=utf-8") w.Header().Set("Content-Type", "text/css;charset=utf-8")
w.Write([]byte(assets.DefaultCSS())) w.Write([]byte(assets.DefaultCSS()))
} }
if bytes, err := ioutil.ReadFile(util.WikiDir + "/static/custom.css"); err == nil { if bytes, err := ioutil.ReadFile(cfg.WikiDir + "/static/custom.css"); err == nil {
w.Write(bytes) w.Write(bytes)
} }
} }
@@ -124,7 +124,7 @@ func main() {
parseCliArgs() parseCliArgs()
// It is ok if the path is "" // It is ok if the path is ""
util.ReadConfigFile(util.ConfigFilePath) cfg.ReadConfigFile(cfg.ConfigFilePath)
if err := files.CalculatePaths(); err != nil { if err := files.CalculatePaths(); err != nil {
log.Fatal(err) log.Fatal(err)
@@ -163,9 +163,9 @@ func main() {
http.HandleFunc("/static/icon/", handlerIcon) http.HandleFunc("/static/icon/", handlerIcon)
http.HandleFunc("/robots.txt", handlerRobotsTxt) http.HandleFunc("/robots.txt", handlerRobotsTxt)
http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
addr, _ := url.Parse("/hypha/" + util.HomePage) // Let's pray it never fails addr, _ := url.Parse("/hypha/" + cfg.HomeHypha) // Let's pray it never fails
rq.URL = addr rq.URL = addr
handlerHypha(w, rq) handlerHypha(w, rq)
}) })
log.Fatal(http.ListenAndServe("0.0.0.0:"+util.ServerPort, nil)) log.Fatal(http.ListenAndServe("0.0.0.0:"+cfg.HTTPPort, nil))
} }

View File

@@ -3,12 +3,12 @@ package markup
import ( import (
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"html" "html"
"regexp" "regexp"
"strings" "strings"
"github.com/bouncepaw/mycorrhiza/link" "github.com/bouncepaw/mycorrhiza/link"
"github.com/bouncepaw/mycorrhiza/util"
) )
// A Mycomarkup-formatted document // A Mycomarkup-formatted document
@@ -63,14 +63,14 @@ func (md *MycoDoc) OpenGraphHTML() string {
ogTag("title", md.hyphaName), ogTag("title", md.hyphaName),
ogTag("type", "article"), ogTag("type", "article"),
ogTag("image", md.firstImageURL), ogTag("image", md.firstImageURL),
ogTag("url", util.URL+"/hypha/"+md.hyphaName), ogTag("url", cfg.URL+"/hypha/"+md.hyphaName),
ogTag("determiner", ""), ogTag("determiner", ""),
ogTag("description", htmlTagRe.ReplaceAllString(md.description, "")), ogTag("description", htmlTagRe.ReplaceAllString(md.description, "")),
}, "\n") }, "\n")
} }
func (md *MycoDoc) ogFillVars() *MycoDoc { func (md *MycoDoc) ogFillVars() *MycoDoc {
md.firstImageURL = util.URL + "/favicon.ico" md.firstImageURL = cfg.URL + "/favicon.ico"
foundDesc := false foundDesc := false
foundImg := false foundImg := false
for _, line := range md.ast { for _, line := range md.ast {
@@ -84,7 +84,7 @@ func (md *MycoDoc) ogFillVars() *MycoDoc {
if !foundImg && len(v.entries) > 0 { if !foundImg && len(v.entries) > 0 {
md.firstImageURL = v.entries[0].srclink.ImgSrc() md.firstImageURL = v.entries[0].srclink.ImgSrc()
if v.entries[0].srclink.Kind != link.LinkExternal { if v.entries[0].srclink.Kind != link.LinkExternal {
md.firstImageURL = util.URL + md.firstImageURL md.firstImageURL = cfg.URL + md.firstImageURL
} }
foundImg = true foundImg = true
} }

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"github.com/bouncepaw/mycorrhiza/cfg"
"log" "log"
"net/http" "net/http"
"strings" "strings"
@@ -19,7 +20,7 @@ func HyphaNameFromRq(rq *http.Request, actions ...string) string {
} }
} }
log.Println("HyphaNameFromRq: this request is invalid, fallback to home hypha") log.Println("HyphaNameFromRq: this request is invalid, fallback to home hypha")
return util.HomePage return cfg.HomeHypha
} }
// geminiHyphaNameFromRq extracts hypha name from gemini request. You have to also pass the action which is embedded in the url or several actions. For url /hypha/hypha, the action would be "hypha". // geminiHyphaNameFromRq extracts hypha name from gemini request. You have to also pass the action which is embedded in the url or several actions. For url /hypha/hypha, the action would be "hypha".

View File

@@ -2,10 +2,10 @@ package shroom
import ( import (
"errors" "errors"
"github.com/bouncepaw/mycorrhiza/cfg"
"github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/markup" "github.com/bouncepaw/mycorrhiza/markup"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views" "github.com/bouncepaw/mycorrhiza/views"
) )
@@ -31,8 +31,8 @@ func init() {
} }
markup.HyphaImageForOG = func(hyphaName string) string { markup.HyphaImageForOG = func(hyphaName string) string {
if h := hyphae.ByName(hyphaName); h.Exists && h.BinaryPath != "" { if h := hyphae.ByName(hyphaName); h.Exists && h.BinaryPath != "" {
return util.URL + "/binary/" + hyphaName return cfg.URL + "/binary/" + hyphaName
} }
return util.URL + "/favicon.ico" return cfg.URL + "/favicon.ico"
} }
} }

View File

@@ -3,6 +3,7 @@ package shroom
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/cfg"
"io/ioutil" "io/ioutil"
"log" "log"
"mime/multipart" "mime/multipart"
@@ -13,7 +14,6 @@ import (
"github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/mimetype" "github.com/bouncepaw/mycorrhiza/mimetype"
"github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
) )
func UploadText(h *hyphae.Hypha, data []byte, u *user.User) (hop *history.HistoryOp, errtitle string) { func UploadText(h *hyphae.Hypha, data []byte, u *user.User) (hop *history.HistoryOp, errtitle string) {
@@ -56,7 +56,7 @@ func UploadBinary(h *hyphae.Hypha, mime string, file multipart.File, u *user.Use
// uploadHelp is a helper function for UploadText and UploadBinary // uploadHelp is a helper function for UploadText and UploadBinary
func uploadHelp(h *hyphae.Hypha, hop *history.HistoryOp, ext string, data []byte, u *user.User) (*history.HistoryOp, string) { func uploadHelp(h *hyphae.Hypha, hop *history.HistoryOp, ext string, data []byte, u *user.User) (*history.HistoryOp, string) {
var ( var (
fullPath = filepath.Join(util.WikiDir, h.Name+ext) fullPath = filepath.Join(cfg.WikiDir, h.Name+ext)
originalFullPath = &h.TextPath originalFullPath = &h.TextPath
) )
if hop.Type == history.TypeEditBinary { if hop.Type == history.TypeEditBinary {

View File

@@ -1,6 +1,7 @@
package shroom package shroom
import ( import (
"github.com/bouncepaw/mycorrhiza/cfg"
"io/ioutil" "io/ioutil"
"os" "os"
@@ -24,7 +25,7 @@ func FetchTextPart(h *hyphae.Hypha) (string, error) {
} }
func SetHeaderLinks() { func SetHeaderLinks() {
if userLinksHypha := hyphae.ByName(util.HeaderLinksHypha); !userLinksHypha.Exists { if userLinksHypha := hyphae.ByName(cfg.HeaderLinksHypha); !userLinksHypha.Exists {
util.SetDefaultHeaderLinks() util.SetDefaultHeaderLinks()
} else { } else {
contents, err := ioutil.ReadFile(userLinksHypha.TextPath) contents, err := ioutil.ReadFile(userLinksHypha.TextPath)

View File

@@ -2,30 +2,30 @@ package user
import ( import (
"encoding/json" "encoding/json"
"github.com/bouncepaw/mycorrhiza/cfg"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"github.com/bouncepaw/mycorrhiza/files" "github.com/bouncepaw/mycorrhiza/files"
"github.com/bouncepaw/mycorrhiza/util"
) )
// InitUserDatabase checks the configuration for auth methods and loads users // InitUserDatabase checks the configuration for auth methods and loads users
// if necessary. Call it during initialization. // if necessary. Call it during initialization.
func InitUserDatabase() { func InitUserDatabase() {
AuthUsed = util.UseFixedAuth || util.UseRegistration AuthUsed = cfg.UseFixedAuth || cfg.UseRegistration
if AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") { if AuthUsed && (cfg.FixedAuthCredentialsPath != "" || cfg.RegistrationCredentialsPath != "") {
ReadUsersFromFilesystem() ReadUsersFromFilesystem()
} }
} }
// ReadUsersFromFilesystem reads all user information from filesystem and stores it internally. // ReadUsersFromFilesystem reads all user information from filesystem and stores it internally.
func ReadUsersFromFilesystem() { func ReadUsersFromFilesystem() {
if util.UseFixedAuth { if cfg.UseFixedAuth {
rememberUsers(usersFromFixedCredentials()) rememberUsers(usersFromFixedCredentials())
} }
if util.UseRegistration { if cfg.UseRegistration {
rememberUsers(usersFromRegistrationCredentials()) rememberUsers(usersFromRegistrationCredentials())
} }
readTokensToUsers() readTokensToUsers()

View File

@@ -2,6 +2,7 @@ package user
import ( import (
"errors" "errors"
"github.com/bouncepaw/mycorrhiza/cfg"
"log" "log"
"net/http" "net/http"
"strconv" "strconv"
@@ -39,8 +40,8 @@ func Register(username, password string) error {
username = util.CanonicalName(username) username = util.CanonicalName(username)
log.Println("Attempt to register user", username) log.Println("Attempt to register user", username)
switch { switch {
case CountRegistered() >= util.LimitRegistration && util.LimitRegistration > 0: case CountRegistered() >= cfg.LimitRegistration && cfg.LimitRegistration > 0:
i := strconv.Itoa(util.LimitRegistration) i := strconv.Itoa(cfg.LimitRegistration)
log.Println("Limit reached: " + i) log.Println("Limit reached: " + i)
return errors.New("Reached the limit of registered users: " + i) return errors.New("Reached the limit of registered users: " + i)
case HasUsername(username): case HasUsername(username):

View File

@@ -1,12 +1,13 @@
package util package util
import ( import (
"github.com/bouncepaw/mycorrhiza/cfg"
"strings" "strings"
) )
func SetDefaultHeaderLinks() { func SetDefaultHeaderLinks() {
HeaderLinks = []HeaderLink{ HeaderLinks = []HeaderLink{
{"/", SiteName}, {"/", cfg.WikiName},
{"/recent-changes", "Recent changes"}, {"/recent-changes", "Recent changes"},
{"/list", "All hyphae"}, {"/list", "All hyphae"},
{"/random", "Random"}, {"/random", "Random"},
@@ -18,7 +19,7 @@ func ParseHeaderLinks(text string, rocketlinkλ func(string, string) (string, st
HeaderLinks = []HeaderLink{} HeaderLinks = []HeaderLink{}
for _, line := range strings.Split(text, "\n") { for _, line := range strings.Split(text, "\n") {
if strings.HasPrefix(line, "=>") { if strings.HasPrefix(line, "=>") {
href, text, _ := rocketlinkλ(line, HeaderLinksHypha) href, text, _ := rocketlinkλ(line, cfg.HeaderLinksHypha)
HeaderLinks = append(HeaderLinks, HeaderLink{ HeaderLinks = append(HeaderLinks, HeaderLink{
Href: href, Href: href,
Display: text, Display: text,

View File

@@ -3,35 +3,13 @@ package util
import ( import (
"crypto/rand" "crypto/rand"
"encoding/hex" "encoding/hex"
"github.com/bouncepaw/mycorrhiza/cfg"
"net/http" "net/http"
"regexp" "regexp"
"strings" "strings"
"unicode" "unicode"
) )
// TODO: make names match to fields of config file
var (
SiteName string
SiteNavIcon string
HomePage string
UserHypha string
HeaderLinksHypha string
ServerPort string
URL string
GeminiCertPath string
WikiDir string
ConfigFilePath string
UseFixedAuth bool
FixedCredentialsPath string
UseRegistration bool
RegistrationCredentialsPath string
LimitRegistration int
)
// LettersNumbersOnly keeps letters and numbers only in the given string. // LettersNumbersOnly keeps letters and numbers only in the given string.
func LettersNumbersOnly(s string) string { func LettersNumbersOnly(s string) string {
var ( var (
@@ -52,8 +30,8 @@ func LettersNumbersOnly(s string) string {
// ShorterPath is used by handlerList to display shorter path to the files. It simply strips WikiDir. // ShorterPath is used by handlerList to display shorter path to the files. It simply strips WikiDir.
func ShorterPath(path string) string { func ShorterPath(path string) string {
if strings.HasPrefix(path, WikiDir) { if strings.HasPrefix(path, cfg.WikiDir) {
tmp := strings.TrimPrefix(path, WikiDir) tmp := strings.TrimPrefix(path, cfg.WikiDir)
if tmp == "" { if tmp == "" {
return "" return ""
} }
@@ -103,9 +81,9 @@ func CanonicalName(name string) string {
} }
// HyphaPattern is a pattern which all hyphae must match. // HyphaPattern is a pattern which all hyphae must match.
var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"\'&%{}]+`) var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}]+`)
var UsernamePattern = regexp.MustCompile(`[^?!:#@><*|"\'&%{}/]+`) var UsernamePattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}/]+`)
// IsCanonicalName checks if the `name` is canonical. // IsCanonicalName checks if the `name` is canonical.
func IsCanonicalName(name string) bool { func IsCanonicalName(name string) bool {

View File

@@ -1,15 +1,15 @@
{% import "net/http" %} {% import "net/http" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% func RegisterHTML(rq *http.Request) %} {% func RegisterHTML(rq *http.Request) %}
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
<section> <section>
{% if util.UseRegistration %} {% if cfg.UseRegistration %}
<form class="modal" method="post" action="/register?{%s rq.URL.RawQuery %}" id="register-form" enctype="multipart/form-data" autocomplete="off"> <form class="modal" method="post" action="/register?{%s rq.URL.RawQuery %}" id="register-form" enctype="multipart/form-data" autocomplete="off">
<fieldset class="modal__fieldset"> <fieldset class="modal__fieldset">
<legend class="modal__title">Register to {%s util.SiteName %}</legend> <legend class="modal__title">Register to {%s cfg.WikiName %}</legend>
<label for="register-form__username">Username</label> <label for="register-form__username">Username</label>
<br> <br>
@@ -24,7 +24,7 @@
<a class="modal__action modal__cancel" href="/">Cancel</a> <a class="modal__action modal__cancel" href="/">Cancel</a>
</fieldset> </fieldset>
</form> </form>
{% elseif util.UseFixedAuth %} {% elseif cfg.UseFixedAuth %}
<p>Administrators have forbidden registration for this wiki. Administrators can make an account for you by hand; contact them.</p> <p>Administrators have forbidden registration for this wiki. Administrators can make an account for you by hand; contact them.</p>
<p><a href="{%s rq.URL.RawQuery %}">← Go back</a></p> <p><a href="{%s rq.URL.RawQuery %}">← Go back</a></p>
{% else %} {% else %}
@@ -43,7 +43,7 @@
{% if user.AuthUsed %} {% if user.AuthUsed %}
<form class="modal" method="post" action="/login-data" id="login-form" enctype="multipart/form-data" autocomplete="on"> <form class="modal" method="post" action="/login-data" id="login-form" enctype="multipart/form-data" autocomplete="on">
<fieldset class="modal__fieldset"> <fieldset class="modal__fieldset">
<legend class="modal__title">Log in to {%s util.SiteName %}</legend> <legend class="modal__title">Log in to {%s cfg.WikiName %}</legend>
<p>Use the data you were given by an administrator.</p> <p>Use the data you were given by an administrator.</p>
<label for="login-form__username">Username</label> <label for="login-form__username">Username</label>
<br> <br>

View File

@@ -11,7 +11,7 @@ import "net/http"
import "github.com/bouncepaw/mycorrhiza/user" import "github.com/bouncepaw/mycorrhiza/user"
//line views/auth.qtpl:3 //line views/auth.qtpl:3
import "github.com/bouncepaw/mycorrhiza/util" import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/auth.qtpl:5 //line views/auth.qtpl:5
import ( import (
@@ -35,7 +35,7 @@ func StreamRegisterHTML(qw422016 *qt422016.Writer, rq *http.Request) {
<section> <section>
`) `)
//line views/auth.qtpl:9 //line views/auth.qtpl:9
if util.UseRegistration { if cfg.UseRegistration {
//line views/auth.qtpl:9 //line views/auth.qtpl:9
qw422016.N().S(` qw422016.N().S(`
<form class="modal" method="post" action="/register?`) <form class="modal" method="post" action="/register?`)
@@ -46,7 +46,7 @@ func StreamRegisterHTML(qw422016 *qt422016.Writer, rq *http.Request) {
<fieldset class="modal__fieldset"> <fieldset class="modal__fieldset">
<legend class="modal__title">Register to `) <legend class="modal__title">Register to `)
//line views/auth.qtpl:12 //line views/auth.qtpl:12
qw422016.E().S(util.SiteName) qw422016.E().S(cfg.WikiName)
//line views/auth.qtpl:12 //line views/auth.qtpl:12
qw422016.N().S(`</legend> qw422016.N().S(`</legend>
@@ -65,7 +65,7 @@ func StreamRegisterHTML(qw422016 *qt422016.Writer, rq *http.Request) {
</form> </form>
`) `)
//line views/auth.qtpl:27 //line views/auth.qtpl:27
} else if util.UseFixedAuth { } else if cfg.UseFixedAuth {
//line views/auth.qtpl:27 //line views/auth.qtpl:27
qw422016.N().S(` qw422016.N().S(`
<p>Administrators have forbidden registration for this wiki. Administrators can make an account for you by hand; contact them.</p> <p>Administrators have forbidden registration for this wiki. Administrators can make an account for you by hand; contact them.</p>
@@ -139,7 +139,7 @@ func StreamLoginHTML(qw422016 *qt422016.Writer) {
<fieldset class="modal__fieldset"> <fieldset class="modal__fieldset">
<legend class="modal__title">Log in to `) <legend class="modal__title">Log in to `)
//line views/auth.qtpl:46 //line views/auth.qtpl:46
qw422016.E().S(util.SiteName) qw422016.E().S(cfg.WikiName)
//line views/auth.qtpl:46 //line views/auth.qtpl:46
qw422016.N().S(`</legend> qw422016.N().S(`</legend>
<p>Use the data you were given by an administrator.</p> <p>Use the data you were given by an administrator.</p>

View File

@@ -1,5 +1,6 @@
{% import "net/http" %} {% import "net/http" %}
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/util" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
@@ -76,7 +77,7 @@ if err != nil {
<li class="rc-entry__time"><time>{%s rev.TimeString() %}</time></li> <li class="rc-entry__time"><time>{%s rev.TimeString() %}</time></li>
<li class="rc-entry__hash">{%s rev.Hash %}</li> <li class="rc-entry__hash">{%s rev.Hash %}</li>
<li class="rc-entry__links">{%s= rev.HyphaeLinksHTML() %}</li> <li class="rc-entry__links">{%s= rev.HyphaeLinksHTML() %}</li>
<li class="rc-entry__msg">{%s rev.Message %} {% if rev.Username != "anon" %}<span class="rc-entry__author">by <a href="/hypha/{%s util.UserHypha %}/{%s rev.Username %}" rel="author">{%s rev.Username %}</a></span>{% endif %}</li> <li class="rc-entry__msg">{%s rev.Message %} {% if rev.Username != "anon" %}<span class="rc-entry__author">by <a href="/hypha/{%s cfg.UserHypha %}/{%s rev.Username %}" rel="author">{%s rev.Username %}</a></span>{% endif %}</li>
{% endfunc %} {% endfunc %}
{% func HistoryHTML(rq *http.Request, hyphaName, list string) %} {% func HistoryHTML(rq *http.Request, hyphaName, list string) %}

View File

@@ -8,101 +8,104 @@ package views
import "net/http" import "net/http"
//line views/history.qtpl:3 //line views/history.qtpl:3
import "github.com/bouncepaw/mycorrhiza/util" import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/history.qtpl:4 //line views/history.qtpl:4
import "github.com/bouncepaw/mycorrhiza/user" import "github.com/bouncepaw/mycorrhiza/util"
//line views/history.qtpl:5 //line views/history.qtpl:5
import "github.com/bouncepaw/mycorrhiza/hyphae" import "github.com/bouncepaw/mycorrhiza/user"
//line views/history.qtpl:6 //line views/history.qtpl:6
import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/history.qtpl:7
import "github.com/bouncepaw/mycorrhiza/history" import "github.com/bouncepaw/mycorrhiza/history"
//line views/history.qtpl:9 //line views/history.qtpl:10
import ( import (
qtio422016 "io" qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate" qt422016 "github.com/valyala/quicktemplate"
) )
//line views/history.qtpl:9 //line views/history.qtpl:10
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer _ = qt422016.AcquireByteBuffer
) )
//line views/history.qtpl:9 //line views/history.qtpl:10
func StreamPrimitiveDiffHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) { func StreamPrimitiveDiffHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) {
//line views/history.qtpl:9 //line views/history.qtpl:10
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:11 //line views/history.qtpl:12
text, err := history.PrimitiveDiffAtRevision(h.TextPath, hash) text, err := history.PrimitiveDiffAtRevision(h.TextPath, hash)
if err != nil { if err != nil {
text = err.Error() text = err.Error()
} }
//line views/history.qtpl:15 //line views/history.qtpl:16
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:16 //line views/history.qtpl:17
StreamNavHTML(qw422016, rq, h.Name, "history") StreamNavHTML(qw422016, rq, h.Name, "history")
//line views/history.qtpl:16 //line views/history.qtpl:17
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
<article> <article>
<h1>Diff `) <h1>Diff `)
//line views/history.qtpl:20 //line views/history.qtpl:21
qw422016.E().S(util.BeautifulName(h.Name)) qw422016.E().S(util.BeautifulName(h.Name))
//line views/history.qtpl:20 //line views/history.qtpl:21
qw422016.N().S(` at `) qw422016.N().S(` at `)
//line views/history.qtpl:20 //line views/history.qtpl:21
qw422016.E().S(hash) qw422016.E().S(hash)
//line views/history.qtpl:20 //line views/history.qtpl:21
qw422016.N().S(`</h1> qw422016.N().S(`</h1>
<pre class="codeblock"><code>`) <pre class="codeblock"><code>`)
//line views/history.qtpl:21 //line views/history.qtpl:22
qw422016.E().S(text) qw422016.E().S(text)
//line views/history.qtpl:21 //line views/history.qtpl:22
qw422016.N().S(`</code></pre> qw422016.N().S(`</code></pre>
</article> </article>
</main> </main>
</div> </div>
`) `)
//line views/history.qtpl:25 //line views/history.qtpl:26
} }
//line views/history.qtpl:25 //line views/history.qtpl:26
func WritePrimitiveDiffHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) { func WritePrimitiveDiffHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) {
//line views/history.qtpl:25 //line views/history.qtpl:26
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/history.qtpl:25 //line views/history.qtpl:26
StreamPrimitiveDiffHTML(qw422016, rq, h, u, hash) StreamPrimitiveDiffHTML(qw422016, rq, h, u, hash)
//line views/history.qtpl:25 //line views/history.qtpl:26
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/history.qtpl:25 //line views/history.qtpl:26
} }
//line views/history.qtpl:25 //line views/history.qtpl:26
func PrimitiveDiffHTML(rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) string { func PrimitiveDiffHTML(rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) string {
//line views/history.qtpl:25 //line views/history.qtpl:26
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/history.qtpl:25 //line views/history.qtpl:26
WritePrimitiveDiffHTML(qb422016, rq, h, u, hash) WritePrimitiveDiffHTML(qb422016, rq, h, u, hash)
//line views/history.qtpl:25 //line views/history.qtpl:26
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/history.qtpl:25 //line views/history.qtpl:26
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/history.qtpl:25 //line views/history.qtpl:26
return qs422016 return qs422016
//line views/history.qtpl:25 //line views/history.qtpl:26
} }
//line views/history.qtpl:27 //line views/history.qtpl:28
func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) { func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) {
//line views/history.qtpl:27 //line views/history.qtpl:28
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width recent-changes"> <main class="main-width recent-changes">
@@ -111,51 +114,51 @@ func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) {
<nav class="recent-changes__count"> <nav class="recent-changes__count">
See See
`) `)
//line views/history.qtpl:34 //line views/history.qtpl:35
for _, m := range []int{20, 0, 50, 0, 100} { for _, m := range []int{20, 0, 50, 0, 100} {
//line views/history.qtpl:34 //line views/history.qtpl:35
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:35 //line views/history.qtpl:36
switch m { switch m {
//line views/history.qtpl:36 //line views/history.qtpl:37
case 0: case 0:
//line views/history.qtpl:36 //line views/history.qtpl:37
qw422016.N().S(` qw422016.N().S(`
<span aria-hidden="true">|</span> <span aria-hidden="true">|</span>
`) `)
//line views/history.qtpl:38 //line views/history.qtpl:39
case n: case n:
//line views/history.qtpl:38 //line views/history.qtpl:39
qw422016.N().S(` qw422016.N().S(`
<b>`) <b>`)
//line views/history.qtpl:39 //line views/history.qtpl:40
qw422016.N().D(n) qw422016.N().D(n)
//line views/history.qtpl:39 //line views/history.qtpl:40
qw422016.N().S(`</b> qw422016.N().S(`</b>
`) `)
//line views/history.qtpl:40 //line views/history.qtpl:41
default: default:
//line views/history.qtpl:40 //line views/history.qtpl:41
qw422016.N().S(` qw422016.N().S(`
<a href="/recent-changes/`) <a href="/recent-changes/`)
//line views/history.qtpl:41 //line views/history.qtpl:42
qw422016.N().D(m) qw422016.N().D(m)
//line views/history.qtpl:41 //line views/history.qtpl:42
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/history.qtpl:41 //line views/history.qtpl:42
qw422016.N().D(m) qw422016.N().D(m)
//line views/history.qtpl:41 //line views/history.qtpl:42
qw422016.N().S(`</a> qw422016.N().S(`</a>
`) `)
//line views/history.qtpl:42 //line views/history.qtpl:43
} }
//line views/history.qtpl:42 //line views/history.qtpl:43
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:43 //line views/history.qtpl:44
} }
//line views/history.qtpl:43 //line views/history.qtpl:44
qw422016.N().S(` qw422016.N().S(`
recent changes recent changes
</nav> </nav>
@@ -163,216 +166,216 @@ func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) {
<p><img class="icon" width="20" height="20" src="/static/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p> <p><img class="icon" width="20" height="20" src="/static/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
`) `)
//line views/history.qtpl:54 //line views/history.qtpl:55
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:57 //line views/history.qtpl:58
changes := history.RecentChanges(n) changes := history.RecentChanges(n)
//line views/history.qtpl:58 //line views/history.qtpl:59
qw422016.N().S(` qw422016.N().S(`
<section class="recent-changes__list" role="feed"> <section class="recent-changes__list" role="feed">
`) `)
//line views/history.qtpl:60 //line views/history.qtpl:61
if len(changes) == 0 { if len(changes) == 0 {
//line views/history.qtpl:60 //line views/history.qtpl:61
qw422016.N().S(` qw422016.N().S(`
<p>Could not find any recent changes.</p> <p>Could not find any recent changes.</p>
`) `)
//line views/history.qtpl:62 //line views/history.qtpl:63
} else { } else {
//line views/history.qtpl:62 //line views/history.qtpl:63
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:63 //line views/history.qtpl:64
for i, entry := range changes { for i, entry := range changes {
//line views/history.qtpl:63 //line views/history.qtpl:64
qw422016.N().S(` qw422016.N().S(`
<ul class="recent-changes__entry rc-entry" role="article" <ul class="recent-changes__entry rc-entry" role="article"
aria-setsize="`) aria-setsize="`)
//line views/history.qtpl:65 //line views/history.qtpl:66
qw422016.N().D(n) qw422016.N().D(n)
//line views/history.qtpl:65 //line views/history.qtpl:66
qw422016.N().S(`" aria-posinset="`) qw422016.N().S(`" aria-posinset="`)
//line views/history.qtpl:65 //line views/history.qtpl:66
qw422016.N().D(i) qw422016.N().D(i)
//line views/history.qtpl:65 //line views/history.qtpl:66
qw422016.N().S(`"> qw422016.N().S(`">
`) `)
//line views/history.qtpl:66 //line views/history.qtpl:67
qw422016.N().S(recentChangesEntry(entry)) qw422016.N().S(recentChangesEntry(entry))
//line views/history.qtpl:66 //line views/history.qtpl:67
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
`) `)
//line views/history.qtpl:68 //line views/history.qtpl:69
} }
//line views/history.qtpl:68 //line views/history.qtpl:69
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:69 //line views/history.qtpl:70
} }
//line views/history.qtpl:69 //line views/history.qtpl:70
qw422016.N().S(` qw422016.N().S(`
</section> </section>
</main> </main>
</div> </div>
`) `)
//line views/history.qtpl:73 //line views/history.qtpl:74
} }
//line views/history.qtpl:73 //line views/history.qtpl:74
func WriteRecentChangesHTML(qq422016 qtio422016.Writer, n int) { func WriteRecentChangesHTML(qq422016 qtio422016.Writer, n int) {
//line views/history.qtpl:73 //line views/history.qtpl:74
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/history.qtpl:73 //line views/history.qtpl:74
StreamRecentChangesHTML(qw422016, n) StreamRecentChangesHTML(qw422016, n)
//line views/history.qtpl:73 //line views/history.qtpl:74
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/history.qtpl:73 //line views/history.qtpl:74
} }
//line views/history.qtpl:73 //line views/history.qtpl:74
func RecentChangesHTML(n int) string { func RecentChangesHTML(n int) string {
//line views/history.qtpl:73 //line views/history.qtpl:74
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/history.qtpl:73 //line views/history.qtpl:74
WriteRecentChangesHTML(qb422016, n) WriteRecentChangesHTML(qb422016, n)
//line views/history.qtpl:73 //line views/history.qtpl:74
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/history.qtpl:73 //line views/history.qtpl:74
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/history.qtpl:73 //line views/history.qtpl:74
return qs422016 return qs422016
//line views/history.qtpl:73 //line views/history.qtpl:74
} }
//line views/history.qtpl:75 //line views/history.qtpl:76
func streamrecentChangesEntry(qw422016 *qt422016.Writer, rev history.Revision) { func streamrecentChangesEntry(qw422016 *qt422016.Writer, rev history.Revision) {
//line views/history.qtpl:75 //line views/history.qtpl:76
qw422016.N().S(` qw422016.N().S(`
<li class="rc-entry__time"><time>`) <li class="rc-entry__time"><time>`)
//line views/history.qtpl:76 //line views/history.qtpl:77
qw422016.E().S(rev.TimeString()) qw422016.E().S(rev.TimeString())
//line views/history.qtpl:76 //line views/history.qtpl:77
qw422016.N().S(`</time></li> qw422016.N().S(`</time></li>
<li class="rc-entry__hash">`) <li class="rc-entry__hash">`)
//line views/history.qtpl:77 //line views/history.qtpl:78
qw422016.E().S(rev.Hash) qw422016.E().S(rev.Hash)
//line views/history.qtpl:77 //line views/history.qtpl:78
qw422016.N().S(`</li> qw422016.N().S(`</li>
<li class="rc-entry__links">`) <li class="rc-entry__links">`)
//line views/history.qtpl:78 //line views/history.qtpl:79
qw422016.N().S(rev.HyphaeLinksHTML()) qw422016.N().S(rev.HyphaeLinksHTML())
//line views/history.qtpl:78 //line views/history.qtpl:79
qw422016.N().S(`</li> qw422016.N().S(`</li>
<li class="rc-entry__msg">`) <li class="rc-entry__msg">`)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.E().S(rev.Message) qw422016.E().S(rev.Message)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.N().S(` `) qw422016.N().S(` `)
//line views/history.qtpl:79 //line views/history.qtpl:80
if rev.Username != "anon" { if rev.Username != "anon" {
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.N().S(`<span class="rc-entry__author">by <a href="/hypha/`) qw422016.N().S(`<span class="rc-entry__author">by <a href="/hypha/`)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.E().S(util.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.E().S(rev.Username) qw422016.E().S(rev.Username)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.N().S(`" rel="author">`) qw422016.N().S(`" rel="author">`)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.E().S(rev.Username) qw422016.E().S(rev.Username)
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.N().S(`</a></span>`) qw422016.N().S(`</a></span>`)
//line views/history.qtpl:79 //line views/history.qtpl:80
} }
//line views/history.qtpl:79 //line views/history.qtpl:80
qw422016.N().S(`</li> qw422016.N().S(`</li>
`) `)
//line views/history.qtpl:80 //line views/history.qtpl:81
} }
//line views/history.qtpl:80 //line views/history.qtpl:81
func writerecentChangesEntry(qq422016 qtio422016.Writer, rev history.Revision) { func writerecentChangesEntry(qq422016 qtio422016.Writer, rev history.Revision) {
//line views/history.qtpl:80 //line views/history.qtpl:81
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/history.qtpl:80 //line views/history.qtpl:81
streamrecentChangesEntry(qw422016, rev) streamrecentChangesEntry(qw422016, rev)
//line views/history.qtpl:80 //line views/history.qtpl:81
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/history.qtpl:80 //line views/history.qtpl:81
} }
//line views/history.qtpl:80 //line views/history.qtpl:81
func recentChangesEntry(rev history.Revision) string { func recentChangesEntry(rev history.Revision) string {
//line views/history.qtpl:80 //line views/history.qtpl:81
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/history.qtpl:80 //line views/history.qtpl:81
writerecentChangesEntry(qb422016, rev) writerecentChangesEntry(qb422016, rev)
//line views/history.qtpl:80 //line views/history.qtpl:81
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/history.qtpl:80 //line views/history.qtpl:81
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/history.qtpl:80 //line views/history.qtpl:81
return qs422016 return qs422016
//line views/history.qtpl:80 //line views/history.qtpl:81
} }
//line views/history.qtpl:82 //line views/history.qtpl:83
func StreamHistoryHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, list string) { func StreamHistoryHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, list string) {
//line views/history.qtpl:82 //line views/history.qtpl:83
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/history.qtpl:83 //line views/history.qtpl:84
StreamNavHTML(qw422016, rq, hyphaName, "history") StreamNavHTML(qw422016, rq, hyphaName, "history")
//line views/history.qtpl:83 //line views/history.qtpl:84
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
<article class="history"> <article class="history">
<h1>History of `) <h1>History of `)
//line views/history.qtpl:87 //line views/history.qtpl:88
qw422016.E().S(util.BeautifulName(hyphaName)) qw422016.E().S(util.BeautifulName(hyphaName))
//line views/history.qtpl:87 //line views/history.qtpl:88
qw422016.N().S(`</h1> qw422016.N().S(`</h1>
`) `)
//line views/history.qtpl:88 //line views/history.qtpl:89
qw422016.N().S(list) qw422016.N().S(list)
//line views/history.qtpl:88 //line views/history.qtpl:89
qw422016.N().S(` qw422016.N().S(`
</article> </article>
</main> </main>
</div> </div>
`) `)
//line views/history.qtpl:92 //line views/history.qtpl:93
} }
//line views/history.qtpl:92 //line views/history.qtpl:93
func WriteHistoryHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, list string) { func WriteHistoryHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, list string) {
//line views/history.qtpl:92 //line views/history.qtpl:93
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/history.qtpl:92 //line views/history.qtpl:93
StreamHistoryHTML(qw422016, rq, hyphaName, list) StreamHistoryHTML(qw422016, rq, hyphaName, list)
//line views/history.qtpl:92 //line views/history.qtpl:93
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/history.qtpl:92 //line views/history.qtpl:93
} }
//line views/history.qtpl:92 //line views/history.qtpl:93
func HistoryHTML(rq *http.Request, hyphaName, list string) string { func HistoryHTML(rq *http.Request, hyphaName, list string) string {
//line views/history.qtpl:92 //line views/history.qtpl:93
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/history.qtpl:92 //line views/history.qtpl:93
WriteHistoryHTML(qb422016, rq, hyphaName, list) WriteHistoryHTML(qb422016, rq, hyphaName, list)
//line views/history.qtpl:92 //line views/history.qtpl:93
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/history.qtpl:92 //line views/history.qtpl:93
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/history.qtpl:92 //line views/history.qtpl:93
return qs422016 return qs422016
//line views/history.qtpl:92 //line views/history.qtpl:93
} }

View File

@@ -1,5 +1,6 @@
{% import "path/filepath" %} {% import "path/filepath" %}
{% import "strings" %} {% import "strings" %}
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/util" %}
@@ -12,8 +13,8 @@
%} %}
<h1 class="navi-title"> <h1 class="navi-title">
{% stripspace %} {% stripspace %}
<a href="/hypha/{%s util.HomePage %}"> <a href="/hypha/{%s cfg.HomeHypha %}">
{%-s= util.SiteNavIcon -%} {%-s= cfg.NaviTitleIcon -%}
<span aria-hidden="true" class="navi-title__colon">:</span> <span aria-hidden="true" class="navi-title__colon">:</span>
</a> </a>

View File

@@ -11,223 +11,226 @@ import "path/filepath"
import "strings" import "strings"
//line views/hypha.qtpl:3 //line views/hypha.qtpl:3
import "github.com/bouncepaw/mycorrhiza/hyphae" import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/hypha.qtpl:4 //line views/hypha.qtpl:4
import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/hypha.qtpl:5
import "github.com/bouncepaw/mycorrhiza/util" import "github.com/bouncepaw/mycorrhiza/util"
//line views/hypha.qtpl:6 //line views/hypha.qtpl:7
import ( import (
qtio422016 "io" qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate" qt422016 "github.com/valyala/quicktemplate"
) )
//line views/hypha.qtpl:6 //line views/hypha.qtpl:7
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer _ = qt422016.AcquireByteBuffer
) )
//line views/hypha.qtpl:6 //line views/hypha.qtpl:7
func StreamNaviTitleHTML(qw422016 *qt422016.Writer, h *hyphae.Hypha) { func StreamNaviTitleHTML(qw422016 *qt422016.Writer, h *hyphae.Hypha) {
//line views/hypha.qtpl:6 //line views/hypha.qtpl:7
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/hypha.qtpl:8 //line views/hypha.qtpl:9
var ( var (
prevAcc = "/hypha/" prevAcc = "/hypha/"
parts = strings.Split(h.Name, "/") parts = strings.Split(h.Name, "/")
) )
//line views/hypha.qtpl:12 //line views/hypha.qtpl:13
qw422016.N().S(` qw422016.N().S(`
<h1 class="navi-title"> <h1 class="navi-title">
`) `)
//line views/hypha.qtpl:14 //line views/hypha.qtpl:15
qw422016.N().S(`<a href="/hypha/`) qw422016.N().S(`<a href="/hypha/`)
//line views/hypha.qtpl:15 //line views/hypha.qtpl:16
qw422016.E().S(util.HomePage) qw422016.E().S(cfg.HomeHypha)
//line views/hypha.qtpl:15 //line views/hypha.qtpl:16
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/hypha.qtpl:16 //line views/hypha.qtpl:17
qw422016.N().S(util.SiteNavIcon) qw422016.N().S(cfg.NaviTitleIcon)
//line views/hypha.qtpl:16 //line views/hypha.qtpl:17
qw422016.N().S(`<span aria-hidden="true" class="navi-title__colon">:</span></a>`) qw422016.N().S(`<span aria-hidden="true" class="navi-title__colon">:</span></a>`)
//line views/hypha.qtpl:20 //line views/hypha.qtpl:21
for i, part := range parts { for i, part := range parts {
//line views/hypha.qtpl:21 //line views/hypha.qtpl:22
if i > 0 { if i > 0 {
//line views/hypha.qtpl:21 //line views/hypha.qtpl:22
qw422016.N().S(`<span aria-hidden="true" class="navi-title__separator">/</span>`) qw422016.N().S(`<span aria-hidden="true" class="navi-title__separator">/</span>`)
//line views/hypha.qtpl:23 //line views/hypha.qtpl:24
} }
//line views/hypha.qtpl:23 //line views/hypha.qtpl:24
qw422016.N().S(`<a href="`) qw422016.N().S(`<a href="`)
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
qw422016.E().S(prevAcc + part) qw422016.E().S(prevAcc + part)
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
qw422016.N().S(`" rel="`) qw422016.N().S(`" rel="`)
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
if i == len(parts)-1 { if i == len(parts)-1 {
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
qw422016.N().S(`bookmark`) qw422016.N().S(`bookmark`)
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
} else { } else {
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
qw422016.N().S(`up`) qw422016.N().S(`up`)
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
} }
//line views/hypha.qtpl:25 //line views/hypha.qtpl:26
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/hypha.qtpl:26 //line views/hypha.qtpl:27
qw422016.N().S(util.BeautifulName(part)) qw422016.N().S(util.BeautifulName(part))
//line views/hypha.qtpl:26 //line views/hypha.qtpl:27
qw422016.N().S(`</a>`) qw422016.N().S(`</a>`)
//line views/hypha.qtpl:28 //line views/hypha.qtpl:29
prevAcc += part + "/" prevAcc += part + "/"
//line views/hypha.qtpl:29
}
//line views/hypha.qtpl:30 //line views/hypha.qtpl:30
}
//line views/hypha.qtpl:31
qw422016.N().S(` qw422016.N().S(`
</h1> </h1>
`) `)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
} }
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
func WriteNaviTitleHTML(qq422016 qtio422016.Writer, h *hyphae.Hypha) { func WriteNaviTitleHTML(qq422016 qtio422016.Writer, h *hyphae.Hypha) {
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
StreamNaviTitleHTML(qw422016, h) StreamNaviTitleHTML(qw422016, h)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
} }
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
func NaviTitleHTML(h *hyphae.Hypha) string { func NaviTitleHTML(h *hyphae.Hypha) string {
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
WriteNaviTitleHTML(qb422016, h) WriteNaviTitleHTML(qb422016, h)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
return qs422016 return qs422016
//line views/hypha.qtpl:32 //line views/hypha.qtpl:33
} }
//line views/hypha.qtpl:34 //line views/hypha.qtpl:35
func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.Hypha) { func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.Hypha) {
//line views/hypha.qtpl:34 //line views/hypha.qtpl:35
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/hypha.qtpl:35 //line views/hypha.qtpl:36
switch filepath.Ext(h.BinaryPath) { switch filepath.Ext(h.BinaryPath) {
//line views/hypha.qtpl:37 //line views/hypha.qtpl:38
case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico": case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico":
//line views/hypha.qtpl:37 //line views/hypha.qtpl:38
qw422016.N().S(` qw422016.N().S(`
<div class="binary-container binary-container_with-img"> <div class="binary-container binary-container_with-img">
<a href="/binary/`) <a href="/binary/`)
//line views/hypha.qtpl:39 //line views/hypha.qtpl:40
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:39 //line views/hypha.qtpl:40
qw422016.N().S(`"><img src="/binary/`) qw422016.N().S(`"><img src="/binary/`)
//line views/hypha.qtpl:39 //line views/hypha.qtpl:40
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:39 //line views/hypha.qtpl:40
qw422016.N().S(`"/></a> qw422016.N().S(`"/></a>
</div> </div>
`) `)
//line views/hypha.qtpl:42 //line views/hypha.qtpl:43
case ".ogg", ".webm", ".mp4": case ".ogg", ".webm", ".mp4":
//line views/hypha.qtpl:42 //line views/hypha.qtpl:43
qw422016.N().S(` qw422016.N().S(`
<div class="binary-container binary-container_with-video"> <div class="binary-container binary-container_with-video">
<video controls> <video controls>
<source src="/binary/`) <source src="/binary/`)
//line views/hypha.qtpl:45 //line views/hypha.qtpl:46
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:45 //line views/hypha.qtpl:46
qw422016.N().S(`"/> qw422016.N().S(`"/>
<p>Your browser does not support video. <a href="/binary/`) <p>Your browser does not support video. <a href="/binary/`)
//line views/hypha.qtpl:46 //line views/hypha.qtpl:47
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:46 //line views/hypha.qtpl:47
qw422016.N().S(`">Download video</a></p> qw422016.N().S(`">Download video</a></p>
</video> </video>
</div> </div>
`) `)
//line views/hypha.qtpl:50 //line views/hypha.qtpl:51
case ".mp3": case ".mp3":
//line views/hypha.qtpl:50 //line views/hypha.qtpl:51
qw422016.N().S(` qw422016.N().S(`
<div class="binary-container binary-container_with-audio"> <div class="binary-container binary-container_with-audio">
<audio controls> <audio controls>
<source src="/binary/`) <source src="/binary/`)
//line views/hypha.qtpl:53 //line views/hypha.qtpl:54
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:53 //line views/hypha.qtpl:54
qw422016.N().S(`"/> qw422016.N().S(`"/>
<p>Your browser does not support audio. <a href="/binary/`) <p>Your browser does not support audio. <a href="/binary/`)
//line views/hypha.qtpl:54 //line views/hypha.qtpl:55
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:54 //line views/hypha.qtpl:55
qw422016.N().S(`">Download audio</a></p> qw422016.N().S(`">Download audio</a></p>
</audio> </audio>
</div> </div>
`) `)
//line views/hypha.qtpl:58 //line views/hypha.qtpl:59
default: default:
//line views/hypha.qtpl:58 //line views/hypha.qtpl:59
qw422016.N().S(` qw422016.N().S(`
<div class="binary-container binary-container_with-nothing"> <div class="binary-container binary-container_with-nothing">
<p><a href="/binary/`) <p><a href="/binary/`)
//line views/hypha.qtpl:60 //line views/hypha.qtpl:61
qw422016.N().S(h.Name) qw422016.N().S(h.Name)
//line views/hypha.qtpl:60 //line views/hypha.qtpl:61
qw422016.N().S(`">Download media</a></p> qw422016.N().S(`">Download media</a></p>
</div> </div>
`) `)
//line views/hypha.qtpl:62 //line views/hypha.qtpl:63
} }
//line views/hypha.qtpl:62 //line views/hypha.qtpl:63
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
} }
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.Hypha) { func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.Hypha) {
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
StreamAttachmentHTML(qw422016, h) StreamAttachmentHTML(qw422016, h)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
} }
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
func AttachmentHTML(h *hyphae.Hypha) string { func AttachmentHTML(h *hyphae.Hypha) string {
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
WriteAttachmentHTML(qb422016, h) WriteAttachmentHTML(qb422016, h)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
return qs422016 return qs422016
//line views/hypha.qtpl:63 //line views/hypha.qtpl:64
} }

View File

@@ -1,7 +1,7 @@
{% import "net/http" %} {% import "net/http" %}
{% import "strings" %} {% import "strings" %}
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
This is the <nav> seen on top of many pages. This is the <nav> seen on top of many pages.
{% code {% code
@@ -52,7 +52,7 @@ var navEntries = []navEntry{
{% if u.Group == "anon" %} {% if u.Group == "anon" %}
<a href="/login" class="header-links__link">Login</a> <a href="/login" class="header-links__link">Login</a>
{% else %} {% else %}
<a href="/hypha/{%s util.UserHypha %}/{%s u.Name %}" class="header-links__link">{%s u.Name %}</a> <a href="/hypha/{%s cfg.UserHypha %}/{%s u.Name %}" class="header-links__link">{%s u.Name %}</a>
{% endif %} {% endif %}
</li> </li>
{% endif %} {% endif %}

View File

@@ -11,10 +11,10 @@ import "net/http"
import "strings" import "strings"
//line views/nav.qtpl:3 //line views/nav.qtpl:3
import "github.com/bouncepaw/mycorrhiza/user" import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/nav.qtpl:4 //line views/nav.qtpl:4
import "github.com/bouncepaw/mycorrhiza/util" import "github.com/bouncepaw/mycorrhiza/user"
// This is the <nav> seen on top of many pages. // This is the <nav> seen on top of many pages.
@@ -164,7 +164,7 @@ func StreamUserMenuHTML(qw422016 *qt422016.Writer, u *user.User) {
qw422016.N().S(` qw422016.N().S(`
<a href="/hypha/`) <a href="/hypha/`)
//line views/nav.qtpl:55 //line views/nav.qtpl:55
qw422016.E().S(util.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/nav.qtpl:55 //line views/nav.qtpl:55
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/nav.qtpl:55 //line views/nav.qtpl:55

View File

@@ -1,4 +1,5 @@
{% import "path/filepath" %} {% import "path/filepath" %}
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/util" %}
@@ -53,19 +54,19 @@ for u := range user.YieldUsers() {
<section> <section>
<h2>Admins</h2> <h2>Admins</h2>
<ol>{% for _, name := range admins %} <ol>{% for _, name := range admins %}
<li><a href="/page/{%s util.UserHypha %}/{%s name %}">{%s name %}</a></li> <li><a href="/page/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol> {% endfor %}</ol>
</section> </section>
<section> <section>
<h2>Moderators</h2> <h2>Moderators</h2>
<ol>{% for _, name := range moderators %} <ol>{% for _, name := range moderators %}
<li><a href="/page/{%s util.UserHypha %}/{%s name %}">{%s name %}</a></li> <li><a href="/page/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol> {% endfor %}</ol>
</section> </section>
<section> <section>
<h2>Editors</h2> <h2>Editors</h2>
<ol>{% for _, name := range editors %} <ol>{% for _, name := range editors %}
<li><a href="/page/{%s util.UserHypha %}/{%s name %}">{%s name %}</a></li> <li><a href="/page/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol> {% endfor %}</ol>
</section> </section>
</main> </main>
@@ -95,16 +96,16 @@ for u := range user.YieldUsers() {
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
<section> <section>
<h1>About {%s util.SiteName %}</h1> <h1>About {%s cfg.WikiName %}</h1>
<ul> <ul>
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.2.0 indev</li> <li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.2.0 indev</li>
{%- if user.AuthUsed -%} {%- if user.AuthUsed -%}
<li><b>User count:</b> {%d user.Count() %}</li> <li><b>User count:</b> {%d user.Count() %}</li>
<li><b>Home page:</b> <a href="/">{%s util.HomePage %}</a></li> <li><b>Home page:</b> <a href="/">{%s cfg.HomeHypha %}</a></li>
<li><b>Administrators:</b> {%- for i, username := range user.ListUsersWithGroup("admin") -%} <li><b>Administrators:</b> {%- for i, username := range user.ListUsersWithGroup("admin") -%}
{%- if i > 0 -%}<span aria-hidden="true">, </span> {%- if i > 0 -%}<span aria-hidden="true">, </span>
{%- endif -%} {%- endif -%}
<a href="/page/{%s util.UserHypha %}/{%s username %}">{%s username %}</a>{%- endfor -%}</li> <a href="/page/{%s cfg.UserHypha %}/{%s username %}">{%s username %}</a>{%- endfor -%}</li>
{%- else -%} {%- else -%}
<li>This wiki does not use authorization</li> <li>This wiki does not use authorization</li>
{%- endif -%} {%- endif -%}

View File

@@ -8,30 +8,33 @@ package views
import "path/filepath" import "path/filepath"
//line views/stuff.qtpl:2 //line views/stuff.qtpl:2
import "github.com/bouncepaw/mycorrhiza/hyphae" import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/stuff.qtpl:3 //line views/stuff.qtpl:3
import "github.com/bouncepaw/mycorrhiza/user" import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/stuff.qtpl:4 //line views/stuff.qtpl:4
import "github.com/bouncepaw/mycorrhiza/user"
//line views/stuff.qtpl:5
import "github.com/bouncepaw/mycorrhiza/util" import "github.com/bouncepaw/mycorrhiza/util"
//line views/stuff.qtpl:6 //line views/stuff.qtpl:7
import ( import (
qtio422016 "io" qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate" qt422016 "github.com/valyala/quicktemplate"
) )
//line views/stuff.qtpl:6 //line views/stuff.qtpl:7
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer _ = qt422016.AcquireByteBuffer
) )
//line views/stuff.qtpl:6 //line views/stuff.qtpl:7
func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, headElements ...string) { func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, headElements ...string) {
//line views/stuff.qtpl:6 //line views/stuff.qtpl:7
qw422016.N().S(` qw422016.N().S(`
<!doctype html> <!doctype html>
<html> <html>
@@ -40,18 +43,18 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User,
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/static/common.css"> <link rel="stylesheet" type="text/css" href="/static/common.css">
<title>`) <title>`)
//line views/stuff.qtpl:13 //line views/stuff.qtpl:14
qw422016.E().S(title) qw422016.E().S(title)
//line views/stuff.qtpl:13 //line views/stuff.qtpl:14
qw422016.N().S(`</title> qw422016.N().S(`</title>
`) `)
//line views/stuff.qtpl:14 //line views/stuff.qtpl:15
for _, el := range headElements { for _, el := range headElements {
//line views/stuff.qtpl:14 //line views/stuff.qtpl:15
qw422016.N().S(el) qw422016.N().S(el)
//line views/stuff.qtpl:14 //line views/stuff.qtpl:15
} }
//line views/stuff.qtpl:14 //line views/stuff.qtpl:15
qw422016.N().S(` qw422016.N().S(`
</head> </head>
<body> <body>
@@ -59,76 +62,76 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User,
<nav class="header-links main-width"> <nav class="header-links main-width">
<ul class="header-links__list"> <ul class="header-links__list">
`) `)
//line views/stuff.qtpl:20 //line views/stuff.qtpl:21
for _, link := range util.HeaderLinks { for _, link := range util.HeaderLinks {
//line views/stuff.qtpl:20 //line views/stuff.qtpl:21
qw422016.N().S(` <li class="header-links__entry"><a class="header-links__link" href="`) qw422016.N().S(` <li class="header-links__entry"><a class="header-links__link" href="`)
//line views/stuff.qtpl:21 //line views/stuff.qtpl:22
qw422016.E().S(link.Href) qw422016.E().S(link.Href)
//line views/stuff.qtpl:21 //line views/stuff.qtpl:22
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:21 //line views/stuff.qtpl:22
qw422016.E().S(link.Display) qw422016.E().S(link.Display)
//line views/stuff.qtpl:21 //line views/stuff.qtpl:22
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:22 //line views/stuff.qtpl:23
} }
//line views/stuff.qtpl:22 //line views/stuff.qtpl:23
qw422016.N().S(` `) qw422016.N().S(` `)
//line views/stuff.qtpl:23 //line views/stuff.qtpl:24
qw422016.N().S(UserMenuHTML(u)) qw422016.N().S(UserMenuHTML(u))
//line views/stuff.qtpl:23 //line views/stuff.qtpl:24
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
</nav> </nav>
</header> </header>
`) `)
//line views/stuff.qtpl:27 //line views/stuff.qtpl:28
qw422016.N().S(body) qw422016.N().S(body)
//line views/stuff.qtpl:27 //line views/stuff.qtpl:28
qw422016.N().S(` qw422016.N().S(`
</body> </body>
</html> </html>
`) `)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
} }
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, u *user.User, headElements ...string) { func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, u *user.User, headElements ...string) {
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
StreamBaseHTML(qw422016, title, body, u, headElements...) StreamBaseHTML(qw422016, title, body, u, headElements...)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
} }
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
func BaseHTML(title, body string, u *user.User, headElements ...string) string { func BaseHTML(title, body string, u *user.User, headElements ...string) string {
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
WriteBaseHTML(qb422016, title, body, u, headElements...) WriteBaseHTML(qb422016, title, body, u, headElements...)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
return qs422016 return qs422016
//line views/stuff.qtpl:30 //line views/stuff.qtpl:31
} }
//line views/stuff.qtpl:32 //line views/stuff.qtpl:33
func StreamUserListHTML(qw422016 *qt422016.Writer) { func StreamUserListHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:32 //line views/stuff.qtpl:33
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width user-list"> <main class="main-width user-list">
<h1>List of users</h1> <h1>List of users</h1>
`) `)
//line views/stuff.qtpl:37 //line views/stuff.qtpl:38
var ( var (
admins = make([]string, 0) admins = make([]string, 0)
moderators = make([]string, 0) moderators = make([]string, 0)
@@ -145,303 +148,303 @@ func StreamUserListHTML(qw422016 *qt422016.Writer) {
} }
} }
//line views/stuff.qtpl:52 //line views/stuff.qtpl:53
qw422016.N().S(` qw422016.N().S(`
<section> <section>
<h2>Admins</h2> <h2>Admins</h2>
<ol>`) <ol>`)
//line views/stuff.qtpl:55 //line views/stuff.qtpl:56
for _, name := range admins { for _, name := range admins {
//line views/stuff.qtpl:55 //line views/stuff.qtpl:56
qw422016.N().S(` qw422016.N().S(`
<li><a href="/page/`) <li><a href="/page/`)
//line views/stuff.qtpl:56 //line views/stuff.qtpl:57
qw422016.E().S(util.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:56 //line views/stuff.qtpl:57
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:56 //line views/stuff.qtpl:57
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:56 //line views/stuff.qtpl:57
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:56 //line views/stuff.qtpl:57
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:56 //line views/stuff.qtpl:57
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:57 //line views/stuff.qtpl:58
} }
//line views/stuff.qtpl:57 //line views/stuff.qtpl:58
qw422016.N().S(`</ol> qw422016.N().S(`</ol>
</section> </section>
<section> <section>
<h2>Moderators</h2> <h2>Moderators</h2>
<ol>`) <ol>`)
//line views/stuff.qtpl:61 //line views/stuff.qtpl:62
for _, name := range moderators { for _, name := range moderators {
//line views/stuff.qtpl:61 //line views/stuff.qtpl:62
qw422016.N().S(` qw422016.N().S(`
<li><a href="/page/`) <li><a href="/page/`)
//line views/stuff.qtpl:62 //line views/stuff.qtpl:63
qw422016.E().S(util.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:62 //line views/stuff.qtpl:63
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:62 //line views/stuff.qtpl:63
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:62 //line views/stuff.qtpl:63
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:62 //line views/stuff.qtpl:63
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:62 //line views/stuff.qtpl:63
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:63 //line views/stuff.qtpl:64
} }
//line views/stuff.qtpl:63 //line views/stuff.qtpl:64
qw422016.N().S(`</ol> qw422016.N().S(`</ol>
</section> </section>
<section> <section>
<h2>Editors</h2> <h2>Editors</h2>
<ol>`) <ol>`)
//line views/stuff.qtpl:67 //line views/stuff.qtpl:68
for _, name := range editors { for _, name := range editors {
//line views/stuff.qtpl:67 //line views/stuff.qtpl:68
qw422016.N().S(` qw422016.N().S(`
<li><a href="/page/`) <li><a href="/page/`)
//line views/stuff.qtpl:68 //line views/stuff.qtpl:69
qw422016.E().S(util.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:68 //line views/stuff.qtpl:69
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:68 //line views/stuff.qtpl:69
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:68 //line views/stuff.qtpl:69
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:68 //line views/stuff.qtpl:69
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:68 //line views/stuff.qtpl:69
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:69 //line views/stuff.qtpl:70
} }
//line views/stuff.qtpl:69 //line views/stuff.qtpl:70
qw422016.N().S(`</ol> qw422016.N().S(`</ol>
</section> </section>
</main> </main>
</div> </div>
`) `)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
} }
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
func WriteUserListHTML(qq422016 qtio422016.Writer) { func WriteUserListHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
StreamUserListHTML(qw422016) StreamUserListHTML(qw422016)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
} }
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
func UserListHTML() string { func UserListHTML() string {
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
WriteUserListHTML(qb422016) WriteUserListHTML(qb422016)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
return qs422016 return qs422016
//line views/stuff.qtpl:73 //line views/stuff.qtpl:74
} }
//line views/stuff.qtpl:75 //line views/stuff.qtpl:76
func StreamHyphaListHTML(qw422016 *qt422016.Writer) { func StreamHyphaListHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:75 //line views/stuff.qtpl:76
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
<h1>List of hyphae</h1> <h1>List of hyphae</h1>
<p>This wiki has `) <p>This wiki has `)
//line views/stuff.qtpl:79 //line views/stuff.qtpl:80
qw422016.N().D(hyphae.Count()) qw422016.N().D(hyphae.Count())
//line views/stuff.qtpl:79 //line views/stuff.qtpl:80
qw422016.N().S(` hyphae.</p> qw422016.N().S(` hyphae.</p>
<ul class="hypha-list"> <ul class="hypha-list">
`) `)
//line views/stuff.qtpl:81 //line views/stuff.qtpl:82
for h := range hyphae.YieldExistingHyphae() { for h := range hyphae.YieldExistingHyphae() {
//line views/stuff.qtpl:81 //line views/stuff.qtpl:82
qw422016.N().S(` qw422016.N().S(`
<li class="hypha-list__entry"> <li class="hypha-list__entry">
<a class="hypha-list__link" href="/hypha/`) <a class="hypha-list__link" href="/hypha/`)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:84
qw422016.E().S(h.Name) qw422016.E().S(h.Name)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:84
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:84
qw422016.E().S(util.BeautifulName(h.Name)) qw422016.E().S(util.BeautifulName(h.Name))
//line views/stuff.qtpl:83 //line views/stuff.qtpl:84
qw422016.N().S(`</a> qw422016.N().S(`</a>
`) `)
//line views/stuff.qtpl:84 //line views/stuff.qtpl:85
if h.BinaryPath != "" { if h.BinaryPath != "" {
//line views/stuff.qtpl:84 //line views/stuff.qtpl:85
qw422016.N().S(` qw422016.N().S(`
<span class="hypha-list__amnt-type">`) <span class="hypha-list__amnt-type">`)
//line views/stuff.qtpl:85 //line views/stuff.qtpl:86
qw422016.E().S(filepath.Ext(h.BinaryPath)[1:]) qw422016.E().S(filepath.Ext(h.BinaryPath)[1:])
//line views/stuff.qtpl:85 //line views/stuff.qtpl:86
qw422016.N().S(`</span> qw422016.N().S(`</span>
`) `)
//line views/stuff.qtpl:86 //line views/stuff.qtpl:87
} }
//line views/stuff.qtpl:86 //line views/stuff.qtpl:87
qw422016.N().S(` qw422016.N().S(`
</li> </li>
`) `)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:89
} }
//line views/stuff.qtpl:88 //line views/stuff.qtpl:89
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
</main> </main>
</div> </div>
`) `)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
} }
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
func WriteHyphaListHTML(qq422016 qtio422016.Writer) { func WriteHyphaListHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
StreamHyphaListHTML(qw422016) StreamHyphaListHTML(qw422016)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
} }
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
func HyphaListHTML() string { func HyphaListHTML() string {
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
WriteHyphaListHTML(qb422016) WriteHyphaListHTML(qb422016)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
return qs422016 return qs422016
//line views/stuff.qtpl:92 //line views/stuff.qtpl:93
} }
//line views/stuff.qtpl:94 //line views/stuff.qtpl:95
func StreamAboutHTML(qw422016 *qt422016.Writer) { func StreamAboutHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:94 //line views/stuff.qtpl:95
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
<section> <section>
<h1>About `) <h1>About `)
//line views/stuff.qtpl:98 //line views/stuff.qtpl:99
qw422016.E().S(util.SiteName) qw422016.E().S(cfg.WikiName)
//line views/stuff.qtpl:98 //line views/stuff.qtpl:99
qw422016.N().S(`</h1> qw422016.N().S(`</h1>
<ul> <ul>
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.2.0 indev</li> <li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.2.0 indev</li>
`) `)
//line views/stuff.qtpl:101 //line views/stuff.qtpl:102
if user.AuthUsed { if user.AuthUsed {
//line views/stuff.qtpl:101 //line views/stuff.qtpl:102
qw422016.N().S(` <li><b>User count:</b> `) qw422016.N().S(` <li><b>User count:</b> `)
//line views/stuff.qtpl:102 //line views/stuff.qtpl:103
qw422016.N().D(user.Count()) qw422016.N().D(user.Count())
//line views/stuff.qtpl:102 //line views/stuff.qtpl:103
qw422016.N().S(`</li> qw422016.N().S(`</li>
<li><b>Home page:</b> <a href="/">`) <li><b>Home page:</b> <a href="/">`)
//line views/stuff.qtpl:103 //line views/stuff.qtpl:104
qw422016.E().S(util.HomePage) qw422016.E().S(cfg.HomeHypha)
//line views/stuff.qtpl:103 //line views/stuff.qtpl:104
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
<li><b>Administrators:</b>`) <li><b>Administrators:</b>`)
//line views/stuff.qtpl:104 //line views/stuff.qtpl:105
for i, username := range user.ListUsersWithGroup("admin") { for i, username := range user.ListUsersWithGroup("admin") {
//line views/stuff.qtpl:105 //line views/stuff.qtpl:106
if i > 0 { if i > 0 {
//line views/stuff.qtpl:105 //line views/stuff.qtpl:106
qw422016.N().S(`<span aria-hidden="true">, </span> qw422016.N().S(`<span aria-hidden="true">, </span>
`) `)
//line views/stuff.qtpl:106 //line views/stuff.qtpl:107
} }
//line views/stuff.qtpl:106 //line views/stuff.qtpl:107
qw422016.N().S(` <a href="/page/`) qw422016.N().S(` <a href="/page/`)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.E().S(util.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.E().S(username) qw422016.E().S(username)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.E().S(username) qw422016.E().S(username)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.N().S(`</a>`) qw422016.N().S(`</a>`)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
} }
//line views/stuff.qtpl:107 //line views/stuff.qtpl:108
qw422016.N().S(`</li> qw422016.N().S(`</li>
`) `)
//line views/stuff.qtpl:108 //line views/stuff.qtpl:109
} else { } else {
//line views/stuff.qtpl:108 //line views/stuff.qtpl:109
qw422016.N().S(` <li>This wiki does not use authorization</li> qw422016.N().S(` <li>This wiki does not use authorization</li>
`) `)
//line views/stuff.qtpl:110 //line views/stuff.qtpl:111
} }
//line views/stuff.qtpl:110 //line views/stuff.qtpl:111
qw422016.N().S(` </ul> qw422016.N().S(` </ul>
<p>See <a href="/list">/list</a> for information about hyphae on this wiki.</p> <p>See <a href="/list">/list</a> for information about hyphae on this wiki.</p>
</section> </section>
</main> </main>
</div> </div>
`) `)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
} }
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
func WriteAboutHTML(qq422016 qtio422016.Writer) { func WriteAboutHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
StreamAboutHTML(qw422016) StreamAboutHTML(qw422016)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
} }
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
func AboutHTML() string { func AboutHTML() string {
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
WriteAboutHTML(qb422016) WriteAboutHTML(qb422016)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
return qs422016 return qs422016
//line views/stuff.qtpl:116 //line views/stuff.qtpl:117
} }
//line views/stuff.qtpl:118 //line views/stuff.qtpl:119
func StreamAdminPanelHTML(qw422016 *qt422016.Writer) { func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:118 //line views/stuff.qtpl:119
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width">
@@ -478,31 +481,31 @@ func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
</main> </main>
</div> </div>
`) `)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
} }
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
func WriteAdminPanelHTML(qq422016 qtio422016.Writer) { func WriteAdminPanelHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
StreamAdminPanelHTML(qw422016) StreamAdminPanelHTML(qw422016)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
} }
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
func AdminPanelHTML() string { func AdminPanelHTML() string {
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
WriteAdminPanelHTML(qb422016) WriteAdminPanelHTML(qb422016)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
return qs422016 return qs422016
//line views/stuff.qtpl:153 //line views/stuff.qtpl:154
} }