Basics are implemented now

This commit is contained in:
Eduard Urbach 2016-11-02 22:47:22 +09:00
parent 4ed5d14bb5
commit 881538a500
8 changed files with 250 additions and 18 deletions

5
.gitignore vendored
View File

@ -34,4 +34,7 @@ node_modules/
debug
# pixy
❖.go
❖.go
# binaries
/notify.moe

1
anime.css Normal file
View File

@ -0,0 +1 @@
.anime-container{float:left;width:100%;padding:0;text-align:left;border-radius:3px;box-sizing:border-box}.anime-links{float:left;width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:row wrap;flex-flow:row wrap}.anime-links-category{-webkit-box-flex:1;-ms-flex:1;flex:1;-ms-flex-preferred-size:100%;flex-basis:100%}.anime-title-db{text-align:left;width:auto}.second-title-container{float:left;width:100%;text-align:left;margin-top:-.6em;margin-bottom:.6em}.second-title{font-size:.9em;font-weight:normal;color:rgba(60,60,60,0.5) !important}.anime-summary-header{display:block}.anime-summary{-webkit-box-flex:1;-ms-flex:1;flex:1;min-width:300px;max-width:100%;margin-left:0;}.anime-summary .anime-header{margin-top:0}.anime-trailer{width:100%}.genre-list{list-style-type:none;margin-left:.5em}.sources{font-size:.8em;opacity:.5}.anime-header{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:row;flex-flow:row}.anime-image{border-radius:3px;box-shadow:4px 4px 8px rgba(0,0,0,0.12);-webkit-filter:saturate(100%);filter:saturate(100%);-webkit-transition:all 290ms ease;transition:all 290ms ease;}.anime-image:hover{-webkit-filter:saturate(130%);filter:saturate(130%);box-shadow:6px 6px 12px rgba(0,0,0,0.2)}.anime-image-container{-ms-flex-negative:0;flex-shrink:0;text-align:center;margin-bottom:1rem;}.anime-image-container .anime-image{margin:0 !important;margin-right:1.5rem !important;width:225px}.info-column{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:column;flex-flow:column}.users-count{opacity:.5;font-size:.9em}.anime-frontpage h2,.anime-frontpage h3{text-align:center}.popular-anime-list{width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.popular-anime{padding:.5em;display:block}.popular-anime-image{width:100px !important;height:141px !important}.light-button-group{float:left;width:100%;margin:0;width:auto;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;font-size:.9em}.light-button{padding:.5em 1em;border-radius:3px;}.light-button:hover{color:#fff !important;background-color:#f25d1e}.entry-error{color:#f00 !important}.entry-ok{color:#008000 !important}#search{float:none}#search-results{width:100%;max-width:560px;text-align:left;margin:0 auto}.search-performance,.anime-count{opacity:.25;text-align:center !important}.search-result{float:left;width:100%;padding:.25em .5em;border-radius:3px;box-sizing:border-box;}.search-result:focus{background-color:#202020 !important;color:#e8e8e8 !important}@media only screen and (max-width:800px){.anime-header{-ms-flex-flow:row wrap;flex-flow:row wrap}.anime-title-db,.second-title-container,.anime-image-container{text-align:center;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}}

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,32 @@
component Layout(content string, css string)
html
head
title Test
title ARN 4.0 - Beta
style!= css
body
main#content
#container
#header-container
#header.header-logged-in
nav#navigation
a.navigation-link.navigation-link-left.ajax(href="/")
.navigation-button
i.fa.fa-dashboard
span.navigation-text Dash
#content-container
main#content.fade!= content
LoadingAnimation
script(src="/scripts.js")
component LoadingAnimation
#loading-animation.sk-cube-grid.fade
.sk-cube.sk-cube1
.sk-cube.sk-cube2
.sk-cube.sk-cube3
.sk-cube.sk-cube4
.sk-cube.sk-cube5
.sk-cube.sk-cube6
.sk-cube.sk-cube7
.sk-cube.sk-cube8
.sk-cube.sk-cube9

86
main.go
View File

@ -1,40 +1,104 @@
package main
import (
"bytes"
"fmt"
"io/ioutil"
"strconv"
"github.com/aerojs/aero"
"github.com/blitzprog/arn"
"github.com/valyala/fasthttp"
"github.com/animenotifier/arn"
)
func s(v interface{}) string {
return fmt.Sprintf("%v", v)
}
func main() {
app := aero.New()
cssBytes, _ := ioutil.ReadFile("layout.css")
css := string(cssBytes)
css = css
animeCSSBytes, _ := ioutil.ReadFile("anime.css")
css += string(animeCSSBytes)
scripts, _ := ioutil.ReadFile("scripts.js")
js := string(scripts)
app.Get("/", func(ctx *aero.Context) {
ctx.Respond(Stream.Dashboard())
ctx.HTML(Render.Layout(Render.Dashboard(), css))
})
app.Get("/_/", func(ctx *aero.Context) {
ctx.HTML(Render.Dashboard())
})
app.Get("/anime/:id", func(ctx *aero.Context) {
id, _ := strconv.Atoi(ctx.Params.ByName("id"))
anime, err := arn.GetAnime(id)
anime = anime
if err != nil {
ctx.Respond("Anime not found")
ctx.Text("Anime not found")
return
}
stream := fasthttp.AcquireByteBuffer()
Stream.Layout(stream, anime, css)
ctx.RespondBytes(stream.Bytes())
Stream.Release(stream)
// ctx.Respond(Render.Layout(Render.Anime(anime), css))
ctx.HTML(Render.Layout(Render.Anime(anime), css))
})
app.Get("/_/anime/:id", func(ctx *aero.Context) {
id, _ := strconv.Atoi(ctx.Params.ByName("id"))
anime, err := arn.GetAnime(id)
if err != nil {
ctx.Text("Anime not found")
return
}
ctx.HTML(Render.Anime(anime))
})
app.Get("/api/anime/:id", func(ctx *aero.Context) {
id, _ := strconv.Atoi(ctx.Params.ByName("id"))
anime, err := arn.GetAnime(id)
if err != nil {
ctx.Text("Anime not found")
return
}
ctx.JSON(anime)
})
app.Get("/api/users/:nick", func(ctx *aero.Context) {
nick := ctx.Params.ByName("nick")
user, err := arn.GetUserByNick(nick)
if err != nil {
ctx.Text("User not found")
return
}
ctx.JSON(user)
})
app.Get("/all", func(ctx *aero.Context) {
var buffer bytes.Buffer
results := make(chan *arn.Anime)
arn.Scan("Anime", results)
for anime := range results {
buffer.WriteString(anime.Title.Romaji)
buffer.WriteByte('\n')
}
ctx.Text(buffer.String())
})
app.Get("/scripts.js", func(ctx *aero.Context) {
ctx.SetHeader("Content-Type", "application/javascript")
ctx.Respond(js)
})
// layout := aero.NewTemplate("layout.pug")

View File

@ -1,3 +1,129 @@
component Anime(anime *arn.Anime)
h2= anime.Title.Romaji
p= anime.Description
section.anime-container(data-id=anime.ID)
header.anime-header
if anime.Image != ""
.anime-image-container
img.anime-image(src=anime.Image, alt=anime.Title.Romaji)
.info-column
h2.anime-title-db(title=anime.Type)= anime.Title.Romaji
//- if user && user.titleLanguage === "japanese"
//- p.second-title-container
//- span.second-title(title=anime.Title.English !== anime.Title.Romaji ? anime.Title.English : null)= anime.Title.Romaji
//- else
if anime.Title.Japanese != anime.Title.Romaji
p.second-title-container
a.second-title(href="http://jisho.org/search/" + anime.Title.Japanese, target="_blank", title="Look up reading on jisho.org", rel="nofollow")= anime.Title.Japanese
//- h3.anime-header.anime-summary-header Summary
p.anime-summary= anime.Description
if anime.YoutubeID != ""
h3.anime-header Video
.anime-trailer.video-container
iframe.video(src="https://www.youtube.com/embed/" + anime.YoutubeID + "?showinfo=0", frameborder="0", allowfullscreen="allowfullscreen")
if anime.Tracks != nil && anime.Tracks.Opening != nil
h3.anime-header Tracks
iframe(width="100%", height="150", scrolling="no", frameborder="no", src="https://w.soundcloud.com/player/?url=" + anime.Tracks.Opening.URI + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
//- if user && friendsWatching && friendsWatching.length > 0
//- include ../messages/avatar.pug
//- h3.anime-header Watching
//- .user-list
//- each watcher in friendsWatching
//- +avatar(watcher)
if len(anime.Genres) > 0
h3.anime-header Genres
.light-button-group
each genre in anime.Genres
if genre != ""
a.light-button.ajax(href="/anime/genres/" + arn.FixGenre(genre))
span= genre
if len(anime.Studios) > 0
h3.anime-header Studios
.light-button-group
each studio in anime.Studios
a.light-button(href="https://anilist.co/studio/" + s(studio.ID), target="_blank")
i.fa.fa-building.fa-fw
span= studio.Name
//- //-if crunchy
//- //- h3.anime-header Episodes
//- if canEdit
//- #staff-info
//- h3.anime-header Links
//- table
//- tbody
//- tr
//- td MyAnimeList
//- td
//- input.save-on-change(id="MyAnimeList", type="text", value=providers.MyAnimeList ? providers.MyAnimeList.providerId : ", disabled=(providers.MyAnimeList && providers.MyAnimeList.similarity === 1) ? true : false)
//- td
//- a(href="https://www.google.co.jp/search?q=site:myanimelist.net/anime+" + anime.title.romaji.replace(/ /g, "+"), target="_blank")
//- .fa.fa-search
//- td
//- tr
//- td HummingBird
//- td
//- input.save-on-change(id="HummingBird", type="text", value=providers.HummingBird ? providers.HummingBird.providerId : ", disabled=(providers.HummingBird && providers.HummingBird.similarity === 1) ? true : false)
//- td
//- a(href="https://www.google.co.jp/search?q=site:hummingbird.me/anime+" + anime.title.romaji.replace(/ /g, "+"), target="_blank")
//- .fa.fa-search
//- td
//- tr
//- td AnimePlanet
//- td
//- input.save-on-change(id="AnimePlanet", type="text", value=providers.AnimePlanet ? providers.AnimePlanet.providerId : ", disabled=(providers.AnimePlanet && providers.AnimePlanet.similarity === 1) ? true : false)
//- td
//- a(href="https://www.google.co.jp/search?q=site:anime-planet.com/anime+" + anime.title.english.replace(/ /g, "+"), target="_blank")
//- .fa.fa-search
//- td
//- - var title = providers.Nyaa ? providers.Nyaa.title : "
//- - var proposedTitle = nyaa.buildNyaaTitle(anime.title.romaji)
//- tr
//- td Nyaa
//- td
//- input.save-on-change(id="Nyaa", type="text", value=title, placeholder=proposedTitle)
//- td
//- a(href="https://www.nyaa.se/?page=search&cats=1_37&filter=0&sort=2&term=" + (title ? title.replace(/ /g, "+") : proposedTitle), target="_blank")
//- .fa.fa-search
//- td
//- if providers.Nyaa && providers.Nyaa.episodes !== undefined
//- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps"
h3.anime-header Links
.light-button-group
if anime.Links != nil
each link in anime.Links
a.light-button(href=link.URL, target="_blank")= link.Title
if anime.CreatedBy == ""
a.light-button(href="https://anilist.co/anime/" + s(anime.ID), target="_blank") AniList
//- if providers.HummingBird
//- a.light-button(href="https://hummingbird.me/anime/" + providers.HummingBird.providerId, target="_blank") HummingBird
//- if providers.MyAnimeList
//- a.light-button(href="http://myanimelist.net/anime/" + providers.MyAnimeList.providerId, target="_blank") MyAnimeList
//- if providers.AnimePlanet
//- a.light-button(href="http://www.anime-planet.com/anime/" + providers.AnimePlanet.providerId, target="_blank") AnimePlanet
.sources
p Powered by Anilist.
//- if descriptionSource
//- span= " Summary by " + summarySource + "."
//- //-
//- h3.anime-header Synonyms
//- if anime.title.synonyms
//- ul.anime-synonyms
//- li.anime-japanese-title= anime.title.japanese
//- each synonym in anime.title.synonyms
//- li= synonym

View File

@ -1,2 +1,14 @@
component Dashboard
h1 notify.moe
section
header
h1 ARN 4.0
p The next version of notify.moe is currently being built here!
hr
p Some test links:
ul
li
a.ajax(href="/anime/21499") Sousei no Onmyouji
li
a.ajax(href="/anime/1000001") RWBY
li
a(href="/api/anime/1000001") RWBY (JSON API)

1
scripts.js Normal file

File diff suppressed because one or more lines are too long