sync: Add partner's info

This commit is contained in:
nemunaire 2021-09-01 10:15:26 +02:00
commit 74d77dce9f
6 changed files with 105 additions and 31 deletions

View file

@ -20,13 +20,16 @@ type exportedExercice struct {
// exportedTheme is a structure representing a Theme, as exposed to players.
type exportedTheme struct {
Name string `json:"name"`
URLId string `json:"urlid"`
Authors string `json:"authors"`
Headline string `json:"headline,omitempty"`
Intro string `json:"intro"`
Image string `json:"image,omitempty"`
Exercices map[string]exportedExercice `json:"exercices"`
Name string `json:"name"`
URLId string `json:"urlid"`
Authors string `json:"authors"`
Headline string `json:"headline,omitempty"`
Intro string `json:"intro"`
Image string `json:"image,omitempty"`
PartnerImage string `json:"partner_img,omitempty"`
PartnerLink string `json:"partner_href,omitempty"`
PartnerText string `json:"partner_txt,omitempty"`
Exercices map[string]exportedExercice `json:"exercices"`
}
// Exportedthemes exports themes from the database, to be displayed to players.
@ -59,6 +62,11 @@ func ExportThemes() (interface{}, error) {
imgpath = path.Join(FilesDir, theme.Image)
}
partnerImgpath := ""
if len(theme.PartnerImage) > 0 {
partnerImgpath = path.Join(FilesDir, theme.PartnerImage)
}
ret[fmt.Sprintf("%d", theme.Id)] = exportedTheme{
theme.Name,
theme.URLId,
@ -66,6 +74,9 @@ func ExportThemes() (interface{}, error) {
theme.Headline,
strings.Replace(theme.Intro, "$FILES$", FilesDir, -1),
imgpath,
partnerImgpath,
theme.PartnerLink,
theme.PartnerText,
exos,
}
}