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

Show message offering to create a page that does not exist yet

This commit is contained in:
Timur Ismagilov 2020-06-22 20:04:19 +05:00
parent 6e50ecf6a3
commit 279a14cb07
14 changed files with 158 additions and 6 deletions

View File

@ -42,6 +42,10 @@ func HandlerZen(w http.ResponseWriter, rq *http.Request) {
func HandlerView(w http.ResponseWriter, rq *http.Request) {
if rev, ok := HandlerBase(w, rq); ok {
rev.ActionView(w, HyphaPage)
} else { // Hypha does not exist
log.Println("Hypha does not exist, showing 404")
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(Hypha404(mux.Vars(rq)["hypha"])))
}
}

View File

@ -22,19 +22,29 @@ func EditHyphaPage(name, textMime, content, tags string) string {
return renderBase(renderFromMap(page, "Hypha/edit/index.html"), keys)
}
// Hypha404 returns 404 page for nonexistent page.
func Hypha404(name string) string {
return HyphaGeneric(name, name, "Hypha/view/404.html")
}
// HyphaPage returns HTML page of hypha viewer.
func HyphaPage(rev Revision, content string) string {
return HyphaGeneric(rev.FullName, content, "Hypha/view/index.html")
}
// HyphaGeneric is used when building renderers for all types of hypha pages
func HyphaGeneric(name string, content, templatePath string) string {
sidebar := DefaultSidebar
if bside := renderFromMap(map[string]string{
"Tree": GetTree(rev.FullName, true).AsHtml(),
"Tree": GetTree(name, true).AsHtml(),
}, "Hypha/view/sidebar.html"); bside != "" {
sidebar = bside
}
keys := map[string]string{
"Title": fmt.Sprintf(TitleTemplate, rev.FullName),
"Title": fmt.Sprintf(TitleTemplate, name),
"Sidebar": sidebar,
}
return renderBase(renderFromString(content, "Hypha/view/index.html"), keys)
return renderBase(renderFromString(content, templatePath), keys)
}
// renderBase collects and renders page from base template

1
w/m/Fungus/1.markdown Normal file
View File

@ -0,0 +1 @@
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.

View File

@ -0,0 +1,3 @@
Amanita muscaria, commonly known as the fly agaric or fly amanita, is a basidiomycete of the genus Amanita. It is also a muscimol mushroom. Native throughout the temperate and boreal regions of the Northern Hemisphere, Amanita muscaria has been unintentionally introduced to many countries in the Southern Hemisphere, generally as a symbiont with pine and birch plantations, and is now a true cosmopolitan species. It associates with various deciduous and coniferous trees.
It is not an [](Apple)!

View File

@ -0,0 +1,4 @@
Amanita muscaria, commonly known as the fly agaric or fly amanita, is a basidiomycete of the genus Amanita. It is also a muscimol mushroom. Native throughout the temperate and boreal regions of the Northern Hemisphere, Amanita muscaria has been unintentionally introduced to many countries in the Southern Hemisphere, generally as a symbiont with pine and birch plantations, and is now a true cosmopolitan species. It associates with various deciduous and coniferous trees.
It is not an [Apple](Apple)!

View File

@ -0,0 +1,5 @@
Amanita muscaria, commonly known as the fly agaric or fly amanita, is a basidiomycete of the genus Amanita. It is also a muscimol mushroom. Native throughout the temperate and boreal regions of the Northern Hemisphere, Amanita muscaria has been unintentionally introduced to many countries in the Southern Hemisphere, generally as a symbiont with pine and birch plantations, and is now a true cosmopolitan species. It associates with various deciduous and coniferous trees.
It is not an [Apple](/Apple)!

View File

@ -0,0 +1,6 @@
Amanita muscaria, commonly known as the fly agaric or fly amanita, is a basidiomycete of the genus Amanita. It is also a muscimol mushroom. Native throughout the temperate and boreal regions of the Northern Hemisphere, Amanita muscaria has been unintentionally introduced to many countries in the Southern Hemisphere, generally as a symbiont with pine and birch plantations, and is now a true cosmopolitan species. It associates with various deciduous and coniferous trees.
It is not an [Apple](/Fruit/Apple)!

View File

@ -0,0 +1,58 @@
{
"views": 0,
"deleted": false,
"revisions": {
"1": {
"tags": [
""
],
"name": "Amanita Muscaria",
"comment": "Update Fungus/Amanita Muscaria",
"author": "",
"time": 1592836062,
"text_mime": "text/markdown",
"binary_mime": "",
"text_name": "1.markdown",
"binary_name": ""
},
"2": {
"tags": [
""
],
"name": "Amanita Muscaria",
"comment": "Update Fungus/Amanita Muscaria",
"author": "",
"time": 1592836073,
"text_mime": "text/markdown",
"binary_mime": "",
"text_name": "2.markdown",
"binary_name": ""
},
"3": {
"tags": [
""
],
"name": "Amanita Muscaria",
"comment": "Update Fungus/Amanita Muscaria",
"author": "",
"time": 1592836084,
"text_mime": "text/markdown",
"binary_mime": "",
"text_name": "3.markdown",
"binary_name": ""
},
"4": {
"tags": [
""
],
"name": "Amanita Muscaria",
"comment": "Update Fungus/Amanita Muscaria",
"author": "",
"time": 1592836099,
"text_mime": "text/markdown",
"binary_mime": "",
"text_name": "4.markdown",
"binary_name": ""
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 KiB

View File

@ -0,0 +1,7 @@
Шляпка 7—16(20) см в диаметре, полушаровидная, раскрывающаяся до выпуклой и почти плоской со слабо вдавленным центром, с радиально разлинованным краем. Окраска тёмно-умброво-коричневая, оливково-охристая, охристо-коричневая, иногда серо-жёлтая, в центре более интенсивная. Общее покрывало на молодых грибах опушённое, ярко-жёлтое, затем остаётся в виде легко смываемых обрывков, на солнце белеющих, а к старости иногда становящихся серо-жёлтыми.
Пластинки частые, сначала узко-приросшие к ножке, затем свободные от неё, кремовые, с многочисленными пластиночками разной длины.
Ножка достигает 9—20 см в высоту и 1—2,5 см в поперечнике, утончающаяся кверху, в основании с яйцевидным или шаровидным утолщением. Поверхность ножки волокнисто-бархатистая, белая или беловатая, при прикосновении иногда слабо буреющая. Кольцо в верхней части ножки, беловатое, перепончатое, не разлинованное. Остатки общего покрывала в виде нескольких поясков желтоватых бородавчатых хлопьев на утолщении ножки.

View File

@ -0,0 +1,19 @@
{
"views": 0,
"deleted": false,
"revisions": {
"1": {
"tags": [
""
],
"name": "Amanita Regalis",
"comment": "Update Fungus/Amanita Regalis",
"author": "",
"time": 1592838045,
"text_mime": "text/markdown",
"binary_mime": "image/jpeg",
"text_name": "1.markdown",
"binary_name": "1.jpeg"
}
}
}

19
w/m/Fungus/meta.json Normal file
View File

@ -0,0 +1,19 @@
{
"views": 0,
"deleted": false,
"revisions": {
"1": {
"tags": [
""
],
"name": "Fungus",
"comment": "Update Fungus",
"author": "",
"time": 1592835944,
"text_mime": "text/markdown",
"binary_mime": "",
"text_name": "1.markdown",
"binary_name": ""
}
}
}

View File

@ -14,12 +14,20 @@ body {
padding: 12px 24px;
}
.msg {
background-color: #f4f4f4;
padding: 1rem;
}
.msg_hypha-does-not-exist {
border-radius: 1rem;
}
.shroom {
margin: 0;
}
.shroom__button {
border-radius: 8px;
border-radius: 1rem;
padding: 8px 16px 8px 0;
border: none;
background: #f0f2f4;
@ -65,7 +73,7 @@ a:visited {
}
h1, h2, h3, h4, h5, h6 {
margin: 1em 0 0.25em;
margin: 0.5em 0 0.25em;
}
.page {
@ -178,7 +186,7 @@ footer a, footer a:visited {
.sidebar {
padding: 16px 0;
border-radius: 8px;
border-radius: 1rem;
background: #f4f4f4;
}

View File

@ -0,0 +1,8 @@
<div class="naviwrapper">
<article class="page">
<h1 class="page__title">{{ . }}</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>
</div>