diff --git a/help/en.myco b/help/en.myco new file mode 100644 index 0000000..50a5921 --- /dev/null +++ b/help/en.myco @@ -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. \ No newline at end of file diff --git a/help/en/attachment.myco b/help/en/attachment.myco new file mode 100644 index 0000000..c55bb14 --- /dev/null +++ b/help/en/attachment.myco @@ -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. \ No newline at end of file diff --git a/help/en/hypha.myco b/help/en/hypha.myco new file mode 100644 index 0000000..97281da --- /dev/null +++ b/help/en/hypha.myco @@ -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. \ No newline at end of file diff --git a/help/help.go b/help/help.go new file mode 100644 index 0000000..bc12477 --- /dev/null +++ b/help/help.go @@ -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: +// / +func Get(path string) ([]byte, error) { + if path == "" { + return Get("en") + } + return fs.ReadFile(path + ".myco") +} diff --git a/static/default.css b/static/default.css index 3928611..7071e98 100644 --- a/static/default.css +++ b/static/default.css @@ -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; } .main-width { margin: 0; } 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%; } .edit-toolbar__buttons {display: grid; } } @@ -89,7 +89,7 @@ header { width: 100%; margin-bottom: 1rem; } .main-width { margin: 0 auto; } .backlinks { grid-column: 1 / span 1; margin-right: 0; } 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; } .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"); } 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::after { width: 1rem; content: "§"; color: transparent; } .heading__link:hover::after, .heading__link:active::after { color: #999; } @@ -594,3 +595,14 @@ kbd { left: -1.6rem; top: .1rem; } + +/* + * Help topics sidebar + */ +.help-topics__list { + margin: .5rem 0; + padding-left: .5rem; +} +.help-topics__list ul { + padding-left: 1rem; +} \ No newline at end of file diff --git a/views/readers.qtpl b/views/readers.qtpl index e4f3525..bd2c4fe 100644 --- a/views/readers.qtpl +++ b/views/readers.qtpl @@ -13,12 +13,12 @@ {% func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) %} {%= NavHTML(rq, h.Name, "attachment") %}
-
+

Attachment of {%s util.BeautifulName(h.Name) %}

{% if h.BinaryPath == "" %} -

This hypha has no attachment, you can upload it here.

+

This hypha has no attachment, you can upload it here. What are attachments?

{% else %} -

You can manage the hypha's attachment on this page.

+

You can manage the hypha's attachment on this page. What are attachments?

{% endif %}
diff --git a/views/readers.qtpl.go b/views/readers.qtpl.go index aa75361..cf44486 100644 --- a/views/readers.qtpl.go +++ b/views/readers.qtpl.go @@ -57,7 +57,7 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy //line views/readers.qtpl:14 qw422016.N().S(`
-
+

Attachment of `) //line views/readers.qtpl:17 qw422016.E().S(util.BeautifulName(h.Name)) @@ -68,13 +68,13 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy if h.BinaryPath == "" { //line views/readers.qtpl:18 qw422016.N().S(` -

This hypha has no attachment, you can upload it here.

+

This hypha has no attachment, you can upload it here. What are attachments?

`) //line views/readers.qtpl:20 } else { //line views/readers.qtpl:20 qw422016.N().S(` -

You can manage the hypha's attachment on this page.

+

You can manage the hypha's attachment on this page. What are attachments?

`) //line views/readers.qtpl:22 } diff --git a/views/stuff.qtpl b/views/stuff.qtpl index 0bc1d0b..c34753f 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -44,6 +44,42 @@ {% endfunc %} +{% func HelpHTML(content string) %} +
+
+
+ {%s= content %} +
+
+{%s= helpTopicsHTML() %} +
+{% endfunc %} + +{% func HelpEmptyErrorHTML() %} +

This entry does not exist!

+

Try finding a different entry that would help you.

+

If you want to write this entry by yourself, consider contributing to Mycorrhiza Wiki directly.

+{% endfunc %} + +{% func helpTopicsHTML() %} + +{% endfunc %} + {% func UserListHTML() %}
diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go index ba8a00d..b953e4a 100644 --- a/views/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -142,14 +142,151 @@ func BaseHTML(title, body string, u *user.User, headElements ...string) string { } //line views/stuff.qtpl:47 -func StreamUserListHTML(qw422016 *qt422016.Writer) { +func StreamHelpHTML(qw422016 *qt422016.Writer, content string) { //line views/stuff.qtpl:47 qw422016.N().S(`
+
+
+ `) +//line views/stuff.qtpl:51 + qw422016.N().S(content) +//line views/stuff.qtpl:51 + qw422016.N().S(` +
+
+`) +//line views/stuff.qtpl:54 + qw422016.N().S(helpTopicsHTML()) +//line views/stuff.qtpl:54 + qw422016.N().S(` +
+`) +//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(` +

This entry does not exist!

+

Try finding a different entry that would help you.

+

If you want to write this entry by yourself, consider contributing to Mycorrhiza Wiki directly.

+`) +//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(` + +`) +//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(` +

List of users

`) -//line views/stuff.qtpl:52 +//line views/stuff.qtpl:88 var ( admins = 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(`

Admins

    `) -//line views/stuff.qtpl:70 +//line views/stuff.qtpl:106 for _, name := range admins { -//line views/stuff.qtpl:70 +//line views/stuff.qtpl:106 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:107 qw422016.E().S(name) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:107 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:72 +//line views/stuff.qtpl:108 } -//line views/stuff.qtpl:72 +//line views/stuff.qtpl:108 qw422016.N().S(`

Moderators

    `) -//line views/stuff.qtpl:76 +//line views/stuff.qtpl:112 for _, name := range moderators { -//line views/stuff.qtpl:76 +//line views/stuff.qtpl:112 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:77 +//line views/stuff.qtpl:113 qw422016.E().S(name) -//line views/stuff.qtpl:77 +//line views/stuff.qtpl:113 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:78 +//line views/stuff.qtpl:114 } -//line views/stuff.qtpl:78 +//line views/stuff.qtpl:114 qw422016.N().S(`

Editors

    `) -//line views/stuff.qtpl:82 +//line views/stuff.qtpl:118 for _, name := range editors { -//line views/stuff.qtpl:82 +//line views/stuff.qtpl:118 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:83 +//line views/stuff.qtpl:119 qw422016.E().S(name) -//line views/stuff.qtpl:83 +//line views/stuff.qtpl:119 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:84 +//line views/stuff.qtpl:120 } -//line views/stuff.qtpl:84 +//line views/stuff.qtpl:120 qw422016.N().S(`
`) -//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) { -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 StreamUserListHTML(qw422016) -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 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 { -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 WriteUserListHTML(qb422016) -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:88 +//line views/stuff.qtpl:124 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) { -//line views/stuff.qtpl:90 +//line views/stuff.qtpl:126 qw422016.N().S(`

List of hyphae

This wiki has `) -//line views/stuff.qtpl:94 +//line views/stuff.qtpl:130 qw422016.N().D(hyphae.Count()) -//line views/stuff.qtpl:94 +//line views/stuff.qtpl:130 qw422016.N().S(` hyphae.

    `) -//line views/stuff.qtpl:96 +//line views/stuff.qtpl:132 for h := range hyphae.YieldExistingHyphae() { -//line views/stuff.qtpl:96 +//line views/stuff.qtpl:132 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:98 +//line views/stuff.qtpl:134 qw422016.E().S(util.BeautifulName(h.Name)) -//line views/stuff.qtpl:98 +//line views/stuff.qtpl:134 qw422016.N().S(` `) -//line views/stuff.qtpl:99 +//line views/stuff.qtpl:135 if h.BinaryPath != "" { -//line views/stuff.qtpl:99 +//line views/stuff.qtpl:135 qw422016.N().S(` `) -//line views/stuff.qtpl:100 +//line views/stuff.qtpl:136 qw422016.E().S(filepath.Ext(h.BinaryPath)[1:]) -//line views/stuff.qtpl:100 +//line views/stuff.qtpl:136 qw422016.N().S(` `) -//line views/stuff.qtpl:101 +//line views/stuff.qtpl:137 } -//line views/stuff.qtpl:101 +//line views/stuff.qtpl:137 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:103 +//line views/stuff.qtpl:139 } -//line views/stuff.qtpl:103 +//line views/stuff.qtpl:139 qw422016.N().S(`
`) -//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) { -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 StreamHyphaListHTML(qw422016) -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 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 { -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 WriteHyphaListHTML(qb422016) -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:107 +//line views/stuff.qtpl:143 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) { -//line views/stuff.qtpl:109 +//line views/stuff.qtpl:145 qw422016.N().S(`

About `) -//line views/stuff.qtpl:113 +//line views/stuff.qtpl:149 qw422016.E().S(cfg.WikiName) -//line views/stuff.qtpl:113 +//line views/stuff.qtpl:149 qw422016.N().S(`

See /list for information about hyphae on this wiki.

`) -//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) { -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 StreamAboutHTML(qw422016) -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 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 { -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 WriteAboutHTML(qb422016) -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:131 +//line views/stuff.qtpl:167 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) { -//line views/stuff.qtpl:133 +//line views/stuff.qtpl:169 qw422016.N().S(` `) -//line views/stuff.qtpl:134 +//line views/stuff.qtpl:170 for _, scriptPath := range cfg.CommonScripts { -//line views/stuff.qtpl:134 +//line views/stuff.qtpl:170 qw422016.N().S(` `) -//line views/stuff.qtpl:136 +//line views/stuff.qtpl:172 } -//line views/stuff.qtpl:136 +//line views/stuff.qtpl:172 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) { -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 StreamCommonScripts(qw422016) -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 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 { -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 WriteCommonScripts(qb422016) -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 return qs422016 -//line views/stuff.qtpl:137 +//line views/stuff.qtpl:173 } diff --git a/web/stuff.go b/web/stuff.go index bf9ed49..a914ea5 100644 --- a/web/stuff.go +++ b/web/stuff.go @@ -2,10 +2,14 @@ package web // stuff.go is used for meta stuff about the wiki or all hyphae at once. import ( + "github.com/bouncepaw/mycomarkup" + "github.com/bouncepaw/mycomarkup/mycocontext" + "github.com/bouncepaw/mycorrhiza/help" "io" "log" "math/rand" "net/http" + "strings" "github.com/bouncepaw/mycorrhiza/cfg" "github.com/bouncepaw/mycorrhiza/files" @@ -18,6 +22,7 @@ import ( ) func initStuff() { + http.HandleFunc("/help/", handlerHelp) http.HandleFunc("/list/", handlerList) http.HandleFunc("/reindex/", handlerReindex) 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. func handlerList(w http.ResponseWriter, rq *http.Request) { u := user.FromRequest(rq)