mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-30 23:23:04 +00:00 
			
		
		
		
	Add header links
This commit is contained in:
		
							
								
								
									
										11
									
								
								flag.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								flag.go
									
									
									
									
									
								
							| @@ -18,6 +18,7 @@ func init() { | ||||
| 	flag.StringVar(&util.UserHypha, "user-hypha", "u", "Hypha which is a superhypha of all user pages") | ||||
| 	flag.StringVar(&util.AuthMethod, "auth-method", "none", "What auth method to use. Variants: \"none\", \"fixed\"") | ||||
| 	flag.StringVar(&util.FixedCredentialsPath, "fixed-credentials-path", "mycocredentials.json", "Used when -auth-method=fixed. Path to file with user credentials.") | ||||
| 	flag.StringVar(&util.HeaderLinksHypha, "header-links-hypha", "", "Optional hypha that overrides the header links") | ||||
| } | ||||
|  | ||||
| // Do the things related to cli args and die maybe | ||||
| @@ -40,13 +41,9 @@ func parseCliArgs() { | ||||
| 		util.URL = "http://0.0.0.0:" + util.ServerPort | ||||
| 	} | ||||
|  | ||||
| 	if !isCanonicalName(util.HomePage) { | ||||
| 		log.Fatal("Error: you must use a proper name for the homepage") | ||||
| 	} | ||||
|  | ||||
| 	if !isCanonicalName(util.UserHypha) { | ||||
| 		log.Fatal("Error: you must use a proper name for user hypha") | ||||
| 	} | ||||
| 	util.HomePage = CanonicalName(util.HomePage) | ||||
| 	util.UserHypha = CanonicalName(util.UserHypha) | ||||
| 	util.HeaderLinksHypha = CanonicalName(util.HeaderLinksHypha) | ||||
|  | ||||
| 	switch util.AuthMethod { | ||||
| 	case "none": | ||||
|   | ||||
							
								
								
									
										14
									
								
								hypha.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								hypha.go
									
									
									
									
									
								
							| @@ -313,3 +313,17 @@ func FetchTextPart(d *HyphaData) (string, error) { | ||||
| 	} | ||||
| 	return string(text), nil | ||||
| } | ||||
|  | ||||
| func setHeaderLinks() { | ||||
| 	if userLinksHypha, ok := GetHyphaData(util.HeaderLinksHypha); !ok { | ||||
| 		util.SetDefaultHeaderLinks() | ||||
| 	} else { | ||||
| 		contents, err := ioutil.ReadFile(userLinksHypha.textPath) | ||||
| 		if err != nil || len(contents) == 0 { | ||||
| 			util.SetDefaultHeaderLinks() | ||||
| 		} else { | ||||
| 			text := string(contents) | ||||
| 			util.ParseHeaderLinks(text, markup.Rocketlink) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										16
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								main.go
									
									
									
									
									
								
							| @@ -75,6 +75,19 @@ func handlerReindex(w http.ResponseWriter, rq *http.Request) { | ||||
| 	log.Println("Start indexing hyphae...") | ||||
| 	Index(WikiDir) | ||||
| 	log.Println("Indexed", hyphae.Count(), "hyphae") | ||||
| 	http.Redirect(w, rq, "/", http.StatusSeeOther) | ||||
| } | ||||
|  | ||||
| // Update header links by reading the configured hypha, if there is any, or resorting to default values. | ||||
| func handlerUpdateHeaderLinks(w http.ResponseWriter, rq *http.Request) { | ||||
| 	log.Println(rq.URL) | ||||
| 	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.") | ||||
| 		log.Println("Rejected", rq.URL) | ||||
| 		return | ||||
| 	} | ||||
| 	setHeaderLinks() | ||||
| 	http.Redirect(w, rq, "/", http.StatusSeeOther) | ||||
| } | ||||
|  | ||||
| // Redirect to a random hypha. | ||||
| @@ -153,11 +166,11 @@ func main() { | ||||
| 		log.Fatal(err) | ||||
| 	} | ||||
| 	log.Println("Wiki storage directory is", WikiDir) | ||||
| 	log.Println("Start indexing hyphae...") | ||||
| 	Index(WikiDir) | ||||
| 	log.Println("Indexed", hyphae.Count(), "hyphae") | ||||
|  | ||||
| 	history.Start(WikiDir) | ||||
| 	setHeaderLinks() | ||||
|  | ||||
| 	// See http_readers.go for /page/, /text/, /binary/ | ||||
| 	// See http_mutators.go for /upload-binary/, /upload-text/, /edit/, /delete-ask/, /delete-confirm/, /rename-ask/, /rename-confirm/, /unattach-ask/, /unattach-confirm/ | ||||
| @@ -165,6 +178,7 @@ func main() { | ||||
| 	// See http_history.go for /history/, /recent-changes | ||||
| 	http.HandleFunc("/list", handlerList) | ||||
| 	http.HandleFunc("/reindex", handlerReindex) | ||||
| 	http.HandleFunc("/update-header-links", handlerUpdateHeaderLinks) | ||||
| 	http.HandleFunc("/random", handlerRandom) | ||||
| 	http.HandleFunc("/about", handlerAbout) | ||||
| 	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(WikiDir+"/static")))) | ||||
|   | ||||
| @@ -27,13 +27,18 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) { | ||||
| @media screen and (min-width: 800px) { | ||||
| 	main { padding:1rem 2rem; margin: 0 auto; width: 800px; } | ||||
| 	.hypha-tabs { padding: 1rem 2rem; margin: 0 auto; width: 800px; } | ||||
| 	header { margin: 0 auto; width: 800px; } | ||||
| 	.header-links__entry { margin-right: 1.5rem; } | ||||
| 	.header-links__entry:nth-of-type(1), | ||||
| 	.hypha-tabs__tab:nth-of-type(1) { margin-left: 2rem; } | ||||
| 	.hypha-tabs__tab { margin-right: 1.5rem; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2); border-bottom: 2px #ddd solid; padding: 0 .5rem; } | ||||
| } | ||||
| @media screen and (max-width: 800px) { | ||||
| 	main { padding: 1rem; margin: 0; width: 100%; } | ||||
| 	.hypha-tabs { padding: 1rem; margin: 0; width: 100%; } | ||||
| 	.hypha-tabs{ padding: 1rem; margin: 0; width: 100%; } | ||||
| 	.hypha-tabs__tab { box-shadow: none; margin-right: .5rem; padding: .25rem .5rem; } | ||||
| 	header { width: 100%; } | ||||
| 	.header-links__entry { margin-right: .5rem; } | ||||
| } | ||||
| *, *::before, *::after {box-sizing: border-box;} | ||||
| html { height:100%; padding:0; } | ||||
| @@ -88,9 +93,11 @@ figcaption { padding-bottom: .5rem; } | ||||
|  | ||||
| #new-name {width:100%;} | ||||
|  | ||||
| header { margin-bottom: .5rem; } | ||||
| .header-links__link { text-decoration: none; display: block; width: 100%; height: 100%; padding: .25rem; } | ||||
| .hypha-tabs { padding: 0; } | ||||
| .hypha-tabs__flex { margin: 0; padding: 0; display: flex; flex-wrap: wrap; } | ||||
| .hypha-tabs__tab { list-style-type: none; } | ||||
| .header-links__list, .hypha-tabs__flex { margin: 0; padding: 0; display: flex; flex-wrap: wrap; } | ||||
| .header-links__entry, .hypha-tabs__tab { list-style-type: none; } | ||||
| .hypha-tabs__tab a { text-decoration: none; } | ||||
| .hypha-tabs__tab_active { font-weight: bold; } | ||||
| .hypha-tabs__user { font-style:italic; } | ||||
| @@ -137,6 +144,9 @@ table { background-color: #eee; } | ||||
| html { background-color: #ddd;  | ||||
| background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23bbbbbb' fill-opacity='0.4'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); | ||||
| } /* heropatterns.com */ | ||||
| header { background-color: #bbb; } | ||||
| .header-links__link { color: black; } | ||||
| .header-links__link:hover { background-color: #eee; } | ||||
|  | ||||
| main, .hypha-tabs__tab { background-color: white; } | ||||
| .hypha-tabs__tab { clip-path: inset(-20px -20px 0 -20px); } | ||||
| @@ -155,12 +165,15 @@ td { border: #ddd 1px solid; } | ||||
| /* Dark theme! */ | ||||
| @media (prefers-color-scheme: dark) { | ||||
| html { background: #222; color: #ddd; } | ||||
| main,  article, .hypha-tabs__tab { background-color: #343434; } | ||||
| main,  article, .hypha-tabs__tab, header { background-color: #343434; color: #ddd; } | ||||
|  | ||||
| a, .wikilink_external { color: #f1fa8c; } | ||||
| a:visited, .wikilink_external:visited { color: #ffb86c; } | ||||
| .wikilink_new, .wikilink_new:visited { color: #dd4444; } | ||||
|  | ||||
| .header-links__link, .header-links__link:visited, | ||||
| .prevnext__el, .prevnext__el:visited { color: #ddd; } | ||||
| .header-links__link:hover { background-color: #444; } | ||||
|  | ||||
| .hypha-tabs__tab a, .hypha-tabs__tab { color: #ddd; background-color: #232323; border: 0; } | ||||
| .hypha-tabs__tab_active { background-color: #343434; } | ||||
|   | ||||
| @@ -2,13 +2,18 @@ | ||||
| @media screen and (min-width: 800px) { | ||||
| 	main { padding:1rem 2rem; margin: 0 auto; width: 800px; } | ||||
| 	.hypha-tabs { padding: 1rem 2rem; margin: 0 auto; width: 800px; } | ||||
| 	header { margin: 0 auto; width: 800px; } | ||||
| 	.header-links__entry { margin-right: 1.5rem; } | ||||
| 	.header-links__entry:nth-of-type(1), | ||||
| 	.hypha-tabs__tab:nth-of-type(1) { margin-left: 2rem; } | ||||
| 	.hypha-tabs__tab { margin-right: 1.5rem; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2); border-bottom: 2px #ddd solid; padding: 0 .5rem; } | ||||
| } | ||||
| @media screen and (max-width: 800px) { | ||||
| 	main { padding: 1rem; margin: 0; width: 100%; } | ||||
| 	.hypha-tabs { padding: 1rem; margin: 0; width: 100%; } | ||||
| 	.hypha-tabs{ padding: 1rem; margin: 0; width: 100%; } | ||||
| 	.hypha-tabs__tab { box-shadow: none; margin-right: .5rem; padding: .25rem .5rem; } | ||||
| 	header { width: 100%; } | ||||
| 	.header-links__entry { margin-right: .5rem; } | ||||
| } | ||||
| *, *::before, *::after {box-sizing: border-box;} | ||||
| html { height:100%; padding:0; } | ||||
| @@ -63,9 +68,11 @@ figcaption { padding-bottom: .5rem; } | ||||
|  | ||||
| #new-name {width:100%;} | ||||
|  | ||||
| header { margin-bottom: .5rem; } | ||||
| .header-links__link { text-decoration: none; display: block; width: 100%; height: 100%; padding: .25rem; } | ||||
| .hypha-tabs { padding: 0; } | ||||
| .hypha-tabs__flex { margin: 0; padding: 0; display: flex; flex-wrap: wrap; } | ||||
| .hypha-tabs__tab { list-style-type: none; } | ||||
| .header-links__list, .hypha-tabs__flex { margin: 0; padding: 0; display: flex; flex-wrap: wrap; } | ||||
| .header-links__entry, .hypha-tabs__tab { list-style-type: none; } | ||||
| .hypha-tabs__tab a { text-decoration: none; } | ||||
| .hypha-tabs__tab_active { font-weight: bold; } | ||||
| .hypha-tabs__user { font-style:italic; } | ||||
| @@ -112,6 +119,9 @@ table { background-color: #eee; } | ||||
| html { background-color: #ddd;  | ||||
| background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23bbbbbb' fill-opacity='0.4'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); | ||||
| } /* heropatterns.com */ | ||||
| header { background-color: #bbb; } | ||||
| .header-links__link { color: black; } | ||||
| .header-links__link:hover { background-color: #eee; } | ||||
|  | ||||
| main, .hypha-tabs__tab { background-color: white; } | ||||
| .hypha-tabs__tab { clip-path: inset(-20px -20px 0 -20px); } | ||||
| @@ -130,12 +140,15 @@ td { border: #ddd 1px solid; } | ||||
| /* Dark theme! */ | ||||
| @media (prefers-color-scheme: dark) { | ||||
| html { background: #222; color: #ddd; } | ||||
| main,  article, .hypha-tabs__tab { background-color: #343434; } | ||||
| main,  article, .hypha-tabs__tab, header { background-color: #343434; color: #ddd; } | ||||
|  | ||||
| a, .wikilink_external { color: #f1fa8c; } | ||||
| a:visited, .wikilink_external:visited { color: #ffb86c; } | ||||
| .wikilink_new, .wikilink_new:visited { color: #dd4444; } | ||||
|  | ||||
| .header-links__link, .header-links__link:visited, | ||||
| .prevnext__el, .prevnext__el:visited { color: #ddd; } | ||||
| .header-links__link:hover { background-color: #444; } | ||||
|  | ||||
| .hypha-tabs__tab a, .hypha-tabs__tab { color: #ddd; background-color: #232323; border: 0; } | ||||
| .hypha-tabs__tab_active { background-color: #343434; } | ||||
|   | ||||
| @@ -11,6 +11,15 @@ | ||||
| 		{% for _, el := range headElements %}{%s= el %}{% endfor %} | ||||
| 	</head> | ||||
| 	<body> | ||||
| 		<header> | ||||
| 			<nav class="header-links"> | ||||
| 				<ul class="header-links__list"> | ||||
| 					{%- for _, link := range util.HeaderLinks -%} | ||||
| 					<li class="header-links__entry"><a class="header-links__link" href="{%s link.Href %}">{%s link.Display %}</a></li> | ||||
| 					{%- endfor -%} | ||||
| 				</ul> | ||||
| 			</nav> | ||||
| 		</header> | ||||
| 		{%s= body %} | ||||
| 	</body> | ||||
| </html> | ||||
|   | ||||
| @@ -48,53 +48,76 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, headElements | ||||
| 	qw422016.N().S(` | ||||
| 	</head> | ||||
| 	<body> | ||||
| 		<header> | ||||
| 			<nav class="header-links"> | ||||
| 				<ul class="header-links__list"> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| 	for _, link := range util.HeaderLinks { | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| 		qw422016.N().S(`					<li class="header-links__entry"><a class="header-links__link" href="`) | ||||
| //line templates/http_stuff.qtpl:18 | ||||
| 		qw422016.E().S(link.Href) | ||||
| //line templates/http_stuff.qtpl:18 | ||||
| 		qw422016.N().S(`">`) | ||||
| //line templates/http_stuff.qtpl:18 | ||||
| 		qw422016.E().S(link.Display) | ||||
| //line templates/http_stuff.qtpl:18 | ||||
| 		qw422016.N().S(`</a></li> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:19 | ||||
| 	} | ||||
| //line templates/http_stuff.qtpl:19 | ||||
| 	qw422016.N().S(`				</ul> | ||||
| 			</nav> | ||||
| 		</header> | ||||
| 		`) | ||||
| //line templates/http_stuff.qtpl:14 | ||||
| //line templates/http_stuff.qtpl:23 | ||||
| 	qw422016.N().S(body) | ||||
| //line templates/http_stuff.qtpl:14 | ||||
| //line templates/http_stuff.qtpl:23 | ||||
| 	qw422016.N().S(` | ||||
| 	</body> | ||||
| </html> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, headElements ...string) { | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	qw422016 := qt422016.AcquireWriter(qq422016) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	StreamBaseHTML(qw422016, title, body, headElements...) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	qt422016.ReleaseWriter(qw422016) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| func BaseHTML(title, body string, headElements ...string) string { | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	qb422016 := qt422016.AcquireByteBuffer() | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	WriteBaseHTML(qb422016, title, body, headElements...) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	qs422016 := string(qb422016.B) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	qt422016.ReleaseByteBuffer(qb422016) | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| 	return qs422016 | ||||
| //line templates/http_stuff.qtpl:17 | ||||
| //line templates/http_stuff.qtpl:26 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:19 | ||||
| //line templates/http_stuff.qtpl:28 | ||||
| func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { | ||||
| //line templates/http_stuff.qtpl:19 | ||||
| //line templates/http_stuff.qtpl:28 | ||||
| 	qw422016.N().S(` | ||||
| <main> | ||||
| 	<h1>List of hyphae</h1> | ||||
| 	<p>This wiki has `) | ||||
| //line templates/http_stuff.qtpl:22 | ||||
| //line templates/http_stuff.qtpl:31 | ||||
| 	qw422016.N().D(pageCount) | ||||
| //line templates/http_stuff.qtpl:22 | ||||
| //line templates/http_stuff.qtpl:31 | ||||
| 	qw422016.N().S(` hyphae.</p> | ||||
| 	<table> | ||||
| 		<thead> | ||||
| @@ -105,203 +128,203 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) | ||||
| 		</thead> | ||||
| 		<tbody> | ||||
| 			`) | ||||
| //line templates/http_stuff.qtpl:31 | ||||
| //line templates/http_stuff.qtpl:40 | ||||
| 	qw422016.N().S(tbody) | ||||
| //line templates/http_stuff.qtpl:31 | ||||
| //line templates/http_stuff.qtpl:40 | ||||
| 	qw422016.N().S(` | ||||
| 		</tbody> | ||||
| 	</table> | ||||
| </main> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) { | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	qw422016 := qt422016.AcquireWriter(qq422016) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	StreamHyphaListHTML(qw422016, tbody, pageCount) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	qt422016.ReleaseWriter(qw422016) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| func HyphaListHTML(tbody string, pageCount int) string { | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	qb422016 := qt422016.AcquireByteBuffer() | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	WriteHyphaListHTML(qb422016, tbody, pageCount) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	qs422016 := string(qb422016.B) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	qt422016.ReleaseByteBuffer(qb422016) | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| 	return qs422016 | ||||
| //line templates/http_stuff.qtpl:35 | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:37 | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { | ||||
| //line templates/http_stuff.qtpl:37 | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| 	qw422016.N().S(` | ||||
| 			<tr> | ||||
| 				<td><a href="/page/`) | ||||
| //line templates/http_stuff.qtpl:39 | ||||
| //line templates/http_stuff.qtpl:48 | ||||
| 	qw422016.E().S(hyphaName) | ||||
| //line templates/http_stuff.qtpl:39 | ||||
| //line templates/http_stuff.qtpl:48 | ||||
| 	qw422016.N().S(`">`) | ||||
| //line templates/http_stuff.qtpl:39 | ||||
| //line templates/http_stuff.qtpl:48 | ||||
| 	qw422016.E().S(hyphaName) | ||||
| //line templates/http_stuff.qtpl:39 | ||||
| //line templates/http_stuff.qtpl:48 | ||||
| 	qw422016.N().S(`</a></td> | ||||
| 			`) | ||||
| //line templates/http_stuff.qtpl:40 | ||||
| //line templates/http_stuff.qtpl:49 | ||||
| 	if binaryPresent { | ||||
| //line templates/http_stuff.qtpl:40 | ||||
| //line templates/http_stuff.qtpl:49 | ||||
| 		qw422016.N().S(` | ||||
| 				<td>`) | ||||
| //line templates/http_stuff.qtpl:41 | ||||
| //line templates/http_stuff.qtpl:50 | ||||
| 		qw422016.E().S(binaryMime) | ||||
| //line templates/http_stuff.qtpl:41 | ||||
| //line templates/http_stuff.qtpl:50 | ||||
| 		qw422016.N().S(`</td> | ||||
| 			`) | ||||
| //line templates/http_stuff.qtpl:42 | ||||
| //line templates/http_stuff.qtpl:51 | ||||
| 	} else { | ||||
| //line templates/http_stuff.qtpl:42 | ||||
| //line templates/http_stuff.qtpl:51 | ||||
| 		qw422016.N().S(` | ||||
| 				<td></td> | ||||
| 			`) | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| //line templates/http_stuff.qtpl:53 | ||||
| 	} | ||||
| //line templates/http_stuff.qtpl:44 | ||||
| //line templates/http_stuff.qtpl:53 | ||||
| 	qw422016.N().S(` | ||||
| 			</tr> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	qw422016 := qt422016.AcquireWriter(qq422016) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	qt422016.ReleaseWriter(qw422016) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string { | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	qb422016 := qt422016.AcquireByteBuffer() | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	qs422016 := string(qb422016.B) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	qt422016.ReleaseByteBuffer(qb422016) | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| 	return qs422016 | ||||
| //line templates/http_stuff.qtpl:46 | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:48 | ||||
| //line templates/http_stuff.qtpl:57 | ||||
| func StreamAboutHTML(qw422016 *qt422016.Writer) { | ||||
| //line templates/http_stuff.qtpl:48 | ||||
| //line templates/http_stuff.qtpl:57 | ||||
| 	qw422016.N().S(` | ||||
| <main> | ||||
| 	<section> | ||||
| 		<h1>About `) | ||||
| //line templates/http_stuff.qtpl:51 | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| 	qw422016.E().S(util.SiteName) | ||||
| //line templates/http_stuff.qtpl:51 | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| 	qw422016.N().S(`</h1> | ||||
| 		<ul> | ||||
| 			<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> β 0.12 indev</li> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:54 | ||||
| //line templates/http_stuff.qtpl:63 | ||||
| 	if user.AuthUsed { | ||||
| //line templates/http_stuff.qtpl:54 | ||||
| //line templates/http_stuff.qtpl:63 | ||||
| 		qw422016.N().S(`			<li><b>User count:</b> `) | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| //line templates/http_stuff.qtpl:64 | ||||
| 		qw422016.N().D(user.Count()) | ||||
| //line templates/http_stuff.qtpl:55 | ||||
| //line templates/http_stuff.qtpl:64 | ||||
| 		qw422016.N().S(`</li> | ||||
| 			<li><b>Home page:</b> <a href="/">`) | ||||
| //line templates/http_stuff.qtpl:56 | ||||
| //line templates/http_stuff.qtpl:65 | ||||
| 		qw422016.E().S(util.HomePage) | ||||
| //line templates/http_stuff.qtpl:56 | ||||
| //line templates/http_stuff.qtpl:65 | ||||
| 		qw422016.N().S(`</a></li> | ||||
| 			<li><b>Administrators:</b>`) | ||||
| //line templates/http_stuff.qtpl:57 | ||||
| //line templates/http_stuff.qtpl:66 | ||||
| 		for i, username := range user.ListUsersWithGroup("admin") { | ||||
| //line templates/http_stuff.qtpl:58 | ||||
| //line templates/http_stuff.qtpl:67 | ||||
| 			if i > 0 { | ||||
| //line templates/http_stuff.qtpl:58 | ||||
| //line templates/http_stuff.qtpl:67 | ||||
| 				qw422016.N().S(`<span aria-hidden="true">, </span> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:59 | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| 			} | ||||
| //line templates/http_stuff.qtpl:59 | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| 			qw422016.N().S(`				<a href="/page/`) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| 			qw422016.E().S(util.UserTree) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 			qw422016.E().S(util.UserHypha) | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 			qw422016.N().S(`/`) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 			qw422016.E().S(username) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 			qw422016.N().S(`">`) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 			qw422016.E().S(username) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 			qw422016.N().S(`</a>`) | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 		} | ||||
| //line templates/http_stuff.qtpl:60 | ||||
| //line templates/http_stuff.qtpl:69 | ||||
| 		qw422016.N().S(`</li> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:61 | ||||
| //line templates/http_stuff.qtpl:70 | ||||
| 	} else { | ||||
| //line templates/http_stuff.qtpl:61 | ||||
| //line templates/http_stuff.qtpl:70 | ||||
| 		qw422016.N().S(`			<li>This wiki does not use authorization</li> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:63 | ||||
| //line templates/http_stuff.qtpl:72 | ||||
| 	} | ||||
| //line templates/http_stuff.qtpl:63 | ||||
| //line templates/http_stuff.qtpl:72 | ||||
| 	qw422016.N().S(`		</ul> | ||||
| 		<p>See <a href="/list">/list</a> for information about hyphae on this wiki.</p> | ||||
| 	</section> | ||||
| </main> | ||||
| `) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| func WriteAboutHTML(qq422016 qtio422016.Writer) { | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	qw422016 := qt422016.AcquireWriter(qq422016) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	StreamAboutHTML(qw422016) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	qt422016.ReleaseWriter(qw422016) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| } | ||||
|  | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| func AboutHTML() string { | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	qb422016 := qt422016.AcquireByteBuffer() | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	WriteAboutHTML(qb422016) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	qs422016 := string(qb422016.B) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	qt422016.ReleaseByteBuffer(qb422016) | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| 	return qs422016 | ||||
| //line templates/http_stuff.qtpl:68 | ||||
| //line templates/http_stuff.qtpl:77 | ||||
| } | ||||
|   | ||||
							
								
								
									
										21
									
								
								user/user.go
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								user/user.go
									
									
									
									
									
								
							| @@ -15,16 +15,17 @@ type User struct { | ||||
|  | ||||
| // Route — Right (more is more right) | ||||
| var minimalRights = map[string]int{ | ||||
| 	"edit":             1, | ||||
| 	"upload-binary":    1, | ||||
| 	"upload-text":      1, | ||||
| 	"rename-ask":       2, | ||||
| 	"rename-confirm":   2, | ||||
| 	"unattach-ask":     2, | ||||
| 	"unattach-confirm": 2, | ||||
| 	"delete-ask":       3, | ||||
| 	"delete-confirm":   3, | ||||
| 	"reindex":          4, | ||||
| 	"edit":                1, | ||||
| 	"upload-binary":       1, | ||||
| 	"upload-text":         1, | ||||
| 	"rename-ask":          2, | ||||
| 	"rename-confirm":      2, | ||||
| 	"unattach-ask":        2, | ||||
| 	"unattach-confirm":    2, | ||||
| 	"update-header-links": 3, | ||||
| 	"delete-ask":          3, | ||||
| 	"delete-confirm":      3, | ||||
| 	"reindex":             4, | ||||
| } | ||||
|  | ||||
| // Group — Right | ||||
|   | ||||
							
								
								
									
										35
									
								
								util/header_links.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								util/header_links.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| package util | ||||
|  | ||||
| import ( | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| func SetDefaultHeaderLinks() { | ||||
| 	HeaderLinks = []HeaderLink{ | ||||
| 		{"/", SiteName}, | ||||
| 		{"/recent-changes", "Recent changes"}, | ||||
| 		{"/list", "All hyphae"}, | ||||
| 		{"/random", "Random"}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // rocketlinkλ is markup.Rocketlink. You have to pass it like that to avoid cyclical dependency. | ||||
| func ParseHeaderLinks(text string, rocketlinkλ func(string, string) (string, string, string, string)) { | ||||
| 	HeaderLinks = []HeaderLink{} | ||||
| 	for _, line := range strings.Split(text, "\n") { | ||||
| 		if strings.HasPrefix(line, "=>") { | ||||
| 			href, text, _, _ := rocketlinkλ(line, HeaderLinksHypha) | ||||
| 			HeaderLinks = append(HeaderLinks, HeaderLink{ | ||||
| 				Href:    href, | ||||
| 				Display: text, | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type HeaderLink struct { | ||||
| 	Href    string | ||||
| 	Display string | ||||
| } | ||||
|  | ||||
| var HeaderLinks []HeaderLink | ||||
| @@ -15,6 +15,7 @@ var ( | ||||
| 	SiteName             string | ||||
| 	WikiDir              string | ||||
| 	UserHypha            string | ||||
| 	HeaderLinksHypha     string | ||||
| 	AuthMethod           string | ||||
| 	FixedCredentialsPath string | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 bouncepaw
					bouncepaw