1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 13:30:26 +00:00

Merge pull request #75 from bouncepaw/help

Help
This commit is contained in:
Timur Ismagilov 2021-07-12 15:23:09 +05:00 committed by GitHub
commit ebd36bdfdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 478 additions and 147 deletions

12
help/en.myco Normal file
View File

@ -0,0 +1,12 @@
# Help
This is Mycorrhiza Wiki built-in documentation.
Hope you are doing well ☺️
See the section on the right (if you are on computer) or below (if you are on mobile) to see what topics are covered by the documentation.
Thanks for reading!
----
You might want to contribute to the documentation. Open a pull-request on [[https://github.com/bouncepaw/mycorrhiza | GitHub]] if you know how to.

34
help/en/attachment.myco Normal file
View File

@ -0,0 +1,34 @@
# Help: Attachment
In hyphae, an **attachment** is some content represented by something that is not [[/help/en/mycomarkup | Mycomarkup]]. Usually, an image, a video, or an audio.
## Supported attachment types
You can upload any file, but only those listed below will be displayed on the website. You can download unsupported attachments, though.
* **Images:** jpg, gif, png, webp, svg, ico
* **Video:** ogg, webm, mp4
* **Audio:** ogg, webm, mp3
## How to add an attachment?
For non-existent hyphae, upload a file in the //Upload a media// section.
For any hyphae, upload a file in the //Attachment// tab.
## Attachment tab
Every hypha has the //Attachment// tab. Click it to see what is out there.
You can upload a new file, you can //delete// the attachment (it is called //unattaching//) and see some file stats (size and type).
## On naming hyphae with attachments
The hypha name should not just copy the file name in most cases. If you are uploading a photo of a rose, do not call it `rose.jpg`, no. Call it `photo of rose` or `rose photo` or whatever. You rarely need to think of file extensions when using Mycorrhiza Wiki.
This is not a rule, of course, just a convention.
## What to put in the text part?
If a hypha has an attachment, here is what the text part might be about:
* A textual description or representation of the picture.
* A transcript of the song.
* An analysis of the attachment.
* Some meta data.
* Things above combined.
The attachment //should not// be an illustration.

35
help/en/hypha.myco Normal file
View File

@ -0,0 +1,35 @@
# Help: Hypha
A **hypha** (//plural:// hyphae) is the main content unit used in Mycorrhiza Wiki.
## The structure of hypha
A hypha consists of two parts:
* **Attachment.** Some form of media. There is only one attachment. See [[/help/en/attachment | Attachment]] for more information about attachments.
* **Text part.** Either a description of the attachment or a stand-alone text unit such as an article, a diary or a poem. It is written in a special markup, called [[/help/en/mycomarkup | Mycomarkup]].
Both parts are optional. You can have a picture without description, an article without an attachment, etc. You can have them both. You must have at least one part, though.
## How to create a hypha?
Some links on wiki are red. It means that they link a hypha that does not exist yet. If you follow this link, you will see a special page where you can upload an attachment or open the text editor. This is how you create hyphae.
You can create such red links and follow them to create hyphae.
Alternatively, you can edit your address in browser to jump to such pages directly.
## Hypha names
Hypha names are case-insensitive. It means that names //amanita muscaria// and //Amanita Muscaria// are the same. Also, space and underscore are also the same (//amanita muscaria// = //amanita_muscaria//). Canonical names are all lowercase and underscored.
There are some characters that cannot be part of a hypha name: `?!:#@><*|"'&%{}\\` Others can be used.
## Genealogy
A **subhypha** is a hypha that has a name starting with a name of a different hypha, followed by a slash and by the rest of the name. For example, hypha //Fruit/Apple// is a subhypha of hypha //Fruit//. There can be as many subhyphae as you want. Subhyphae can have subhyphae themselves.
Thus, a **superhypha** is a reverse of subhypha: //Fruit// is the superhypha of //Fruit/Apple//. There can be only one superhypha.
**Sister hyphae** are hyphae that are subhyphae of the same hypha. For example, //Fruit/Apple// and //Fruit/Pear// are sister hyphae.
## Word
Read the word //hypha// as /ˈhaɪfə/. The plural form is //hyphae//. Read it as /ˈhaɪfi/.
The word is taken from mycology, the study of fungi. In a fungus, hyphae are thin white threads from which the mycelium is made. See [[https://en.wikipedia.org/wiki/Hypha | this Wikipedia article]] for more information about real hyphae.
Think of Mycorrhiza Wiki hyphae as of small elements that build up your wiki.

18
help/help.go Normal file
View File

@ -0,0 +1,18 @@
// Package help contains help messages and the utilities for retrieving them.
package help
import (
"embed"
)
//go:embed en en.myco
var fs embed.FS
// Get determines what help text you need and returns it. The path is a substring from URL, it follows this form:
// <language>/<topic>
func Get(path string) ([]byte, error) {
if path == "" {
return Get("en")
}
return fs.ReadFile(path + ".myco")
}

View File

@ -74,7 +74,7 @@ header { width: 100%; margin-bottom: 1rem; }
.layout { display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; margin: 0 1rem; row-gap: 1rem; } .layout { display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; margin: 0 1rem; row-gap: 1rem; }
.main-width { margin: 0; } .main-width { margin: 0; }
main { grid-column: 1 / span 1; grid-row: 1 / span 2; } main { grid-column: 1 / span 1; grid-row: 1 / span 2; }
.sister-hyphae, .edit-toolbar { grid-column: 2 / span 1; grid-row: 1 / span 1; } .sister-hyphae, .edit-toolbar, .help-topics { grid-column: 2 / span 1; grid-row: 1 / span 1; }
.layout-card { width: 100%; } .layout-card { width: 100%; }
.edit-toolbar__buttons {display: grid; } .edit-toolbar__buttons {display: grid; }
} }
@ -89,7 +89,7 @@ header { width: 100%; margin-bottom: 1rem; }
.main-width { margin: 0 auto; } .main-width { margin: 0 auto; }
.backlinks { grid-column: 1 / span 1; margin-right: 0; } .backlinks { grid-column: 1 / span 1; margin-right: 0; }
main { grid-column: 2 / span 1; } main { grid-column: 2 / span 1; }
.sister-hyphae, .edit-toolbar { grid-column: 3 / span 1; margin-left: 0; } .sister-hyphae, .edit-toolbar, .help-topics { grid-column: 3 / span 1; margin-left: 0; }
.edit-toolbar__buttons { grid-template-columns: 1fr; } .edit-toolbar__buttons { grid-template-columns: 1fr; }
.backlinks__title { text-align: right; } .backlinks__title { text-align: right; }
@ -129,7 +129,8 @@ blockquote { margin: 0; padding-left: .75rem; }
.wikilink_mailto::before { content: url("/static/icon/mailto-proto.svg"); } .wikilink_mailto::before { content: url("/static/icon/mailto-proto.svg"); }
article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; } article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; }
main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; } main h1 { margin: .5rem 0 0 0; }
main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; }
.heading__link { text-decoration: none; display: inline-block; } .heading__link { text-decoration: none; display: inline-block; }
.heading__link::after { width: 1rem; content: "§"; color: transparent; } .heading__link::after { width: 1rem; content: "§"; color: transparent; }
.heading__link:hover::after, .heading__link:active::after { color: #999; } .heading__link:hover::after, .heading__link:active::after { color: #999; }
@ -594,3 +595,14 @@ kbd {
left: -1.6rem; left: -1.6rem;
top: .1rem; top: .1rem;
} }
/*
* Help topics sidebar
*/
.help-topics__list {
margin: .5rem 0;
padding-left: .5rem;
}
.help-topics__list ul {
padding-left: 1rem;
}

View File

@ -13,12 +13,12 @@
{% func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) %} {% func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) %}
{%= NavHTML(rq, h.Name, "attachment") %} {%= NavHTML(rq, h.Name, "attachment") %}
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width attachment-tab">
<h1>Attachment of {%s util.BeautifulName(h.Name) %}</h1> <h1>Attachment of {%s util.BeautifulName(h.Name) %}</h1>
{% if h.BinaryPath == "" %} {% if h.BinaryPath == "" %}
<p class="warning">This hypha has no attachment, you can upload it here.</p> <p class="explanation">This hypha has no attachment, you can upload it here. <a href="/help/en/attachment" class="shy-link">What are attachments?</a></p>
{% else %} {% else %}
<p class="warning">You can manage the hypha's attachment on this page.</p> <p class="explanation">You can manage the hypha's attachment on this page. <a href="/help/en/attachment" class="shy-link">What are attachments?</a></p>
{% endif %} {% endif %}
<section class="amnt-grid"> <section class="amnt-grid">

View File

@ -57,7 +57,7 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy
//line views/readers.qtpl:14 //line views/readers.qtpl:14
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width"> <main class="main-width attachment-tab">
<h1>Attachment of `) <h1>Attachment of `)
//line views/readers.qtpl:17 //line views/readers.qtpl:17
qw422016.E().S(util.BeautifulName(h.Name)) qw422016.E().S(util.BeautifulName(h.Name))
@ -68,13 +68,13 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy
if h.BinaryPath == "" { if h.BinaryPath == "" {
//line views/readers.qtpl:18 //line views/readers.qtpl:18
qw422016.N().S(` qw422016.N().S(`
<p class="warning">This hypha has no attachment, you can upload it here.</p> <p class="explanation">This hypha has no attachment, you can upload it here. <a href="/help/en/attachment" class="shy-link">What are attachments?</a></p>
`) `)
//line views/readers.qtpl:20 //line views/readers.qtpl:20
} else { } else {
//line views/readers.qtpl:20 //line views/readers.qtpl:20
qw422016.N().S(` qw422016.N().S(`
<p class="warning">You can manage the hypha's attachment on this page.</p> <p class="explanation">You can manage the hypha's attachment on this page. <a href="/help/en/attachment" class="shy-link">What are attachments?</a></p>
`) `)
//line views/readers.qtpl:22 //line views/readers.qtpl:22
} }

View File

@ -44,6 +44,42 @@
</html> </html>
{% endfunc %} {% endfunc %}
{% func HelpHTML(content string) %}
<div class="layout">
<main class="main-width help">
<article>
{%s= content %}
</article>
</main>
{%s= helpTopicsHTML() %}
</div>
{% endfunc %}
{% func HelpEmptyErrorHTML() %}
<h1>This entry does not exist!</h1>
<p>Try finding a different entry that would help you.</p>
<p>If you want to write this entry by yourself, consider <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">contributing</a> to Mycorrhiza Wiki directly.</p>
{% endfunc %}
{% func helpTopicsHTML() %}
<aside class="help-topics layout-card">
<h2 class="layout-card__title">Help topics</h2>
<ul class="help-topics__list">
<li>
<a href="/help/en">Main</a>
</li>
<li>
<a href="/help/en/hypha">Hypha</a>
<ul>
<li>
<a href="/help/en/attachment">Attachment</a>
</li>
</ul
</li>
</ul>
</aside>
{% endfunc %}
{% func UserListHTML() %} {% func UserListHTML() %}
<div class="layout"> <div class="layout">
<main class="main-width user-list"> <main class="main-width user-list">

View File

@ -142,14 +142,151 @@ func BaseHTML(title, body string, u *user.User, headElements ...string) string {
} }
//line views/stuff.qtpl:47 //line views/stuff.qtpl:47
func StreamUserListHTML(qw422016 *qt422016.Writer) { func StreamHelpHTML(qw422016 *qt422016.Writer, content string) {
//line views/stuff.qtpl:47 //line views/stuff.qtpl:47
qw422016.N().S(` qw422016.N().S(`
<div class="layout"> <div class="layout">
<main class="main-width help">
<article>
`)
//line views/stuff.qtpl:51
qw422016.N().S(content)
//line views/stuff.qtpl:51
qw422016.N().S(`
</article>
</main>
`)
//line views/stuff.qtpl:54
qw422016.N().S(helpTopicsHTML())
//line views/stuff.qtpl:54
qw422016.N().S(`
</div>
`)
//line views/stuff.qtpl:56
}
//line views/stuff.qtpl:56
func WriteHelpHTML(qq422016 qtio422016.Writer, content string) {
//line views/stuff.qtpl:56
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:56
StreamHelpHTML(qw422016, content)
//line views/stuff.qtpl:56
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:56
}
//line views/stuff.qtpl:56
func HelpHTML(content string) string {
//line views/stuff.qtpl:56
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:56
WriteHelpHTML(qb422016, content)
//line views/stuff.qtpl:56
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:56
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:56
return qs422016
//line views/stuff.qtpl:56
}
//line views/stuff.qtpl:58
func StreamHelpEmptyErrorHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:58
qw422016.N().S(`
<h1>This entry does not exist!</h1>
<p>Try finding a different entry that would help you.</p>
<p>If you want to write this entry by yourself, consider <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">contributing</a> to Mycorrhiza Wiki directly.</p>
`)
//line views/stuff.qtpl:62
}
//line views/stuff.qtpl:62
func WriteHelpEmptyErrorHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:62
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:62
StreamHelpEmptyErrorHTML(qw422016)
//line views/stuff.qtpl:62
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:62
}
//line views/stuff.qtpl:62
func HelpEmptyErrorHTML() string {
//line views/stuff.qtpl:62
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:62
WriteHelpEmptyErrorHTML(qb422016)
//line views/stuff.qtpl:62
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:62
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:62
return qs422016
//line views/stuff.qtpl:62
}
//line views/stuff.qtpl:64
func streamhelpTopicsHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:64
qw422016.N().S(`
<aside class="help-topics layout-card">
<h2 class="layout-card__title">Help topics</h2>
<ul class="help-topics__list">
<li>
<a href="/help/en">Main</a>
</li>
<li>
<a href="/help/en/hypha">Hypha</a>
<ul>
<li>
<a href="/help/en/attachment">Attachment</a>
</li>
</ul
</li>
</ul>
</aside>
`)
//line views/stuff.qtpl:81
}
//line views/stuff.qtpl:81
func writehelpTopicsHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:81
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:81
streamhelpTopicsHTML(qw422016)
//line views/stuff.qtpl:81
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:81
}
//line views/stuff.qtpl:81
func helpTopicsHTML() string {
//line views/stuff.qtpl:81
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:81
writehelpTopicsHTML(qb422016)
//line views/stuff.qtpl:81
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:81
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:81
return qs422016
//line views/stuff.qtpl:81
}
//line views/stuff.qtpl:83
func StreamUserListHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:83
qw422016.N().S(`
<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:52 //line views/stuff.qtpl:88
var ( var (
admins = make([]string, 0) admins = make([]string, 0)
moderators = make([]string, 0) moderators = make([]string, 0)
@ -166,345 +303,345 @@ func StreamUserListHTML(qw422016 *qt422016.Writer) {
} }
} }
//line views/stuff.qtpl:67 //line views/stuff.qtpl:103
qw422016.N().S(` qw422016.N().S(`
<section> <section>
<h2>Admins</h2> <h2>Admins</h2>
<ol>`) <ol>`)
//line views/stuff.qtpl:70 //line views/stuff.qtpl:106
for _, name := range admins { for _, name := range admins {
//line views/stuff.qtpl:70 //line views/stuff.qtpl:106
qw422016.N().S(` qw422016.N().S(`
<li><a href="/hypha/`) <li><a href="/hypha/`)
//line views/stuff.qtpl:71 //line views/stuff.qtpl:107
qw422016.E().S(cfg.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:71 //line views/stuff.qtpl:107
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:71 //line views/stuff.qtpl:107
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:71 //line views/stuff.qtpl:107
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:71 //line views/stuff.qtpl:107
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:71 //line views/stuff.qtpl:107
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:72 //line views/stuff.qtpl:108
} }
//line views/stuff.qtpl:72 //line views/stuff.qtpl:108
qw422016.N().S(`</ol> qw422016.N().S(`</ol>
</section> </section>
<section> <section>
<h2>Moderators</h2> <h2>Moderators</h2>
<ol>`) <ol>`)
//line views/stuff.qtpl:76 //line views/stuff.qtpl:112
for _, name := range moderators { for _, name := range moderators {
//line views/stuff.qtpl:76 //line views/stuff.qtpl:112
qw422016.N().S(` qw422016.N().S(`
<li><a href="/hypha/`) <li><a href="/hypha/`)
//line views/stuff.qtpl:77 //line views/stuff.qtpl:113
qw422016.E().S(cfg.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:77 //line views/stuff.qtpl:113
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:77 //line views/stuff.qtpl:113
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:77 //line views/stuff.qtpl:113
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:77 //line views/stuff.qtpl:113
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:77 //line views/stuff.qtpl:113
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:78 //line views/stuff.qtpl:114
} }
//line views/stuff.qtpl:78 //line views/stuff.qtpl:114
qw422016.N().S(`</ol> qw422016.N().S(`</ol>
</section> </section>
<section> <section>
<h2>Editors</h2> <h2>Editors</h2>
<ol>`) <ol>`)
//line views/stuff.qtpl:82 //line views/stuff.qtpl:118
for _, name := range editors { for _, name := range editors {
//line views/stuff.qtpl:82 //line views/stuff.qtpl:118
qw422016.N().S(` qw422016.N().S(`
<li><a href="/hypha/`) <li><a href="/hypha/`)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:119
qw422016.E().S(cfg.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:119
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:119
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:119
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:119
qw422016.E().S(name) qw422016.E().S(name)
//line views/stuff.qtpl:83 //line views/stuff.qtpl:119
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
`) `)
//line views/stuff.qtpl:84 //line views/stuff.qtpl:120
} }
//line views/stuff.qtpl:84 //line views/stuff.qtpl:120
qw422016.N().S(`</ol> qw422016.N().S(`</ol>
</section> </section>
</main> </main>
</div> </div>
`) `)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
} }
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
func WriteUserListHTML(qq422016 qtio422016.Writer) { func WriteUserListHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
StreamUserListHTML(qw422016) StreamUserListHTML(qw422016)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
} }
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
func UserListHTML() string { func UserListHTML() string {
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
WriteUserListHTML(qb422016) WriteUserListHTML(qb422016)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
return qs422016 return qs422016
//line views/stuff.qtpl:88 //line views/stuff.qtpl:124
} }
//line views/stuff.qtpl:90 //line views/stuff.qtpl:126
func StreamHyphaListHTML(qw422016 *qt422016.Writer) { func StreamHyphaListHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:90 //line views/stuff.qtpl:126
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:94 //line views/stuff.qtpl:130
qw422016.N().D(hyphae.Count()) qw422016.N().D(hyphae.Count())
//line views/stuff.qtpl:94 //line views/stuff.qtpl:130
qw422016.N().S(` hyphae.</p> qw422016.N().S(` hyphae.</p>
<ul class="hypha-list"> <ul class="hypha-list">
`) `)
//line views/stuff.qtpl:96 //line views/stuff.qtpl:132
for h := range hyphae.YieldExistingHyphae() { for h := range hyphae.YieldExistingHyphae() {
//line views/stuff.qtpl:96 //line views/stuff.qtpl:132
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:98 //line views/stuff.qtpl:134
qw422016.E().S(h.Name) qw422016.E().S(h.Name)
//line views/stuff.qtpl:98 //line views/stuff.qtpl:134
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:98 //line views/stuff.qtpl:134
qw422016.E().S(util.BeautifulName(h.Name)) qw422016.E().S(util.BeautifulName(h.Name))
//line views/stuff.qtpl:98 //line views/stuff.qtpl:134
qw422016.N().S(`</a> qw422016.N().S(`</a>
`) `)
//line views/stuff.qtpl:99 //line views/stuff.qtpl:135
if h.BinaryPath != "" { if h.BinaryPath != "" {
//line views/stuff.qtpl:99 //line views/stuff.qtpl:135
qw422016.N().S(` qw422016.N().S(`
<span class="hypha-list__amnt-type">`) <span class="hypha-list__amnt-type">`)
//line views/stuff.qtpl:100 //line views/stuff.qtpl:136
qw422016.E().S(filepath.Ext(h.BinaryPath)[1:]) qw422016.E().S(filepath.Ext(h.BinaryPath)[1:])
//line views/stuff.qtpl:100 //line views/stuff.qtpl:136
qw422016.N().S(`</span> qw422016.N().S(`</span>
`) `)
//line views/stuff.qtpl:101 //line views/stuff.qtpl:137
} }
//line views/stuff.qtpl:101 //line views/stuff.qtpl:137
qw422016.N().S(` qw422016.N().S(`
</li> </li>
`) `)
//line views/stuff.qtpl:103 //line views/stuff.qtpl:139
} }
//line views/stuff.qtpl:103 //line views/stuff.qtpl:139
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
</main> </main>
</div> </div>
`) `)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
} }
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
func WriteHyphaListHTML(qq422016 qtio422016.Writer) { func WriteHyphaListHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
StreamHyphaListHTML(qw422016) StreamHyphaListHTML(qw422016)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
} }
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
func HyphaListHTML() string { func HyphaListHTML() string {
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
WriteHyphaListHTML(qb422016) WriteHyphaListHTML(qb422016)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
return qs422016 return qs422016
//line views/stuff.qtpl:107 //line views/stuff.qtpl:143
} }
//line views/stuff.qtpl:109 //line views/stuff.qtpl:145
func StreamAboutHTML(qw422016 *qt422016.Writer) { func StreamAboutHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:109 //line views/stuff.qtpl:145
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:113 //line views/stuff.qtpl:149
qw422016.E().S(cfg.WikiName) qw422016.E().S(cfg.WikiName)
//line views/stuff.qtpl:113 //line views/stuff.qtpl:149
qw422016.N().S(`</h1> qw422016.N().S(`</h1>
<ul> <ul>
<li><b><a href="https://mycorrhiza.wiki">Mycorrhiza Wiki</a> version:</b> 1.3.0</li> <li><b><a href="https://mycorrhiza.wiki">Mycorrhiza Wiki</a> version:</b> 1.3.0</li>
`) `)
//line views/stuff.qtpl:116 //line views/stuff.qtpl:152
if cfg.UseAuth { if cfg.UseAuth {
//line views/stuff.qtpl:116 //line views/stuff.qtpl:152
qw422016.N().S(` <li><b>User count:</b> `) qw422016.N().S(` <li><b>User count:</b> `)
//line views/stuff.qtpl:117 //line views/stuff.qtpl:153
qw422016.N().DUL(user.Count()) qw422016.N().DUL(user.Count())
//line views/stuff.qtpl:117 //line views/stuff.qtpl:153
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:118 //line views/stuff.qtpl:154
qw422016.E().S(cfg.HomeHypha) qw422016.E().S(cfg.HomeHypha)
//line views/stuff.qtpl:118 //line views/stuff.qtpl:154
qw422016.N().S(`</a></li> qw422016.N().S(`</a></li>
<li><b>Administrators:</b>`) <li><b>Administrators:</b>`)
//line views/stuff.qtpl:119 //line views/stuff.qtpl:155
for i, username := range user.ListUsersWithGroup("admin") { for i, username := range user.ListUsersWithGroup("admin") {
//line views/stuff.qtpl:120 //line views/stuff.qtpl:156
if i > 0 { if i > 0 {
//line views/stuff.qtpl:120 //line views/stuff.qtpl:156
qw422016.N().S(`<span aria-hidden="true">, </span> qw422016.N().S(`<span aria-hidden="true">, </span>
`) `)
//line views/stuff.qtpl:121 //line views/stuff.qtpl:157
} }
//line views/stuff.qtpl:121 //line views/stuff.qtpl:157
qw422016.N().S(` <a href="/hypha/`) qw422016.N().S(` <a href="/hypha/`)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.E().S(cfg.UserHypha) qw422016.E().S(cfg.UserHypha)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.E().S(username) qw422016.E().S(username)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.E().S(username) qw422016.E().S(username)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.N().S(`</a>`) qw422016.N().S(`</a>`)
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
} }
//line views/stuff.qtpl:122 //line views/stuff.qtpl:158
qw422016.N().S(`</li> qw422016.N().S(`</li>
`) `)
//line views/stuff.qtpl:123 //line views/stuff.qtpl:159
} else { } else {
//line views/stuff.qtpl:123 //line views/stuff.qtpl:159
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:125 //line views/stuff.qtpl:161
} }
//line views/stuff.qtpl:125 //line views/stuff.qtpl:161
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:131 //line views/stuff.qtpl:167
} }
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
func WriteAboutHTML(qq422016 qtio422016.Writer) { func WriteAboutHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
StreamAboutHTML(qw422016) StreamAboutHTML(qw422016)
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
} }
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
func AboutHTML() string { func AboutHTML() string {
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
WriteAboutHTML(qb422016) WriteAboutHTML(qb422016)
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
return qs422016 return qs422016
//line views/stuff.qtpl:131 //line views/stuff.qtpl:167
} }
//line views/stuff.qtpl:133 //line views/stuff.qtpl:169
func StreamCommonScripts(qw422016 *qt422016.Writer) { func StreamCommonScripts(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:133 //line views/stuff.qtpl:169
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/stuff.qtpl:134 //line views/stuff.qtpl:170
for _, scriptPath := range cfg.CommonScripts { for _, scriptPath := range cfg.CommonScripts {
//line views/stuff.qtpl:134 //line views/stuff.qtpl:170
qw422016.N().S(` qw422016.N().S(`
<script src="`) <script src="`)
//line views/stuff.qtpl:135 //line views/stuff.qtpl:171
qw422016.E().S(scriptPath) qw422016.E().S(scriptPath)
//line views/stuff.qtpl:135 //line views/stuff.qtpl:171
qw422016.N().S(`"></script> qw422016.N().S(`"></script>
`) `)
//line views/stuff.qtpl:136 //line views/stuff.qtpl:172
} }
//line views/stuff.qtpl:136 //line views/stuff.qtpl:172
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
} }
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
func WriteCommonScripts(qq422016 qtio422016.Writer) { func WriteCommonScripts(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
StreamCommonScripts(qw422016) StreamCommonScripts(qw422016)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
} }
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
func CommonScripts() string { func CommonScripts() string {
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
WriteCommonScripts(qb422016) WriteCommonScripts(qb422016)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
return qs422016 return qs422016
//line views/stuff.qtpl:137 //line views/stuff.qtpl:173
} }

View File

@ -2,10 +2,14 @@ package web
// stuff.go is used for meta stuff about the wiki or all hyphae at once. // stuff.go is used for meta stuff about the wiki or all hyphae at once.
import ( import (
"github.com/bouncepaw/mycomarkup"
"github.com/bouncepaw/mycomarkup/mycocontext"
"github.com/bouncepaw/mycorrhiza/help"
"io" "io"
"log" "log"
"math/rand" "math/rand"
"net/http" "net/http"
"strings"
"github.com/bouncepaw/mycorrhiza/cfg" "github.com/bouncepaw/mycorrhiza/cfg"
"github.com/bouncepaw/mycorrhiza/files" "github.com/bouncepaw/mycorrhiza/files"
@ -18,6 +22,7 @@ import (
) )
func initStuff() { func initStuff() {
http.HandleFunc("/help/", handlerHelp)
http.HandleFunc("/list/", handlerList) http.HandleFunc("/list/", handlerList)
http.HandleFunc("/reindex/", handlerReindex) http.HandleFunc("/reindex/", handlerReindex)
http.HandleFunc("/update-header-links/", handlerUpdateHeaderLinks) http.HandleFunc("/update-header-links/", handlerUpdateHeaderLinks)
@ -28,6 +33,48 @@ func initStuff() {
}) })
} }
// handlerHelp gets the appropriate documentation or tells you where you (personally) have failed.
func handlerHelp(w http.ResponseWriter, rq *http.Request) {
if shown := user.FromRequest(rq).ShowLockMaybe(w, rq); shown {
return
}
content, err := help.Get(rq.URL.Path[6:]) // Drop /help/
if err != nil && strings.HasPrefix(err.Error(), "open") {
w.WriteHeader(http.StatusNotFound)
_, _ = io.WriteString(
w,
views.BaseHTML("Entry not found",
views.HelpHTML(views.HelpEmptyErrorHTML()),
user.FromRequest(rq)),
)
return
}
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
_, _ = io.WriteString(
w,
views.BaseHTML(err.Error(),
views.HelpHTML(err.Error()),
user.FromRequest(rq)),
)
return
}
// TODO: change for the function that uses byte array when there is such function in mycomarkup.
ctx, _ := mycocontext.ContextFromStringInput(rq.URL.Path[1:3], string(content))
ast := mycomarkup.BlockTree(ctx)
result := mycomarkup.BlocksToHTML(ctx, ast)
// TODO: styled output idk
w.WriteHeader(http.StatusOK)
_, _ = io.WriteString(
w,
views.BaseHTML("Help",
views.HelpHTML(result),
user.FromRequest(rq)),
)
}
// handlerList shows a list of all hyphae in the wiki in random order. // handlerList shows a list of all hyphae in the wiki in random order.
func handlerList(w http.ResponseWriter, rq *http.Request) { func handlerList(w http.ResponseWriter, rq *http.Request) {
u := user.FromRequest(rq) u := user.FromRequest(rq)