sync: search theme's label in a title.txt file, fallback on dirname
This commit is contained in:
parent
6f7bd3b785
commit
4e01377a29
2 changed files with 14 additions and 2 deletions
|
@ -62,6 +62,16 @@ func GetThemeByName(name string) (Theme, error) {
|
|||
return t, nil
|
||||
}
|
||||
|
||||
// GetThemeByPath retrieves a Theme from its dirname
|
||||
func GetThemeByPath(dirname string) (Theme, error) {
|
||||
var t Theme
|
||||
if err := DBQueryRow("SELECT id_theme, name, url_id, path, authors, intro, headline, image FROM themes WHERE path=?", dirname).Scan(&t.Id, &t.Name, &t.URLId, &t.Path, &t.Authors, &t.Intro, &t.Headline, &t.Image); err != nil {
|
||||
return t, err
|
||||
}
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// CreateTheme creates and fills a new struct Theme and registers it into the database.
|
||||
func CreateTheme(theme Theme) (Theme, error) {
|
||||
if res, err := DBExec("INSERT INTO themes (name, url_id, authors, path, intro, headline, image) VALUES (?, ?, ?, ?, ?, ?, ?)", theme.Name, theme.URLId, theme.Authors, theme.Path, theme.Intro, theme.Headline, theme.Image); err != nil {
|
||||
|
|
Reference in a new issue