1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-17 10:56:24 -07:00

Replace all usage of webroot template variable with webPath function

This commit is contained in:
Eggbertx 2023-01-04 23:13:59 -08:00
parent aba84ceed2
commit 43d941c837
28 changed files with 97 additions and 104 deletions

View file

@ -76,7 +76,6 @@ func moveThread(checkedPosts []int, moveBtn string, doMove string, writer http.R
}
if err = serverutil.MinifyTemplate(gctemplates.MoveThreadPage, map[string]interface{}{
"postid": post.ID,
"webroot": config.GetSystemCriticalConfig().WebRoot,
"destBoards": destBoards,
"pageTitle": fmt.Sprintf("Move thread #%d", post.ID),
"srcBoard": srcBoard,

View file

@ -27,7 +27,11 @@ func serveFile(writer http.ResponseWriter, request *http.Request) {
systemCritical := config.GetSystemCriticalConfig()
siteConfig := config.GetSiteConfig()
filePath := path.Join(systemCritical.DocumentRoot, request.URL.Path)
requestPath := request.URL.Path
if len(systemCritical.WebRoot) > 0 && systemCritical.WebRoot != "/" {
requestPath = requestPath[len(systemCritical.WebRoot):]
}
filePath := path.Join(systemCritical.DocumentRoot, requestPath)
var fileBytes []byte
results, err := os.Stat(filePath)
if err != nil {

View file

@ -1,4 +1,4 @@
import $ from "jquery";
import $, { ready } from "jquery";
const opRE = /\/res\/(\d+)(p(\d)+)?.html$/;
const threadRE = /^\d+/;
@ -11,7 +11,14 @@ export function currentBoard() {
}
export function getPageThread() {
let arr = opRE.exec(window.location.pathname);
let pathname = window.location.pathname;
if(typeof webroot == "string" && webroot != "/") {
pathname = pathname.slice(webroot.length);
if(pathname === "" || pathname[0] != '/') {
pathname = "/" + pathname;
}
}
let arr = opRE.exec(pathname);
let info = {
board: currentBoard(),
boardID: -1,
@ -28,7 +35,14 @@ export function getPageThread() {
export function currentThread() {
// returns the board and thread ID if we are viewing a thread
let thread = {board: currentBoard(), thread: 0};
let splits = location.pathname.split("/");
let pathname = location.pathname;
if(typeof webroot == "string" && webroot != "/") {
pathname = pathname.slice(webroot.length);
if(pathname === "" || pathname[0] != '/') {
pathname = "/" + pathname;
}
}
let splits = pathname.split("/");
if(splits.length != 4)
return thread;
let reArr = threadRE.exec(splits[3]);

View file

@ -176,7 +176,6 @@ 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,
@ -240,7 +239,6 @@ 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,

View file

@ -126,7 +126,6 @@ func BuildFrontPage() error {
}
if err = serverutil.MinifyTemplate(gctemplates.FrontPage, map[string]interface{}{
"webroot": criticalCfg.WebRoot,
"siteConfig": siteCfg,
"sections": gcsql.AllSections,
"boards": gcsql.AllBoards,
@ -144,7 +143,6 @@ func BuildFrontPage() error {
func BuildPageHeader(writer io.Writer, pageTitle string, board string, misc map[string]interface{}) error {
phMap := map[string]interface{}{
"pageTitle": pageTitle,
"webroot": config.GetSystemCriticalConfig().WebRoot,
"siteConfig": config.GetSiteConfig(),
"sections": gcsql.AllSections,
"boards": gcsql.AllBoards,
@ -160,9 +158,7 @@ func BuildPageHeader(writer io.Writer, pageTitle string, board string, misc map[
// of every normal HTML page
func BuildPageFooter(writer io.Writer) (err error) {
return serverutil.MinifyTemplate(gctemplates.PageFooter,
map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
}, writer, "text/html")
map[string]interface{}{}, writer, "text/html")
}
// BuildJS minifies (if enabled) consts.js, which is built from a template
@ -193,7 +189,6 @@ func BuildJS() error {
if err = serverutil.MinifyTemplate(gctemplates.JsConsts,
map[string]interface{}{
"webroot": criticalCfg.WebRoot,
"styles": boardCfg.Styles,
"defaultStyle": boardCfg.DefaultStyle,
"timezone": criticalCfg.TimeZone,

View file

@ -102,7 +102,6 @@ func BuildCatalog(boardID int) error {
if err = serverutil.MinifyTemplate(gctemplates.Catalog, map[string]interface{}{
"boards": gcsql.AllBoards,
"webroot": criticalCfg.WebRoot,
"board": board,
"boardConfig": boardConfig,
"sections": gcsql.AllSections,

View file

@ -98,7 +98,6 @@ 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,
"boardConfig": config.GetBoardConfig(board.Dir),

View file

@ -42,10 +42,6 @@ const (
AlwaysJSON
)
var (
chopPortNumRegex = regexp.MustCompile(`(.+|\w+):(\d+)$`)
)
// Action represents the functions accessed by staff members at /manage/<functionname>.
type Action struct {
// the string used when the user requests /manage/<ID>
@ -203,7 +199,6 @@ var actions = []Action{
"allBoards": gcsql.AllBoards,
"boardid": boardid,
"limit": limit,
"webroot": config.GetSystemCriticalConfig().WebRoot,
}, manageRecentsBuffer, "text/html"); err != nil {
errEv.Err(err).Caller().Send()
return "", errors.New("Error executing ban management page template: " + err.Error())
@ -335,7 +330,7 @@ var actions = []Action{
manageAppealsBuffer := bytes.NewBufferString("")
pageData := map[string]interface{}{}
if appeals != nil && len(appeals) > 0 {
if len(appeals) > 0 {
pageData["appeals"] = appeals
}
if err = serverutil.MinifyTemplate(gctemplates.ManageAppeals, pageData, manageAppealsBuffer, "text/html"); err != nil {
@ -505,7 +500,6 @@ var actions = []Action{
}
}
data := map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
"currentStaff": staff.Username,
"allBoards": gcsql.AllBoards,
}
@ -549,7 +543,6 @@ var actions = []Action{
ipQuery := request.FormValue("ip")
limitStr := request.FormValue("limit")
data := map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
"ipQuery": ipQuery,
"limit": 20,
}
@ -738,7 +731,6 @@ var actions = []Action{
staffBuffer := bytes.NewBufferString("")
if err = serverutil.MinifyTemplate(gctemplates.ManageStaff, map[string]interface{}{
"allstaff": allStaff,
"webroot": config.GetSystemCriticalConfig().WebRoot,
"currentUsername": staff.Username,
}, staffBuffer, "text/html"); err != nil {
errEv.Err(err).Str("template", "manage_staff.html").Send()
@ -767,7 +759,6 @@ 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,
"siteConfig": config.GetSiteConfig(),
"sections": gcsql.AllSections,
"boards": gcsql.AllBoards,
@ -897,7 +888,6 @@ var actions = []Action{
pageBuffer := bytes.NewBufferString("")
if err = serverutil.MinifyTemplate(gctemplates.ManageBoards,
map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
"siteConfig": config.GetSiteConfig(),
"sections": gcsql.AllSections,
"boards": gcsql.AllBoards,
@ -998,7 +988,6 @@ var actions = []Action{
}
pageBuffer := bytes.NewBufferString("")
pageMap := map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
"siteConfig": config.GetSiteConfig(),
"sections": sections,
}
@ -1299,7 +1288,6 @@ var actions = []Action{
}
}
filterMap := map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
"wordfilters": wordfilters,
"edit": editFilter,
}

View file

@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"net/http"
"regexp"
"strconv"
"github.com/gochan-org/gochan/pkg/config"
@ -22,10 +23,19 @@ const (
sOtherError
)
var (
chopPortNumRegex = regexp.MustCompile(`(.+|\w+):(\d+)$`)
)
func createSession(key, username, password string, request *http.Request, writer http.ResponseWriter) int {
//returns 0 for successful, 1 for password mismatch, and 2 for other
domain := request.Host
var err error
errEv := gcutil.LogError(nil).
Str("staff", username).
Str("IP", gcutil.GetRealIP(request))
defer errEv.Discard()
domain = chopPortNumRegex.Split(domain, -1)[0]
if !serverutil.ValidReferer(request) {
@ -39,9 +49,7 @@ func createSession(key, username, password string, request *http.Request, writer
staff, err := gcsql.GetStaffByUsername(username, true)
if err != nil {
if err != sql.ErrNoRows {
gcutil.LogError(err).
Str("staff", username).
Str("IP", gcutil.GetRealIP(request)).
errEv.Err(err).
Str("remoteAddr", request.RemoteAddr).
Caller().Msg("Invalid password")
}
@ -51,10 +59,8 @@ func createSession(key, username, password string, request *http.Request, writer
err = bcrypt.CompareHashAndPassword([]byte(staff.PasswordChecksum), []byte(password))
if err == bcrypt.ErrMismatchedHashAndPassword {
// password mismatch
gcutil.LogError(nil).
Str("staff", username).
Str("IP", gcutil.GetRealIP(request)).
Caller().Msg("Invalid password")
errEv.Caller().
Msg("Invalid password")
return sInvalidPassword
}
@ -166,7 +172,6 @@ func dashboardCallback(writer http.ResponseWriter, request *http.Request, staff
"rankString": rankString,
"announcements": announcements,
"boards": gcsql.AllBoards,
"webroot": config.GetSystemCriticalConfig().WebRoot,
}, dashBuffer, "text/html"); err != nil {
errEv.Err(err).Str("template", "manage_dashboard.html").Caller().Send()
return "", err

View file

@ -10,6 +10,7 @@ import (
"time"
"github.com/gochan-org/gochan/pkg/config"
"github.com/gochan-org/gochan/pkg/gcsql"
"github.com/gochan-org/gochan/pkg/gctemplates"
"github.com/gochan-org/gochan/pkg/gcutil"
"github.com/gochan-org/gochan/pkg/serverutil"
@ -105,8 +106,9 @@ func ServeCaptcha(writer http.ResponseWriter, request *http.Request) {
fmt.Println("Success:", result)
}
err := serverutil.MinifyTemplate(gctemplates.Captcha, map[string]interface{}{
"webroot": config.GetSystemCriticalConfig().WebRoot,
"siteKey": captchaCfg.SiteKey,
"boardConfig": config.GetBoardConfig(""),
"boards": gcsql.AllBoards,
"siteKey": captchaCfg.SiteKey,
}, writer, "text/html")
if err != nil {
serverutil.ServeErrorPage(writer, "Error serving CAPTCHA: "+err.Error())

View file

@ -3,11 +3,11 @@
<h1 id="board-title">/{{$.board.Dir}}/ - {{$.board.Title}}</h1>
<div id="board-subtitle">
{{$.board.Subtitle}}<br/>
<a href="{{.webroot}}{{.board.Dir}}/catalog.html">Catalog</a> | <a href="#footer">Bottom</a>
<a href="{{webPath .board.Dir "/catalog.html"}}">Catalog</a> | <a href="#footer">Bottom</a>
</div>
</header><hr />
{{- template "postbox.html" . -}}<hr />
<form action="{{.webroot}}util" method="POST" id="main-form">
<form action="{{webPath "/util"}}" method="POST" id="main-form">
{{$global := .}}
{{- range $t, $thread := .threads}}{{$op := index $thread.Posts 0}}
<div class="thread">
@ -47,7 +47,7 @@
</tr>
</table>
<span id="boardmenu-bottom">
[<a href="{{$.webroot}}">home</a>]&nbsp;
[<a href="{{webPath `/`}}">home</a>]&nbsp;
[{{range $i, $boardlink := $.boards -}}
{{- if gt $i 0}}/{{end}} <a href="{{$boardlink.WebPath `` `boardPage`}}/">{{$boardlink.Dir}}</a> {{end}}]
</span>

View file

@ -3,35 +3,23 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{with .board -}}
{{with $.op -}}
<title>{{$.op.TitleText}}</title>
{{- else}}
<title>/{{$.board.Dir}}/ - {{$.board.Title}}</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/{{.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>
<title>CAPTCHA test</title>
<link rel="stylesheet" href="{{webPath "/css/global.css"}}" />
<link id="theme" rel="stylesheet" href="{{webPath "css/" .boardConfig.DefaultStyle}}" />
<link rel="shortcut icon" href="{{webPath "/favicon.png"}}">
<script type="text/javascript" src="{{webPath "js/consts.js"}}"></script>
<script type="text/javascript" src="{{webPath "js/gochan.js"}}"></script>
</head>
<body>
<div id="topbar">
<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}}
<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}}
</div>
{{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>
<h1 id="board-title">hCAPTCHA test</h1>
</header><br />
<form method="POST" action="{{.webroot}}captcha">
<form method="POST" action="{{webPath "/captcha"}}">
<div class="h-captcha" data-sitekey="{{.siteKey}}"></div>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
<input type="submit" value="Post">

View file

@ -4,7 +4,7 @@
<span id="board-subtitle">Catalog</span>
</header><hr />
<div id="catalog-links" style="float: left;">
<a href="{{$.webroot}}{{$.board.Dir}}">Return</a> | <a href="{{$.webroot}}{{$.board.Dir}}/catalog.html">Refresh</a> | <a href="#footer">Scroll to bottom</a>
<a href="{{webPath $.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>
@ -15,7 +15,7 @@
</div><hr />
{{range $_,$thread := .threads}}
<div class="catalog-thread">
<a href="{{$.webroot}}{{$.board.Dir}}/res/{{$thread.ID}}.html">
<a href="{{webPath $.board.Dir "res" (print $thread.ID)}}.html">
{{if eq $thread.Filename ""}}(No file){{else if eq $thread.Filename "deleted"}}(File deleted){{else}}
<img src="{{$thread.ThumbnailPath}}" alt="{{$thread.UploadPath}}" width="{{$thread.ThumbnailWidth}}" height="{{$thread.ThumbnailHeight}}" />
{{end}}</a><br />

View file

@ -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="{{$.webroot}}{{$board.Dir}}/" title="{{$board.Description}}">/{{$board.Dir}}/</a> — {{$board.Title}}</li>
<li><a href="{{webPath $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="{{$.webroot}}{{$post.Board}}/">/{{$post.Board}}/</a><hr />
<a href="{{webPath $post.Board}}/">/{{$post.Board}}/</a><hr />
{{$post.MessageSample}}
</div>{{end}}
</div>

View file

@ -1,4 +1,4 @@
<form action="{{$.webroot}}manage/boards" method="GET">
<form action="{{webPath "/manage/boards"}}" method="GET">
{{with $.boards}}{{else}}
<input type="hidden" name="noboards" value="1">
{{end}}
@ -19,7 +19,7 @@
{{else}}
<h2>Create new board</h2>
{{end}}
<form action="{{$.webroot}}manage/boards" method="POST">
<form action="{{webPath "manage/boards"}}" method="POST">
<input type="hidden" name="board" value="{{$.board.ID}}"/>
<table>
<tr>

View file

@ -13,7 +13,7 @@
{{with $.boards}}
<ul>
{{range $b, $board := $.boards}}
<li><a href="{{$.webroot}}{{$board.Dir}}/">/{{$board.Dir}}/</a> - {{$board.Title}}</li>
<li><a href="{{webPath $board.Dir}}/">/{{$board.Dir}}/</a> - {{$board.Title}}</li>
{{end}}
</ul>
{{else}}
@ -23,7 +23,7 @@
<fieldset><legend>Staff actions (role: {{$.rankString}})</legend>
<ul>
{{range $a, $action := $.actions}}
{{if ne $action.Title "Dashboard"}}<li><a href="{{$.webroot}}manage/{{$action.ID}}">{{$action.Title}}</a> </li>{{end}}
{{if ne $action.Title "Dashboard"}}<li><a href="{{webPath "/manage" $action.ID}}">{{$action.Title}}</a> </li>{{end}}
{{end}}
</ul>
</fieldset>

View file

@ -5,7 +5,7 @@
</ul>
<div id="filename-bans">
<h2>Create new filename ban</h2>
<form id="filenamebanform" action="{{.webroot}}manage/filebans" method="POST">
<form id="filenamebanform" action="{{webPath "manage/filebans"}}" method="POST">
<input type="hidden" name="bantype" value="filename">
<table>
<tr><td>Filename:</td><td><input type="text" name="filename" id="filename"></td></tr>
@ -34,7 +34,7 @@
<td>{{$staff := (getStaffNameFromID $ban.StaffID)}}{{if eq $staff ""}}<i>?</i>{{else}}{{$staff}}{{end}}</td>
<td>{{$ban.StaffNote}}</td>
<td><a href="{{$.webroot}}manage/filebans?delfnb={{$ban.ID}}">Delete</a></td>
<td><a href="{{webPath "manage/filebans"}}?delfnb={{$ban.ID}}">Delete</a></td>
</tr>
{{end -}}
</table>
@ -42,7 +42,7 @@
</div>
<div id="checksum-bans">
<h2>Create new file checksum ban</h2>
<form id="checksumbanform" action="{{.webroot}}manage/filebans#checksum-bans" method="POST">
<form id="checksumbanform" action="{{webPath "manage/filebans"}}#checksum-bans" method="POST">
<input type="hidden" name="bantype" value="checksum">
<table>
<tr><td>Checksum</td><td><input type="text" name="checksum"></td></tr>
@ -68,7 +68,7 @@
<td>{{$uri := (intPtrToBoardDir $ban.BoardID "" "?")}}{{if eq $uri ""}}<i>All boards</i>{{else}}/{{$uri}}/{{end}}</td>
<td>{{$staff := (getStaffNameFromID $ban.StaffID)}}{{if eq $staff ""}}<i>?</i>{{else}}{{$staff}}{{end}}</td>
<td>{{$ban.StaffNote}}</td>
<td><a href="{{$.webroot}}manage/filebans?delcsb={{$ban.ID}}#checksum-bans">Delete</a></td>
<td><a href="{{webPath "manage/filebans"}}?delcsb={{$ban.ID}}#checksum-bans">Delete</a></td>
</tr>
{{- end -}}
</table>

View file

@ -5,7 +5,7 @@
{{- end -}}
<fieldset>
<legend>Search</legend>
<form method="GET" action="{{.webroot}}manage/ipsearch" class="staff-form">
<form method="GET" action="{{webPath "manage/ipsearch"}}" class="staff-form">
<label for="ip">IP Address</label>
<input type="text" name="ip" id="ipquery" value="{{.ipQuery}}"><br />
<label for="number">Max results</label>

View file

@ -1,4 +1,4 @@
<form method="POST" action="{{.webroot}}manage/login" id="login-box" class="staff-form">
<form method="POST" action="{{webPath "manage/login"}}" id="login-box" class="staff-form">
<input type="hidden" name="redirect" value="{{.redirect}}" />
<table>
<tr><td>Login</td><td><input type="text" name="username" class="logindata" /><br /></td></tr>

View file

@ -1,5 +1,5 @@
<h2>Create a new name/tripcode ban</h2>
<form id="namebanform" action="{{.webroot}}manage/namebans" method="post">
<form id="namebanform" action="{{webPath "manage/namebans"}}" method="post">
<table>
<tr><td>Name/Tripcode:</td><td><input type="text" name="name" id="name"> (ex: "Name", "Name!Tripcode", "!Tripcode, etc)</td></tr>
<tr><td>Regular expression:</td><td><input type="checkbox" name="isregex" id="isregex"/></td></tr>
@ -25,7 +25,7 @@
<td>{{$uri := (intPtrToBoardDir $ban.BoardID "" "?")}}{{if eq $uri ""}}<i>All boards</i>{{else}}/{{$uri}}/{{end}}</td>
<td>{{$staff := (getStaffNameFromID $ban.StaffID)}}{{if eq $staff ""}}<i>?</i>{{else}}{{$staff}}{{end}}</td>
<td>{{$ban.StaffNote}}</td>
<td><a href="{{$.webroot}}manage/namebans?del={{$ban.ID}}">Delete</a></td>
<td><a href="{{webPath "manage/namebans"}}?del={{$ban.ID}}">Delete</a></td>
{{end -}}
</table>
{{end}}

View file

@ -1,4 +1,4 @@
<form action="{{$.webroot}}manage/recentposts" method="GET">
<form action="{{webPath "manage/recentposts"}}" method="GET">
<label for="boardid">Board:</label>
<select name="boardid" id="boardid">
<option value="0">All boards</option>

View file

@ -1,4 +1,4 @@
<form action="{{.webroot}}manage/boardsections" method="POST" id="sectionform">
<form action="{{webPath "manage/boardsections"}}" method="POST" id="sectionform">
{{with .edit_section}}<input type="hidden" name="updatesection" value="{{.ID}}" />{{end}}
<h2>{{with .edit_section}}Edit{{else}}New{{end}} section</h2>
<table>
@ -9,7 +9,7 @@
</table>
<input type="submit" name="save_section" value="{{with .edit_section}}Save{{else}}Create{{end}} section">
{{with .edit_section}}
<input type="button" onclick="window.location='{{$.webroot}}manage/boardsections'" value="Cancel">
<input type="button" onclick="window.location='{{webPath "manage/boardsections"}}'" value="Cancel">
{{else}}
<input type="button" onclick="document.getElementById('sectionform').reset()" value="Reset"/>
{{end}}
@ -24,8 +24,8 @@
<td>{{$section.Abbreviation}}</td>
<td>{{$section.Position}}</td>
<td>{{if eq $section.Hidden true}}Yes{{else}}No{{end}}</td>
<td><a href="{{$.webroot}}manage/boardsections?edit={{$section.ID}}">Edit</a> |
<a href="{{$.webroot}}manage/boardsections?delete={{$section.ID}}" onclick="return confirm('Are you sure you want to delete this section?')">Delete</a></td>
<td><a href="{{webPath "manage/boardsections"}}?edit={{$section.ID}}">Edit</a> |
<a href="{{webPath "manage/boardsections"}}?delete={{$section.ID}}" onclick="return confirm('Are you sure you want to delete this section?')">Delete</a></td>
</tr>
{{end}}
</table>

View file

@ -12,16 +12,16 @@
<td>{{formatTimestamp $staff.AddedOn}}</td>
<td>
<a {{if eq $staff.Username $.currentUsername -}}
href="{{$.webroot}}manage/staff" title="Cannot self terminate" style="color: black;"
href="{{webPath "/manage/staff"}}" title="Cannot self terminate" style="color: black;"
{{- else -}}
href="{{$.webroot}}manage/staff?do=del&username={{$staff.Username}}" title="Delete {{$staff.Username}}" style="color:red;"
href="{{webPath "/manage/staff"}}?do=del&username={{$staff.Username}}" title="Delete {{$staff.Username}}" onclick="return confirm('Are you sure you want to delete the staff account for \'{{$staff.Username}}\'?')" style="color:red;"
{{end}}>Delete</a>
</td>
</tr>
{{end}}
</table><hr />
<h2>Add new staff</h2>
<form action="{{.webroot}}manage/staff" onsubmit="return makeNewStaff();" method="POST">
<form action="{{webPath "/manage/staff"}}" onsubmit="return makeNewStaff();" method="POST">
<input type="hidden" name="do" value="add" />
<table>
<tr><td>Username:</td><td><input id="username" name="username" type="text"/></td></tr>

View file

@ -1,5 +1,5 @@
<h2>{{with $.edit}}Edit filter{{else}}Create new{{end}}</h2>
<form id="wordfilterform" action="{{.webroot}}manage/wordfilters{{with $.edit}}?edit={{$.edit.ID}}{{end}}" method="POST">
<form id="wordfilterform" action="{{webPath "/manage/wordfilters"}}{{with $.edit}}?edit={{$.edit.ID}}{{end}}" method="POST">
<table>
<tr><td>Search for:</td><td><input type="text" name="find" id="findfilter" value="{{with $.edit}}{{$.edit.Search}}{{end}}"/></td></tr>
<tr><td>Replace with:</td><td><input type="text" name="replace" id="replacefilter" value="{{with $.edit}}{{$.edit.ChangeTo}}{{end}}"/></td></tr>
@ -9,7 +9,9 @@
<tr><td>
<input type="submit" name="dowordfilter" value="{{with $.edit}}Edit{{else}}Create new{{end}} wordfilter"/>
<input type="button" onclick="document.getElementById('wordfilterform').reset()" value="Reset"/>
{{with $.edit}}<input type="button" onclick="window.location='{{$.webroot}}manage/wordfilters'" value="Cancel"/>{{end}}
{{with $.edit -}}
<input type="button" onclick="window.location='{{webPath "manage/wordfilters"}}'" value="Cancel"/>
{{- end}}
</td></tr>
</table>
</form>
@ -21,7 +23,7 @@
<tr><th>Actions</th><th>Search</th><th>Replace with</th><th>Is regex</th><th>Dirs</th><th>Created by</th><th>Staff note</th></tr>
{{- range $f,$filter := .wordfilters}}
<tr>
<td><a href="{{$.webroot}}manage/wordfilters?edit={{$filter.ID}}">Edit</a> | <a href="{{$.webroot}}manage/wordfilters?delete={{$filter.ID}}" onclick="return confirm('Are you sure you want to delete this wordfilter?')">Delete</a> </td>
<td><a href="{{webPath "manage/wordfilters"}}?edit={{$filter.ID}}">Edit</a> | <a href="{{webPath "manage/wordfilters"}}?delete={{$filter.ID}}" onclick="return confirm('Are you sure you want to delete this wordfilter?')">Delete</a> </td>
<td>{{$filter.Search}}</td>
<td>{{$filter.ChangeTo}}</td>
<td>{{if $filter.IsRegex}}yes{{else}}no{{end}}</td>

View file

@ -2,7 +2,7 @@
<header>
<h1 id="board-title">Move thread</h1>
</header><hr />
<form action="{{.webroot}}util" method="POST" id="main-form">
<form action="{{webPath "/util"}}" method="POST" id="main-form">
<input name="srcboardid" type="hidden" value="{{.srcBoard.ID}}" />
<input name="postid" type="hidden" value="{{.postid}}" />
<input name="domove" type="hidden" value="1" />
@ -15,6 +15,6 @@
<tr><td>Password:</td><td><input type="password" name="postpassword"/></td></tr>
</table>
<input type="submit" value="Move thread" />
<input type="button" value="Cancel" onclick="window.location = '{{.webroot}}{{.srcBoard.Dir}}/'">
<input type="button" value="Cancel" onclick="window.location = '{{webPath .srcBoard.Dir}}/'">
</form>
{{- template "page_footer.html" .}}

View file

@ -12,21 +12,21 @@
{{- 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/{{.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>
<link rel="stylesheet" href="{{webPath "/css/global.css"}}" />
<link id="theme" rel="stylesheet" href="{{webPath "/css/" .boardConfig.DefaultStyle}}" />
<link rel="shortcut icon" href="{{webPath "/favicon.png"}}">
<script type="text/javascript" src="{{webPath "/js/consts.js"}}"></script>
<script type="text/javascript" src="{{webPath "/js/gochan.js"}}"></script>
</head>
<body>
<div id="topbar">
<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}}
<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}}
</div>
{{with $.pageTitle -}}<header>
<h1 id="board-title">{{$.pageTitle}}</h1>
{{with $.includeDashboardLink -}}
<a href="{{$.webroot}}manage" class="board-subtitle">Return to dashboard</a><br/>
<a href="{{webPath "/manage"}}" class="board-subtitle">Return to dashboard</a><br/>
{{- end}}
</header>{{end}}
<div id="content">

View file

@ -1,6 +1,6 @@
{{define "postbox.html"}}
<div id="postbox-area">
<form id="postform" name="postform" action="/post" method="POST" enctype="multipart/form-data">
<form id="postform" name="postform" action="{{webPath "/post"}}" method="POST" enctype="multipart/form-data">
{{- with .op}}
<input type="hidden" name="threadid" value="{{$.op.ID}}" />
{{- else -}}

View file

@ -3,7 +3,7 @@
<h1 id="board-title">/{{$.board.Dir}}/ - {{$.board.Title}}</h1>
<div id="board-subtitle">
{{$.board.Subtitle}}<br/>
<a href="{{$.webroot}}{{$.board.Dir}}/" >Return</a> | <a href="{{$.webroot}}{{$.board.Dir}}/catalog.html">Catalog</a> | <a href="#footer">Bottom</a>
<a href="{{webPath $.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="{{.webroot}}{{.board.Dir}}/">Return</a> | <a href="#">Scroll to top</a><br /><br />
<a href="{{webPath .board.Dir}}/">Return</a> | <a href="#">Scroll to top</a><br /><br />
<span id="boardmenu-bottom">
[<a href="{{$.webroot}}">home</a>]&nbsp;
[<a href="{{webPath "/"}}">home</a>]&nbsp;
[{{range $i, $boardlink := .boards -}}
{{if gt $i 0}}/{{end -}}&nbsp;<a href="/{{$boardlink.Dir}}/">{{$boardlink.Dir}}</a>&nbsp;
{{if gt $i 0}}/{{end -}}&nbsp;<a href="{{webPath $boardlink.Dir}}/">{{$boardlink.Dir}}</a>&nbsp;
{{- end}}]
</span>
</div>