mirror of
https://github.com/nxshock/promodj.git
synced 2024-11-27 03:01:01 +05:00
Split site to separate files
This commit is contained in:
parent
a0e0b7b1cc
commit
b0f9ea1f49
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
func handleGenres(w http.ResponseWriter, r *http.Request) {
|
func handleGenres(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.RequestURI != "/" {
|
if r.RequestURI != "/" {
|
||||||
http.Error(w, "not found", http.StatusNotFound)
|
http.FileServer(http.FS(stripSiteFS)).ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ func handleGenres(w http.ResponseWriter, r *http.Request) {
|
|||||||
Domain: r.Host,
|
Domain: r.Host,
|
||||||
Genres: Genres}
|
Genres: Genres}
|
||||||
|
|
||||||
err := templates.Lookup("genres.html").Execute(w, data)
|
err := templates.Lookup("index.htm").Execute(w, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
8
main.go
8
main.go
@ -1,19 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "embed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates/genres.html
|
|
||||||
var templateBytes embed.FS
|
|
||||||
|
|
||||||
var templates *template.Template
|
var templates *template.Template
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -45,7 +39,7 @@ func init() {
|
|||||||
func initTepmplates() error {
|
func initTepmplates() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
templates, err = template.ParseFS(templateBytes, "templates/*.html")
|
templates, err = template.ParseFS(siteFS, "site/*.htm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
15
site.go
Normal file
15
site.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"io/fs"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed site/*
|
||||||
|
var siteFS embed.FS
|
||||||
|
|
||||||
|
var stripSiteFS fs.FS
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
stripSiteFS, _ = fs.Sub(siteFS, "site")
|
||||||
|
}
|
1
site/favicon.svg
Normal file
1
site/favicon.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" stroke="none" viewBox="0 0 30 30"><path d="M 10,25 0,20 v 10 l 10,-5" fill="#8abeb7"/><path d="M 10,15 0,10 v 10 l 10,-5" fill="#8abeb7"/><path d="m 0,20 10,5 V 15 L 0,20" fill="#b5bd68"/><path d="M 20,20 10,15 v 10 l 10,-5" fill="#f0c674"/><path d="M 30,15 20,10 v 10 l 10,-5" fill="#cc6666"/><path d="m 10,15 10,5 V 10 l -10,5" fill="#de935f"/><path d="M 20,10 10,5 v 10 l 10,-5" fill="#f0c674"/><path d="m 0,10 10,5 V 5 L 0,10" fill="#b5bd68"/><path d="M 10,5 0,0 V 10 L 10,5" fill="#8abeb7"/></svg>
|
After Width: | Height: | Size: 557 B |
24
site/index.htm
Normal file
24
site/index.htm
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
|
<title>Список жанров</title>
|
||||||
|
<link rel="stylesheet" href="/style.css">
|
||||||
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<img src="/favicon.svg">
|
||||||
|
{{.Domain}}
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<h1>Список жанров</h1>
|
||||||
|
<ul id="genres-list">
|
||||||
|
{{range .Genres}}
|
||||||
|
<li><a href="/getm3u?genre={{.Code}}">{{.Name}}</a></li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
65
site/style.css
Normal file
65
site/style.css
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
* {
|
||||||
|
font-family: Verdana;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #abb2bf;
|
||||||
|
margin: .5em;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
height: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #282c34;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #61afef;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg, img {
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
flex-grow: 0;
|
||||||
|
background-color: #353b45;
|
||||||
|
border-bottom: 1px solid #3e4451;
|
||||||
|
padding: .5em;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-top: 1em;
|
||||||
|
font-size: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
width: calc(100% - 1em);
|
||||||
|
}
|
||||||
|
|
||||||
|
form>input {
|
||||||
|
width: calc(100% - 2em);
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><title>Список жанров</title><style>*{font-family: Verdana;font-size: 16px;color: #abb2bf;margin: .5em;padding: 0;}html{margin: 0;padding: 0;height: 100%}body{background-color: #282c34;display: flex;justify-content: space-between;flex-wrap: nowrap;flex-direction: column;height: 100%;margin: 0;padding: 0;}a{text-decoration: none;color: #61afef;}svg, img{vertical-align: middle;width: 1em;height: 1em;}header{flex-grow: 0;background-color: #353b45;border-bottom: 1px solid #3e4451;padding: .5em;margin: 0;}h1{margin-top: 1em;font-size: 150%;}ul{list-style-type: none;}form{width: calc(100% - 1em);}form > input{width: calc(100% - 2em);padding: .5em;}main{flex-grow: 1;}</style></head><body><header><svg xmlns="http://www.w3.org/2000/svg" version="1.1" stroke="none" viewBox="0 0 30 30"><path d="M 10,25 0,20 v 10 l 10,-5" fill="#8abeb7"/><path d="M 10,15 0,10 v 10 l 10,-5" fill="#8abeb7"/><path d="m 0,20 10,5 V 15 L 0,20" fill="#b5bd68"/><path d="M 20,20 10,15 v 10 l 10,-5" fill="#f0c674"/><path d="M 30,15 20,10 v 10 l 10,-5" fill="#cc6666"/><path d="m 10,15 10,5 V 10 l -10,5" fill="#de935f"/><path d="M 20,10 10,5 v 10 l 10,-5" fill="#f0c674"/><path d="m 0,10 10,5 V 5 L 0,10" fill="#b5bd68"/><path d="M 10,5 0,0 V 10 L 10,5" fill="#8abeb7"/></svg>{{.Domain}}</header><main><h1>Список жанров</h1><ul id="genres-list">{{range .Genres}}<li><a href="/getm3u?genre={{.Code}}">{{.Name}}</a></li>{{end}}</ul></main></body></html>
|
|
Loading…
Reference in New Issue
Block a user