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

Show edit author in recent changes and let anons upload attachments on no-auth wikis

This commit is contained in:
bouncepaw 2020-11-18 18:27:18 +05:00
parent b30c368c48
commit 26aaabe9e8
7 changed files with 34 additions and 23 deletions

View File

@ -9,6 +9,7 @@ import (
"strings"
"time"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
)
@ -76,11 +77,19 @@ func (rev Revision) HyphaeLinks() (html string) {
}
func (rev Revision) RecentChangesEntry() (html string) {
if user.AuthUsed && rev.Username != "anon" {
return fmt.Sprintf(`
<li class="rc-entry__time"><time>%[1]s</time></li>
<li class="rc-entry__hash">%[2]s</li>
<li class="rc-entry__links">%[5]s</li>
<li class="rc-entry__msg">%[6]s <span class="rc-entry__author">by <a href="/page/%[3]s/%[4]s" rel="author">%[4]s</a></span></li>
`, rev.TimeString(), rev.Hash, util.UserTree, rev.Username, rev.HyphaeLinks(), rev.Message)
}
return fmt.Sprintf(`
<li class="rc-entry__time"><time>%s</time></li>
<li class="rc-entry__hash">%s</li>
<li class="rc-entry__links">%s</li>
<li class="rc-entry__msg">%s</li>
<li class="rc-entry__time"><time>%[1]s</time></li>
<li class="rc-entry__hash">%[2]s</li>
<li class="rc-entry__links">%[3]s</li>
<li class="rc-entry__msg">%[4]s</li>
`, rev.TimeString(), rev.Hash, rev.HyphaeLinks(), rev.Message)
}

View File

@ -15,7 +15,7 @@ func RecentChanges(n int) string {
var (
out, err = gitsh(
"log", "--oneline", "--no-merges",
"--pretty=format:\"%h\t%ce\t%ct\t%s\"",
"--pretty=format:\"%h\t%ae\t%at\t%s\"",
"--max-count="+strconv.Itoa(n),
)
revs []Revision

@ -1 +1 @@
Subproject commit 8d595c930664f271e58d3cfb3fa12c6feabfec3c
Subproject commit 41b572a78082e8eaa62a04937f95dad295039e8a

View File

@ -46,4 +46,5 @@ nav ul li {list-style-type:none;margin-right:1rem;}
.rc-entry__time { font-style: italic; }
.rc-entry__hash { font-style: italic; text-align: right; }
.rc-entry__links { grid-column: 1 / span 2; }
.rc-entry__author { font-style: italic; }
{% endfunc %}

View File

@ -68,32 +68,33 @@ nav ul li {list-style-type:none;margin-right:1rem;}
.rc-entry__time { font-style: italic; }
.rc-entry__hash { font-style: italic; text-align: right; }
.rc-entry__links { grid-column: 1 / span 2; }
.rc-entry__author { font-style: italic; }
`)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
}
//line templates/css.qtpl:49
//line templates/css.qtpl:50
func WriteDefaultCSS(qq422016 qtio422016.Writer) {
//line templates/css.qtpl:49
//line templates/css.qtpl:50
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
StreamDefaultCSS(qw422016)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
qt422016.ReleaseWriter(qw422016)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
}
//line templates/css.qtpl:49
//line templates/css.qtpl:50
func DefaultCSS() string {
//line templates/css.qtpl:49
//line templates/css.qtpl:50
qb422016 := qt422016.AcquireByteBuffer()
//line templates/css.qtpl:49
//line templates/css.qtpl:50
WriteDefaultCSS(qb422016)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
qs422016 := string(qb422016.B)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
qt422016.ReleaseByteBuffer(qb422016)
//line templates/css.qtpl:49
//line templates/css.qtpl:50
return qs422016
//line templates/css.qtpl:49
//line templates/css.qtpl:50
}

View File

@ -47,10 +47,10 @@ If `contents` == "", a helpful message is shown instead.
{% endif %}
</article>
<hr/>
{% if u := user.FromRequest(rq).OrAnon(); u.Group > user.UserAnon %}
{% if u := user.FromRequest(rq).OrAnon(); !user.AuthUsed || u.Group > user.UserAnon %}
<form action="/upload-binary/{%s hyphaName %}"
method="post" enctype="multipart/form-data">
<label for="upload-binary__input">Upload new binary part</label>
<label for="upload-binary__input">Upload a new attachment</label>
<br>
<input type="file" id="upload-binary__input" name="binary"/>
<input type="submit"/>

View File

@ -189,7 +189,7 @@ func StreamPageHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navi
<hr/>
`)
//line templates/http_readers.qtpl:50
if u := user.FromRequest(rq).OrAnon(); u.Group > user.UserAnon {
if u := user.FromRequest(rq).OrAnon(); !user.AuthUsed || u.Group > user.UserAnon {
//line templates/http_readers.qtpl:50
qw422016.N().S(`
<form action="/upload-binary/`)
@ -198,7 +198,7 @@ func StreamPageHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navi
//line templates/http_readers.qtpl:51
qw422016.N().S(`"
method="post" enctype="multipart/form-data">
<label for="upload-binary__input">Upload new binary part</label>
<label for="upload-binary__input">Upload a new attachment</label>
<br>
<input type="file" id="upload-binary__input" name="binary"/>
<input type="submit"/>