mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-06-02 19:24:05 +00:00
Redo templates a little, support w3m and phones, add Makefile
This commit is contained in:
parent
8aec02c961
commit
944deb4cab
12
Makefile
Normal file
12
Makefile
Normal file
@ -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."
|
||||||
|
|
@ -28,7 +28,7 @@ var (
|
|||||||
configJsonPath string
|
configJsonPath string
|
||||||
|
|
||||||
// Default values that can be overriden in config.json
|
// Default values that can be overriden in config.json
|
||||||
Address = "127.0.0.1:80"
|
Address = "0.0.0.0:80"
|
||||||
TitleEditTemplate = `Edit %s`
|
TitleEditTemplate = `Edit %s`
|
||||||
TitleTemplate = `%s`
|
TitleTemplate = `%s`
|
||||||
GenericErrorMsg = `<b>Sorry, something went wrong</b>`
|
GenericErrorMsg = `<b>Sorry, something went wrong</b>`
|
||||||
|
@ -23,7 +23,6 @@ func HyphaEdit(h *fs.Hypha) []byte { //
|
|||||||
withMap(hyphaData).
|
withMap(hyphaData).
|
||||||
wrapInBase(map[string]string{
|
wrapInBase(map[string]string{
|
||||||
"Title": fmt.Sprintf(cfg.TitleEditTemplate, h.FullName),
|
"Title": fmt.Sprintf(cfg.TitleEditTemplate, h.FullName),
|
||||||
"Header": layout("edit/header").withString(h.FullName).String(),
|
|
||||||
"Sidebar": layout("edit/sidebar").withMap(hyphaData).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.
|
// Hypha404 renders 404 page for nonexistent page.
|
||||||
func Hypha404(name, _ string) []byte {
|
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.
|
// HyphaPage renders hypha viewer.
|
||||||
func HyphaPage(name, content string) []byte {
|
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
|
// 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{
|
page := map[string]string{
|
||||||
"Title": cfg.SiteTitle,
|
"Title": cfg.SiteTitle,
|
||||||
"Main": "",
|
"Content": lyt.String(),
|
||||||
"SiteTitle": cfg.SiteTitle,
|
"SiteTitle": cfg.SiteTitle,
|
||||||
}
|
}
|
||||||
for key, val := range keys {
|
for key, val := range keys {
|
||||||
page[key] = val
|
page[key] = val
|
||||||
}
|
}
|
||||||
page["Main"] = lyt.String()
|
|
||||||
return layout("base").withMap(page).Bytes()
|
return layout("base").withMap(page).Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func hyphaTree(name string) string {
|
func hyphaTree(name string) string {
|
||||||
return layout("view/sidebar").
|
return fs.Hs.GetTree(name, true).AsHtml()
|
||||||
withMap(map[string]string{"Tree": fs.Hs.GetTree(name, true).AsHtml()}).
|
|
||||||
String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Layout struct {
|
type Layout struct {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"address": "127.0.0.1:1737",
|
"address": "0.0.0.0:1737",
|
||||||
"theme": "default-light",
|
"theme": "default-light",
|
||||||
"site-title": "🍄 MycorrhizaWiki",
|
"site-title": "🍄 MycorrhizaWiki",
|
||||||
"title-templates": {
|
"title-templates": {
|
||||||
|
5
wiki/main/fruit/pear/2.markdown
Normal file
5
wiki/main/fruit/pear/2.markdown
Normal file
@ -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)
|
||||||
|
|
||||||
|
По-русски: груша
|
@ -14,6 +14,17 @@
|
|||||||
"binary_mime": "",
|
"binary_mime": "",
|
||||||
"text_name": "1.markdown",
|
"text_name": "1.markdown",
|
||||||
"binary_name": ""
|
"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": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
3
wiki/main/fungus/2.markdown
Normal file
3
wiki/main/fungus/2.markdown
Normal file
@ -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.
|
||||||
|
|
||||||
|
По-русски: грибы.
|
@ -14,6 +14,19 @@
|
|||||||
"binary_mime": "",
|
"binary_mime": "",
|
||||||
"text_name": "1.markdown",
|
"text_name": "1.markdown",
|
||||||
"binary_name": ""
|
"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": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1
wiki/main/test/1.markdown
Normal file
1
wiki/main/test/1.markdown
Normal file
@ -0,0 +1 @@
|
|||||||
|
This is a testing page to test that editing works, etc
|
19
wiki/main/test/meta.json
Normal file
19
wiki/main/test/meta.json
Normal file
@ -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": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<link rel="stylesheet" href="/:sys/theme/default-light/main.css?action=raw">
|
<link rel="stylesheet" href="/:sys/theme/default-light/main.css?action=raw">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="header">
|
<header class="header">
|
||||||
@ -13,10 +14,8 @@
|
|||||||
≡
|
≡
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
<aside class="sidebar hidden_mobile" id="sidebar">
|
<!-- <main> and <aside> are in .Content -->
|
||||||
{{ .Sidebar }}
|
{{ .Content }}
|
||||||
</aside>
|
|
||||||
<main class="main">{{ .Main }}</main>
|
|
||||||
<footer>
|
<footer>
|
||||||
<p>This website runs <a href='https://github.com/bouncepaw/mycorrhiza'>MycorrhizaWiki</a></p>
|
<p>This website runs <a href='https://github.com/bouncepaw/mycorrhiza'>MycorrhizaWiki</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<h1 class="header__edit-title">Edit {{ . }}</h1>
|
|
@ -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": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,9 +3,42 @@
|
|||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data"
|
||||||
action="?action=update"
|
action="?action=update"
|
||||||
id="edit-form">
|
id="edit-form">
|
||||||
<h4>Edit box</h4>
|
<aside class="sidebar hidden_mobile" id="sidebar"><!-- TODO: i18n -->
|
||||||
<!-- It is important that there is no indent ↓ -->
|
<fieldset><!-- TODO: make this thing work with radiobuttons that are generated automatically for all supported mimes -->
|
||||||
<textarea class="edit-box__text" name="text">
|
<legend>Text MIME-type</legend>
|
||||||
{{ .Text }}</textarea>
|
<p>Good types are <code>text/markdown</code> and <code>text/plain</code></p>
|
||||||
|
<input type="text" name="text_mime" value="{{ .TextMime }}" id="text_mime"/>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Revision comment</legend>
|
||||||
|
<p>Please make your comment helpful</p>
|
||||||
|
<input type="text" name="comment" value="Update {{ .Name }}" id="comment"/>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Edit tags</legend>
|
||||||
|
<p>Tags are separated by commas, whitespace is ignored</p>
|
||||||
|
<input type="text" name="tags" value="{{ .Tags }}" id="tags"/>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Upload file</legend>
|
||||||
|
<p>Only images are supported for now</p>
|
||||||
|
<input type="file" name="binary" id="binary"/>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="update" form="edit-form"/>
|
||||||
|
<a href="?">Cancel</a>
|
||||||
|
</p>
|
||||||
|
</aside>
|
||||||
|
<main class="main">
|
||||||
|
<h1 class="page__title">Edit {{ .Name }}</h1>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Edit box</legend>
|
||||||
|
<textarea class="edit-box__text" name="text">{{ .Text }}</textarea>
|
||||||
|
</fieldset>
|
||||||
|
</main>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
<div>
|
|
||||||
<h4>Text MIME-type</h4>
|
|
||||||
<p>Good types are <code>text/markdown</code> and <code>text/plain</code></p>
|
|
||||||
<input type="text" name="text_mime" value="{{ .TextMime }}" form="edit-form"/>
|
|
||||||
|
|
||||||
<h4>Revision comment</h4>
|
|
||||||
<p>Please make your comment helpful</p>
|
|
||||||
<input type="text" name="comment" value="Update {{ .Name }}" form="edit-form"/>
|
|
||||||
|
|
||||||
<h4>Edit tags</h4>
|
|
||||||
<p>Tags are separated by commas, whitespace is ignored</p>
|
|
||||||
<input type="text" name="tags" value="{{ .Tags }}" form="edit-form"/>
|
|
||||||
|
|
||||||
<h4>Upload file</h4>
|
|
||||||
<p>If this hypha has a file like that, the text above is meant to be a description of it</p>
|
|
||||||
<input type="file" name="binary" form="edit-form"/>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<input type="submit" value="update" form="edit-form"/>
|
|
||||||
<a href="?">Cancel</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
@ -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": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,6 @@ footer { padding: 1rem 0; font-size: .8rem; }
|
|||||||
footer a, footer a:visited { color: black; }
|
footer a, footer a:visited { color: black; }
|
||||||
/* Sidebar section */
|
/* Sidebar section */
|
||||||
.sidebar { padding: 1rem 0; background: #f4f4f4; }
|
.sidebar { padding: 1rem 0; background: #f4f4f4; }
|
||||||
.sidebar div { margin-left: 1rem; }
|
|
||||||
.sidebar-controller { font: inherit; padding: .25rem 1rem;
|
.sidebar-controller { font: inherit; padding: .25rem 1rem;
|
||||||
font-size: 2rem; float: right; }
|
font-size: 2rem; float: right; }
|
||||||
|
|
||||||
@ -39,6 +38,8 @@ text-decoration: none; color: black; }
|
|||||||
.navitree__ancestor { list-style: none; margin-left: -1rem; }
|
.navitree__ancestor { list-style: none; margin-left: -1rem; }
|
||||||
.navitree__pagename a { font-weight: bold; }
|
.navitree__pagename a { font-weight: bold; }
|
||||||
|
|
||||||
|
.edit-box aside { padding-left: 1rem; }
|
||||||
|
|
||||||
@media (max-width: 950px) {
|
@media (max-width: 950px) {
|
||||||
.hidden_mobile { display: none; }
|
.hidden_mobile { display: none; }
|
||||||
aside { height: 100%; }
|
aside { height: 100%; }
|
||||||
@ -52,3 +53,7 @@ text-decoration: none; color: black; }
|
|||||||
main, footer { margin: 0 0 auto 2rem; }
|
main, footer { margin: 0 0 auto 2rem; }
|
||||||
.edit-box__text { min-width: 600px; height: 70%; }
|
.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; }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Saved {{ .Name }}</title>
|
<title>Saved {{ .Name }}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Saved successfully. <a href="/{{ .Name }}">Go back</a></p>
|
<p>Saved successfully. <a href="/{{ .Name }}">Go back</a></p>
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
<article class="page page404">
|
<aside class="sidebar hidden_mobile" id="sidebar">
|
||||||
<h1 class="page__title">{{ . }}</h1>
|
<div class="hypha-actions">
|
||||||
<p class="msg_hypha-does-not-exist msg">
|
<ul>
|
||||||
The hypha you are trying to access does not exist yet. Why not <a href="?action=edit">create</a> it?
|
<li><a href="?action=edit">Edit</a></li>
|
||||||
</p>
|
</ul>
|
||||||
</article>
|
</div>
|
||||||
|
{{ .Tree }}
|
||||||
|
</aside>
|
||||||
|
<main class="main">
|
||||||
|
<article class="page page404">
|
||||||
|
<h1 class="page__title">{{ .PageTitle }}</h1>
|
||||||
|
<p class="msg_hypha-does-not-exist msg">
|
||||||
|
The hypha you are trying to access does not exist yet. Why not <a href="?action=edit">create</a> it?
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1,14 @@
|
|||||||
{{ . }}
|
<aside class="sidebar hidden_mobile" id="sidebar">
|
||||||
|
<div class="hypha-actions">
|
||||||
|
<ul>
|
||||||
|
<li><a href="?action=edit">Edit</a></li>
|
||||||
|
<li><a href="?action=binary">Download</a></li>
|
||||||
|
<li><a href="?action=zen">Zen mode</a></li>
|
||||||
|
<li><a href="?action=raw">View raw</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{ .Tree }}
|
||||||
|
</aside>
|
||||||
|
<main class="main">
|
||||||
|
{{ .Content }}
|
||||||
|
</main>
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<div class="hypha-actions">
|
|
||||||
<ul>
|
|
||||||
<li><a href="?action=edit">Edit</a></li>
|
|
||||||
<li><a href="?action=binary">Download</a></li>
|
|
||||||
<li><a href="?action=zen">Zen mode</a></li>
|
|
||||||
<li><a href="?action=raw">View raw</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{ .Tree }}
|
|
@ -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": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user