-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converting list and new to templates
- Loading branch information
1 parent
b70f42b
commit db897c8
Showing
6 changed files
with
247 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,14 @@ | ||
package rest | ||
|
||
import ( | ||
"io" | ||
"net/http" | ||
"strings" | ||
) | ||
|
||
func GetNew(w http.ResponseWriter, r *http.Request) { | ||
|
||
w.Header().Set("Content-Type", "text/html") | ||
|
||
sb := &strings.Builder{} | ||
sb.WriteString("<!doctype html>") | ||
sb.WriteString("<html>") | ||
sb.WriteString("<head>" + | ||
"<meta charset='UTF-8'>" + | ||
"<link rel='icon' href='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔻</text></svg>' type='image/svg+xml'/>" + | ||
"<meta name='viewport' content='width=device-width, initial-scale=1.0'>" + | ||
"<meta name='color-scheme' content='dark light'>" + | ||
"<title>🔻 Watch new</title>" + | ||
"<style>") | ||
|
||
writeSharedStyles(sb) | ||
|
||
// new specific styles | ||
sb.WriteString( | ||
"input[type='text'] {width:90%}" + | ||
"input {font-size:1.25rem;display:block;}" + | ||
"input[type='submit'] {margin-block: 1rem;}") | ||
|
||
sb.WriteString("</style></head>") | ||
sb.WriteString("<body>") | ||
|
||
sb.WriteString("<a class='video highlight' href='/list'>Watch list</a>") | ||
|
||
sb.WriteString("<form method='get' action='/watch'>") | ||
sb.WriteString("<input id='v' name='v' type='text' placeholder='Paste or enter YouTube link or video-id' />") | ||
sb.WriteString("<input type='submit' />") | ||
sb.WriteString("</form>") | ||
|
||
sb.WriteString("</body>") | ||
sb.WriteString("</html>") | ||
|
||
if _, err := io.WriteString(w, sb.String()); err != nil { | ||
if err := tmpl.ExecuteTemplate(w, "new", nil); err != nil { | ||
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{{define "list"}} | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset='UTF-8'> | ||
<link rel='icon' | ||
href='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔻</text></svg>' | ||
type='image/svg+xml'/> | ||
<meta name='viewport' content='width=device-width, initial-scale=1.0'> | ||
<meta name='color-scheme' content='dark light'> | ||
<title>🔻 Watch list</title> | ||
{{template "css-shared"}} | ||
<style id="css-list"> | ||
a.playlist { | ||
display: flex; | ||
flex-direction: column; | ||
color: var(--color-pink); | ||
font-size: 1.3rem; | ||
font-weight: bold; | ||
text-decoration: none; | ||
margin-block: 2rem; | ||
} | ||
|
||
a.playlist.ended { | ||
color: var(--subtle-color) | ||
} | ||
|
||
a.playlist .subtitle { | ||
color: inherit | ||
} | ||
|
||
ul { | ||
list-style: none; | ||
padding-inline-start: 0 | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<a class='video highlight' href='/new'>Watch new</a> | ||
|
||
{{if .Continue}} | ||
<details open> | ||
<summary><h1>Continue</h1></summary> | ||
{{range .Continue}} | ||
{{template "video" .}} | ||
{{end}} | ||
</details> | ||
{{end}} | ||
|
||
{{if .Watchlist}} | ||
<details> | ||
<summary><h1>Watchlist</h1></summary> | ||
{{range .Watchlist}} | ||
{{template "video" .}} | ||
{{end}} | ||
</details> | ||
{{if .HasNewPlaylistVideos}} | ||
<div class='subtle'>Looking for more? New videos are available in the Playlists</div> | ||
{{end}} | ||
{{end}} | ||
|
||
{{if .Downloads}} | ||
<details> | ||
<summary><h1>Downloads</h1></summary> | ||
{{range .Downloads}} | ||
{{template "video" .}} | ||
{{end}} | ||
</details> | ||
{{end}} | ||
|
||
{{if .Playlists}} | ||
<details> | ||
<summary><h1>Playlists</h1></summary> | ||
<ul> | ||
{{range .Playlists}} | ||
<li> | ||
<a class="{{.Class}}" href='/playlist?list={{.PlaylistId}}'> | ||
<span class='playlistTitle'>{{.PlaylistTitle}}</span> | ||
{{if gt .NewVideos 0}} | ||
<span class='subtitle'>{{.NewVideos}} new</span> | ||
{{end}} | ||
</a> | ||
</li> | ||
|
||
{{end}} | ||
</ul> | ||
</details> | ||
{{end}} | ||
|
||
{{if .HasHistory}} | ||
<h1 class='highlight'>History</h1> | ||
<a class='video' href='/history'>Check out your watch history</a> | ||
{{end}} | ||
|
||
</body> | ||
</html> | ||
|
||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{{define "new"}} | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset='UTF-8'> | ||
<link rel='icon' | ||
href='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔻</text></svg>' | ||
type='image/svg+xml'/> | ||
<meta name='viewport' content='width=device-width, initial-scale=1.0'> | ||
<meta name='color-scheme' content='dark light'> | ||
<title>🔻 Watch new</title> | ||
{{template "css-shared"}} | ||
<style id="css-new"> | ||
|
||
input[type='text'] { | ||
width: 90% | ||
} | ||
|
||
input { | ||
font-size: 1.25rem; | ||
display: block; | ||
} | ||
|
||
input[type='submit'] { | ||
margin-block: 1rem; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<a class='video highlight' href='/list'>Watch list</a> | ||
|
||
<form method='get' action='/watch'> | ||
<input id='v' name='v' type='text' placeholder='Paste or enter YouTube link or video-id'/> | ||
<input type='submit'/> | ||
</form> | ||
|
||
</body> | ||
</html> | ||
{{end}} |
Oops, something went wrong.