Extract background color to continue image
This commit is contained in:
parent
35d07c1aa4
commit
26c282138e
23 changed files with 218 additions and 115 deletions
|
|
@ -10,32 +10,34 @@ var GlobalScoreCoefficient float64 = 1
|
|||
|
||||
// exportedExercice is a structure representing a challenge, as exposed to players.
|
||||
type exportedExercice struct {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Authors string `json:"authors,omitempty"`
|
||||
Headline string `json:"headline,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
URLId string `json:"urlid"`
|
||||
Tags []string `json:"tags"`
|
||||
Gain int64 `json:"gain"`
|
||||
Coeff float64 `json:"curcoeff"`
|
||||
Solved int64 `json:"solved"`
|
||||
Tried int64 `json:"tried"`
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Authors string `json:"authors,omitempty"`
|
||||
Headline string `json:"headline,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
BackgroundColor string `json:"background_color,omitempty"`
|
||||
URLId string `json:"urlid"`
|
||||
Tags []string `json:"tags"`
|
||||
Gain int64 `json:"gain"`
|
||||
Coeff float64 `json:"curcoeff"`
|
||||
Solved int64 `json:"solved"`
|
||||
Tried int64 `json:"tried"`
|
||||
}
|
||||
|
||||
// exportedTheme is a structure representing a Theme, as exposed to players.
|
||||
type exportedTheme struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
URLId string `json:"urlid"`
|
||||
Locked bool `json:"locked,omitempty"`
|
||||
Authors string `json:"authors,omitempty"`
|
||||
Headline string `json:"headline,omitempty"`
|
||||
Intro string `json:"intro,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
PartnerImage string `json:"partner_img,omitempty"`
|
||||
PartnerLink string `json:"partner_href,omitempty"`
|
||||
PartnerText string `json:"partner_txt,omitempty"`
|
||||
Exercices []exportedExercice `json:"exercices"`
|
||||
Name string `json:"name,omitempty"`
|
||||
URLId string `json:"urlid"`
|
||||
Locked bool `json:"locked,omitempty"`
|
||||
Authors string `json:"authors,omitempty"`
|
||||
Headline string `json:"headline,omitempty"`
|
||||
Intro string `json:"intro,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
BackgroundColor string `json:"background_color,omitempty"`
|
||||
PartnerImage string `json:"partner_img,omitempty"`
|
||||
PartnerLink string `json:"partner_href,omitempty"`
|
||||
PartnerText string `json:"partner_txt,omitempty"`
|
||||
Exercices []exportedExercice `json:"exercices"`
|
||||
}
|
||||
|
||||
// Exportedthemes exports themes from the database, to be displayed to players.
|
||||
|
|
@ -69,6 +71,10 @@ func ExportThemes() (interface{}, error) {
|
|||
if len(exercice.Image) > 0 {
|
||||
exoimgpath = path.Join(FilesDir, exercice.Image)
|
||||
}
|
||||
exobackgroundcolor := ""
|
||||
if exercice.BackgroundColor > 0 || len(exercice.Image) > 0 {
|
||||
exobackgroundcolor = fmt.Sprintf("#%06X", exercice.BackgroundColor)
|
||||
}
|
||||
|
||||
tags, _ := exercice.GetTags()
|
||||
exos = append(exos, exportedExercice{
|
||||
|
|
@ -77,6 +83,7 @@ func ExportThemes() (interface{}, error) {
|
|||
exercice.Authors,
|
||||
exercice.Headline,
|
||||
exoimgpath,
|
||||
exobackgroundcolor,
|
||||
exercice.URLId,
|
||||
tags,
|
||||
int64(float64(exercice.Gain) * GlobalScoreCoefficient),
|
||||
|
|
@ -92,6 +99,11 @@ func ExportThemes() (interface{}, error) {
|
|||
imgpath = path.Join(FilesDir, theme.Image)
|
||||
}
|
||||
|
||||
thmbackgroundcolor := ""
|
||||
if theme.BackgroundColor > 0 || len(theme.Image) > 0 {
|
||||
thmbackgroundcolor = fmt.Sprintf("#%06X", theme.BackgroundColor)
|
||||
}
|
||||
|
||||
partnerImgpath := ""
|
||||
if len(theme.PartnerImage) > 0 {
|
||||
partnerImgpath = path.Join(FilesDir, theme.PartnerImage)
|
||||
|
|
@ -105,6 +117,7 @@ func ExportThemes() (interface{}, error) {
|
|||
theme.Headline,
|
||||
strings.Replace(theme.Intro, "$FILES$", FilesDir, -1),
|
||||
imgpath,
|
||||
thmbackgroundcolor,
|
||||
partnerImgpath,
|
||||
theme.PartnerLink,
|
||||
theme.PartnerText,
|
||||
|
|
|
|||
Reference in a new issue