Improved annimations

This commit is contained in:
Adphi 2018-11-04 19:00:15 +01:00
parent 6d1a924d53
commit 6099b72570
6 changed files with 71 additions and 23 deletions

View File

@ -26,6 +26,7 @@ func main() {
r := mux.NewRouter() r := mux.NewRouter()
r.HandleFunc("/", h.Home).Methods(http.MethodGet) r.HandleFunc("/", h.Home).Methods(http.MethodGet)
r.HandleFunc("/movies/{search}", h.Search).Methods(http.MethodGet) r.HandleFunc("/movies/{search}", h.Search).Methods(http.MethodGet)
r.HandleFunc("/movies/category/{category}", h.Category).Methods(http.MethodGet)
r.HandleFunc("/movie/{id}", h.Movie).Methods(http.MethodGet) r.HandleFunc("/movie/{id}", h.Movie).Methods(http.MethodGet)
r.HandleFunc("/torrent/{id}", h.Torrents).Methods(http.MethodGet) r.HandleFunc("/torrent/{id}", h.Torrents).Methods(http.MethodGet)
r.HandleFunc("/watch/{movie}", h.Serve).Methods(http.MethodGet) r.HandleFunc("/watch/{movie}", h.Serve).Methods(http.MethodGet)

View File

@ -138,22 +138,58 @@ func (h *Handler) Movie(w http.ResponseWriter, r *http.Request) {
t.Execute(w, md) t.Execute(w, md)
} }
func (h *Handler) Category(w http.ResponseWriter, r *http.Request) {
category := mux.Vars(r)["category"]
res, err := h.yts.List(&ytsclient.ListParams{Genre: ytsclient.Genre(category), Limit: 50, Page: 1})
if err != nil {
sendError(w, err)
}
mm := map[string]Movie{}
for _, m := range res {
mm[m.Title] = Movie{
Link: fmt.Sprintf("/movie/%d", m.ID),
Cover: m.MediumCoverImage,
}
}
d := struct {
Category string
Movies map[string]Movie
}{
Category: category,
Movies: mm,
}
t := templates.ListTemplate()
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(200)
t.Execute(w, d)
}
func (h *Handler) Search(writer http.ResponseWriter, request *http.Request) { func (h *Handler) Search(writer http.ResponseWriter, request *http.Request) {
vars := mux.Vars(request) vars := mux.Vars(request)
s := vars["search"] s := vars["search"]
ms, err := h.yts.Search(s, &ytsclient.ListParams{Quality: ytsclient.Quality1080p}) res, err := h.yts.Search(s, &ytsclient.ListParams{Quality: ytsclient.Quality1080p})
if err != nil { if err != nil {
sendError(writer, err) sendError(writer, err)
return return
} }
html := "<ul>" mm := map[string]Movie{}
for _, m := range ms { for _, m := range res {
html += fmt.Sprintf("<li><a href=\"/movie/%d\">%s</a></li>", m.ID, m.Title) mm[m.Title] = Movie{
Link: fmt.Sprintf("/movie/%d", m.ID),
Cover: m.MediumCoverImage,
}
} }
html += "</ul>" d := struct {
Category string
Movies map[string]Movie
}{
Category: fmt.Sprintf("Search: %s", s),
Movies: mm,
}
t := templates.ListTemplate()
writer.Header().Set("Content-Type", "text/html; charset=utf-8") writer.Header().Set("Content-Type", "text/html; charset=utf-8")
writer.WriteHeader(200) writer.WriteHeader(200)
fmt.Fprint(writer, html) t.Execute(writer, d)
} }
func (h *Handler) Torrents(writer http.ResponseWriter, request *http.Request) { func (h *Handler) Torrents(writer http.ResponseWriter, request *http.Request) {

View File

@ -122,20 +122,21 @@
width: 130px; width: 130px;
} }
.row__inner:hover { .row__inner:hover {
-webkit-transform: translate3d(-10.724999999999994px, 0, 0); /*-webkit-transform: translate3d(-10.724999999999994px, 0, 0);*/
transform: translate3d(-10.724999999999994px, 0, 0); /*transform: translate3d(-10.724999999999994px, 0, 0);*/
} }
.row__inner:hover .tile { .row__inner:hover .tile {
opacity: 0.6; opacity: 0.6;
} }
.row__inner:hover .tile:hover { .row__inner:hover .tile:hover {
-webkit-transform: scale(1.15); -webkit-transform: scale(1.15) translate3d(-11px, 0, 0);
transform: scale(1.15); transform: scale(1.15) translate3d(-11px, 0, 0);
opacity: 1; opacity: 1;
z-index: 2;
} }
.tile:hover ~ .tile { .tile:hover ~ .tile {
-webkit-transform: translate3d(21.44999999999999px, 0, 0); /*-webkit-transform: translate3d(21.44999999999999px, 0, 0);*/
transform: translate3d(21.44999999999999px, 0, 0); /*transform: translate3d(21.44999999999999px, 0, 0);*/
} }
.category-title { .category-title {
margin: 0; margin: 0;

View File

@ -57,7 +57,6 @@
display: inline-block; display: inline-block;
width: 143px; width: 143px;
height: 201px; height: 201px;
margin-right: 10px;
font-size: 20px; font-size: 20px;
cursor: pointer; cursor: pointer;
transition: 450ms all; transition: 450ms all;
@ -126,22 +125,22 @@
width: 130px; width: 130px;
} }
.row__inner:hover { .row__inner:hover {
-webkit-transform: translate3d(-10.724999999999994px, 0, 0); /*-webkit-transform: translate3d(-10.724999999999994px, 0, 0);*/
transform: translate3d(-10.724999999999994px, 0, 0); /*transform: translate3d(-10.724999999999994px, 0, 0);*/
} }
.row__inner:hover .tile { .row__inner:hover .tile {
opacity: 0.6; opacity: 0.6;
z-index: 1; z-index: 1;
} }
.row__inner:hover .tile:hover { .row__inner:hover .tile:hover {
-webkit-transform: scale(1.15); -webkit-transform: scale(1.15) translate3d(-11px, 0, 0);
transform: scale(1.15); transform: scale(1.15) translate3d(-11px, 0, 0);
opacity: 1; opacity: 1;
z-index: 2; z-index: 2;
} }
.tile:hover ~ .tile { .tile:hover ~ .tile {
-webkit-transform: translate3d(21.44999999999999px, 0, 0); /*-webkit-transform: translate3d(-21.44999999999999px, 0, 0);*/
transform: translate3d(21.44999999999999px, 0, 0); /*transform: translate3d(-21.44999999999999px, 0, 0);*/
} }
.category-title { .category-title {
margin: 0; margin: 0;

View File

@ -11,7 +11,7 @@
height: 70px; height: 70px;
position: fixed; position: fixed;
top: 0; top: 0;
z-index: 2; z-index: 10;
} }
a:link, a:link,

View File

@ -16,7 +16,20 @@ func HomeTemplate() *template.Template {
logrus.Fatal(err) logrus.Fatal(err)
} }
t, err = t.Parse(box.String("nav.html")) t, err = t.Parse(box.String("nav.html"))
//t, err = t.ParseFiles("./static/index.html", "./static/nav.html") if err != nil {
logrus.Fatal(err)
}
return t
}
func ListTemplate() *template.Template {
t := template.New("list.html")
var err error
t, err = t.Parse(box.String("list.html"))
if err != nil {
logrus.Fatal(err)
}
t, err = t.Parse(box.String("nav.html"))
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
@ -31,7 +44,6 @@ func MovieTemplate() *template.Template {
logrus.Fatal(err) logrus.Fatal(err)
} }
t, err = t.Parse(box.String("nav.html")) t, err = t.Parse(box.String("nav.html"))
//t, err = t.ParseFiles("./static/movie.html", "./static/nav.html")
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
@ -42,7 +54,6 @@ func WatchTemplate() *template.Template {
t := template.New(box.String("watch.html")) t := template.New(box.String("watch.html"))
var err error var err error
t, err = t.Parse(box.String("watch.html")) t, err = t.Parse(box.String("watch.html"))
//t, err = t.ParseFiles("./static/watch.html")
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }