diff --git a/admin/api/settings.go b/admin/api/settings.go index 19e44b00..2f949449 100644 --- a/admin/api/settings.go +++ b/admin/api/settings.go @@ -54,7 +54,7 @@ func getSettings(_ httprouter.Params, body []byte) (interface{}, error) { } func saveSettings(_ httprouter.Params, body []byte) (interface{}, error) { - var config *settings.FICSettings + var config *settings.Settings if err := json.Unmarshal(body, &config); err != nil { return nil, err } @@ -67,7 +67,7 @@ func saveSettings(_ httprouter.Params, body []byte) (interface{}, error) { } } -func ApplySettings(config *settings.FICSettings) { +func ApplySettings(config *settings.Settings) { fic.PartialValidation = config.PartialValidation fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth fic.DisplayAllFlags = config.DisplayAllFlags diff --git a/admin/main.go b/admin/main.go index d4ba4fd1..7e3765d8 100644 --- a/admin/main.go +++ b/admin/main.go @@ -203,7 +203,7 @@ func main() { log.Fatal("Unable to initialize settings.json:", err) } } else { - var config *settings.FICSettings + var config *settings.Settings if config, err = settings.ReadSettings(path.Join(settings.SettingsDir, settings.SettingsFile)); err != nil { log.Fatal("Unable to read settings.json:", err) } else { diff --git a/backend/main.go b/backend/main.go index 857225e0..2bae6bca 100644 --- a/backend/main.go +++ b/backend/main.go @@ -67,7 +67,7 @@ var ChStarted = false var lastRegeneration time.Time var skipInitialGeneration = false -func reloadSettings(config *settings.FICSettings) { +func reloadSettings(config *settings.Settings) { allowRegistration = config.AllowRegistration canJoinTeam = config.CanJoinTeam denyTeamCreation = config.DenyTeamCreation diff --git a/frontend/settings.go b/frontend/settings.go index 44304f3c..3e60166a 100644 --- a/frontend/settings.go +++ b/frontend/settings.go @@ -27,7 +27,7 @@ func touchStartedFile() { } } -func reloadSettings(config *settings.FICSettings) { +func reloadSettings(config *settings.Settings) { // Copy the new settings file for distribution if data, err := ioutil.ReadFile(path.Join(settings.SettingsDir, settings.SettingsFile)); err != nil { log.Println("Unable to read settings file:", err) diff --git a/libfic/zqsd.go b/libfic/zqsd.go index 6afe4bde..66118fa1 100644 --- a/libfic/zqsd.go +++ b/libfic/zqsd.go @@ -28,7 +28,7 @@ type SessionZQDS struct { Challenges []*ChallengeZQDS `json:"challenges"` } -func GenZQDSSessionFile(s *settings.FICSettings) (*SessionZQDS, error) { +func GenZQDSSessionFile(s *settings.Settings) (*SessionZQDS, error) { themes, err := GetThemes() if err != nil { return nil, err diff --git a/settings/settings.go b/settings/settings.go index fcf28d88..b2d74d24 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -20,8 +20,8 @@ const SettingsFile = "settings.json" // SettingsDir is the relative location where the SettingsFile lies. var SettingsDir string = "./SETTINGS" -// FICSettings represents the settings panel. -type FICSettings struct { +// Settings represents the settings panel. +type Settings struct { // Title is the displayed name of the challenge. Title string `json:"title"` // Authors is the group name of people making the challenge. @@ -92,8 +92,8 @@ func ExistsSettings(settingsPath string) bool { } // ReadSettings parses the file at the given location. -func ReadSettings(path string) (*FICSettings, error) { - var s FICSettings +func ReadSettings(path string) (*Settings, error) { + var s Settings if fd, err := os.Open(path); err != nil { return nil, err } else { @@ -109,7 +109,7 @@ func ReadSettings(path string) (*FICSettings, error) { } // SaveSettings saves settings at the given location. -func SaveSettings(path string, s *FICSettings) error { +func SaveSettings(path string, s *Settings) error { if fd, err := os.Create(path); err != nil { return err } else { @@ -139,7 +139,7 @@ func ForceRegeneration() error { // Giving the location and a callback, this function will first call your reload function // before returning (if the file can be parsed); then it starts watching modifications made to // this file. Your callback is then run each time the file is modified. -func LoadAndWatchSettings(settingsPath string, reload func(*FICSettings)) { +func LoadAndWatchSettings(settingsPath string, reload func(*Settings)) { // First load of configuration if it exists if _, err := os.Stat(settingsPath); !os.IsNotExist(err) { if config, err := ReadSettings(settingsPath); err != nil { @@ -184,7 +184,7 @@ func LoadAndWatchSettings(settingsPath string, reload func(*FICSettings)) { } } -func tryReload(settingsPath string, reload func(*FICSettings)) { +func tryReload(settingsPath string, reload func(*Settings)) { if config, err := ReadSettings(settingsPath); err != nil { log.Println("ERROR: Unable to read challenge settings:", err) } else if time.Until(config.ActivateTime) > 0 {