mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-18 07:36:24 -07:00
Add webPathDir template function (appends a trailing slash)
This commit is contained in:
parent
5785530279
commit
2e5e56b142
9 changed files with 23 additions and 16 deletions
|
@ -216,6 +216,13 @@ var funcMap = template.FuncMap{
|
|||
"webPath": func(part ...string) string {
|
||||
return config.WebPath(part...)
|
||||
},
|
||||
"webPathDir": func(part ...string) string {
|
||||
dir := config.WebPath(part...)
|
||||
if len(dir) > 0 && dir[len(dir)-1] != '/' {
|
||||
dir += "/"
|
||||
}
|
||||
return dir
|
||||
},
|
||||
"sectionBoards": func(sectionID int) []gcsql.Board {
|
||||
var boards []gcsql.Board
|
||||
for _, board := range gcsql.AllBoards {
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<table id="pages">
|
||||
<tr>
|
||||
{{- with .prevPage -}}
|
||||
<td><a href="{{webPath "/" $.board.Dir (printf "%d.html" $.prevPage) }}">Prev</a></td>
|
||||
<td><a href="{{webPathDir "/" $.board.Dir (printf "%d.html" $.prevPage) }}">Prev</a></td>
|
||||
{{- end -}}
|
||||
<td>{{range $_,$i := makeLoop .numPages 1 -}}
|
||||
{{- if eq $.currentPage $i -}}
|
||||
|
@ -48,12 +48,12 @@
|
|||
{{- end -}}
|
||||
{{- end}}</td>
|
||||
{{- with .nextPage -}}
|
||||
<td><a href="{{webPath "/" $.board.Dir (printf "%d.html" $.nextPage) }}">Next</a></td>
|
||||
<td><a href="{{webPathDir "/" $.board.Dir (printf "%d.html" $.nextPage) }}">Next</a></td>
|
||||
{{- end -}}
|
||||
</tr>
|
||||
</table>
|
||||
<span id="boardmenu-bottom">
|
||||
[<a href="{{webPath `/`}}">home</a>]
|
||||
[<a href="{{webPathDir `/`}}">home</a>]
|
||||
[{{range $i, $boardlink := $.boards -}}
|
||||
{{- if gt $i 0}}/{{end}} <a href="{{$boardlink.WebPath `` `boardPage`}}/">{{$boardlink.Dir}}</a> {{end}}]
|
||||
</span>
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="topbar">
|
||||
<a href="{{webPath "/"}}" class="topbar-item">home</a>
|
||||
{{range $i, $board := .boards}}<a href="{{webPath $board.Dir}}/" class="topbar-item" title="{{$board.Title}}">/{{$board.Dir}}/</a>{{end}}
|
||||
<a href="{{webPathDir "/"}}" class="topbar-item">home</a>
|
||||
{{range $i, $board := .boards}}<a href="{{webPathDir $board.Dir}}/" class="topbar-item" title="{{$board.Title}}">/{{$board.Dir}}/</a>{{end}}
|
||||
</div>
|
||||
<div id="content">
|
||||
<header>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<span id="board-subtitle">Catalog</span>
|
||||
</header><hr />
|
||||
<div id="catalog-links" style="float: left;">
|
||||
<a href="{{webPath $.board.Dir}}/">Return</a> | <a href="{{webPath $.board.Dir "/catalog.html"}}">Refresh</a> | <a href="#footer">Scroll to bottom</a>
|
||||
<a href="{{webPathDir $.board.Dir}}/">Return</a> | <a href="{{webPath $.board.Dir "/catalog.html"}}">Refresh</a> | <a href="#footer">Scroll to bottom</a>
|
||||
</div>
|
||||
<div id="catalog-controls" style="float: right;">
|
||||
Sort by: <select>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<li style="text-align: center; font-weight: bold"><b><u>{{$section.Name}}</u></b></li>
|
||||
{{range $_, $board := $.boards}}
|
||||
{{if and (eq $board.SectionID $section.ID) (ne $board.Dir $.siteConfig.Modboard)}}
|
||||
<li><a href="{{webPath $board.Dir}}/" title="{{$board.Description}}">/{{$board.Dir}}/</a> — {{$board.Title}}</li>
|
||||
<li><a href="{{webPathDir $board.Dir}}" title="{{$board.Description}}">/{{$board.Dir}}/</a> — {{$board.Title}}</li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</ul>
|
||||
|
@ -38,7 +38,7 @@
|
|||
{{else}}
|
||||
<div class="file-deleted-box" style="text-align:center; float:none;"><a href="{{$post.URL}}" class="front-reply" target="_blank">No file</a></div>
|
||||
{{- end}}<br />
|
||||
<a href="{{webPath $post.Board}}/">/{{$post.Board}}/</a><hr />
|
||||
<a href="{{webPathDir $post.Board}}">/{{$post.Board}}/</a><hr />
|
||||
{{$post.MessageSample}}
|
||||
</div>{{end}}
|
||||
</div>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{{with $.boards}}
|
||||
<ul>
|
||||
{{range $b, $board := $.boards}}
|
||||
<li><a href="{{webPath $board.Dir}}/">/{{$board.Dir}}/</a> - {{$board.Title}}</li>
|
||||
<li><a href="{{webPathDir $board.Dir}}">/{{$board.Dir}}/</a> - {{$board.Title}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{else}}
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
</select></td></tr>
|
||||
</table>
|
||||
<input type="submit" value="Move thread" />
|
||||
<input type="button" value="Cancel" onclick="window.location = '{{webPath .srcBoard.Dir}}/'">
|
||||
<input type="button" value="Cancel" onclick="window.location = '{{webPathDir .srcBoard.Dir}}'">
|
||||
</form>
|
||||
{{- template "page_footer.html" .}}
|
|
@ -3,7 +3,7 @@
|
|||
<h1 id="board-title">/{{$.board.Dir}}/ - {{$.board.Title}}</h1>
|
||||
<div id="board-subtitle">
|
||||
{{$.board.Subtitle}}<br/>
|
||||
<a href="{{webPath $.board.Dir}}/" >Return</a> | <a href="{{webPath $.board.Dir "/catalog.html"}}">Catalog</a> | <a href="#footer">Bottom</a>
|
||||
<a href="{{webPathDir $.board.Dir}}" >Return</a> | <a href="{{webPath $.board.Dir "/catalog.html"}}">Catalog</a> | <a href="#footer">Bottom</a>
|
||||
</div>
|
||||
</header><hr />
|
||||
{{template "postbox.html" .}}<hr />
|
||||
|
@ -27,11 +27,11 @@
|
|||
</div>
|
||||
</form>
|
||||
<div id="left-bottom-content">
|
||||
<a href="{{webPath .board.Dir}}/">Return</a> | <a href="#">Scroll to top</a><br /><br />
|
||||
<a href="{{webPathDir .board.Dir}}">Return</a> | <a href="#">Scroll to top</a><br /><br />
|
||||
<span id="boardmenu-bottom">
|
||||
[<a href="{{webPath "/"}}">home</a>]
|
||||
[<a href="{{webPathDir "/"}}">home</a>]
|
||||
[{{range $i, $boardlink := .boards -}}
|
||||
{{if gt $i 0}}/{{end -}} <a href="{{webPath $boardlink.Dir}}/">{{$boardlink.Dir}}</a>
|
||||
{{if gt $i 0}}/{{end -}} <a href="{{webPathDir $boardlink.Dir}}">{{$boardlink.Dir}}</a>
|
||||
{{- end}}]
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{{define "topbar" -}}
|
||||
<div id="topbar">
|
||||
<div class="topbar-section"><a href="{{webPath "/"}}" class="topbar-item">home</a></div>
|
||||
<div class="topbar-section"><a href="{{webPathDir "/"}}" class="topbar-item">home</a></div>
|
||||
{{- range $s, $section := .sections -}}
|
||||
<div class="topbar-section">
|
||||
{{- with $sectionBoards := sectionBoards $section.ID -}}
|
||||
{{range $b, $board := $sectionBoards -}}
|
||||
<a href="{{webPath $board.Dir}}/" class="topbar-item" title="{{$board.Title}}">/{{$board.Dir}}/</a>
|
||||
<a href="{{webPathDir $board.Dir}}" class="topbar-item" title="{{$board.Title}}">/{{$board.Dir}}/</a>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue