From 6099b725706db1b2c16704fe1e47ae4a3d2b2f07 Mon Sep 17 00:00:00 2001 From: Adphi Date: Sun, 4 Nov 2018 19:00:15 +0100 Subject: [PATCH] Improved annimations --- cmd/main.go | 1 + handler/handler.go | 48 ++++++++++++++++++++++++++++++++++++------ static/index.html | 13 ++++++------ static/list.html | 13 ++++++------ static/nav.html | 2 +- templates/templates.go | 17 ++++++++++++--- 6 files changed, 71 insertions(+), 23 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 9d0b0f3..4c61330 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -26,6 +26,7 @@ func main() { r := mux.NewRouter() r.HandleFunc("/", h.Home).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("/torrent/{id}", h.Torrents).Methods(http.MethodGet) r.HandleFunc("/watch/{movie}", h.Serve).Methods(http.MethodGet) diff --git a/handler/handler.go b/handler/handler.go index eae5e9f..5546c0b 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -138,22 +138,58 @@ func (h *Handler) Movie(w http.ResponseWriter, r *http.Request) { 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) { vars := mux.Vars(request) 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 { sendError(writer, err) return } - html := "" + 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.WriteHeader(200) - fmt.Fprint(writer, html) + t.Execute(writer, d) } func (h *Handler) Torrents(writer http.ResponseWriter, request *http.Request) { diff --git a/static/index.html b/static/index.html index 82e09f2..819421f 100644 --- a/static/index.html +++ b/static/index.html @@ -122,20 +122,21 @@ width: 130px; } .row__inner:hover { - -webkit-transform: translate3d(-10.724999999999994px, 0, 0); - transform: translate3d(-10.724999999999994px, 0, 0); + /*-webkit-transform: translate3d(-10.724999999999994px, 0, 0);*/ + /*transform: translate3d(-10.724999999999994px, 0, 0);*/ } .row__inner:hover .tile { opacity: 0.6; } .row__inner:hover .tile:hover { - -webkit-transform: scale(1.15); - transform: scale(1.15); + -webkit-transform: scale(1.15) translate3d(-11px, 0, 0); + transform: scale(1.15) translate3d(-11px, 0, 0); opacity: 1; + z-index: 2; } .tile:hover ~ .tile { - -webkit-transform: translate3d(21.44999999999999px, 0, 0); - transform: translate3d(21.44999999999999px, 0, 0); + /*-webkit-transform: translate3d(21.44999999999999px, 0, 0);*/ + /*transform: translate3d(21.44999999999999px, 0, 0);*/ } .category-title { margin: 0; diff --git a/static/list.html b/static/list.html index 6a0a77d..59071b1 100644 --- a/static/list.html +++ b/static/list.html @@ -57,7 +57,6 @@ display: inline-block; width: 143px; height: 201px; - margin-right: 10px; font-size: 20px; cursor: pointer; transition: 450ms all; @@ -126,22 +125,22 @@ width: 130px; } .row__inner:hover { - -webkit-transform: translate3d(-10.724999999999994px, 0, 0); - transform: translate3d(-10.724999999999994px, 0, 0); + /*-webkit-transform: translate3d(-10.724999999999994px, 0, 0);*/ + /*transform: translate3d(-10.724999999999994px, 0, 0);*/ } .row__inner:hover .tile { opacity: 0.6; z-index: 1; } .row__inner:hover .tile:hover { - -webkit-transform: scale(1.15); - transform: scale(1.15); + -webkit-transform: scale(1.15) translate3d(-11px, 0, 0); + transform: scale(1.15) translate3d(-11px, 0, 0); opacity: 1; z-index: 2; } .tile:hover ~ .tile { - -webkit-transform: translate3d(21.44999999999999px, 0, 0); - transform: translate3d(21.44999999999999px, 0, 0); + /*-webkit-transform: translate3d(-21.44999999999999px, 0, 0);*/ + /*transform: translate3d(-21.44999999999999px, 0, 0);*/ } .category-title { margin: 0; diff --git a/static/nav.html b/static/nav.html index cfb0181..0bf41d6 100644 --- a/static/nav.html +++ b/static/nav.html @@ -11,7 +11,7 @@ height: 70px; position: fixed; top: 0; - z-index: 2; + z-index: 10; } a:link, diff --git a/templates/templates.go b/templates/templates.go index 774751a..5aa5e95 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -16,7 +16,20 @@ func HomeTemplate() *template.Template { logrus.Fatal(err) } 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 { logrus.Fatal(err) } @@ -31,7 +44,6 @@ func MovieTemplate() *template.Template { logrus.Fatal(err) } t, err = t.Parse(box.String("nav.html")) - //t, err = t.ParseFiles("./static/movie.html", "./static/nav.html") if err != nil { logrus.Fatal(err) } @@ -42,7 +54,6 @@ func WatchTemplate() *template.Template { t := template.New(box.String("watch.html")) var err error t, err = t.Parse(box.String("watch.html")) - //t, err = t.ParseFiles("./static/watch.html") if err != nil { logrus.Fatal(err) }