sync: Add partner's info
This commit is contained in:
parent
f2bf07fd28
commit
74d77dce9f
6 changed files with 105 additions and 31 deletions
|
@ -153,6 +153,22 @@ func BuildTheme(i Importer, tdir string) (th *fic.Theme, errs []string) {
|
|||
errs = append(errs, fmt.Sprintf("%q: heading.jpg: No such file", tdir))
|
||||
}
|
||||
|
||||
if i.exists(path.Join(tdir, "partner.jpg")) {
|
||||
th.PartnerImage = path.Join(tdir, "partner.jpg")
|
||||
} else if i.exists(path.Join(tdir, "partner.png")) {
|
||||
th.PartnerImage = path.Join(tdir, "partner.png")
|
||||
}
|
||||
|
||||
if i.exists(path.Join(tdir, "partner.txt")) {
|
||||
if txt, err := getFileContent(i, path.Join(tdir, "partner.txt")); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to get partner's text: %s", th.Name, err))
|
||||
} else {
|
||||
th.PartnerText, err = ProcessMarkdown(i, txt, tdir)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: partner.txt: an error occurs during markdown formating: %s", tdir, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -189,6 +205,16 @@ func SyncThemes(i Importer) []string {
|
|||
}
|
||||
}
|
||||
|
||||
if len(btheme.PartnerImage) > 0 {
|
||||
if _, err := i.importFile(btheme.PartnerImage,
|
||||
func(filePath string, origin string) (interface{}, error) {
|
||||
btheme.PartnerImage = strings.TrimPrefix(filePath, fic.FilesDir)
|
||||
return nil, nil
|
||||
}); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to import partner image: %s", tdir, err))
|
||||
}
|
||||
}
|
||||
|
||||
var theme fic.Theme
|
||||
if theme, err = fic.GetThemeByPath(btheme.Path); err != nil {
|
||||
if _, err := fic.CreateTheme(*btheme); err != nil {
|
||||
|
|
Reference in a new issue