Add custom flag validation, as well as custom flag validation
|
@ -42,6 +42,17 @@
|
|||
],
|
||||
"DefaultStyle": "pipes.css",
|
||||
|
||||
"CustomFlags": [
|
||||
{"Flag":"california.png", "Name": "California"},
|
||||
{"Flag":"cia.png", "Name": "CIA"},
|
||||
{"Flag":"lgbtq.png", "Name": "LGBTQ"},
|
||||
{"Flag":"ms-dos.png", "Name": "MS-DOS"},
|
||||
{"Flag":"stallman.png", "Name": "Stallman"},
|
||||
{"Flag":"templeos.png", "Name": "TempleOS"},
|
||||
{"Flag":"tux.png", "Name": "Linux"},
|
||||
{"Flag":"windows9x.png", "Name": "Windows 9x"}
|
||||
],
|
||||
|
||||
"Banners": [
|
||||
{"Filename": "gochan_go-parody.png", "Width": 300, "Height": 100}
|
||||
],
|
||||
|
|
BIN
html/static/flags/california.png
Normal file
After Width: | Height: | Size: 915 B |
BIN
html/static/flags/cia.png
Normal file
After Width: | Height: | Size: 748 B |
BIN
html/static/flags/lgbtq.png
Normal file
After Width: | Height: | Size: 399 B |
BIN
html/static/flags/ms-dos.png
Executable file
After Width: | Height: | Size: 290 B |
BIN
html/static/flags/stallman.png
Normal file
After Width: | Height: | Size: 700 B |
BIN
html/static/flags/templeos.png
Normal file
After Width: | Height: | Size: 402 B |
BIN
html/static/flags/tux.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
html/static/flags/windows9x.png
Normal file
After Width: | Height: | Size: 504 B |
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/Eggbertx/durationutil"
|
||||
"github.com/gochan-org/gochan/pkg/gcutil"
|
||||
"github.com/gochan-org/gochan/pkg/posting/geoip"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -232,10 +233,21 @@ type BoardConfig struct {
|
|||
ThreadsPerPage int
|
||||
EnableGeoIP bool
|
||||
EnableNoFlag bool
|
||||
CustomFlags map[string]string
|
||||
CustomFlags []geoip.Country
|
||||
isGlobal bool
|
||||
}
|
||||
|
||||
// CheckFlag returns true if the given flag and name are configured for
|
||||
// the board (or are globally set)
|
||||
func (bc *BoardConfig) CheckFlag(flag string, name string) bool {
|
||||
for _, country := range bc.CustomFlags {
|
||||
if flag == country.Flag && name == country.Name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsGlobal returns true if this is the global configuration applied to all
|
||||
// boards by default, or false if it is an explicitly configured board
|
||||
func (bc *BoardConfig) IsGlobal() bool {
|
||||
|
|
|
@ -18,11 +18,14 @@ var (
|
|||
ErrUnrecognized = errors.New("unrecognized GeoIP handler ID")
|
||||
)
|
||||
|
||||
// Country represents the GeoIP data used by gochan (the country/flag name and
|
||||
// country abbreviation/flag filename, accessible in /static/flags/{flag}).
|
||||
// Country represents the country data (or custom flag data) used by gochan.
|
||||
// For posts set to use the poster's country, `Flag` is the country's
|
||||
// abbreviation, and `Name` is the country name. If a custom flag is selected,
|
||||
// Flag is the filename accessible in /static/flags/{flag}, and Name is the
|
||||
// configured flag name. This package does not handle custom flag validation.
|
||||
type Country struct {
|
||||
Name string
|
||||
Flag string
|
||||
Name string
|
||||
}
|
||||
|
||||
// IsGeoIP is true of the country has a recognized abbreviation set as its
|
||||
|
|