admin/sync: theme's name is now part of the theme's dirname
This commit is contained in:
parent
cb02fa98dd
commit
9ab5738cff
5 changed files with 37 additions and 24 deletions
|
|
@ -42,19 +42,27 @@ func SyncThemes(i Importer) []string {
|
|||
if themes, err := getThemes(i); err != nil {
|
||||
errs = append(errs, err.Error())
|
||||
} else {
|
||||
for _, tname := range themes {
|
||||
for _, tdir := range themes {
|
||||
var authors []string
|
||||
var intro string
|
||||
var theme fic.Theme
|
||||
var tname string
|
||||
|
||||
if authors, err = getAuthors(i, tname); err != nil {
|
||||
// Extract theme's label
|
||||
if f := strings.Index(tdir, "-"); f >= 0 {
|
||||
tname = tdir[f+1:]
|
||||
} else {
|
||||
tname = tdir
|
||||
}
|
||||
|
||||
if authors, err = getAuthors(i, tdir); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to get AUTHORS: %s", tname, err))
|
||||
continue
|
||||
} else if intro, err = getFileContent(i, path.Join(tname, "overview.txt")); err != nil {
|
||||
} else if intro, err = getFileContent(i, path.Join(tdir, "overview.txt")); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to get theme's overview: %s", tname, err))
|
||||
} else if theme, err = fic.GetThemeByName(tname); err != nil {
|
||||
if _, err := fic.CreateTheme(tname, fic.ToURLid(tname), strings.Join(authors, ", "), intro); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: an error occurs during add: %s", tname, err))
|
||||
if _, err := fic.CreateTheme(tname, fic.ToURLid(tname), tdir, strings.Join(authors, ", "), intro); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: an error occurs during add: %s", tdir, err))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
@ -65,8 +73,9 @@ func SyncThemes(i Importer) []string {
|
|||
theme.Name = tname
|
||||
theme.Authors = authors_str
|
||||
theme.Intro = intro
|
||||
theme.Path = tdir
|
||||
if _, err := theme.Update(); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: an error occurs during update: %s", tname, err))
|
||||
errs = append(errs, fmt.Sprintf("%q: an error occurs during update: %s", tdir, err))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue