PrivateGER
3 years ago
9 changed files with 128 additions and 82 deletions
@ -0,0 +1,58 @@ |
|||||
|
package PageHandlers |
||||
|
|
||||
|
import ( |
||||
|
_ "embed" |
||||
|
"fmt" |
||||
|
"html/template" |
||||
|
) |
||||
|
|
||||
|
//go:embed templates/index.html
|
||||
|
var indexTmplSource string |
||||
|
|
||||
|
//go:embed templates/view.html
|
||||
|
var viewTmplSource string |
||||
|
|
||||
|
//go:embed templates/search.html
|
||||
|
var searchTmplSource string |
||||
|
|
||||
|
//go:embed templates/base.html
|
||||
|
var baseTmplSource string |
||||
|
|
||||
|
var tmpl map[string]*template.Template |
||||
|
|
||||
|
func init() { |
||||
|
tmpl = make(map[string]*template.Template) |
||||
|
|
||||
|
var err error |
||||
|
tmpl["index.html"] = template.New("index.html") |
||||
|
tmpl["index.html"], err = tmpl["index.html"].Parse(baseTmplSource) |
||||
|
if err != nil { |
||||
|
fmt.Println(err) |
||||
|
} |
||||
|
tmpl["index.html"], err = tmpl["index.html"].Parse(indexTmplSource) |
||||
|
if err != nil { |
||||
|
fmt.Println(err) |
||||
|
} |
||||
|
|
||||
|
fmt.Println(tmpl["index.html"].Name()) |
||||
|
|
||||
|
tmpl["search.html"] = template.New("search.html") |
||||
|
tmpl["search.html"], err = tmpl["search.html"].Parse(searchTmplSource) |
||||
|
if err != nil { |
||||
|
fmt.Println(err) |
||||
|
} |
||||
|
tmpl["search.html"], err = tmpl["search.html"].Parse(baseTmplSource) |
||||
|
if err != nil { |
||||
|
fmt.Println(err) |
||||
|
} |
||||
|
|
||||
|
tmpl["view.html"] = template.New("view.html") |
||||
|
tmpl["view.html"], err = tmpl["view.html"].Parse(viewTmplSource) |
||||
|
if err != nil { |
||||
|
fmt.Println(err) |
||||
|
} |
||||
|
tmpl["view.html"], err = tmpl["view.html"].Parse(baseTmplSource) |
||||
|
if err != nil { |
||||
|
fmt.Println(err) |
||||
|
} |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
{{define "base"}} |
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<style> |
||||
|
* { |
||||
|
color: white; |
||||
|
} |
||||
|
input{ |
||||
|
color: black; |
||||
|
} |
||||
|
</style> |
||||
|
{{template "head" .}} |
||||
|
</head> |
||||
|
<body style="background-color: #212121"> |
||||
|
<div style="background-color: #424242; padding: 8px; border-radius: 15px; margin-bottom: 50px"> |
||||
|
<h1 style="float: left">yt-dlp Archive Viewer</h1> |
||||
|
<form action="/search" method="get" style="float: right; margin: auto"> |
||||
|
<label> |
||||
|
Search term: |
||||
|
<input type="text" name="term" required> |
||||
|
</label> |
||||
|
</form> |
||||
|
<div style="clear:both;"></div> |
||||
|
</div> |
||||
|
<div style="padding: 10px"> |
||||
|
{{template "body" .}} |
||||
|
</div> |
||||
|
</body> |
||||
|
</html> |
||||
|
{{end}} |
Loading…
Reference in new issue