diff --git a/db/db.go b/db/db.go
index 1be722f..6d583e3 100644
--- a/db/db.go
+++ b/db/db.go
@@ -31,6 +31,7 @@ type Item struct {
}
type Jdb struct {
+ Foo string `json:"-"`
Items []Item `json:"items"`
}
@@ -72,7 +73,7 @@ func (d *Db) Transact(id int, persist bool, f func(*Item)) error {
}
func (d *Db) save() error {
- data, err := json.Marshal(Jdb{d.items})
+ data, err := json.Marshal(Jdb{"", d.items})
if err != nil {
return err
}
@@ -82,7 +83,7 @@ func (d *Db) save() error {
func (d *Db) Run(f func(*Jdb)) {
d.mutex.Lock()
defer d.mutex.Unlock()
- f(&Jdb{d.items})
+ f(&Jdb{"", d.items})
}
func (d *Db) Save() error {
diff --git a/main.go b/main.go
index 8a99612..b9094d3 100644
--- a/main.go
+++ b/main.go
@@ -70,9 +70,11 @@ func main() {
log.Panic(err)
}
defer d.Save()
+ http.Handle("/assets/", http.FileServer(http.Dir("./")))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
d.Run(func(d *db.Jdb) {
+ d.Foo = "Hello"
if err := tmpl.Execute(w, d); err != nil {
log.Panic(err)
}
@@ -106,7 +108,6 @@ func main() {
w.WriteHeader(http.StatusInternalServerError)
return
}
- fmt.Println("path is", p, "id is", id)
var sc <-chan string
d.Transact(id, false, func(i *db.Item) {
pt := i.Pt
diff --git a/templates/index.html b/templates/index.html
index 8ded8dd..25e1355 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,82 +1,119 @@
+
+
Youtube Downloader UI
+
-
-
- Vidoes
-
-
- Date |
- URL |
- Title |
- Link |
-
-
-
- {{ range .Items }}
-
- {{ .Date }} |
- {{ .URL }} |
-
- {{ if eq .Title "Loading" }}
- Loading...
- {{ else }}
- {{ .Title }}
- {{ end }}
- |
-
- {{ if eq .Status "Done" }}
- Watch
- {{ else if eq .Status "InProgress" }}
- In Progress
- {{ else }}
- {{ .Status }}
- {{ end }}
- |
-
- {{ end }}
-
-
+ {{ .Foo }}
+
+
+
+
+
+ {{ range .Items }}
+
+
+
+
+ {{ if eq .Title "Loading" }}
+ Loading...
+ {{ else }}
+ {{ .Title }}
+ {{ end }}
+
+
On {{ .Date }}
+
Youtube Link
+ {{ if eq .Status "Done" }}
+
Watch
+ {{ else if eq .Status "InProgress" }}
+
In Progress
+ {{ else }}
+
{{ .Status }}
+ {{ end }}
+
+
+
+ {{ end }}
+
+
+ All Vidoes
+
+
+ Date |
+ URL |
+ Title |
+ Link |
+
+
+
+ {{ range .Items }}
+
+ {{ .Date }} |
+ {{ .URL }} |
+
+ {{ if eq .Title "Loading" }}
+ Loading...
+ {{ else }}
+ {{ .Title }}
+ {{ end }}
+ |
+
+ {{ if eq .Status "Done" }}
+ Watch
+ {{ else if eq .Status "InProgress" }}
+ In Progress
+ {{ else }}
+ {{ .Status }}
+ {{ end }}
+ |
+
+ {{ end }}
+
+
+