Add sidebar
This commit is contained in:
parent
1f105eff39
commit
556f462a2d
|
@ -191,8 +191,7 @@ function renderGraphs() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder) {
|
const MD = new MarkdownIt({
|
||||||
const MD = new MarkdownIt({
|
|
||||||
linkify: true,
|
linkify: true,
|
||||||
highlight: function (str, lang) {
|
highlight: function (str, lang) {
|
||||||
if (lang === 'mermaid') {
|
if (lang === 'mermaid') {
|
||||||
|
@ -200,16 +199,17 @@ if (holder) {
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
MD.use(MarkdownItWikilinks({
|
MD.use(MarkdownItWikilinks({
|
||||||
baseURL: holder.dataset.baseUrl,
|
baseURL: document.querySelector('body').dataset.baseUrl,
|
||||||
uriSuffix: '',
|
uriSuffix: '',
|
||||||
relativeBaseURL: '/edit/',
|
relativeBaseURL: '/edit/',
|
||||||
htmlAttributes: {
|
htmlAttributes: {
|
||||||
class: 'wiki-link'
|
class: 'wiki-link'
|
||||||
},
|
},
|
||||||
})).use(MarkdownItMark).use(MarkdownItKatex)
|
})).use(MarkdownItMark).use(MarkdownItKatex)
|
||||||
|
|
||||||
|
if (holder) {
|
||||||
const options = {
|
const options = {
|
||||||
transform(text, element) {
|
transform(text, element) {
|
||||||
let converted = text
|
let converted = text
|
||||||
|
@ -489,3 +489,10 @@ search(searchInput).then(searcher => {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.querySelectorAll(".page-loader")
|
||||||
|
.forEach((el, key, parent) => {
|
||||||
|
fetch('/' + el.dataset.page + '?format=markdown').then(res => res.text()).then(text => {
|
||||||
|
el.innerHTML = MD.render(text)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -207,3 +207,17 @@ mark {
|
||||||
.marker, .fold {
|
.marker, .fold {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 300px auto;
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
padding: 0 12px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
25
main.go
25
main.go
|
@ -151,6 +151,8 @@ type recentPage struct {
|
||||||
Recent []Change
|
Recent []Change
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var baseTemplate = []string{"templates/layout.html", "templates/sidebar.html"}
|
||||||
|
|
||||||
type indexHandler struct{}
|
type indexHandler struct{}
|
||||||
type graphHandler struct{}
|
type graphHandler struct{}
|
||||||
type saveHandler struct {
|
type saveHandler struct {
|
||||||
|
@ -177,7 +179,9 @@ func (*authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if r.Method == http.MethodGet {
|
if r.Method == http.MethodGet {
|
||||||
if r.URL.Path == "/auth/login" {
|
if r.URL.Path == "/auth/login" {
|
||||||
t, err := template.ParseFiles("templates/layout.html", "templates/login.html")
|
templates := baseTemplate
|
||||||
|
templates = append(templates, "templates/login.html")
|
||||||
|
t, err := template.ParseFiles(templates...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
@ -215,7 +219,9 @@ func (*authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, sess.NextURI, 302)
|
http.Redirect(w, r, sess.NextURI, 302)
|
||||||
return
|
return
|
||||||
} else if r.URL.Path == "/auth/logout" {
|
} else if r.URL.Path == "/auth/logout" {
|
||||||
t, err := template.ParseFiles("templates/layout.html", "templates/logout.html")
|
templates := baseTemplate
|
||||||
|
templates = append(templates, "templates/logout.html")
|
||||||
|
t, err := template.ParseFiles(templates...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
@ -459,8 +465,9 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
TodayPage: todayPage(),
|
TodayPage: todayPage(),
|
||||||
ShowGraph: page != "Daily_Notes",
|
ShowGraph: page != "Daily_Notes",
|
||||||
}
|
}
|
||||||
|
templates := baseTemplate
|
||||||
t, err := template.ParseFiles("templates/layout.html", "templates/edit.html")
|
templates = append(templates, "templates/edit.html")
|
||||||
|
t, err := template.ParseFiles(templates...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
@ -540,8 +547,9 @@ func (h *graphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
Nodes: template.JS(nodesBuf.String()),
|
Nodes: template.JS(nodesBuf.String()),
|
||||||
Edges: template.JS(edgesBuf.String()),
|
Edges: template.JS(edgesBuf.String()),
|
||||||
}
|
}
|
||||||
|
templates := baseTemplate
|
||||||
t, err := template.ParseFiles("templates/layout.html", "templates/graph.html")
|
templates = append(templates, "templates/graph.html")
|
||||||
|
t, err := template.ParseFiles(templates...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
@ -670,8 +678,9 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ShowGraph: page != "Daily_Notes",
|
ShowGraph: page != "Daily_Notes",
|
||||||
TodayPage: todayPage(),
|
TodayPage: todayPage(),
|
||||||
}
|
}
|
||||||
|
templates := baseTemplate
|
||||||
t, err := template.ParseFiles("templates/layout.html", "templates/view.html")
|
templates = append(templates, "templates/view.html")
|
||||||
|
t, err := template.ParseFiles(templates...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
|
|
@ -225,7 +225,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-base-url="{{ .BaseURL }}">
|
||||||
<div>
|
<div>
|
||||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
|
@ -262,9 +262,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
{{ template "sidebar" . }}
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
</section>
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="h-app">
|
<div class="h-app">
|
||||||
<a href="/" class="u-url p-name">Wiki</a>
|
<a href="/" class="u-url p-name">Wiki</a>
|
||||||
|
|
3
templates/sidebar.html
Normal file
3
templates/sidebar.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{ define "sidebar" }}
|
||||||
|
<div class="sidebar page-loader content" data-page="Sidebar"></div>
|
||||||
|
{{ end }}
|
Loading…
Reference in New Issue
Block a user