Requires login to see themes (when using fic-nginx container)
This commit is contained in:
parent
51e3bfde90
commit
cb2cd7f4c0
|
@ -150,9 +150,15 @@ server {
|
|||
add_header Cache-Control no-cache;
|
||||
}
|
||||
location /themes.json {
|
||||
include fic-get-team.conf;
|
||||
|
||||
root ${PATH_TEAMS};
|
||||
expires epoch;
|
||||
add_header Cache-Control no-cache;
|
||||
|
||||
if (!-f ${PATH_TEAMS}/$team/my.json) {
|
||||
rewrite ^/ /themes-wait.json break;
|
||||
}
|
||||
}
|
||||
location /challenge.json {
|
||||
root ${PATH_SETTINGS}/;
|
||||
|
|
|
@ -103,6 +103,7 @@ services:
|
|||
- fic-net
|
||||
volumes:
|
||||
- teams:/srv/TEAMS
|
||||
- settingsdist:/srv/SETTINGSDIST
|
||||
command: -baseurl /qa/
|
||||
depends_on:
|
||||
- mysql
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
import { goto } from '$app/navigation';
|
||||
|
||||
import { my } from '$lib/stores/my.js';
|
||||
import { themesStore } from '$lib/stores/themes.js';
|
||||
import { settings } from '$lib/stores/settings.js';
|
||||
|
||||
import RegistrationFormCreateTeam from '$lib/components/RegistrationFormCreateTeam.svelte';
|
||||
|
@ -26,7 +27,9 @@
|
|||
function gotoHomeOnDiff(i) {
|
||||
my.refresh((my) => {
|
||||
if (my && my.team_id) {
|
||||
goto('.');
|
||||
themesStore.refresh(() => {
|
||||
goto('.');
|
||||
});
|
||||
} else if (i > 0) {
|
||||
setTimeout(gotoHomeOnDiff, 650, i-1);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -298,12 +299,43 @@ func genTeamsFile() error {
|
|||
|
||||
// Generate general themes.json file
|
||||
func genThemesFile() error {
|
||||
if themes, err := fic.ExportThemes(); err != nil {
|
||||
return err
|
||||
} else if j, err := json.Marshal(themes); err != nil {
|
||||
return err
|
||||
} else if err = ioutil.WriteFile(path.Join(TeamsDir, "themes.json"), j, 0666); err != nil {
|
||||
return err
|
||||
themes, err := fic.ExportThemes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to generate themes: %w", err)
|
||||
}
|
||||
|
||||
var wr io.Writer
|
||||
|
||||
themesfd, err := os.Create(path.Join(TeamsDir, "themes.json"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to re-create themes.json: %w", err)
|
||||
}
|
||||
defer themesfd.Close()
|
||||
|
||||
themeswait, err := os.Create(path.Join(TeamsDir, "themes-wait.json"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to re-create themes-wait.json: %w", err)
|
||||
}
|
||||
defer themeswait.Close()
|
||||
|
||||
if allowRegistration {
|
||||
wr = io.MultiWriter(themesfd, themeswait)
|
||||
} else {
|
||||
wr = themesfd
|
||||
}
|
||||
|
||||
enc := json.NewEncoder(wr)
|
||||
err = enc.Encode(themes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to encode themes.json: %w", err)
|
||||
}
|
||||
|
||||
if !allowRegistration {
|
||||
enc = json.NewEncoder(themeswait)
|
||||
err = enc.Encode(map[string]string{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to encode themes-wait.json: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -23,13 +23,16 @@ var TeamsDir string
|
|||
var ChStarted = false
|
||||
var lastRegeneration time.Time
|
||||
var skipInitialGeneration = false
|
||||
var allowRegistration bool
|
||||
|
||||
func reloadSettings(config *settings.Settings) {
|
||||
fic.HintCoefficient = config.HintCurCoefficient
|
||||
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
|
||||
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
|
||||
ChStarted = config.Start.Unix() > 0 && time.Since(config.Start) >= 0
|
||||
if fic.PartialValidation != config.PartialValidation || fic.UnlockedChallengeDepth != config.UnlockedChallengeDepth || fic.UnlockedChallengeUpTo != config.UnlockedChallengeUpTo || fic.DisplayAllFlags != config.DisplayAllFlags || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness || fic.DiscountedFactor != config.DiscountedFactor {
|
||||
if allowRegistration != config.AllowRegistration || fic.PartialValidation != config.PartialValidation || fic.UnlockedChallengeDepth != config.UnlockedChallengeDepth || fic.UnlockedChallengeUpTo != config.UnlockedChallengeUpTo || fic.DisplayAllFlags != config.DisplayAllFlags || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness || fic.DiscountedFactor != config.DiscountedFactor {
|
||||
allowRegistration = config.AllowRegistration
|
||||
|
||||
fic.PartialValidation = config.PartialValidation
|
||||
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
||||
fic.UnlockedChallengeUpTo = config.UnlockedChallengeUpTo
|
||||
|
|
Loading…
Reference in New Issue