settings: Rename struct to remove FIC occurence

This commit is contained in:
nemunaire 2022-05-01 22:15:16 +02:00
parent 457cd307dd
commit e8f6a03cd9
6 changed files with 13 additions and 13 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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 {