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;
|
add_header Cache-Control no-cache;
|
||||||
}
|
}
|
||||||
location /themes.json {
|
location /themes.json {
|
||||||
|
include fic-get-team.conf;
|
||||||
|
|
||||||
root ${PATH_TEAMS};
|
root ${PATH_TEAMS};
|
||||||
expires epoch;
|
expires epoch;
|
||||||
add_header Cache-Control no-cache;
|
add_header Cache-Control no-cache;
|
||||||
|
|
||||||
|
if (!-f ${PATH_TEAMS}/$team/my.json) {
|
||||||
|
rewrite ^/ /themes-wait.json break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
location /challenge.json {
|
location /challenge.json {
|
||||||
root ${PATH_SETTINGS}/;
|
root ${PATH_SETTINGS}/;
|
||||||
|
|
|
@ -103,6 +103,7 @@ services:
|
||||||
- fic-net
|
- fic-net
|
||||||
volumes:
|
volumes:
|
||||||
- teams:/srv/TEAMS
|
- teams:/srv/TEAMS
|
||||||
|
- settingsdist:/srv/SETTINGSDIST
|
||||||
command: -baseurl /qa/
|
command: -baseurl /qa/
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
import { my } from '$lib/stores/my.js';
|
import { my } from '$lib/stores/my.js';
|
||||||
|
import { themesStore } from '$lib/stores/themes.js';
|
||||||
import { settings } from '$lib/stores/settings.js';
|
import { settings } from '$lib/stores/settings.js';
|
||||||
|
|
||||||
import RegistrationFormCreateTeam from '$lib/components/RegistrationFormCreateTeam.svelte';
|
import RegistrationFormCreateTeam from '$lib/components/RegistrationFormCreateTeam.svelte';
|
||||||
|
@ -26,7 +27,9 @@
|
||||||
function gotoHomeOnDiff(i) {
|
function gotoHomeOnDiff(i) {
|
||||||
my.refresh((my) => {
|
my.refresh((my) => {
|
||||||
if (my && my.team_id) {
|
if (my && my.team_id) {
|
||||||
goto('.');
|
themesStore.refresh(() => {
|
||||||
|
goto('.');
|
||||||
|
});
|
||||||
} else if (i > 0) {
|
} else if (i > 0) {
|
||||||
setTimeout(gotoHomeOnDiff, 650, i-1);
|
setTimeout(gotoHomeOnDiff, 650, i-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -298,12 +299,43 @@ func genTeamsFile() error {
|
||||||
|
|
||||||
// Generate general themes.json file
|
// Generate general themes.json file
|
||||||
func genThemesFile() error {
|
func genThemesFile() error {
|
||||||
if themes, err := fic.ExportThemes(); err != nil {
|
themes, err := fic.ExportThemes()
|
||||||
return err
|
if err != nil {
|
||||||
} else if j, err := json.Marshal(themes); err != nil {
|
return fmt.Errorf("unable to generate themes: %w", err)
|
||||||
return err
|
}
|
||||||
} else if err = ioutil.WriteFile(path.Join(TeamsDir, "themes.json"), j, 0666); err != nil {
|
|
||||||
return 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
|
return nil
|
||||||
|
|
|
@ -23,13 +23,16 @@ var TeamsDir string
|
||||||
var ChStarted = false
|
var ChStarted = false
|
||||||
var lastRegeneration time.Time
|
var lastRegeneration time.Time
|
||||||
var skipInitialGeneration = false
|
var skipInitialGeneration = false
|
||||||
|
var allowRegistration bool
|
||||||
|
|
||||||
func reloadSettings(config *settings.Settings) {
|
func reloadSettings(config *settings.Settings) {
|
||||||
fic.HintCoefficient = config.HintCurCoefficient
|
fic.HintCoefficient = config.HintCurCoefficient
|
||||||
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
|
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
|
||||||
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
|
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
|
||||||
ChStarted = config.Start.Unix() > 0 && time.Since(config.Start) >= 0
|
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.PartialValidation = config.PartialValidation
|
||||||
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
fic.UnlockedChallengeDepth = config.UnlockedChallengeDepth
|
||||||
fic.UnlockedChallengeUpTo = config.UnlockedChallengeUpTo
|
fic.UnlockedChallengeUpTo = config.UnlockedChallengeUpTo
|
||||||
|
|
Loading…
Reference in New Issue
Block a user