mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 05:20:26 +00:00
Make a better /list page
This commit is contained in:
parent
41551fd63b
commit
bcceb12009
21
main.go
21
main.go
@ -44,23 +44,14 @@ func HttpErr(w http.ResponseWriter, status int, name, title, errMsg string) {
|
||||
// Show all hyphae
|
||||
func handlerList(w http.ResponseWriter, rq *http.Request) {
|
||||
log.Println(rq.URL)
|
||||
var tbody string
|
||||
// It should be moved to templates too, right?
|
||||
for name, data := range HyphaStorage {
|
||||
tbody += fmt.Sprintf(`
|
||||
<tr>
|
||||
<td><a href="/page/%s">%s</a></td>
|
||||
<td>%s</td>
|
||||
<td>%d</td>
|
||||
<td>%s</td>
|
||||
<td>%d</td>
|
||||
</tr>`,
|
||||
name, name,
|
||||
util.ShorterPath(data.textPath), data.textType,
|
||||
util.ShorterPath(data.binaryPath), data.binaryType,
|
||||
var (
|
||||
tbody string
|
||||
pageCount = len(HyphaStorage)
|
||||
)
|
||||
for hyphaName, data := range HyphaStorage {
|
||||
tbody += templates.HyphaListRowHTML(hyphaName, data.binaryType.Mime(), data.binaryPath != "")
|
||||
}
|
||||
util.HTTP200Page(w, base("List of pages", templates.PageListHTML(tbody)))
|
||||
util.HTTP200Page(w, base("List of pages", templates.HyphaListHTML(tbody, pageCount)))
|
||||
}
|
||||
|
||||
// This part is present in all html documents.
|
||||
|
@ -12,17 +12,15 @@
|
||||
</html>
|
||||
{% endfunc %}
|
||||
|
||||
{% func PageListHTML(tbody string) %}
|
||||
{% func HyphaListHTML(tbody string, pageCount int) %}
|
||||
<main>
|
||||
<h1>List of pages</h1>
|
||||
<h1>List of hyphae</h1>
|
||||
<p>This wiki has {%d pageCount %} hyphae.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Text path</th>
|
||||
<th>Text type</th>
|
||||
<th>Binary path</th>
|
||||
<th>Binary type</th>
|
||||
<th>Full name</th>
|
||||
<th>Binary part type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -31,3 +29,14 @@
|
||||
</table>
|
||||
</main>
|
||||
{% endfunc %}
|
||||
|
||||
{% func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) %}
|
||||
<tr>
|
||||
<td><a href="/page/{%s hyphaName %}">{%s hyphaName %}</a></td>
|
||||
{% if binaryPresent %}
|
||||
<td>{%s binaryMime %}</td>
|
||||
{% else %}
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfunc %}
|
||||
|
@ -71,56 +71,124 @@ func BaseHTML(title, body string) string {
|
||||
}
|
||||
|
||||
//line templates/http_stuff.qtpl:15
|
||||
func StreamPageListHTML(qw422016 *qt422016.Writer, tbody string) {
|
||||
func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) {
|
||||
//line templates/http_stuff.qtpl:15
|
||||
qw422016.N().S(`
|
||||
<main>
|
||||
<h1>List of pages</h1>
|
||||
<h1>List of hyphae</h1>
|
||||
<p>This wiki has `)
|
||||
//line templates/http_stuff.qtpl:18
|
||||
qw422016.N().D(pageCount)
|
||||
//line templates/http_stuff.qtpl:18
|
||||
qw422016.N().S(` hyphae.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Text path</th>
|
||||
<th>Text type</th>
|
||||
<th>Binary path</th>
|
||||
<th>Binary type</th>
|
||||
<th>Full name</th>
|
||||
<th>Binary part type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`)
|
||||
//line templates/http_stuff.qtpl:29
|
||||
//line templates/http_stuff.qtpl:27
|
||||
qw422016.N().S(tbody)
|
||||
//line templates/http_stuff.qtpl:29
|
||||
//line templates/http_stuff.qtpl:27
|
||||
qw422016.N().S(`
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
`)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
//line templates/http_stuff.qtpl:31
|
||||
}
|
||||
|
||||
//line templates/http_stuff.qtpl:33
|
||||
func WritePageListHTML(qq422016 qtio422016.Writer, tbody string) {
|
||||
//line templates/http_stuff.qtpl:33
|
||||
//line templates/http_stuff.qtpl:31
|
||||
func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) {
|
||||
//line templates/http_stuff.qtpl:31
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
StreamPageListHTML(qw422016, tbody)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
//line templates/http_stuff.qtpl:31
|
||||
StreamHyphaListHTML(qw422016, tbody, pageCount)
|
||||
//line templates/http_stuff.qtpl:31
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
//line templates/http_stuff.qtpl:31
|
||||
}
|
||||
|
||||
//line templates/http_stuff.qtpl:31
|
||||
func HyphaListHTML(tbody string, pageCount int) string {
|
||||
//line templates/http_stuff.qtpl:31
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/http_stuff.qtpl:31
|
||||
WriteHyphaListHTML(qb422016, tbody, pageCount)
|
||||
//line templates/http_stuff.qtpl:31
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/http_stuff.qtpl:31
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/http_stuff.qtpl:31
|
||||
return qs422016
|
||||
//line templates/http_stuff.qtpl:31
|
||||
}
|
||||
|
||||
//line templates/http_stuff.qtpl:33
|
||||
func PageListHTML(tbody string) string {
|
||||
//line templates/http_stuff.qtpl:33
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/http_stuff.qtpl:33
|
||||
WritePageListHTML(qb422016, tbody)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/http_stuff.qtpl:33
|
||||
return qs422016
|
||||
func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) {
|
||||
//line templates/http_stuff.qtpl:33
|
||||
qw422016.N().S(`
|
||||
<tr>
|
||||
<td><a href="/page/`)
|
||||
//line templates/http_stuff.qtpl:35
|
||||
qw422016.E().S(hyphaName)
|
||||
//line templates/http_stuff.qtpl:35
|
||||
qw422016.N().S(`">`)
|
||||
//line templates/http_stuff.qtpl:35
|
||||
qw422016.E().S(hyphaName)
|
||||
//line templates/http_stuff.qtpl:35
|
||||
qw422016.N().S(`</a></td>
|
||||
`)
|
||||
//line templates/http_stuff.qtpl:36
|
||||
if binaryPresent {
|
||||
//line templates/http_stuff.qtpl:36
|
||||
qw422016.N().S(`
|
||||
<td>`)
|
||||
//line templates/http_stuff.qtpl:37
|
||||
qw422016.E().S(binaryMime)
|
||||
//line templates/http_stuff.qtpl:37
|
||||
qw422016.N().S(`</td>
|
||||
`)
|
||||
//line templates/http_stuff.qtpl:38
|
||||
} else {
|
||||
//line templates/http_stuff.qtpl:38
|
||||
qw422016.N().S(`
|
||||
<td></td>
|
||||
`)
|
||||
//line templates/http_stuff.qtpl:40
|
||||
}
|
||||
//line templates/http_stuff.qtpl:40
|
||||
qw422016.N().S(`
|
||||
</tr>
|
||||
`)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
}
|
||||
|
||||
//line templates/http_stuff.qtpl:42
|
||||
func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) {
|
||||
//line templates/http_stuff.qtpl:42
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
}
|
||||
|
||||
//line templates/http_stuff.qtpl:42
|
||||
func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string {
|
||||
//line templates/http_stuff.qtpl:42
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/http_stuff.qtpl:42
|
||||
WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/http_stuff.qtpl:42
|
||||
return qs422016
|
||||
//line templates/http_stuff.qtpl:42
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user