From ccc26c3a0bb65ae2613e222c3ead7f6db377b483 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sat, 17 Sep 2022 11:41:20 -0400 Subject: More work on the editor and update the example site to utilize it. --- example-site/conf.yml | 3 +- example-site/inc/base.html | 51 -------------------------- example-site/login.md | 21 +++++++++++ example-site/reIndex.md | 4 ++- example-site/tpl/4xx.md | 7 ++++ example-site/tpl/5xx.md | 30 ++++++++++++++++ example-site/tpl/base.md | 77 ++++++++++++++++++++++++++++++++++++++++ example-site/tpl/dashboard.md | 53 +++++++++++++++++++++++++++ example-site/tpl/edit.md | 27 ++++++++++++++ example-site/tpl/new-template.md | 55 ++++++++++++++++++++++++++++ 10 files changed, 275 insertions(+), 53 deletions(-) delete mode 100644 example-site/inc/base.html create mode 100644 example-site/login.md create mode 100644 example-site/tpl/4xx.md create mode 100644 example-site/tpl/5xx.md create mode 100644 example-site/tpl/base.md create mode 100644 example-site/tpl/dashboard.md create mode 100644 example-site/tpl/edit.md create mode 100644 example-site/tpl/new-template.md (limited to 'example-site') diff --git a/example-site/conf.yml b/example-site/conf.yml index b6f0202..3cdb44d 100644 --- a/example-site/conf.yml +++ b/example-site/conf.yml @@ -1,7 +1,8 @@ # All these can be unset reindexpath: /reIndex staticdirectory: static -basetemplate: inc/base.html +templatedirectory: tpl +basetemplate: tpl/base.md documentsplit: "|---\n" suffix: ".md" diff --git a/example-site/inc/base.html b/example-site/inc/base.html deleted file mode 100644 index 2f93ec7..0000000 --- a/example-site/inc/base.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - {{if .AuthorName }} - - {{else if .Global.App.Author.Name }} - - {{else}} - {{end}} - -{{if .Title}} - {{.Title}} -{{else}} - Please change me! -{{end}} - -{{if .Description}} - -{{else}} - -{{end}} - - - - - -{{if .Description}}{{else}} -

- - This is a draft, preview or otherwise unfinished page. - -

-{{end}} - - - -{{.RenderBody}} - - diff --git a/example-site/login.md b/example-site/login.md new file mode 100644 index 0000000..1b29ddd --- /dev/null +++ b/example-site/login.md @@ -0,0 +1,21 @@ +--- +title: Login +description: Login page +|--- + +
+ + + + + + + +
+ + +{{if .Vars}} +``` +{{.Vars}} +``` +{{else}}{{end}} diff --git a/example-site/reIndex.md b/example-site/reIndex.md index 12c608a..88cb278 100644 --- a/example-site/reIndex.md +++ b/example-site/reIndex.md @@ -6,7 +6,7 @@ description: > # {{.Title}} -{{.ClearRedis}} +{{.Global.App.ClearRedis}} this is the reindex page @@ -22,3 +22,5 @@ This handler adds some information to the page vars: {{.Vars}} ``` + + diff --git a/example-site/tpl/4xx.md b/example-site/tpl/4xx.md new file mode 100644 index 0000000..3b0103b --- /dev/null +++ b/example-site/tpl/4xx.md @@ -0,0 +1,7 @@ +--- +title: Page not found +description: Page not found +|--- +# {{.Title}} + +That's all we know. Perhaps you'd like to go back to the [home page](/)? diff --git a/example-site/tpl/5xx.md b/example-site/tpl/5xx.md new file mode 100644 index 0000000..43b28b6 --- /dev/null +++ b/example-site/tpl/5xx.md @@ -0,0 +1,30 @@ +--- +title: Server Error +description: Server Error +|--- +{{if .Vars}} + +{{if .Vars.Error}} +{{.Vars.Error}} +{{else}} +# Internal server error +{{end}} + +{{else}} +# Internal server error +{{end}} + +{{if .Vars}} + +{{if .Vars.Description}} +{{.Vars.Description}} +{{else}} +That's all we know. + +{{end}} + +{{else}} +That's all we know. +{{end}} + +Perhaps you'd like to go back to the [home page](/)? diff --git a/example-site/tpl/base.md b/example-site/tpl/base.md new file mode 100644 index 0000000..97842c1 --- /dev/null +++ b/example-site/tpl/base.md @@ -0,0 +1,77 @@ + + + + + + + + + + {{if .AuthorName }} + + {{else if .Global.App.Author.Name }} + + {{else}} + {{end}} + +{{if .Title}} + {{.Title}} +{{else}} + Please change me! +{{end}} + +{{if .Description}} + +{{else}} + +{{end}} + + + + + +{{if .Description}}{{else}} +

+ + This is a draft, preview or otherwise unfinished page. + +

+{{end}} + +{{block "nav" .}} + +{{end}} + +{{.RenderBody}} + + +{{if .Vars.LoggedIn}} + +{{end}} + + diff --git a/example-site/tpl/dashboard.md b/example-site/tpl/dashboard.md new file mode 100644 index 0000000..9b90445 --- /dev/null +++ b/example-site/tpl/dashboard.md @@ -0,0 +1,53 @@ +--- +title: Website Dashboard +description: Website dashboard +|--- + +# Dashboard page ( File: `tpl/dashboard.md` ) + +Almost every page on the website can be edited by simply adding `edit/` before +the path, for instance if we want to edit our `/reIndex` page, we simply go to +`/edit/reIndex` + +There are a few pages where this is not possible, such as with the dashboard and +other templated pages like 404's and 5xx's. That being said, you can still edit +them by referencing their path on disk. + +You can create new pages that way too, the new page template is +`tpl/new-template.md` if you wish to change what the defaults are. + +You'll also notice there's an `edit` button in the navbar, that's a little bit +of Javascript trickery that you'll have to edit if you wish to change the +template directory from `tpl` to anything else. + +Some useful edit links: + + * 4xx page [visit](/some/path/that/does/not/exist) [edit](/edit/tpl/4xx) + * 5xx page [visit](/tpl/5xx) [edit](/edit/tpl/5xx) + * New page template [visit](/tpl/new-template) [edit](/edit/tpl/new-template) + * Edit page [visit](/tpl/edit) [edit](/edit/tpl/edit) + * Login page [visit](/login) [edit](/edit/login) + * Base template [edit](/edit/tpl/base) + +A note about the base template page, editing works, but viewing does not. + +Pages by tags: + +{{range $key, $val := .Index}} +### {{$key}}: + +{{range $v2 := $val}} + * {{$v2.Path}} [visit](/{{$v2.Path}}) [edit](/edit/{{$v2.Path}}){{end}} + + + +{{end}} + + + diff --git a/example-site/tpl/edit.md b/example-site/tpl/edit.md new file mode 100644 index 0000000..4e55f82 --- /dev/null +++ b/example-site/tpl/edit.md @@ -0,0 +1,27 @@ +--- +title: Editing Page +description: Editor +|--- + +
+
+
+
+ + + + +
+ +
+ + + + + diff --git a/example-site/tpl/new-template.md b/example-site/tpl/new-template.md new file mode 100644 index 0000000..c4fdd95 --- /dev/null +++ b/example-site/tpl/new-template.md @@ -0,0 +1,55 @@ +--- +# This is the contents of the `tpl/new-template.md` file. You're likely seeing +# This because you've created a new page, or are trying to edit a page that +# does not exist. To save yourself some confusion in the future, if you save +# This page it may be helpful to delete this first paragraph, as it will no +# longer be true. + +# This top section is YAML, this sets up a few of the variables for rendering +# a web page. Below is also some markdown that's executed as a go template +# for the page's content + +# You can edit this page by editing `tpl/new-template` If you changed the +# template directory, take that into account. + +# Controls whether or not the page is published, this includes the +# Atom/RSS feed +published: false +# What tags should be applied to this page? +# The default index/home page shows a list of published blog pages +tags: + Blog: +# This is the meta description, i.e. what you're going to seeing the little blurb +# if you post the link to in say a discord chat. It's also what shows up in +# Google and other search engines +description: >- + This is an example description. Note that the line starts with spaces, and + not tabs. +title: New page from `new-template` +# Used for the RSS/Atom feed, you can also use it in the template below +date: 09.11.2022 09:59:00 EDT + +# This line tells our server to stop parsing yaml and start processing +# the rest of the text file as a markdown template +|--- + +{{/* This is a comment inside of the template */}} + +{{/* + Print out the date, format information can be found here: + https://pkg.go.dev/time#pkg-constants +*/}} +`{{.Date.Time.Format "Monday January 2 2006"}}` + +# {{.Title}} + +Some documentation on the templating language can be found [here]( +https://pkg.go.dev/text/template) + + +A nice markdown reference can be found +[here](https://www.markdownguide.org/basic-syntax/) + + +Additionally html tags can be used in here as well. + -- cgit v1.2.3