1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-20 09:26:23 -07:00

Add ability to override template files, remove minimum recent posts

This commit is contained in:
eggbertx 2019-01-03 11:51:59 -08:00
parent 15a42b6473
commit 964914d63d
3 changed files with 14 additions and 5 deletions

1
.gitignore vendored
View file

@ -8,4 +8,5 @@ vagrant/*.log
html/boards.json
html/index.html
html/test/
templates/override/
**/*.bak

View file

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"html"
"os"
"reflect"
"strconv"
"strings"
@ -173,6 +174,13 @@ var funcMap = template.FuncMap{
},
"isBanned": isBanned,
"numReplies": numReplies,
"getBoardDir": func(id int) string {
board, err := getBoardFromID(id)
if err != nil {
return ""
}
return board.Dir
},
// Template convenience functions
"makeLoop": func(n int, offset int) []int {
@ -266,7 +274,11 @@ func loadTemplate(files ...string) (*template.Template, error) {
var templates []string
for i, file := range files {
templates = append(templates, file)
files[i] = config.TemplateDir + "/" + files[i]
if _, err := os.Stat(config.TemplateDir + "/override/" + file); !os.IsNotExist(err) {
files[i] = config.TemplateDir + "/override/" + files[i]
} else {
files[i] = config.TemplateDir + "/" + files[i]
}
}
return template.New(templates[0]).Funcs(funcMap).ParseFiles(files...)

View file

@ -675,10 +675,6 @@ DefaultStyle must refer to a given Style's Filename field. If DefaultStyle does
}
}
if config.MaxRecentPosts == 0 {
config.MaxRecentPosts = 10
}
if config.MaxLogDays == 0 {
config.MaxLogDays = 15
}