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
23
main.go
23
main.go
@ -44,23 +44,14 @@ func HttpErr(w http.ResponseWriter, status int, name, title, errMsg string) {
|
|||||||
// Show all hyphae
|
// Show all hyphae
|
||||||
func handlerList(w http.ResponseWriter, rq *http.Request) {
|
func handlerList(w http.ResponseWriter, rq *http.Request) {
|
||||||
log.Println(rq.URL)
|
log.Println(rq.URL)
|
||||||
var tbody string
|
var (
|
||||||
// It should be moved to templates too, right?
|
tbody string
|
||||||
for name, data := range HyphaStorage {
|
pageCount = len(HyphaStorage)
|
||||||
tbody += fmt.Sprintf(`
|
)
|
||||||
<tr>
|
for hyphaName, data := range HyphaStorage {
|
||||||
<td><a href="/page/%s">%s</a></td>
|
tbody += templates.HyphaListRowHTML(hyphaName, data.binaryType.Mime(), data.binaryPath != "")
|
||||||
<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,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
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.
|
// This part is present in all html documents.
|
||||||
|
@ -12,17 +12,15 @@
|
|||||||
</html>
|
</html>
|
||||||
{% endfunc %}
|
{% endfunc %}
|
||||||
|
|
||||||
{% func PageListHTML(tbody string) %}
|
{% func HyphaListHTML(tbody string, pageCount int) %}
|
||||||
<main>
|
<main>
|
||||||
<h1>List of pages</h1>
|
<h1>List of hyphae</h1>
|
||||||
|
<p>This wiki has {%d pageCount %} hyphae.</p>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Full name</th>
|
||||||
<th>Text path</th>
|
<th>Binary part type</th>
|
||||||
<th>Text type</th>
|
|
||||||
<th>Binary path</th>
|
|
||||||
<th>Binary type</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -31,3 +29,14 @@
|
|||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
{% endfunc %}
|
{% 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
|
//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
|
//line templates/http_stuff.qtpl:15
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<main>
|
<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>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Full name</th>
|
||||||
<th>Text path</th>
|
<th>Binary part type</th>
|
||||||
<th>Text type</th>
|
|
||||||
<th>Binary path</th>
|
|
||||||
<th>Binary type</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
`)
|
`)
|
||||||
//line templates/http_stuff.qtpl:29
|
//line templates/http_stuff.qtpl:27
|
||||||
qw422016.N().S(tbody)
|
qw422016.N().S(tbody)
|
||||||
//line templates/http_stuff.qtpl:29
|
//line templates/http_stuff.qtpl:27
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
`)
|
`)
|
||||||
//line templates/http_stuff.qtpl:33
|
//line templates/http_stuff.qtpl:31
|
||||||
}
|
}
|
||||||
|
|
||||||
//line templates/http_stuff.qtpl:33
|
//line templates/http_stuff.qtpl:31
|
||||||
func WritePageListHTML(qq422016 qtio422016.Writer, tbody string) {
|
func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) {
|
||||||
//line templates/http_stuff.qtpl:33
|
//line templates/http_stuff.qtpl:31
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line templates/http_stuff.qtpl:33
|
//line templates/http_stuff.qtpl:31
|
||||||
StreamPageListHTML(qw422016, tbody)
|
StreamHyphaListHTML(qw422016, tbody, pageCount)
|
||||||
//line templates/http_stuff.qtpl:33
|
//line templates/http_stuff.qtpl:31
|
||||||
qt422016.ReleaseWriter(qw422016)
|
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
|
//line templates/http_stuff.qtpl:33
|
||||||
func PageListHTML(tbody string) string {
|
func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) {
|
||||||
//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
|
|
||||||
//line templates/http_stuff.qtpl:33
|
//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