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

Add the attachment tab

This commit is contained in:
bouncepaw 2021-02-24 22:34:42 +05:00
parent 22420bf690
commit a8a2735363
10 changed files with 514 additions and 254 deletions

View File

@ -23,7 +23,11 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) {
qw422016.N().S(`
`)
//line assets/assets.qtpl:2
qw422016.N().S(`.modal__title { font-size: 2rem; }
qw422016.N().S(`.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; }
.upload-binary__input { display: block; margin: .25rem 0; }
.modal__title { font-size: 2rem; }
.modal__title_small { font-size: 1.5rem; }
.modal__confirmation-msg { margin: 0 0 .5rem 0; }
.modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; }
.modal__submit { border: 1px #999 solid; }
@ -56,6 +60,7 @@ header { width: 100%; margin-bottom: 1rem; }
.backlinks__link { text-decoration: none; display: block; padding: .25rem; padding-left: 1.25rem; }
@media screen and (max-width: 800px) {
.amnt-grid { grid-template-columns: 1fr; }
.layout { grid-template-column: auto; grid-template-row: auto auto auto; }
.main-width { width: 100%; }
main { padding: 1rem; margin: 0; }

View File

@ -1,4 +1,8 @@
.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; }
.upload-binary__input { display: block; margin: .25rem 0; }
.modal__title { font-size: 2rem; }
.modal__title_small { font-size: 1.5rem; }
.modal__confirmation-msg { margin: 0 0 .5rem 0; }
.modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; }
.modal__submit { border: 1px #999 solid; }
@ -31,6 +35,7 @@ header { width: 100%; margin-bottom: 1rem; }
.backlinks__link { text-decoration: none; display: block; padding: .25rem; padding-left: 1.25rem; }
@media screen and (max-width: 800px) {
.amnt-grid { grid-template-columns: 1fr; }
.layout { grid-template-column: auto; grid-template-row: auto auto auto; }
.main-width { width: 100%; }
main { padding: 1rem; margin: 0; }

View File

@ -24,6 +24,21 @@ func init() {
http.HandleFunc("/text/", handlerText)
http.HandleFunc("/binary/", handlerBinary)
http.HandleFunc("/rev/", handlerRevision)
http.HandleFunc("/attachment/", handlerAttachment)
}
func handlerAttachment(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
var (
hyphaName = HyphaNameFromRq(rq, "attachment")
h = hyphae.ByName(hyphaName)
u = user.FromRequest(rq)
)
util.HTTP200Page(w,
views.BaseHTML(
fmt.Sprintf("Attachment of %s", util.BeautifulName(hyphaName)),
views.AttachmentMenuHTML(rq, h, u),
u))
}
// handlerRevision displays a specific revision of text part a page

View File

@ -178,7 +178,7 @@ func main() {
// See http_admin.go for /admin, /admin/*
initAdmin()
// See http_readers.go for /page/, /hypha/, /text/, /binary/
// See http_readers.go for /page/, /hypha/, /text/, /binary/, /attachment/
// See http_mutators.go for /upload-binary/, /upload-text/, /edit/, /delete-ask/, /delete-confirm/, /rename-ask/, /rename-confirm/, /unattach-ask/, /unattach-confirm/
// See http_auth.go for /login, /login-data, /logout, /logout-confirm
// See http_history.go for /history/, /recent-changes

View File

@ -16,7 +16,7 @@
{% func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) %}
{%= NavHTML(rq, hyphaName, "unattach-ask") %}
{%= modalBegin(
"unattach-confirm",
"unattach",
hyphaName,
"",
"Unattach "+util.BeautifulName(hyphaName)+"?") %}

View File

@ -94,7 +94,7 @@ func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaNam
`)
//line views/modal.qtpl:18
streammodalBegin(qw422016,
"unattach-confirm",
"unattach",
hyphaName,
"",
"Unattach "+util.BeautifulName(hyphaName)+"?")

View File

@ -12,6 +12,7 @@ type navEntry struct {
var navEntries = []navEntry{
{"page", "Hypha"},
{"edit", "Edit"},
{"attachment", "Attachment"},
{"history", "History"},
{"revision", "NOT REACHED"},
{"rename-ask", "Rename"},

View File

@ -40,6 +40,7 @@ type navEntry struct {
var navEntries = []navEntry{
{"page", "Hypha"},
{"edit", "Edit"},
{"attachment", "Attachment"},
{"history", "History"},
{"revision", "NOT REACHED"},
{"rename-ask", "Rename"},
@ -47,268 +48,268 @@ var navEntries = []navEntry{
{"text", "Raw text"},
}
//line views/nav.qtpl:23
//line views/nav.qtpl:24
func StreamNavHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) {
//line views/nav.qtpl:23
//line views/nav.qtpl:24
qw422016.N().S(`
`)
//line views/nav.qtpl:25
//line views/nav.qtpl:26
u := user.FromRequest(rq)
//line views/nav.qtpl:26
//line views/nav.qtpl:27
qw422016.N().S(`
<nav class="hypha-tabs main-width">
<ul class="hypha-tabs__flex">
`)
//line views/nav.qtpl:29
//line views/nav.qtpl:30
for _, entry := range navEntries {
//line views/nav.qtpl:30
//line views/nav.qtpl:31
if navType == "revision" && entry.path == "revision" {
//line views/nav.qtpl:30
//line views/nav.qtpl:31
qw422016.N().S(` <li class="hypha-tabs__tab hypha-tabs__tab_active">
<span class="hypha-tabs__selection">`)
//line views/nav.qtpl:32
//line views/nav.qtpl:33
qw422016.E().S(revisionHash[0])
//line views/nav.qtpl:32
//line views/nav.qtpl:33
qw422016.N().S(`</span>
</li>
`)
//line views/nav.qtpl:34
//line views/nav.qtpl:35
} else if navType == entry.path {
//line views/nav.qtpl:34
//line views/nav.qtpl:35
qw422016.N().S(` <li class="hypha-tabs__tab hypha-tabs__tab_active">
<span class="hypha-tabs__selection">`)
//line views/nav.qtpl:36
//line views/nav.qtpl:37
qw422016.E().S(entry.title)
//line views/nav.qtpl:36
//line views/nav.qtpl:37
qw422016.N().S(`</span>
</li>
`)
//line views/nav.qtpl:38
//line views/nav.qtpl:39
} else if entry.path != "revision" && u.CanProceed(entry.path) {
//line views/nav.qtpl:38
//line views/nav.qtpl:39
qw422016.N().S(` <li class="hypha-tabs__tab">
<a class="hypha-tabs__link" href="/`)
//line views/nav.qtpl:40
//line views/nav.qtpl:41
qw422016.E().S(entry.path)
//line views/nav.qtpl:40
//line views/nav.qtpl:41
qw422016.N().S(`/`)
//line views/nav.qtpl:40
//line views/nav.qtpl:41
qw422016.E().S(hyphaName)
//line views/nav.qtpl:40
//line views/nav.qtpl:41
qw422016.N().S(`">`)
//line views/nav.qtpl:40
//line views/nav.qtpl:41
qw422016.E().S(entry.title)
//line views/nav.qtpl:40
//line views/nav.qtpl:41
qw422016.N().S(`</a>
</li>
`)
//line views/nav.qtpl:42
}
//line views/nav.qtpl:43
}
//line views/nav.qtpl:43
//line views/nav.qtpl:44
}
//line views/nav.qtpl:44
qw422016.N().S(` </ul>
</nav>
`)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
}
//line views/nav.qtpl:46
//line views/nav.qtpl:47
func WriteNavHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) {
//line views/nav.qtpl:46
//line views/nav.qtpl:47
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
StreamNavHTML(qw422016, rq, hyphaName, navType, revisionHash...)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
}
//line views/nav.qtpl:46
//line views/nav.qtpl:47
func NavHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) string {
//line views/nav.qtpl:46
//line views/nav.qtpl:47
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:46
//line views/nav.qtpl:47
WriteNavHTML(qb422016, rq, hyphaName, navType, revisionHash...)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
qs422016 := string(qb422016.B)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:46
//line views/nav.qtpl:47
return qs422016
//line views/nav.qtpl:46
//line views/nav.qtpl:47
}
//line views/nav.qtpl:48
//line views/nav.qtpl:49
func StreamUserMenuHTML(qw422016 *qt422016.Writer, u *user.User) {
//line views/nav.qtpl:48
//line views/nav.qtpl:49
qw422016.N().S(`
`)
//line views/nav.qtpl:49
//line views/nav.qtpl:50
if user.AuthUsed {
//line views/nav.qtpl:49
//line views/nav.qtpl:50
qw422016.N().S(`
<li class="header-links__entry header-links__entry_user">
`)
//line views/nav.qtpl:51
//line views/nav.qtpl:52
if u.Group == "anon" {
//line views/nav.qtpl:51
//line views/nav.qtpl:52
qw422016.N().S(`
<a href="/login" class="header-links__link">Login</a>
`)
//line views/nav.qtpl:53
//line views/nav.qtpl:54
} else {
//line views/nav.qtpl:53
//line views/nav.qtpl:54
qw422016.N().S(`
<a href="/page/`)
//line views/nav.qtpl:54
//line views/nav.qtpl:55
qw422016.E().S(util.UserHypha)
//line views/nav.qtpl:54
//line views/nav.qtpl:55
qw422016.N().S(`/`)
//line views/nav.qtpl:54
//line views/nav.qtpl:55
qw422016.E().S(u.Name)
//line views/nav.qtpl:54
//line views/nav.qtpl:55
qw422016.N().S(`" class="header-links__link">`)
//line views/nav.qtpl:54
//line views/nav.qtpl:55
qw422016.E().S(u.Name)
//line views/nav.qtpl:54
//line views/nav.qtpl:55
qw422016.N().S(`</a>
`)
//line views/nav.qtpl:55
//line views/nav.qtpl:56
}
//line views/nav.qtpl:55
//line views/nav.qtpl:56
qw422016.N().S(`
</li>
`)
//line views/nav.qtpl:57
//line views/nav.qtpl:58
}
//line views/nav.qtpl:57
//line views/nav.qtpl:58
qw422016.N().S(`
`)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
}
//line views/nav.qtpl:58
//line views/nav.qtpl:59
func WriteUserMenuHTML(qq422016 qtio422016.Writer, u *user.User) {
//line views/nav.qtpl:58
//line views/nav.qtpl:59
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
StreamUserMenuHTML(qw422016, u)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
}
//line views/nav.qtpl:58
//line views/nav.qtpl:59
func UserMenuHTML(u *user.User) string {
//line views/nav.qtpl:58
//line views/nav.qtpl:59
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:58
//line views/nav.qtpl:59
WriteUserMenuHTML(qb422016, u)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
qs422016 := string(qb422016.B)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:58
//line views/nav.qtpl:59
return qs422016
//line views/nav.qtpl:58
//line views/nav.qtpl:59
}
//line views/nav.qtpl:60
//line views/nav.qtpl:61
func StreamRelativeHyphaeHTML(qw422016 *qt422016.Writer, relatives string) {
//line views/nav.qtpl:60
//line views/nav.qtpl:61
qw422016.N().S(`
<aside class="relative-hyphae layout-card">
<h2 class="relative-hyphae__title layout-card__title">Relative hyphae</h2>
`)
//line views/nav.qtpl:63
//line views/nav.qtpl:64
qw422016.N().S(relatives)
//line views/nav.qtpl:63
//line views/nav.qtpl:64
qw422016.N().S(`
</aside>
`)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
}
//line views/nav.qtpl:65
//line views/nav.qtpl:66
func WriteRelativeHyphaeHTML(qq422016 qtio422016.Writer, relatives string) {
//line views/nav.qtpl:65
//line views/nav.qtpl:66
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
StreamRelativeHyphaeHTML(qw422016, relatives)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
}
//line views/nav.qtpl:65
//line views/nav.qtpl:66
func RelativeHyphaeHTML(relatives string) string {
//line views/nav.qtpl:65
//line views/nav.qtpl:66
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:65
//line views/nav.qtpl:66
WriteRelativeHyphaeHTML(qb422016, relatives)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
qs422016 := string(qb422016.B)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:65
//line views/nav.qtpl:66
return qs422016
//line views/nav.qtpl:65
//line views/nav.qtpl:66
}
//line views/nav.qtpl:67
//line views/nav.qtpl:68
func StreamSubhyphaeHTML(qw422016 *qt422016.Writer, subhyphae string) {
//line views/nav.qtpl:67
//line views/nav.qtpl:68
qw422016.N().S(`
`)
//line views/nav.qtpl:68
//line views/nav.qtpl:69
if strings.TrimSpace(subhyphae) != "" {
//line views/nav.qtpl:68
//line views/nav.qtpl:69
qw422016.N().S(`
<section class="subhyphae">
<h2 class="subhyphae__title">Subhyphae</h2>
<nav class="subhyphae__nav">
<ul class="subhyphae__list">
`)
//line views/nav.qtpl:73
//line views/nav.qtpl:74
qw422016.N().S(subhyphae)
//line views/nav.qtpl:73
//line views/nav.qtpl:74
qw422016.N().S(`
</ul>
</nav>
</section>
`)
//line views/nav.qtpl:77
//line views/nav.qtpl:78
}
//line views/nav.qtpl:77
//line views/nav.qtpl:78
qw422016.N().S(`
`)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
}
//line views/nav.qtpl:78
//line views/nav.qtpl:79
func WriteSubhyphaeHTML(qq422016 qtio422016.Writer, subhyphae string) {
//line views/nav.qtpl:78
//line views/nav.qtpl:79
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
StreamSubhyphaeHTML(qw422016, subhyphae)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
}
//line views/nav.qtpl:78
//line views/nav.qtpl:79
func SubhyphaeHTML(subhyphae string) string {
//line views/nav.qtpl:78
//line views/nav.qtpl:79
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:78
//line views/nav.qtpl:79
WriteSubhyphaeHTML(qb422016, subhyphae)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
qs422016 := string(qb422016.B)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:78
//line views/nav.qtpl:79
return qs422016
//line views/nav.qtpl:78
//line views/nav.qtpl:79
}

View File

@ -1,10 +1,75 @@
{% import "net/http" %}
{% import "strings" %}
{% import "path" %}
{% import "os" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
{% import "github.com/bouncepaw/mycorrhiza/mimetype" %}
{% import "github.com/bouncepaw/mycorrhiza/tree" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
{% import "github.com/bouncepaw/mycorrhiza/tree" %}
{% func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) %}
{%= NavHTML(rq, h.Name, "attachment") %}
<div class="layout">
<main class="main-width">
<h1>Attachment of {%s util.BeautifulName(h.Name) %}</h1>
{% if h.BinaryPath == "" %}
<p class="warning">This hypha has no attachment, you can upload it here.</p>
{% else %}
<p class="warning">You can manage the hypha's attachment on this page.</p>
{% endif %}
<section class="amnt-grid">
{% if h.BinaryPath != "" %}
{% code
mime := mimetype.FromExtension(path.Ext(h.BinaryPath))
fileinfo, err := os.Stat(h.BinaryPath) %}
{% if err == nil %}
<fieldset class="amnt-menu-block">
<legend class="modal__title modal__title_small">Stat</legend>
<p class="modal__confirmation-msg"><b>File size:</b> {%dl fileinfo.Size() %} bytes</p>
<p><b>MIME type:</b> {%s mime %}</p>
</fieldset>
{% endif %}
{% if strings.HasPrefix(mime, "image/") %}
<fieldset class="amnt-menu-block">
<legend class="modal__title modal__title_small">Include</legend>
<p class="modal__confirmation-msg">This attachment is an image. To include it to a page, use a syntax like this:</p>
<pre class="codebleck"><code>img { {%s h.Name %} }</code></pre>
</fieldset>
{% endif %}
{% endif %}
{% if u.CanProceed("upload-binary") %}
<form action="/upload-binary/{%s h.Name %}"
method="post" enctype="multipart/form-data"
class="modal amnt-menu-block">
<fieldset class="modal__fieldset upload-binary">
<legend class="modal__title modal__title_small">Attach</legend>
<p class="modal__confirmation-msg">You can upload a new attachment. Please do not upload too big pictures unless you need to because no server-side compression is done and other readers may not want to wait for big pictures to load.</p>
<input type="file" class="upload-binary__input" name="binary">
<input type="submit" class="modal__action modal__submit">
</fieldset>
</form>
{% endif %}
{% if h.BinaryPath != "" && u.CanProceed("unattach-confirm") %}
<form action="/unattach-confirm/{%s h.Name %}" method="post" class="modal amnt-menu-block">
<fieldset class="modal__fieldset">
<legend class="modal__title modal__title_small">Unattach</legend>
<p class="modal__confirmation-msg">Please note that you don't have to unattach before uploading a new attachment.</p>
<input type="submit" class="modal__action modal__submit">
</fieldset>
</form>
{% endif %}
</section>
</main>
</div>
{% endfunc %}
If `contents` == "", a helpful message is shown instead.
{% func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) %}
@ -18,6 +83,16 @@ If `contents` == "", a helpful message is shown instead.
{%s= NaviTitleHTML(h) %}
{% if contents == "" %}
<p>This hypha has no text. Why not <a href="/edit/{%s h.Name %}">create it</a>?</p>
{% if u := user.FromRequest(rq); (!user.AuthUsed || u.Group != "anon") && !h.Exists %}
<form action="/upload-binary/{%s h.Name %}"
method="post" enctype="multipart/form-data"
class="upload-binary">
<label for="upload-binary__input">Upload an attachment:</label>
<input type="file" id="upload-binary__input" name="binary">
<input type="submit">
</form>
<br>
{% endif %}
{% else %}
{%s= contents %}
{% endif %}
@ -30,19 +105,6 @@ If `contents` == "", a helpful message is shown instead.
<a class="prevnext__el prevnext__next" href="/hypha/{%s nextHyphaName %}" rel="next">{%s util.BeautifulName(path.Base(nextHyphaName)) %} →</a>
{% endif %}
</section>
{% if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" %}
<form action="/upload-binary/{%s h.Name %}"
method="post" enctype="multipart/form-data"
class="upload-amnt">
{% if h.Exists && h.BinaryPath != "" %}
<a class="upload-amnt__unattach" href="/unattach-ask/{%s h.Name %}">Unattach current attachment?</a>
{% endif %}
<label for="upload-binary__input">Upload a new attachment</label>
<br>
<input type="file" id="upload-binary__input" name="binary"/>
<input type="submit"/>
</form>
{% endif %}
{%= SubhyphaeHTML(subhyphae) %}
</main>
{%= RelativeHyphaeHTML(relatives) %}

View File

@ -8,276 +8,447 @@ package views
import "net/http"
//line views/readers.qtpl:2
import "strings"
//line views/readers.qtpl:3
import "path"
//line views/readers.qtpl:4
import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/readers.qtpl:5
import "github.com/bouncepaw/mycorrhiza/user"
import "os"
//line views/readers.qtpl:6
import "github.com/bouncepaw/mycorrhiza/util"
import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/readers.qtpl:7
import "github.com/bouncepaw/mycorrhiza/mimetype"
//line views/readers.qtpl:8
import "github.com/bouncepaw/mycorrhiza/tree"
// If `contents` == "", a helpful message is shown instead.
//line views/readers.qtpl:9
import "github.com/bouncepaw/mycorrhiza/user"
//line views/readers.qtpl:10
import "github.com/bouncepaw/mycorrhiza/util"
//line views/readers.qtpl:12
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/readers.qtpl:10
//line views/readers.qtpl:12
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/readers.qtpl:10
func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) {
//line views/readers.qtpl:10
//line views/readers.qtpl:12
func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User) {
//line views/readers.qtpl:12
qw422016.N().S(`
`)
//line views/readers.qtpl:12
relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name)
//line views/readers.qtpl:13
StreamNavHTML(qw422016, rq, h.Name, "attachment")
//line views/readers.qtpl:13
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>Attachment of `)
//line views/readers.qtpl:16
qw422016.E().S(util.BeautifulName(h.Name))
//line views/readers.qtpl:16
qw422016.N().S(`</h1>
`)
//line views/readers.qtpl:17
if h.BinaryPath == "" {
//line views/readers.qtpl:17
qw422016.N().S(`
<p class="warning">This hypha has no attachment, you can upload it here.</p>
`)
//line views/readers.qtpl:19
} else {
//line views/readers.qtpl:19
qw422016.N().S(`
<p class="warning">You can manage the hypha's attachment on this page.</p>
`)
//line views/readers.qtpl:21
}
//line views/readers.qtpl:21
qw422016.N().S(`
<section class="amnt-grid">
`)
//line views/readers.qtpl:25
if h.BinaryPath != "" {
//line views/readers.qtpl:25
qw422016.N().S(`
`)
//line views/readers.qtpl:27
mime := mimetype.FromExtension(path.Ext(h.BinaryPath))
fileinfo, err := os.Stat(h.BinaryPath)
//line views/readers.qtpl:28
qw422016.N().S(`
`)
//line views/readers.qtpl:29
if err == nil {
//line views/readers.qtpl:29
qw422016.N().S(`
<fieldset class="amnt-menu-block">
<legend class="modal__title modal__title_small">Stat</legend>
<p class="modal__confirmation-msg"><b>File size:</b> `)
//line views/readers.qtpl:32
qw422016.N().DL(fileinfo.Size())
//line views/readers.qtpl:32
qw422016.N().S(` bytes</p>
<p><b>MIME type:</b> `)
//line views/readers.qtpl:33
qw422016.E().S(mime)
//line views/readers.qtpl:33
qw422016.N().S(`</p>
</fieldset>
`)
//line views/readers.qtpl:35
}
//line views/readers.qtpl:35
qw422016.N().S(`
`)
//line views/readers.qtpl:37
if strings.HasPrefix(mime, "image/") {
//line views/readers.qtpl:37
qw422016.N().S(`
<fieldset class="amnt-menu-block">
<legend class="modal__title modal__title_small">Include</legend>
<p class="modal__confirmation-msg">This attachment is an image. To include it to a page, use a syntax like this:</p>
<pre class="codebleck"><code>img { `)
//line views/readers.qtpl:41
qw422016.E().S(h.Name)
//line views/readers.qtpl:41
qw422016.N().S(` }</code></pre>
</fieldset>
`)
//line views/readers.qtpl:43
}
//line views/readers.qtpl:43
qw422016.N().S(`
`)
//line views/readers.qtpl:44
}
//line views/readers.qtpl:44
qw422016.N().S(`
`)
//line views/readers.qtpl:46
if u.CanProceed("upload-binary") {
//line views/readers.qtpl:46
qw422016.N().S(`
<form action="/upload-binary/`)
//line views/readers.qtpl:47
qw422016.E().S(h.Name)
//line views/readers.qtpl:47
qw422016.N().S(`"
method="post" enctype="multipart/form-data"
class="modal amnt-menu-block">
<fieldset class="modal__fieldset upload-binary">
<legend class="modal__title modal__title_small">Attach</legend>
<p class="modal__confirmation-msg">You can upload a new attachment. Please do not upload too big pictures unless you need to because no server-side compression is done and other readers may not want to wait for big pictures to load.</p>
<input type="file" class="upload-binary__input" name="binary">
<input type="submit" class="modal__action modal__submit">
</fieldset>
</form>
`)
//line views/readers.qtpl:57
}
//line views/readers.qtpl:57
qw422016.N().S(`
`)
//line views/readers.qtpl:59
if h.BinaryPath != "" && u.CanProceed("unattach-confirm") {
//line views/readers.qtpl:59
qw422016.N().S(`
<form action="/unattach-confirm/`)
//line views/readers.qtpl:60
qw422016.E().S(h.Name)
//line views/readers.qtpl:60
qw422016.N().S(`" method="post" class="modal amnt-menu-block">
<fieldset class="modal__fieldset">
<legend class="modal__title modal__title_small">Unattach</legend>
<p class="modal__confirmation-msg">Please note that you don't have to unattach before uploading a new attachment.</p>
<input type="submit" class="modal__action modal__submit">
</fieldset>
</form>
`)
//line views/readers.qtpl:67
}
//line views/readers.qtpl:67
qw422016.N().S(`
</section>
</main>
</div>
`)
//line views/readers.qtpl:14
//line views/readers.qtpl:72
}
//line views/readers.qtpl:72
func WriteAttachmentMenuHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User) {
//line views/readers.qtpl:72
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:72
StreamAttachmentMenuHTML(qw422016, rq, h, u)
//line views/readers.qtpl:72
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:72
}
//line views/readers.qtpl:72
func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) string {
//line views/readers.qtpl:72
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:72
WriteAttachmentMenuHTML(qb422016, rq, h, u)
//line views/readers.qtpl:72
qs422016 := string(qb422016.B)
//line views/readers.qtpl:72
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:72
return qs422016
//line views/readers.qtpl:72
}
// If `contents` == "", a helpful message is shown instead.
//line views/readers.qtpl:75
func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) {
//line views/readers.qtpl:75
qw422016.N().S(`
`)
//line views/readers.qtpl:77
relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name)
//line views/readers.qtpl:78
qw422016.N().S(`
`)
//line views/readers.qtpl:79
StreamNavHTML(qw422016, rq, h.Name, "page")
//line views/readers.qtpl:14
//line views/readers.qtpl:79
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<article>
`)
//line views/readers.qtpl:18
//line views/readers.qtpl:83
qw422016.N().S(NaviTitleHTML(h))
//line views/readers.qtpl:18
//line views/readers.qtpl:83
qw422016.N().S(`
`)
//line views/readers.qtpl:19
//line views/readers.qtpl:84
if contents == "" {
//line views/readers.qtpl:19
//line views/readers.qtpl:84
qw422016.N().S(`
<p>This hypha has no text. Why not <a href="/edit/`)
//line views/readers.qtpl:20
//line views/readers.qtpl:85
qw422016.E().S(h.Name)
//line views/readers.qtpl:20
//line views/readers.qtpl:85
qw422016.N().S(`">create it</a>?</p>
`)
//line views/readers.qtpl:21
} else {
//line views/readers.qtpl:21
//line views/readers.qtpl:86
if u := user.FromRequest(rq); (!user.AuthUsed || u.Group != "anon") && !h.Exists {
//line views/readers.qtpl:86
qw422016.N().S(`
<form action="/upload-binary/`)
//line views/readers.qtpl:87
qw422016.E().S(h.Name)
//line views/readers.qtpl:87
qw422016.N().S(`"
method="post" enctype="multipart/form-data"
class="upload-binary">
<label for="upload-binary__input">Upload an attachment:</label>
<input type="file" id="upload-binary__input" name="binary">
<input type="submit">
</form>
<br>
`)
//line views/readers.qtpl:22
qw422016.N().S(contents)
//line views/readers.qtpl:22
qw422016.N().S(`
`)
//line views/readers.qtpl:23
//line views/readers.qtpl:95
}
//line views/readers.qtpl:23
//line views/readers.qtpl:95
qw422016.N().S(`
`)
//line views/readers.qtpl:96
} else {
//line views/readers.qtpl:96
qw422016.N().S(`
`)
//line views/readers.qtpl:97
qw422016.N().S(contents)
//line views/readers.qtpl:97
qw422016.N().S(`
`)
//line views/readers.qtpl:98
}
//line views/readers.qtpl:98
qw422016.N().S(`
</article>
<section class="prevnext">
`)
//line views/readers.qtpl:26
//line views/readers.qtpl:101
if prevHyphaName != "" {
//line views/readers.qtpl:26
//line views/readers.qtpl:101
qw422016.N().S(`
<a class="prevnext__el prevnext__prev" href="/hypha/`)
//line views/readers.qtpl:27
//line views/readers.qtpl:102
qw422016.E().S(prevHyphaName)
//line views/readers.qtpl:27
//line views/readers.qtpl:102
qw422016.N().S(`" rel="prev">← `)
//line views/readers.qtpl:27
//line views/readers.qtpl:102
qw422016.E().S(util.BeautifulName(path.Base(prevHyphaName)))
//line views/readers.qtpl:27
//line views/readers.qtpl:102
qw422016.N().S(`</a>
`)
//line views/readers.qtpl:28
//line views/readers.qtpl:103
}
//line views/readers.qtpl:28
//line views/readers.qtpl:103
qw422016.N().S(`
`)
//line views/readers.qtpl:29
//line views/readers.qtpl:104
if nextHyphaName != "" {
//line views/readers.qtpl:29
//line views/readers.qtpl:104
qw422016.N().S(`
<a class="prevnext__el prevnext__next" href="/hypha/`)
//line views/readers.qtpl:30
//line views/readers.qtpl:105
qw422016.E().S(nextHyphaName)
//line views/readers.qtpl:30
//line views/readers.qtpl:105
qw422016.N().S(`" rel="next">`)
//line views/readers.qtpl:30
//line views/readers.qtpl:105
qw422016.E().S(util.BeautifulName(path.Base(nextHyphaName)))
//line views/readers.qtpl:30
//line views/readers.qtpl:105
qw422016.N().S(` </a>
`)
//line views/readers.qtpl:31
//line views/readers.qtpl:106
}
//line views/readers.qtpl:31
//line views/readers.qtpl:106
qw422016.N().S(`
</section>
`)
//line views/readers.qtpl:33
if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" {
//line views/readers.qtpl:33
qw422016.N().S(`
<form action="/upload-binary/`)
//line views/readers.qtpl:34
qw422016.E().S(h.Name)
//line views/readers.qtpl:34
qw422016.N().S(`"
method="post" enctype="multipart/form-data"
class="upload-amnt">
`)
//line views/readers.qtpl:37
if h.Exists && h.BinaryPath != "" {
//line views/readers.qtpl:37
qw422016.N().S(`
<a class="upload-amnt__unattach" href="/unattach-ask/`)
//line views/readers.qtpl:38
qw422016.E().S(h.Name)
//line views/readers.qtpl:38
qw422016.N().S(`">Unattach current attachment?</a>
`)
//line views/readers.qtpl:39
}
//line views/readers.qtpl:39
qw422016.N().S(`
<label for="upload-binary__input">Upload a new attachment</label>
<br>
<input type="file" id="upload-binary__input" name="binary"/>
<input type="submit"/>
</form>
`)
//line views/readers.qtpl:45
}
//line views/readers.qtpl:45
qw422016.N().S(`
`)
//line views/readers.qtpl:46
//line views/readers.qtpl:108
StreamSubhyphaeHTML(qw422016, subhyphae)
//line views/readers.qtpl:46
//line views/readers.qtpl:108
qw422016.N().S(`
</main>
`)
//line views/readers.qtpl:48
//line views/readers.qtpl:110
StreamRelativeHyphaeHTML(qw422016, relatives)
//line views/readers.qtpl:48
//line views/readers.qtpl:110
qw422016.N().S(`
`)
//line views/readers.qtpl:49
//line views/readers.qtpl:111
StreamBackLinksHTML(qw422016, h)
//line views/readers.qtpl:49
//line views/readers.qtpl:111
qw422016.N().S(`
</div>
`)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
}
//line views/readers.qtpl:51
//line views/readers.qtpl:113
func WriteHyphaHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) {
//line views/readers.qtpl:51
//line views/readers.qtpl:113
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
StreamHyphaHTML(qw422016, rq, h, contents)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
}
//line views/readers.qtpl:51
//line views/readers.qtpl:113
func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) string {
//line views/readers.qtpl:51
//line views/readers.qtpl:113
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:51
//line views/readers.qtpl:113
WriteHyphaHTML(qb422016, rq, h, contents)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
qs422016 := string(qb422016.B)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:51
//line views/readers.qtpl:113
return qs422016
//line views/readers.qtpl:51
//line views/readers.qtpl:113
}
//line views/readers.qtpl:53
//line views/readers.qtpl:115
func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents, revHash string) {
//line views/readers.qtpl:53
//line views/readers.qtpl:115
qw422016.N().S(`
`)
//line views/readers.qtpl:55
//line views/readers.qtpl:117
relatives, subhyphae, _, _ := tree.Tree(h.Name)
//line views/readers.qtpl:56
//line views/readers.qtpl:118
qw422016.N().S(`
`)
//line views/readers.qtpl:57
//line views/readers.qtpl:119
StreamNavHTML(qw422016, rq, h.Name, "revision", revHash)
//line views/readers.qtpl:57
//line views/readers.qtpl:119
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<article>
<p>Please note that viewing binary parts of hyphae is not supported in history for now.</p>
`)
//line views/readers.qtpl:62
//line views/readers.qtpl:124
qw422016.N().S(NaviTitleHTML(h))
//line views/readers.qtpl:62
//line views/readers.qtpl:124
qw422016.N().S(`
`)
//line views/readers.qtpl:63
//line views/readers.qtpl:125
qw422016.N().S(contents)
//line views/readers.qtpl:63
//line views/readers.qtpl:125
qw422016.N().S(`
</article>
`)
//line views/readers.qtpl:65
//line views/readers.qtpl:127
StreamSubhyphaeHTML(qw422016, subhyphae)
//line views/readers.qtpl:65
//line views/readers.qtpl:127
qw422016.N().S(`
</main>
`)
//line views/readers.qtpl:67
//line views/readers.qtpl:129
StreamRelativeHyphaeHTML(qw422016, relatives)
//line views/readers.qtpl:67
//line views/readers.qtpl:129
qw422016.N().S(`
</div>
`)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
}
//line views/readers.qtpl:69
//line views/readers.qtpl:131
func WriteRevisionHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, contents, revHash string) {
//line views/readers.qtpl:69
//line views/readers.qtpl:131
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
StreamRevisionHTML(qw422016, rq, h, contents, revHash)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
}
//line views/readers.qtpl:69
//line views/readers.qtpl:131
func RevisionHTML(rq *http.Request, h *hyphae.Hypha, contents, revHash string) string {
//line views/readers.qtpl:69
//line views/readers.qtpl:131
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:69
//line views/readers.qtpl:131
WriteRevisionHTML(qb422016, rq, h, contents, revHash)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
qs422016 := string(qb422016.B)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:69
//line views/readers.qtpl:131
return qs422016
//line views/readers.qtpl:69
//line views/readers.qtpl:131
}