diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1573ad2 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +run: build + ./mycorrhiza wiki + +build: + go build . + +test: + go test ./util + +help: + echo "Read the Makefile to see what it can do. It is simple." + diff --git a/cfg/config.go b/cfg/config.go index 0a40da1..ed03401 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -28,7 +28,7 @@ var ( configJsonPath string // Default values that can be overriden in config.json - Address = "127.0.0.1:80" + Address = "0.0.0.0:80" TitleEditTemplate = `Edit %s` TitleTemplate = `%s` GenericErrorMsg = `Sorry, something went wrong` diff --git a/render/render.go b/render/render.go index a70f9f8..b1a4b60 100644 --- a/render/render.go +++ b/render/render.go @@ -23,7 +23,6 @@ func HyphaEdit(h *fs.Hypha) []byte { // withMap(hyphaData). wrapInBase(map[string]string{ "Title": fmt.Sprintf(cfg.TitleEditTemplate, h.FullName), - "Header": layout("edit/header").withString(h.FullName).String(), "Sidebar": layout("edit/sidebar").withMap(hyphaData).String(), }) } @@ -37,12 +36,26 @@ func HyphaUpdateOk(h *fs.Hypha) []byte { // // Hypha404 renders 404 page for nonexistent page. func Hypha404(name, _ string) []byte { - return hyphaGeneric(name, name, "view/404") + return layout("view/404"). + withMap(map[string]string{ + "PageTitle": name, + "Tree": hyphaTree(name), + }). + wrapInBase(map[string]string{ + "Title": fmt.Sprintf(cfg.TitleTemplate, name), + }) } // HyphaPage renders hypha viewer. func HyphaPage(name, content string) []byte { - return hyphaGeneric(name, content, "view/index") + return layout("view/index"). + withMap(map[string]string{ + "Content": content, + "Tree": hyphaTree(name), + }). + wrapInBase(map[string]string{ + "Title": fmt.Sprintf(cfg.TitleTemplate, name), + }) } // hyphaGeneric is used when building renderers for all types of hypha pages @@ -62,20 +75,17 @@ func (lyt *Layout) wrapInBase(keys map[string]string) []byte { } page := map[string]string{ "Title": cfg.SiteTitle, - "Main": "", + "Content": lyt.String(), "SiteTitle": cfg.SiteTitle, } for key, val := range keys { page[key] = val } - page["Main"] = lyt.String() return layout("base").withMap(page).Bytes() } func hyphaTree(name string) string { - return layout("view/sidebar"). - withMap(map[string]string{"Tree": fs.Hs.GetTree(name, true).AsHtml()}). - String() + return fs.Hs.GetTree(name, true).AsHtml() } type Layout struct { diff --git a/wiki/config.json b/wiki/config.json index 2f2abee..5e49f42 100644 --- a/wiki/config.json +++ b/wiki/config.json @@ -1,5 +1,5 @@ { - "address": "127.0.0.1:1737", + "address": "0.0.0.0:1737", "theme": "default-light", "site-title": "🍄 MycorrhizaWiki", "title-templates": { diff --git a/wiki/main/fruit/pear/2.markdown b/wiki/main/fruit/pear/2.markdown new file mode 100644 index 0000000..30c8f65 --- /dev/null +++ b/wiki/main/fruit/pear/2.markdown @@ -0,0 +1,5 @@ +A **pear** is a sweet fruit, usually with a green skin and a lot of juice, that has a round base and is slightly pointed towards the stem. + +Source of info: [cambridge dict](https://dictionary.cambridge.org/ru/словарь/английский/pear) + +По-русски: груша \ No newline at end of file diff --git a/wiki/main/fruit/pear/meta.json b/wiki/main/fruit/pear/meta.json index 648d1be..ddb6a14 100644 --- a/wiki/main/fruit/pear/meta.json +++ b/wiki/main/fruit/pear/meta.json @@ -14,6 +14,17 @@ "binary_mime": "", "text_name": "1.markdown", "binary_name": "" + }, + "2": { + "tags": null, + "name": "Pear", + "comment": "Update :Main/Fruit/Pear", + "author": "", + "time": 1593949655, + "text_mime": "text/markdown", + "binary_mime": "", + "text_name": "2.markdown", + "binary_name": "" } } } \ No newline at end of file diff --git a/wiki/main/fungus/2.markdown b/wiki/main/fungus/2.markdown new file mode 100644 index 0000000..4233359 --- /dev/null +++ b/wiki/main/fungus/2.markdown @@ -0,0 +1,3 @@ +A **fungus** is any member of the group of eukaryotic organisms that includes microorganisms such as yeasts and molds, as well as the more familiar mushrooms. These organisms are classified as a kingdom, which is separate from the other eukaryotic life kingdoms of plants and animals. + +По-русски: грибы. diff --git a/wiki/main/fungus/meta.json b/wiki/main/fungus/meta.json index 1742e90..065253b 100644 --- a/wiki/main/fungus/meta.json +++ b/wiki/main/fungus/meta.json @@ -14,6 +14,19 @@ "binary_mime": "", "text_name": "1.markdown", "binary_name": "" + }, + "2": { + "tags": [ + "" + ], + "name": "Fungus", + "comment": "Update :Main/Fungus", + "author": "", + "time": 1593951453, + "text_mime": "text/markdown", + "binary_mime": "", + "text_name": "2.markdown", + "binary_name": "" } } } \ No newline at end of file diff --git a/wiki/main/test/1.markdown b/wiki/main/test/1.markdown new file mode 100644 index 0000000..565097b --- /dev/null +++ b/wiki/main/test/1.markdown @@ -0,0 +1 @@ +This is a testing page to test that editing works, etc diff --git a/wiki/main/test/meta.json b/wiki/main/test/meta.json new file mode 100644 index 0000000..7478662 --- /dev/null +++ b/wiki/main/test/meta.json @@ -0,0 +1,19 @@ +{ + "views": 0, + "deleted": false, + "revisions": { + "1": { + "tags": [ + "" + ], + "name": "Test", + "comment": "Update :Main/Test", + "author": "", + "time": 1593943985, + "text_mime": "text/markdown", + "binary_mime": "", + "text_name": "1.markdown", + "binary_name": "" + } + } +} \ No newline at end of file diff --git a/wiki/sys/theme/default-light/base.html/1.html b/wiki/sys/theme/default-light/base.html/1.html index 54bc2f7..07d5cbf 100644 --- a/wiki/sys/theme/default-light/base.html/1.html +++ b/wiki/sys/theme/default-light/base.html/1.html @@ -2,6 +2,7 @@ {{ .Title }} +
@@ -13,10 +14,8 @@ ≡
- -
{{ .Main }}
+ + {{ .Content }} diff --git a/wiki/sys/theme/default-light/edit/header.html/1.html b/wiki/sys/theme/default-light/edit/header.html/1.html deleted file mode 100644 index 31dfc0f..0000000 --- a/wiki/sys/theme/default-light/edit/header.html/1.html +++ /dev/null @@ -1 +0,0 @@ -

Edit {{ . }}

diff --git a/wiki/sys/theme/default-light/edit/header.html/meta.json b/wiki/sys/theme/default-light/edit/header.html/meta.json deleted file mode 100644 index 5ba815a..0000000 --- a/wiki/sys/theme/default-light/edit/header.html/meta.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "views": 0, - "deleted": false, - "revisions": { - "1": { - "tags": null, - "name": "header.html", - "comment": "Create Templates/default-light/Hypha/edit/header.html", - "author": "", - "time": 1592996801, - "text_mime": "text/html", - "binary_mime": "", - "text_name": "1.html", - "binary_name": "" - } - } -} \ No newline at end of file diff --git a/wiki/sys/theme/default-light/edit/index.html/1.html b/wiki/sys/theme/default-light/edit/index.html/1.html index 034a437..080e1a5 100644 --- a/wiki/sys/theme/default-light/edit/index.html/1.html +++ b/wiki/sys/theme/default-light/edit/index.html/1.html @@ -3,9 +3,42 @@ enctype="multipart/form-data" action="?action=update" id="edit-form"> -

Edit box

- - + +
+

Edit {{ .Name }}

+
+ Edit box + +
+
diff --git a/wiki/sys/theme/default-light/edit/sidebar.html/1.html b/wiki/sys/theme/default-light/edit/sidebar.html/1.html deleted file mode 100644 index 54feb61..0000000 --- a/wiki/sys/theme/default-light/edit/sidebar.html/1.html +++ /dev/null @@ -1,22 +0,0 @@ -
-

Text MIME-type

-

Good types are text/markdown and text/plain

- - -

Revision comment

-

Please make your comment helpful

- - -

Edit tags

-

Tags are separated by commas, whitespace is ignored

- - -

Upload file

-

If this hypha has a file like that, the text above is meant to be a description of it

- - -

- - Cancel -

-
diff --git a/wiki/sys/theme/default-light/edit/sidebar.html/meta.json b/wiki/sys/theme/default-light/edit/sidebar.html/meta.json deleted file mode 100644 index 1fe3342..0000000 --- a/wiki/sys/theme/default-light/edit/sidebar.html/meta.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "views": 0, - "deleted": false, - "revisions": { - "1": { - "tags": [ - "" - ], - "name": "sidebar.html", - "comment": "Create Templates/default-dark/Hypha/edit/sidebar.html", - "author": "", - "time": 1593003792, - "text_mime": "text/html", - "binary_mime": "", - "text_name": "1.html", - "binary_name": "" - } - } -} diff --git a/wiki/sys/theme/default-light/main.css/1.css b/wiki/sys/theme/default-light/main.css/1.css index 5b212a8..f0c19b6 100644 --- a/wiki/sys/theme/default-light/main.css/1.css +++ b/wiki/sys/theme/default-light/main.css/1.css @@ -22,7 +22,6 @@ footer { padding: 1rem 0; font-size: .8rem; } footer a, footer a:visited { color: black; } /* Sidebar section */ .sidebar { padding: 1rem 0; background: #f4f4f4; } -.sidebar div { margin-left: 1rem; } .sidebar-controller { font: inherit; padding: .25rem 1rem; font-size: 2rem; float: right; } @@ -39,6 +38,8 @@ text-decoration: none; color: black; } .navitree__ancestor { list-style: none; margin-left: -1rem; } .navitree__pagename a { font-weight: bold; } +.edit-box aside { padding-left: 1rem; } + @media (max-width: 950px) { .hidden_mobile { display: none; } aside { height: 100%; } @@ -52,3 +53,7 @@ text-decoration: none; color: black; } main, footer { margin: 0 0 auto 2rem; } .edit-box__text { min-width: 600px; height: 70%; } } + +legend { font-weight: bold; padding: 0; } +fieldset { border: 0; padding: 0; margin: 0; margin-bottom: .5rem; } +fieldset * { margin: 0; } diff --git a/wiki/sys/theme/default-light/update_ok.html/1.html b/wiki/sys/theme/default-light/update_ok.html/1.html index f64067d..4d5854c 100644 --- a/wiki/sys/theme/default-light/update_ok.html/1.html +++ b/wiki/sys/theme/default-light/update_ok.html/1.html @@ -1,6 +1,7 @@ Saved {{ .Name }} +

Saved successfully. Go back

diff --git a/wiki/sys/theme/default-light/view/404.html/1.html b/wiki/sys/theme/default-light/view/404.html/1.html index 1a16087..d8cf4a5 100644 --- a/wiki/sys/theme/default-light/view/404.html/1.html +++ b/wiki/sys/theme/default-light/view/404.html/1.html @@ -1,6 +1,18 @@ -
-

{{ . }}

-

- The hypha you are trying to access does not exist yet. Why not create it? -

-
\ No newline at end of file + +
+
+

{{ .PageTitle }}

+

+ The hypha you are trying to access does not exist yet. Why not create it? +

+
+
+ + diff --git a/wiki/sys/theme/default-light/view/index.html/1.html b/wiki/sys/theme/default-light/view/index.html/1.html index 55a25b3..f053efb 100644 --- a/wiki/sys/theme/default-light/view/index.html/1.html +++ b/wiki/sys/theme/default-light/view/index.html/1.html @@ -1 +1,14 @@ -{{ . }} + +
+ {{ .Content }} +
diff --git a/wiki/sys/theme/default-light/view/sidebar.html/1.html b/wiki/sys/theme/default-light/view/sidebar.html/1.html deleted file mode 100644 index b85536f..0000000 --- a/wiki/sys/theme/default-light/view/sidebar.html/1.html +++ /dev/null @@ -1,9 +0,0 @@ -
- -
-{{ .Tree }} diff --git a/wiki/sys/theme/default-light/view/sidebar.html/meta.json b/wiki/sys/theme/default-light/view/sidebar.html/meta.json deleted file mode 100644 index 0c89342..0000000 --- a/wiki/sys/theme/default-light/view/sidebar.html/meta.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "views": 0, - "deleted": false, - "revisions": { - "1": { - "tags": null, - "name": "sidebar.html", - "comment": "Create Templates/default-light/Hypha/view/sidebar.html", - "author": "", - "time": 1592996977, - "text_mime": "text/html", - "binary_mime": "", - "text_name": "1.html", - "binary_name": "" - } - } -} \ No newline at end of file