move templates to user config dir
All checks were successful
/ build-linux-amd64 (push) Successful in 1m10s
All checks were successful
/ build-linux-amd64 (push) Successful in 1m10s
This commit is contained in:
parent
34065bd06f
commit
6cafff34a8
2 changed files with 6 additions and 7 deletions
2
main.go
2
main.go
|
|
@ -151,7 +151,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// good to have early on
|
// good to have early on
|
||||||
templates, err := yt.FetchTemplates()
|
templates, err := yt.FetchTemplates(path.Join(userConfigDir, "templates"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to fetch templates: %v", err)
|
log.Fatalf("Failed to fetch templates: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
||||||
|
|
@ -113,11 +113,6 @@ var videoYtCategory = map[CategoryType]string {
|
||||||
CATEGORY_ENTERTAINMENT: YT_CATEGORY_ENTERTAINMENT,
|
CATEGORY_ENTERTAINMENT: YT_CATEGORY_ENTERTAINMENT,
|
||||||
}
|
}
|
||||||
|
|
||||||
var templateDir = "templates"
|
|
||||||
var tagsPath = path.Join(templateDir, "tags.txt")
|
|
||||||
var titlePath = path.Join(templateDir, "title.txt")
|
|
||||||
var descriptionPath = path.Join(templateDir, "description.txt")
|
|
||||||
|
|
||||||
const defaultTitleTemplate =
|
const defaultTitleTemplate =
|
||||||
"{{.Title}} - {{FormatTime .Date \"02 Jan 2006\"}}"
|
"{{.Title}} - {{FormatTime .Date \"02 Jan 2006\"}}"
|
||||||
const defaultDescriptionTemplate =
|
const defaultDescriptionTemplate =
|
||||||
|
|
@ -135,9 +130,13 @@ var templateFuncs = template.FuncMap{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func FetchTemplates() (*Template, error) {
|
func FetchTemplates(templateDir string) (*Template, error) {
|
||||||
tmpl := Template{}
|
tmpl := Template{}
|
||||||
|
|
||||||
|
var tagsPath = path.Join(templateDir, "tags.txt")
|
||||||
|
var titlePath = path.Join(templateDir, "title.txt")
|
||||||
|
var descriptionPath = path.Join(templateDir, "description.txt")
|
||||||
|
|
||||||
// tags
|
// tags
|
||||||
if tagsFile, err := os.ReadFile(tagsPath); err == nil {
|
if tagsFile, err := os.ReadFile(tagsPath); err == nil {
|
||||||
tmpl.Tags = strings.Split(string(tagsFile), "\n")
|
tmpl.Tags = strings.Split(string(tagsFile), "\n")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue