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

Instead of failing if config.SiteWebfolder isn't set, use default "/"

Also append and/or prepend "/" as necessary to prevent possible issues
Also also fixed issues with broken links caused by the previous commit
This commit is contained in:
Joshua Merrell 2018-09-27 13:44:30 -07:00
parent e1de5162ac
commit 01877937eb
3 changed files with 9 additions and 5 deletions

View file

@ -531,8 +531,12 @@ func initConfig() {
} }
if config.SiteWebfolder == "" { if config.SiteWebfolder == "" {
println(0, "SiteWebfolder not set in gochan.json, halting.") println(0, "SiteWebFolder not set in gochan.json, using / as default.")
os.Exit(2) } else if string(config.SiteWebfolder[0]) != "/" {
config.SiteWebfolder = "/" + config.SiteWebfolder
}
if config.SiteWebfolder[len(config.SiteWebfolder)-1:] != "/" {
config.SiteWebfolder += "/"
} }
if config.DomainRegex == "" { if config.DomainRegex == "" {

View file

@ -70,7 +70,7 @@
{{else}}Next{{end}}</td></tr> {{else}}Next{{end}}</td></tr>
</table> </table>
<span id="boardmenu-bottom"> <span id="boardmenu-bottom">
[{{range $i, $boardlink := $.boards}}{{if gt $i 0}}/{{end}} <a href="{{$.config.SiteWebfolder}}/{{$boardlink.Dir}}/">{{$boardlink.Dir}}</a> {{end}}] [{{range $i, $boardlink := $.boards}}{{if gt $i 0}}/{{end}} <a href="{{$.config.SiteWebfolder}}{{$boardlink.Dir}}/">{{$boardlink.Dir}}</a> {{end}}]
</span> </span>
</div> </div>
</div> </div>

View file

@ -10,7 +10,7 @@
<title>/{{$.board.Dir}}/ - {{truncateString $.op.MessageText 20 true}}</title> <title>/{{$.board.Dir}}/ - {{truncateString $.op.MessageText 20 true}}</title>
{{end}} {{end}}
{{else}}<title>/{{.board.Dir}}/ - {{.board.Title}}</title>{{end}} {{else}}<title>/{{.board.Dir}}/ - {{.board.Title}}</title>{{end}}
<script type="text/javascript" src="{{$.config.SiteWebfolder}}/javascript/jquery-3.3.1.min.js"></script> <script type="text/javascript" src="{{$.config.SiteWebfolder}}javascript/jquery-3.3.1.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var styles = [{{range $ii, $style := $.config.Styles}}{{if gt $ii 0}}, {{end}}"{{$style}}"{{end}}]; var styles = [{{range $ii, $style := $.config.Styles}}{{if gt $ii 0}}, {{end}}"{{$style}}"{{end}}];
var webroot = "{{$.config.SiteWebfolder}}"; var webroot = "{{$.config.SiteWebfolder}}";
@ -25,7 +25,7 @@
<link rel="stylesheet" href="{{$.config.SiteWebfolder}}css/global/img.css" /> <link rel="stylesheet" href="{{$.config.SiteWebfolder}}css/global/img.css" />
{{range $_, $style := .config.Styles}} {{range $_, $style := .config.Styles}}
<link rel="{{if not (isStyleDefault $style)}}alternate {{end}}stylesheet" href="{{$.config.SiteWebfolder}}css/{{$style}}/img.css" />{{end}} <link rel="{{if not (isStyleDefault $style)}}alternate {{end}}stylesheet" href="{{$.config.SiteWebfolder}}css/{{$style}}/img.css" />{{end}}
<link rel="shortcut icon" href="{{$.config.SiteWebfolder}}/favicon.png" /> <link rel="shortcut icon" href="{{$.config.SiteWebfolder}}favicon.png" />
</head> </head>
<body> <body>
<div id="topbar"> <div id="topbar">