diff --git a/admin/api/settings.go b/admin/api/settings.go index e5dd9bca..4213d37a 100644 --- a/admin/api/settings.go +++ b/admin/api/settings.go @@ -157,7 +157,7 @@ func saveChallengeInfo(c *gin.Context) { // Ignore the error, try to continue } - err = sync.ImportChallengeInfo(info) + err = sync.ImportChallengeInfo(info, DashboardDir) if err != nil { log.Println("Unable to ImportChallengeInfo:", err.Error()) c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": fmt.Sprintf("Something goes wrong when trying to import related files: %s", err.Error())}) diff --git a/admin/static/views/settings.html b/admin/static/views/settings.html index c3b2e363..ca51cae1 100644 --- a/admin/static/views/settings.html +++ b/admin/static/views/settings.html @@ -350,6 +350,13 @@ +
+ +
+ +
+
+
diff --git a/admin/sync/challengeinfo.go b/admin/sync/challengeinfo.go index 436756e8..6e3b4a73 100644 --- a/admin/sync/challengeinfo.go +++ b/admin/sync/challengeinfo.go @@ -9,7 +9,7 @@ import ( ) // ImportChallengeInfo imports images defined in the challengeinfo. -func ImportChallengeInfo(ci *settings.ChallengeInfo) (err error) { +func ImportChallengeInfo(ci *settings.ChallengeInfo, dashboardDir string) (err error) { if len(ci.MainLogo) > 0 { for i, logo := range ci.MainLogo { dest := path.Join(fic.FilesDir, "logo", path.Base(logo)) @@ -22,6 +22,14 @@ func ImportChallengeInfo(ci *settings.ChallengeInfo) (err error) { } } + if len(ci.DashboardBackground) > 0 { + dest := path.Join(dashboardDir, path.Base(ci.DashboardBackground)) + err = importFile(GlobalImporter, ci.DashboardBackground, dest) + if err != nil { + return + } + } + if len(ci.Partners) > 0 { for i, partner := range ci.Partners { dest := path.Join(fic.FilesDir, "partner", path.Base(partner.Src)) diff --git a/dashboard/static.go b/dashboard/static.go index a5a8cdaf..55308ce0 100644 --- a/dashboard/static.go +++ b/dashboard/static.go @@ -149,6 +149,14 @@ func declareStaticRoutes(router *gin.RouterGroup, baseURL string) { } }) + router.GET("/background.png", func(c *gin.Context) { + if forwarder != nil && fwdPublicJson { + fwd_request(c.Writer, c.Request, *forwarder) + } else { + http.ServeFile(c.Writer, c.Request, path.Join(DashboardDir, "background.png")) + } + }) + router.GET("/public.json", func(c *gin.Context) { c.Writer.Header().Set("Cache-Control", "no-cache") if forwarder != nil && fwdPublicJson { diff --git a/dashboard/static/css/fic.css b/dashboard/static/css/fic.css index fc12b00d..9c88d5ca 100644 --- a/dashboard/static/css/fic.css +++ b/dashboard/static/css/fic.css @@ -36,7 +36,7 @@ body { } .bg-public { - background-image: url('../img/logo-epita-bw.png'); + background-image: url('../background.png'); background-repeat: no-repeat; background-size: contain; height: 100vh; diff --git a/dashboard/static/img/logo-epita-bw.png b/dashboard/static/img/logo-epita-bw.png deleted file mode 100644 index 5dd2d925..00000000 Binary files a/dashboard/static/img/logo-epita-bw.png and /dev/null differ diff --git a/dashboard/static/index.html b/dashboard/static/index.html index 9172f533..1aa98ad5 100644 --- a/dashboard/static/index.html +++ b/dashboard/static/index.html @@ -6,7 +6,7 @@ - + diff --git a/settings/challenge.go b/settings/challenge.go index 150ff1aa..fdc32e6b 100644 --- a/settings/challenge.go +++ b/settings/challenge.go @@ -39,6 +39,8 @@ type ChallengeInfo struct { MainLogo []string `json:"main_logo,omitempty"` // MainLink stores link to the parent website. MainLink string `json:"main_link,omitempty"` + // DashboardBackground stores path to the background used on the public dashboard. + DashboardBackground string `json:"dashboard_background,omitempty"` // Partners holds the challenge partners list. Partners []ChallengePartner `json:"partners,omitempty"` }