admin: Use logo from challengeinfo in ui template
This commit is contained in:
parent
7e301b8ecb
commit
f1ada8ce99
2 changed files with 18 additions and 4 deletions
|
@ -4,7 +4,7 @@ const indextpl = `<!DOCTYPE html>
|
||||||
<html ng-app="FICApp">
|
<html ng-app="FICApp">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Challenge Forensic - Administration</title>
|
<title>{{ .title }} - Administration</title>
|
||||||
<link href="{{.urlbase}}css/bootstrap.min.css" type="text/css" rel="stylesheet">
|
<link href="{{.urlbase}}css/bootstrap.min.css" type="text/css" rel="stylesheet">
|
||||||
<link href="{{.urlbase}}css/glyphicon.css" type="text/css" rel="stylesheet" media="screen">
|
<link href="{{.urlbase}}css/glyphicon.css" type="text/css" rel="stylesheet" media="screen">
|
||||||
<style>
|
<style>
|
||||||
|
@ -86,7 +86,7 @@ const indextpl = `<!DOCTYPE html>
|
||||||
<body class="bg-light text-dark">
|
<body class="bg-light text-dark">
|
||||||
<nav class="navbar sticky-top navbar-expand-lg navbar-dark text-light" ng-class="{'bg-dark': settings.wip, 'bg-danger': !settings.wip}">
|
<nav class="navbar sticky-top navbar-expand-lg navbar-dark text-light" ng-class="{'bg-dark': settings.wip, 'bg-danger': !settings.wip}">
|
||||||
<a class="navbar-brand" href=".">
|
<a class="navbar-brand" href=".">
|
||||||
<img alt="FIC" src="img/fic.png" style="height: 30px">
|
<img alt="{{ .title }}" src="{{ .logo }}" style="height: 30px">
|
||||||
</a>
|
</a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#adminMenu" aria-controls="adminMenu" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#adminMenu" aria-controls="adminMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
|
|
@ -25,10 +25,24 @@ var assets embed.FS
|
||||||
var indexPage []byte
|
var indexPage []byte
|
||||||
|
|
||||||
func genIndex(baseURL string) {
|
func genIndex(baseURL string) {
|
||||||
|
tplcfg := map[string]string{
|
||||||
|
"logo": "img/logo.png",
|
||||||
|
"title": "Challenge",
|
||||||
|
"urlbase": path.Clean(path.Join(baseURL+"/", "nuke"))[:len(path.Clean(path.Join(baseURL+"/", "nuke")))-4],
|
||||||
|
}
|
||||||
|
|
||||||
|
ci, err := api.GetChallengeInfo()
|
||||||
|
if err == nil && ci != nil {
|
||||||
|
tplcfg["title"] = ci.Title
|
||||||
|
if len(ci.MainLogo) > 0 {
|
||||||
|
tplcfg["logo"] = "/files/logo/" + path.Base(ci.MainLogo[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
b := bytes.NewBufferString("")
|
b := bytes.NewBufferString("")
|
||||||
if indexTmpl, err := template.New("index").Parse(indextpl); err != nil {
|
if indexTmpl, err := template.New("index").Parse(indextpl); err != nil {
|
||||||
log.Fatal("Cannot create template:", err)
|
log.Fatal("Cannot create template:", err)
|
||||||
} else if err = indexTmpl.Execute(b, map[string]string{"urlbase": path.Clean(path.Join(baseURL+"/", "nuke"))[:len(path.Clean(path.Join(baseURL+"/", "nuke")))-4]}); err != nil {
|
} else if err = indexTmpl.Execute(b, tplcfg); err != nil {
|
||||||
log.Fatal("An error occurs during template execution:", err)
|
log.Fatal("An error occurs during template execution:", err)
|
||||||
} else {
|
} else {
|
||||||
indexPage = b.Bytes()
|
indexPage = b.Bytes()
|
||||||
|
@ -108,7 +122,7 @@ func declareStaticRoutes(router *gin.RouterGroup, cfg *settings.Settings, baseUR
|
||||||
|
|
||||||
router.GET("/files/*_", func(c *gin.Context) {
|
router.GET("/files/*_", func(c *gin.Context) {
|
||||||
// TODO: handle .gz file here
|
// TODO: handle .gz file here
|
||||||
http.ServeFile(c.Writer, c.Request, path.Join(fic.FilesDir, strings.TrimPrefix(c.Request.URL.Path, path.Join(baseURL, "files"))))
|
http.ServeFile(c.Writer, c.Request, path.Join(fic.FilesDir, strings.TrimPrefix(strings.TrimPrefix(c.Request.URL.Path, baseURL), "/files")))
|
||||||
})
|
})
|
||||||
router.GET("/submissions/*_", func(c *gin.Context) {
|
router.GET("/submissions/*_", func(c *gin.Context) {
|
||||||
http.ServeFile(c.Writer, c.Request, path.Join(api.TimestampCheck, strings.TrimPrefix(c.Request.URL.Path, path.Join(baseURL, "submissions"))))
|
http.ServeFile(c.Writer, c.Request, path.Join(api.TimestampCheck, strings.TrimPrefix(c.Request.URL.Path, path.Join(baseURL, "submissions"))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue