mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-17 10:56:24 -07:00
Make naming conventions in templates more consistent with Go conventions
This commit is contained in:
parent
d371c1289d
commit
ec34ff9f4a
15 changed files with 101 additions and 95 deletions
|
@ -78,7 +78,7 @@ func moveThread(checkedPosts []int, moveBtn string, doMove string, writer http.R
|
|||
"postid": post.ID,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"destBoards": destBoards,
|
||||
"page_title": fmt.Sprintf("Move thread #%d", post.ID),
|
||||
"pageTitle": fmt.Sprintf("Move thread #%d", post.ID),
|
||||
"srcBoard": srcBoard,
|
||||
}, writer, "text/html"); err != nil {
|
||||
gcutil.LogError(err).
|
||||
|
|
|
@ -170,16 +170,16 @@ func BuildBoardPages(board *gcsql.Board) error {
|
|||
// packaging the board/section list, threads, and board info
|
||||
captchaCfg := config.GetSiteConfig().Captcha
|
||||
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threads,
|
||||
"numPages": 1,
|
||||
"currentPage": 1,
|
||||
"board": board,
|
||||
"board_config": boardConfig,
|
||||
"useCaptcha": captchaCfg.UseCaptcha(),
|
||||
"captcha": captchaCfg,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threads,
|
||||
"numPages": 1,
|
||||
"currentPage": 1,
|
||||
"board": board,
|
||||
"boardConfig": boardConfig,
|
||||
"useCaptcha": captchaCfg.UseCaptcha(),
|
||||
"captcha": captchaCfg,
|
||||
}, boardPageFile, "text/html"); err != nil {
|
||||
errEv.Err(err).
|
||||
Str("page", "board.html").
|
||||
|
@ -223,16 +223,16 @@ func BuildBoardPages(board *gcsql.Board) error {
|
|||
// Render the boardpage template
|
||||
captchaCfg := config.GetSiteConfig().Captcha
|
||||
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": page.Threads,
|
||||
"numPages": len(threads) / boardConfig.ThreadsPerPage,
|
||||
"currentPage": catalog.currentPage,
|
||||
"board": board,
|
||||
"board_config": boardCfg,
|
||||
"useCaptcha": captchaCfg.UseCaptcha(),
|
||||
"captcha": captchaCfg,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": page.Threads,
|
||||
"numPages": len(threads) / boardConfig.ThreadsPerPage,
|
||||
"currentPage": catalog.currentPage,
|
||||
"board": board,
|
||||
"boardConfig": boardCfg,
|
||||
"useCaptcha": captchaCfg.UseCaptcha(),
|
||||
"captcha": captchaCfg,
|
||||
}, currentPageFile, "text/html"); err != nil {
|
||||
errEv.Err(err).
|
||||
Caller().Send()
|
||||
|
|
|
@ -121,12 +121,12 @@ func BuildFrontPage() error {
|
|||
}
|
||||
|
||||
if err = serverutil.MinifyTemplate(gctemplates.FrontPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"site_config": siteCfg,
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board_config": config.GetBoardConfig(""),
|
||||
"recent_posts": recentPostsArr,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"siteConfig": siteCfg,
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"boardConfig": config.GetBoardConfig(""),
|
||||
"recentPosts": recentPostsArr,
|
||||
}, frontFile, "text/html"); err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return errors.New("Failed executing front page template: " + err.Error())
|
||||
|
@ -138,12 +138,12 @@ func BuildFrontPage() error {
|
|||
// of every normal HTML page
|
||||
func BuildPageHeader(writer io.Writer, pageTitle string, board string, misc map[string]interface{}) error {
|
||||
phMap := map[string]interface{}{
|
||||
"page_title": pageTitle,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"site_config": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board_config": config.GetBoardConfig(board),
|
||||
"pageTitle": pageTitle,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"siteConfig": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"boardConfig": config.GetBoardConfig(board),
|
||||
}
|
||||
for k, val := range misc {
|
||||
phMap[k] = val
|
||||
|
@ -183,10 +183,10 @@ func BuildJS() error {
|
|||
|
||||
if err = serverutil.MinifyTemplate(gctemplates.JsConsts,
|
||||
map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"styles": boardCfg.Styles,
|
||||
"default_style": boardCfg.DefaultStyle,
|
||||
"timezone": criticalCfg.TimeZone,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"styles": boardCfg.Styles,
|
||||
"defaultStyle": boardCfg.DefaultStyle,
|
||||
"timezone": criticalCfg.TimeZone,
|
||||
},
|
||||
constsJSFile, "text/javascript"); err != nil {
|
||||
gcutil.LogError(err).
|
||||
|
|
|
@ -95,12 +95,12 @@ func BuildCatalog(boardID int) error {
|
|||
boardConfig := config.GetBoardConfig(board.Dir)
|
||||
|
||||
if err = serverutil.MinifyTemplate(gctemplates.Catalog, map[string]interface{}{
|
||||
"boards": gcsql.AllBoards,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"board": board,
|
||||
"board_config": boardConfig,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threadOPs,
|
||||
"boards": gcsql.AllBoards,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"board": board,
|
||||
"boardConfig": boardConfig,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threadOPs,
|
||||
}, catalogFile, "text/html"); err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return fmt.Errorf("failed building catalog for /%s/: %s", board.Dir, err.Error())
|
||||
|
|
|
@ -93,15 +93,15 @@ func BuildThreadPages(op *gcsql.Post) error {
|
|||
// render thread page
|
||||
captchaCfg := config.GetSiteConfig().Captcha
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ThreadPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board": board,
|
||||
"board_config": config.GetBoardConfig(board.Dir),
|
||||
"sections": gcsql.AllSections,
|
||||
"posts": posts[1:],
|
||||
"op": posts[0],
|
||||
"useCaptcha": captchaCfg.UseCaptcha() && !captchaCfg.OnlyNeededForThreads,
|
||||
"captcha": captchaCfg,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board": board,
|
||||
"boardConfig": config.GetBoardConfig(board.Dir),
|
||||
"sections": gcsql.AllSections,
|
||||
"posts": posts[1:],
|
||||
"op": posts[0],
|
||||
"useCaptcha": captchaCfg.UseCaptcha() && !captchaCfg.OnlyNeededForThreads,
|
||||
"captcha": captchaCfg,
|
||||
}, threadPageFile, "text/html"); err != nil {
|
||||
errEv.Err(err).
|
||||
Caller().Send()
|
||||
|
|
|
@ -767,12 +767,12 @@ var actions = []Action{
|
|||
//assume that they haven't logged in
|
||||
manageLoginBuffer := bytes.NewBufferString("")
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ManageLogin, map[string]interface{}{
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"site_config": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board_config": config.GetBoardConfig(""),
|
||||
"redirect": redirectAction,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"siteConfig": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"boardConfig": config.GetBoardConfig(""),
|
||||
"redirect": redirectAction,
|
||||
}, manageLoginBuffer, "text/html"); err != nil {
|
||||
errEv.Err(err).Str("template", "manage_login.html").Send()
|
||||
return "", errors.New("Error executing staff login page template: " + err.Error())
|
||||
|
@ -897,13 +897,13 @@ var actions = []Action{
|
|||
pageBuffer := bytes.NewBufferString("")
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ManageBoards,
|
||||
map[string]interface{}{
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"site_config": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board_config": config.GetBoardConfig(""),
|
||||
"editing": requestType == "edit",
|
||||
"board": board,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"siteConfig": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"boardConfig": config.GetBoardConfig(""),
|
||||
"editing": requestType == "edit",
|
||||
"board": board,
|
||||
}, pageBuffer, "text/html"); err != nil {
|
||||
errEv.Err(err).Str("template", "manage_boards.html").Caller().Send()
|
||||
return "", err
|
||||
|
@ -998,9 +998,9 @@ var actions = []Action{
|
|||
}
|
||||
pageBuffer := bytes.NewBufferString("")
|
||||
pageMap := map[string]interface{}{
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"site_config": config.GetSiteConfig(),
|
||||
"sections": sections,
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"siteConfig": config.GetSiteConfig(),
|
||||
"sections": sections,
|
||||
}
|
||||
if section.ID > 0 {
|
||||
pageMap["edit_section"] = section
|
||||
|
|
|
@ -128,7 +128,7 @@ func CallManageFunction(writer http.ResponseWriter, request *http.Request) {
|
|||
"page_type": "manage",
|
||||
}
|
||||
if action.ID != "dashboard" && action.ID != "login" && action.ID != "logout" {
|
||||
headerMap["include_dashboard_link"] = true
|
||||
headerMap["includeDashboardLink"] = true
|
||||
}
|
||||
if err = building.BuildPageHeader(&managePageBuffer, action.Title, "", headerMap); err != nil {
|
||||
gcutil.LogError(err).
|
||||
|
|
|
@ -41,9 +41,9 @@ func ServeErrorPage(writer http.ResponseWriter, err string) {
|
|||
"systemCritical": config.GetSystemCriticalConfig(),
|
||||
"siteConfig": config.GetSiteConfig(),
|
||||
"boardConfig": config.GetBoardConfig(""),
|
||||
"ErrorTitle": "Error :c",
|
||||
"ErrorHeader": "Error",
|
||||
"ErrorText": err,
|
||||
"errorTitle": "Error :c",
|
||||
"errorHeader": "Error",
|
||||
"errorText": err,
|
||||
}, writer, "text/html")
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
You are banned from posting on <b>{{.board.Dir}}</b> for the following reason:{{end}}
|
||||
<br /><br />
|
||||
<b>{{.ban.Message}}</b>
|
||||
<br /><br />{{$expires_timestamp := formatTimestamp .ban.ExpiresAt}}{{$appeal_timestamp := formatTimestamp .ban.AppealAt}}
|
||||
<br /><br />{{$expiresTimestamp := formatTimestamp .ban.ExpiresAt}}{{$appealTimestamp := formatTimestamp .ban.AppealAt}}
|
||||
Your ban was placed on {{formatTimestamp .ban.IssuedAt}} and will
|
||||
{{if .ban.Permanent}}<b>not expire</b>{{else}}expire on <b>{{$expires_timestamp}}</b>{{end}}.<br />
|
||||
{{if .ban.Permanent}}<b>not expire</b>{{else}}expire on <b>{{$expiresTimestamp}}</b>{{end}}.<br />
|
||||
Your IP address is <b>{{.ban.IP}}</b>.<br /><br />
|
||||
{{if .ban.CanAppeal}}You may appeal this ban:<br />
|
||||
<form id="appeal-form" action="/post" method="POST">
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
{{- else}}
|
||||
<title>/{{$.board.Dir}}/ - {{$.board.Title}}</title>
|
||||
{{end}}
|
||||
{{- else}}<title>{{with $.page_title}}{{$.page_title}} - {{end}}{{.site_config.SiteName}}</title>{{end}}
|
||||
{{- else}}<title>{{with $.pageTitle}}{{$.pageTitle}} - {{end}}{{.siteConfig.SiteName}}</title>{{end}}
|
||||
<link rel="stylesheet" href="{{.webroot}}css/global.css" />
|
||||
<link id="theme" rel="stylesheet" href="{{.webroot}}css/{{.board_config.DefaultStyle}}" />
|
||||
<link id="theme" rel="stylesheet" href="{{.webroot}}css/{{.boardConfig.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.webroot}}favicon.png">
|
||||
<script type="text/javascript" src="{{.webroot}}js/consts.js"></script>
|
||||
<script type="text/javascript" src="{{.webroot}}js/gochan.js"></script>
|
||||
|
@ -21,9 +21,11 @@
|
|||
<a href="{{$.webroot}}" class="topbar-item">home</a>
|
||||
{{range $i, $board := .boards}}<a href="{{$.webroot}}{{$board.Dir}}/" class="topbar-item" title="{{$board.Title}}">/{{$board.Dir}}/</a>{{end}}
|
||||
</div>
|
||||
{{with $.page_title }}<header>
|
||||
<h1 id="board-title">{{$.page_title}}</h1>
|
||||
{{with $.include_dashboard_link}}<a href="{{$.webroot}}manage" class="board-subtitle">Return to dashboard</a><br/>{{end}}
|
||||
{{with $.pageTitle}}<header>
|
||||
<h1 id="board-title">{{$.pageTitle}}</h1>
|
||||
{{with $.includeDashboardLink -}}
|
||||
<a href="{{$.webroot}}manage" class="board-subtitle">Return to dashboard</a><br/>
|
||||
{{- end}}
|
||||
</header>{{end}}
|
||||
<div id="content">
|
||||
<header>
|
||||
|
|
|
@ -8,6 +8,6 @@ var styles = [
|
|||
{Name: "{{js $style.Name}}", Filename: "{{js $style.Filename}}"}
|
||||
{{- end -}}
|
||||
];
|
||||
var defaultStyle = "{{js .default_style}}";
|
||||
var defaultStyle = "{{js .defaultStyle}}";
|
||||
var webroot = "{{js .webroot}}";
|
||||
var serverTZ = {{.timezone}};
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{.ErrorTitle}}</title>
|
||||
<title>{{.errorTitle}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{.ErrorHeader}}</h1>
|
||||
{{/*<img src="{{.ErrorImage}}" border="0" alt="">*/}}
|
||||
<p>{{.ErrorText}}</p>
|
||||
<h1>{{.errorHeader}}</h1>
|
||||
{{/*<img src="{{.errorImage}}" border="0" alt="">*/}}
|
||||
<p>{{.errorText}}</p>
|
||||
<hr><address>Site powered by Gochan {{version}}</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,7 +1,7 @@
|
|||
{{- template "page_header.html" .}}
|
||||
<div id="top-pane">
|
||||
<span id="site-title">{{.site_config.SiteName}}</span><br />
|
||||
<span id="site-slogan">{{.site_config.SiteSlogan}}</span>
|
||||
<span id="site-title">{{.siteConfig.SiteName}}</span><br />
|
||||
<span id="site-slogan">{{.siteConfig.SiteSlogan}}</span>
|
||||
</div><br />
|
||||
<div id="frontpage">
|
||||
<div class="section-block" style="margin: 16px 64px 16px 64px;">
|
||||
|
@ -17,7 +17,7 @@
|
|||
<ul style="float:left; list-style: none">
|
||||
<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 $.site_config.Modboard)}}
|
||||
{{if and (eq $board.SectionID $section.ID) (ne $board.Dir $.siteConfig.Modboard)}}
|
||||
<li><a href="{{$.webroot}}{{$board.Dir}}/" title="{{$board.Description}}">/{{$board.Dir}}/</a> — {{$board.Title}}</li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
@ -26,12 +26,12 @@
|
|||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{- if gt .site_config.MaxRecentPosts 0}}
|
||||
{{- if gt .siteConfig.MaxRecentPosts 0}}
|
||||
<div class="section-block">
|
||||
<div class="section-title-block"><b>Recent Posts</b></div>
|
||||
<div class="section-body">
|
||||
<div id="recent-posts">
|
||||
{{- range $i, $post := $.recent_posts}}
|
||||
{{- range $i, $post := $.recentPosts}}
|
||||
<div class="recent-post">
|
||||
{{if and (not $post.FileDeleted) (ne $post.Filename "") -}}
|
||||
<a href="{{$post.URL}}" class="front-reply" target="_blank"><img src="{{$post.ThumbURL}}" alt="post thumbnail"/></a><br />
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<tr>
|
||||
<td>Default style</td>
|
||||
<td><select name="defaultstyle">
|
||||
{{range $_, $style := $.board_config.Styles}}
|
||||
{{range $_, $style := $.boardConfig.Styles}}
|
||||
<option value="{{$style.Filename}}" {{if eq $style.Filename $.board.DefaultStyle -}}
|
||||
selected="selected"
|
||||
{{- end}}>{{$style.Name}}</option>
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
{{- else}}
|
||||
<title>/{{$.board.Dir}}/ - {{$.board.Title}}</title>
|
||||
{{end}}
|
||||
{{- else}}<title>{{with $.page_title}}{{$.page_title}} - {{end}}{{.site_config.SiteName}}</title>{{end}}
|
||||
{{- else -}}
|
||||
<title>{{with $.pageTitle}}{{$.pageTitle}} - {{end}}{{.siteConfig.SiteName}}</title>
|
||||
{{- end}}
|
||||
<link rel="stylesheet" href="{{.webroot}}css/global.css" />
|
||||
<link id="theme" rel="stylesheet" href="{{.webroot}}css/{{.board_config.DefaultStyle}}" />
|
||||
<link id="theme" rel="stylesheet" href="{{.webroot}}css/{{.boardConfig.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.webroot}}favicon.png">
|
||||
<script type="text/javascript" src="{{.webroot}}js/consts.js"></script>
|
||||
<script type="text/javascript" src="{{.webroot}}js/gochan.js"></script>
|
||||
|
@ -21,8 +23,10 @@
|
|||
<a href="{{$.webroot}}" class="topbar-item">home</a>
|
||||
{{range $i, $board := .boards}}<a href="{{$.webroot}}{{$board.Dir}}/" class="topbar-item" title="{{$board.Title}}">/{{$board.Dir}}/</a>{{end}}
|
||||
</div>
|
||||
{{with $.page_title }}<header>
|
||||
<h1 id="board-title">{{$.page_title}}</h1>
|
||||
{{with $.include_dashboard_link}}<a href="{{$.webroot}}manage" class="board-subtitle">Return to dashboard</a><br/>{{end}}
|
||||
{{with $.pageTitle -}}<header>
|
||||
<h1 id="board-title">{{$.pageTitle}}</h1>
|
||||
{{with $.includeDashboardLink -}}
|
||||
<a href="{{$.webroot}}manage" class="board-subtitle">Return to dashboard</a><br/>
|
||||
{{- end}}
|
||||
</header>{{end}}
|
||||
<div id="content">
|
Loading…
Add table
Add a link
Reference in a new issue