Fix static not loading and de-qtpl tree
This commit is contained in:
parent
4c31c8cc32
commit
a2e5db444a
@ -64,7 +64,7 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img class="icon" width="20" height="20" src="/web/static/icon/feed.svg" aria-hidden="true" alt="RSS icon">
|
||||
<img class="icon" width="20" height="20" src="/static/icon/feed.svg" aria-hidden="true" alt="RSS icon">
|
||||
{{block "subscribe via" .}}Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.{{end}}
|
||||
</p>
|
||||
</main>
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
{{end}}
|
||||
</section>
|
||||
</aside>
|
||||
<script src="/web/static/toolbar.js"></script>
|
||||
<script src="/static/toolbar.js"></script>
|
||||
{{end}}
|
||||
|
||||
{{define "editing hypha"}}Edit {{beautifulName .}}{{end}}
|
||||
@ -98,7 +98,7 @@
|
||||
{{end}}
|
||||
</main>
|
||||
{{template "toolbar" .}}
|
||||
<script src="/web/static/editor.js"></script>
|
||||
<script src="/static/editor.js"></script>
|
||||
{{range .EditScripts}}
|
||||
<script src="{{.}}"></script>
|
||||
{{end}}
|
||||
|
||||
13
main.go
13
main.go
@ -1,6 +1,5 @@
|
||||
// Command mycorrhiza is a program that runs a mycorrhiza wiki.
|
||||
//
|
||||
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=tree
|
||||
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=history
|
||||
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=mycoopts
|
||||
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=auth
|
||||
@ -17,9 +16,9 @@ import (
|
||||
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/files"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/hyphae"
|
||||
migration2 "github.com/bouncepaw/mycorrhiza/internal/migration"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/migration"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/shroom"
|
||||
user2 "github.com/bouncepaw/mycorrhiza/internal/user"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/user"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/version"
|
||||
"github.com/bouncepaw/mycorrhiza/interwiki"
|
||||
"github.com/bouncepaw/mycorrhiza/web"
|
||||
@ -49,11 +48,11 @@ func main() {
|
||||
hyphae.Index(files.HyphaeDir())
|
||||
backlinks.IndexBacklinks()
|
||||
go backlinks.RunBacklinksConveyor()
|
||||
user2.InitUserDatabase()
|
||||
user.InitUserDatabase()
|
||||
history.Start()
|
||||
history.InitGitRepo()
|
||||
migration2.MigrateRocketsMaybe()
|
||||
migration2.MigrateHeadingsMaybe()
|
||||
migration.MigrateRocketsMaybe()
|
||||
migration.MigrateHeadingsMaybe()
|
||||
shroom.SetHeaderLinks()
|
||||
categories.Init()
|
||||
interwiki.Init()
|
||||
@ -61,7 +60,7 @@ func main() {
|
||||
// Static files:
|
||||
static.InitFS(files.StaticFiles())
|
||||
|
||||
if !user2.HasAnyAdmins() {
|
||||
if !user.HasAnyAdmins() {
|
||||
log.Println("Your wiki has no admin yet. Run Mycorrhiza with -create-admin <username> option to create an admin.")
|
||||
}
|
||||
|
||||
|
||||
43
tree/tree.go
43
tree/tree.go
@ -1,7 +1,10 @@
|
||||
package tree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/hyphae"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"io"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
@ -44,6 +47,41 @@ type child struct {
|
||||
children []child
|
||||
}
|
||||
|
||||
/*
|
||||
Subhyphae links are recursive. It may end up looking like that if drawn with
|
||||
pseudographics:
|
||||
╔══════════════╗
|
||||
║Foo ║ The presented hyphae are ./foo and ./foo/bar
|
||||
║╔════════════╗║
|
||||
║║Bar ║║
|
||||
║╚════════════╝║
|
||||
╚══════════════╝
|
||||
*/
|
||||
func childHTML(c *child, w io.Writer) {
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
|
||||
_, _ = io.WriteString(w, "<li class=\"subhyphae__entry\">\n<a class=\"subhyphae__link")
|
||||
if !c.exists {
|
||||
_, _ = io.WriteString(w, " wikilink_new")
|
||||
}
|
||||
_, _ = io.WriteString(w, fmt.Sprintf(
|
||||
"\" href=\"/hypha/%s\">%s</a>\n",
|
||||
c.name,
|
||||
util.BeautifulName(path.Base(c.name)),
|
||||
))
|
||||
|
||||
if len(c.children) > 0 {
|
||||
_, _ = io.WriteString(w, "<ul>\n")
|
||||
for _, child := range c.children {
|
||||
childHTML(&child, w)
|
||||
}
|
||||
_, _ = io.WriteString(w, "</ul>\n")
|
||||
}
|
||||
_, _ = io.WriteString(w, "</li>\n")
|
||||
}
|
||||
|
||||
func addHyphaToChild(hyphaName, subPath string, child *child) {
|
||||
// when hyphaName = "root/a/b", subPath = "a/b", and child.name = "root"
|
||||
// addHyphaToChild("root/a/b", "b", child{"root/a"})
|
||||
@ -82,8 +120,9 @@ func subhyphaeMatrix(children []child) (html string) {
|
||||
sort.Slice(children, func(i, j int) bool {
|
||||
return children[i].name < children[j].name
|
||||
})
|
||||
var buf strings.Builder
|
||||
for _, child := range children {
|
||||
html += childHTML(&child)
|
||||
childHTML(&child, &buf)
|
||||
}
|
||||
return html
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
{% import "sort" %}
|
||||
{% import "path" %}
|
||||
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
||||
|
||||
Subhyphae links are recursive. It may end up looking like that if drawn with
|
||||
pseudographics:
|
||||
╔══════════════╗
|
||||
║Foo ║ The presented hyphae are ./foo and ./foo/bar
|
||||
║╔════════════╗║
|
||||
║║Bar ║║
|
||||
║╚════════════╝║
|
||||
╚══════════════╝
|
||||
{% func childHTML(c *child) %}
|
||||
{% code
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
%}
|
||||
<li class="subhyphae__entry">
|
||||
<a class="subhyphae__link {% if !c.exists %}wikilink_new{% endif %}" href="/hypha/{%s c.name %}">
|
||||
{%s util.BeautifulName(path.Base(c.name)) %}
|
||||
</a>
|
||||
{% if len(c.children) > 0 %}
|
||||
<ul>
|
||||
{% for _, child := range c.children %}
|
||||
{%s= childHTML(&child) %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfunc %}
|
||||
|
||||
@ -1,126 +0,0 @@
|
||||
// Code generated by qtc from "view.qtpl". DO NOT EDIT.
|
||||
// See https://github.com/valyala/quicktemplate for details.
|
||||
|
||||
//line tree/view.qtpl:1
|
||||
package tree
|
||||
|
||||
//line tree/view.qtpl:1
|
||||
import "sort"
|
||||
|
||||
//line tree/view.qtpl:2
|
||||
import "path"
|
||||
|
||||
//line tree/view.qtpl:3
|
||||
import "github.com/bouncepaw/mycorrhiza/util"
|
||||
|
||||
// Subhyphae links are recursive. It may end up looking like that if drawn with
|
||||
// pseudographics:
|
||||
// ╔══════════════╗
|
||||
// ║Foo ║ The presented hyphae are ./foo and ./foo/bar
|
||||
// ║╔════════════╗║
|
||||
// ║║Bar ║║
|
||||
// ║╚════════════╝║
|
||||
// ╚══════════════╝
|
||||
|
||||
//line tree/view.qtpl:13
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line tree/view.qtpl:13
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line tree/view.qtpl:13
|
||||
func streamchildHTML(qw422016 *qt422016.Writer, c *child) {
|
||||
//line tree/view.qtpl:13
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:15
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
|
||||
//line tree/view.qtpl:18
|
||||
qw422016.N().S(`
|
||||
<li class="subhyphae__entry">
|
||||
<a class="subhyphae__link `)
|
||||
//line tree/view.qtpl:20
|
||||
if !c.exists {
|
||||
//line tree/view.qtpl:20
|
||||
qw422016.N().S(`wikilink_new`)
|
||||
//line tree/view.qtpl:20
|
||||
}
|
||||
//line tree/view.qtpl:20
|
||||
qw422016.N().S(`" href="/hypha/`)
|
||||
//line tree/view.qtpl:20
|
||||
qw422016.E().S(c.name)
|
||||
//line tree/view.qtpl:20
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line tree/view.qtpl:21
|
||||
qw422016.E().S(util.BeautifulName(path.Base(c.name)))
|
||||
//line tree/view.qtpl:21
|
||||
qw422016.N().S(`
|
||||
</a>
|
||||
`)
|
||||
//line tree/view.qtpl:23
|
||||
if len(c.children) > 0 {
|
||||
//line tree/view.qtpl:23
|
||||
qw422016.N().S(`
|
||||
<ul>
|
||||
`)
|
||||
//line tree/view.qtpl:25
|
||||
for _, child := range c.children {
|
||||
//line tree/view.qtpl:25
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:26
|
||||
qw422016.N().S(childHTML(&child))
|
||||
//line tree/view.qtpl:26
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:27
|
||||
}
|
||||
//line tree/view.qtpl:27
|
||||
qw422016.N().S(`
|
||||
</ul>
|
||||
`)
|
||||
//line tree/view.qtpl:29
|
||||
}
|
||||
//line tree/view.qtpl:29
|
||||
qw422016.N().S(`
|
||||
</li>
|
||||
`)
|
||||
//line tree/view.qtpl:31
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:31
|
||||
func writechildHTML(qq422016 qtio422016.Writer, c *child) {
|
||||
//line tree/view.qtpl:31
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:31
|
||||
streamchildHTML(qw422016, c)
|
||||
//line tree/view.qtpl:31
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:31
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:31
|
||||
func childHTML(c *child) string {
|
||||
//line tree/view.qtpl:31
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:31
|
||||
writechildHTML(qb422016, c)
|
||||
//line tree/view.qtpl:31
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:31
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:31
|
||||
return qs422016
|
||||
//line tree/view.qtpl:31
|
||||
}
|
||||
@ -32,6 +32,7 @@ func ShorterPath(path string) string {
|
||||
}
|
||||
|
||||
// HTTP404Page writes a 404 error in the status, needed when no content is found on the page.
|
||||
// TODO: demolish
|
||||
func HTTP404Page(w http.ResponseWriter, page string) {
|
||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
@ -39,6 +40,7 @@ func HTTP404Page(w http.ResponseWriter, page string) {
|
||||
}
|
||||
|
||||
// HTTP200Page wraps some frequently used things for successful 200 responses.
|
||||
// TODO: demolish
|
||||
func HTTP200Page(w http.ResponseWriter, page string) {
|
||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{block "title" .}}{{end}}</title>
|
||||
<link rel="icon" href="/web/static/favicon.ico">
|
||||
<link rel="stylesheet" href="/web/static/style.css">
|
||||
<link rel="icon" href="/static/favicon.ico">
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
{{range .HeadElements}}{{.}}{{end}}
|
||||
</head>
|
||||
<body data-rrh-addr="{{if .Addr}}{{.Addr}}{{else}}{{.Meta.Addr}}{{end}}"{{range $key, $value := .BodyAttributes}} data-rrh-{{$key}}="{{$value}}"{{end}}>
|
||||
@ -45,9 +45,9 @@
|
||||
</nav>
|
||||
</header>
|
||||
{{block "body" .}}{{end}}
|
||||
<script src="/web/static/common.js"></script>
|
||||
<script src="/web/static/shortcuts.js"></script>
|
||||
<script src="/web/static/view.js"></script>
|
||||
<script src="/static/common.js"></script>
|
||||
<script src="/static/shortcuts.js"></script>
|
||||
<script src="/static/view.js"></script>
|
||||
{{range .CommonScripts}}
|
||||
<script src="{{.}}"></script>
|
||||
{{end}}
|
||||
|
||||
@ -108,11 +108,11 @@ main h1:not(.navi-title) {font-size:1.7rem;}
|
||||
blockquote { margin: 0; padding-left: .75rem; }
|
||||
.wikilink_external::before { display: inline-block; width: 18px; height: 16px; vertical-align: sub; }
|
||||
/* .wikilink_external { padding-left: 16px; } */
|
||||
.wikilink_gopher::before { content: url("/web/staticatic/icon/gopher-proto.svg"); }
|
||||
.wikilink_http::before, .wikilink_https::before { content: url("/web/staticatic/icon/http-proto.svg"); }
|
||||
.wikilink_gopher::before { content: url("/staticatic/icon/gopher-proto.svg"); }
|
||||
.wikilink_http::before, .wikilink_https::before { content: url("/staticatic/icon/http-proto.svg"); }
|
||||
/* .wikilink_https { background: transparent url("/static/icon/http-proto.svg") center left no-repeat; } */
|
||||
.wikilink_gemini::before { content: url("/web/staticatic/icon/gemini-proto.svg"); }
|
||||
.wikilink_mailto::before { content: url("/web/staticatic/icon/mailto-proto.svg"); }
|
||||
.wikilink_gemini::before { content: url("/staticatic/icon/gemini-proto.svg"); }
|
||||
.wikilink_mailto::before { content: url("/staticatic/icon/mailto-proto.svg"); }
|
||||
|
||||
article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; }
|
||||
main h1 { margin: .5rem 0 0 0; }
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{block "title" .}}{{end}}</title>
|
||||
<link rel="icon" href="/web/static/favicon.ico">
|
||||
<link rel="stylesheet" href="/web/static/style.css">
|
||||
<link rel="icon" href="/static/favicon.ico">
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
{{range .HeadElements}}{{.}}{{end}}
|
||||
</head>
|
||||
<body data-rrh-addr="{{if .Addr}}{{.Addr}}{{else}}{{.Meta.Addr}}{{end}}"{{range $key, $value := .BodyAttributes}} data-rrh-{{$key}}="{{$value}}"{{end}}>
|
||||
@ -45,9 +45,9 @@
|
||||
</nav>
|
||||
</header>
|
||||
{{block "body" .}}{{end}}
|
||||
<script src="/web/static/common.js"></script>
|
||||
<script src="/web/static/shortcuts.js"></script>
|
||||
<script src="/web/static/view.js"></script>
|
||||
<script src="/static/common.js"></script>
|
||||
<script src="/static/shortcuts.js"></script>
|
||||
<script src="/static/view.js"></script>
|
||||
{{range .CommonScripts}}
|
||||
<script src="{{.}}"></script>
|
||||
{{end}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user