Implement beginnings of tagging
This commit is contained in:
parent
4fb4bec5a8
commit
105275f3e0
5 changed files with 142 additions and 40 deletions
|
|
@ -65,7 +65,8 @@ type Config struct {
|
|||
var (
|
||||
Conf Config
|
||||
assets []Asset = []Asset{
|
||||
{Path: "css/bootstrap.min.css", Url: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"},
|
||||
{Path: "css/bootstrap.min.css", Url: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css"},
|
||||
{Path: "js/bootstrap.bundle.min.js", Url: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"},
|
||||
{Path: "css/tiny-mde.min.css", Url: "https://unpkg.com/tiny-markdown-editor/dist/tiny-mde.min.css"},
|
||||
{Path: "js/tiny-mde.min.js", Url: "https://unpkg.com/tiny-markdown-editor/dist/tiny-mde.min.js"},
|
||||
{Path: "icons/eye.svg", Url: "https://raw.githubusercontent.com/twbs/icons/refs/heads/main/icons/eye.svg"},
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
crossorigin="anonymous">
|
||||
<link rel="icon" type="image/svg+xml"
|
||||
href="/static/icons/favicon.svg">
|
||||
|
||||
<script src="/static/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI"
|
||||
crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-sm bg-body-tertiary mb-3">
|
||||
|
|
@ -35,6 +39,11 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="/notes/">All Notes</a>
|
||||
</li>
|
||||
{{range .userTags}}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/notes/?tag={{.}}">{{.}}</a>
|
||||
</li>
|
||||
{{end}}
|
||||
{{template "navLinks" .}}
|
||||
<li>
|
||||
<a class="nav-link" href="/logout/">Logout {{.user}}</a>
|
||||
|
|
|
|||
|
|
@ -1,57 +1,96 @@
|
|||
{{define "title"}}{{.note.Title}}{{end}}
|
||||
{{define "main"}}
|
||||
<div>
|
||||
{{.note.BodyRendered}}
|
||||
{{.note.BodyRendered}}
|
||||
</div>
|
||||
<div class="d-flex justify-content-between">
|
||||
<a class="btn btn-primary" href="{{.urlEdit}}">Edit</a>
|
||||
<a class="btn btn-danger" href="{{.urlDelete}}">Delete</a>
|
||||
</div>
|
||||
{{ if .isOwner }}
|
||||
<div class="mt-2">
|
||||
<h3>Ownership</h3>
|
||||
{{if .note.Viewers}}
|
||||
<p>This note is owned by <em>{{.note.Owner}}</em> and is further visible to</p>
|
||||
<form action="{{.urlUnshare}}" method="POST">
|
||||
<table class="table vertical-align-middle">
|
||||
{{range .viewers}}
|
||||
<tr>
|
||||
<td>{{.}}</td>
|
||||
<td class="text-end">
|
||||
<button class="btn btn-outline-warning btn-sm" type="submit" name="viewer" value="{{.}}">Un-Share</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>This note is owned by <em>{{.note.Owner}}</em>.</p>
|
||||
{{end}}
|
||||
<div class="accordion mt-3" id="supplementaryAccordion">
|
||||
<div class="accordion-item">
|
||||
<h3 class="accordion-header">
|
||||
<button class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseOwnership"
|
||||
aria-expanded="false"
|
||||
aria-controls="collapseOwnership">
|
||||
Ownership
|
||||
</button>
|
||||
</h3>
|
||||
<div id="collapseOwnership" class="accordion-collapse collapse" data-bs-parent="#supplementaryAccordion">
|
||||
<div class="accordion-body">
|
||||
{{if .note.Viewers}}
|
||||
<p>This note is owned by <em>{{.note.Owner}}</em> and is further visible to</p>
|
||||
<form action="{{.urlUnshare}}" method="POST">
|
||||
<table class="table vertical-align-middle">
|
||||
{{range .viewers}}
|
||||
<tr>
|
||||
<td>{{.}}</td>
|
||||
<td class="text-end">
|
||||
<button class="btn btn-outline-warning btn-sm" type="submit" name="viewer" value="{{.}}">Un-Share</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>This note is owned by <em>{{.note.Owner}}</em>.</p>
|
||||
{{end}}
|
||||
|
||||
<form action="{{.urlShare}}" method="POST">
|
||||
<div class="mb-3">
|
||||
<input type="text" class="form-control" id="viewerInput" name="viewer" aria-described-by="viewerHelp" />
|
||||
<div id="viewerHelp" class="form-text">Share with other user</div>
|
||||
<form action="{{.urlShare}}" method="POST">
|
||||
<div class="mb-3">
|
||||
<input type="text" class="form-control" id="viewerInput" name="viewer" aria-described-by="viewerHelp" />
|
||||
<div id="viewerHelp" class="form-text">Share with other user</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Share</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h3 class="accordion-header">
|
||||
<button class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseTags"
|
||||
aria-expanded="false"
|
||||
aria-controls="collapseTags">
|
||||
Tags
|
||||
</button>
|
||||
</h3>
|
||||
<div id="collapseTags" class="accordion-collapse collapse" data-bs-parent="#supplementaryAccordion">
|
||||
<div class="accordion-body">
|
||||
<form action="{{.urlSetTags}}" method="POST">
|
||||
<div class="mb-3">
|
||||
<input type="text" class="form-control" id="tagInput" name="tags" aria-described-by="tagHelp" value="{{.note.Tags}}"/>
|
||||
<div id="tagHelp" class="form-text">Tags</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Set Tags</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Share</button>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<script>
|
||||
let checkBoxes = document.querySelectorAll('input[type=checkbox]')
|
||||
for (const i in checkBoxes) {
|
||||
let box = checkBoxes[i]
|
||||
box.disabled = false
|
||||
let checkBoxes = document.querySelectorAll('input[type=checkbox]')
|
||||
for (const i in checkBoxes) {
|
||||
let box = checkBoxes[i]
|
||||
box.disabled = false
|
||||
|
||||
box.onchange = function(event) {
|
||||
let form = new FormData()
|
||||
form.append("box", i)
|
||||
box.onchange = function(event) {
|
||||
let form = new FormData()
|
||||
form.append("box", i)
|
||||
|
||||
fetch("togglebox/", {method: "POST", body: form}).then((response) => {
|
||||
location.reload();
|
||||
})
|
||||
}
|
||||
fetch("togglebox/", {method: "POST", body: form}).then((response) => {
|
||||
location.reload();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
{{end}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue