add bootstrap js. Not sure if it is useful for now

This commit is contained in:
Balakrishnan Balasubramanian 2022-07-21 16:23:42 -04:00
parent 911a55b502
commit dc20e1ea30
4 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,7 @@
update-bootstrap: update-bootstrap:
curl -L "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css" -o assets/bootstrap.min.css curl -L "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css" -o assets/bootstrap.min.css
curl -L "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.min.js" -o assets/bootstrap.min.js
build: build:
go build . go build .

7
assets/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

13
main.go
View File

@ -80,7 +80,10 @@ func main() {
} }
defer d.Save() defer d.Save()
assets := []string{"assets/bootstrap.min.css"} assets := []string{
"assets/bootstrap.min.css",
"assets/bootstrap.min.js",
}
if saveAssets { if saveAssets {
for _, assetFile := range assets { for _, assetFile := range assets {
@ -288,24 +291,24 @@ func downloadYt(id int, yturl string, pc chan<- string) (string, error) {
var fname string var fname string
if err != nil { if err != nil {
pc <- "Download Error" pc <- "Download Error"
return "", fmt.Errorf("Download Error, err: %w", err) return "", fmt.Errorf("download Error, err: %w", err)
} }
pc <- "Download Done, renaming" pc <- "Download Done, renaming"
matches, err := fs.Glob(os.DirFS(cachePath), fmt.Sprintf("video_%d.*", id)) matches, err := fs.Glob(os.DirFS(cachePath), fmt.Sprintf("video_%d.*", id))
if err != nil { if err != nil {
pc <- "Match Error" pc <- "Match Error"
return "", fmt.Errorf("Glob match error, err: %w\n", err) return "", fmt.Errorf("glob match error, err: %w", err)
} }
if len(matches) != 1 { if len(matches) != 1 {
pc <- "Multiple Match Error" pc <- "Multiple Match Error"
return "", fmt.Errorf("Got multiple matches, count: %v", len(matches)) return "", fmt.Errorf("got multiple matches, count: %v", len(matches))
} }
fname = matches[0] fname = matches[0]
source := path.Join(cachePath, fname) source := path.Join(cachePath, fname)
destination := path.Join(videosPath, fname) destination := path.Join(videosPath, fname)
if err := os.Rename(source, destination); err != nil { if err := os.Rename(source, destination); err != nil {
pc <- "Rename error" pc <- "Rename error"
return "", fmt.Errorf("Rename error, fname: %q, source: %q, destination: %q, err: %w\n", fname, source, destination, err) return "", fmt.Errorf("rename error, fname: %q, source: %q, destination: %q, err: %w", fname, source, destination, err)
} }
return fname, nil return fname, nil
} }

View File

@ -37,6 +37,7 @@
}) })
}) })
</script> </script>
<script src="assets/bootstrap.min.js" defer></script>
</head> </head>
<body> <body>
<h1 class="text-center">{{ $.Title }}</h1> <h1 class="text-center">{{ $.Title }}</h1>