From adb6ca1e0c3680accf89dbc7dfbdccb39d00043f Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 27 Nov 2016 23:28:22 +0900 Subject: [PATCH] Slowly moving away from stylus to scarlet --- config.json | 1 + jobs/airing-anime.go | 17 ++++------- jobs/main.go | 18 ++++++++++++ main.go | 23 +++++++-------- pages/airing/airing.go | 3 +- pages/genre/genre.go | 2 +- pages/test.pixy | 2 ++ styles/config.scarlet | 1 + styles/fade.scarlet | 7 +++++ styles/{ => old}/animelist.styl | 0 styles/{ => old}/base.styl | 0 styles/{ => old}/colors.styl | 0 styles/{ => old}/config.styl | 0 styles/{ => old}/elements.styl | 0 styles/{ => old}/embedded.styl | 0 styles/{ => old}/fade.styl | 0 styles/{ => old}/font-awesome.styl | 0 styles/{ => old}/forms.styl | 0 styles/{ => old}/forum.styl | 0 styles/{ => old}/grid.styl | 0 styles/{ => old}/headers.styl | 0 styles/{ => old}/layout.styl | 0 styles/{ => old}/loading.styl | 0 styles/{ => old}/mobile.styl | 0 styles/{ => old}/navigation.styl | 0 styles/{ => old}/reset.styl | 0 styles/{ => old}/settings.styl | 0 styles/{ => old}/staff.styl | 0 styles/{ => old}/user.styl | 0 styles/{ => old}/video.styl | 0 styles/reset.scarlet | 46 ++++++++++++++++++++++++++++++ 31 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 jobs/main.go create mode 100644 pages/test.pixy create mode 100644 styles/config.scarlet create mode 100644 styles/fade.scarlet rename styles/{ => old}/animelist.styl (100%) rename styles/{ => old}/base.styl (100%) rename styles/{ => old}/colors.styl (100%) rename styles/{ => old}/config.styl (100%) rename styles/{ => old}/elements.styl (100%) rename styles/{ => old}/embedded.styl (100%) rename styles/{ => old}/fade.styl (100%) rename styles/{ => old}/font-awesome.styl (100%) rename styles/{ => old}/forms.styl (100%) rename styles/{ => old}/forum.styl (100%) rename styles/{ => old}/grid.styl (100%) rename styles/{ => old}/headers.styl (100%) rename styles/{ => old}/layout.styl (100%) rename styles/{ => old}/loading.styl (100%) rename styles/{ => old}/mobile.styl (100%) rename styles/{ => old}/navigation.styl (100%) rename styles/{ => old}/reset.styl (100%) rename styles/{ => old}/settings.styl (100%) rename styles/{ => old}/staff.styl (100%) rename styles/{ => old}/user.styl (100%) rename styles/{ => old}/video.styl (100%) create mode 100644 styles/reset.scarlet diff --git a/config.json b/config.json index 1f7a71f5..12a690cf 100644 --- a/config.json +++ b/config.json @@ -7,6 +7,7 @@ "styles": [ "reset", "font-awesome", + "config", "base", "elements", "layout", diff --git a/jobs/airing-anime.go b/jobs/airing-anime.go index 23017af0..96c96c89 100644 --- a/jobs/airing-anime.go +++ b/jobs/airing-anime.go @@ -1,24 +1,17 @@ -package jobs +package main import ( + "fmt" "sort" "github.com/animenotifier/arn" "github.com/fatih/color" ) -// AiringAnimeCache ... -type AiringAnimeCache struct { - Anime []*arn.Anime `json:"anime"` -} - -// AiringAnimeCacheSmall ... -type AiringAnimeCacheSmall struct { - Anime []*arn.AnimeSmall `json:"anime"` -} - // AiringAnime ... func AiringAnime() { + fmt.Println("Running background job: Airing Anime") + animeList, err := arn.GetAiringAnime() if err != nil { @@ -41,7 +34,7 @@ func AiringAnime() { }) } - saveErr := arn.SetObject("Cache", "airingAnime", &AiringAnimeCacheSmall{ + saveErr := arn.SetObject("Cache", "airingAnime", &arn.AiringAnimeCacheSmall{ Anime: animeListSmall, }) diff --git a/jobs/main.go b/jobs/main.go new file mode 100644 index 00000000..d535a4e8 --- /dev/null +++ b/jobs/main.go @@ -0,0 +1,18 @@ +package main + +import "time" + +func main() { + // Background jobs + go func() { + for { + AiringAnime() + time.Sleep(time.Duration(2) * time.Second) + } + }() + + // Main loop + for { + time.Sleep(time.Duration(10) * time.Second) + } +} diff --git a/main.go b/main.go index 622634fd..510f1177 100644 --- a/main.go +++ b/main.go @@ -5,9 +5,7 @@ import ( "runtime" "github.com/aerogo/aero" - "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" - "github.com/animenotifier/notify.moe/jobs" "github.com/animenotifier/notify.moe/pages/airing" "github.com/animenotifier/notify.moe/pages/anime" "github.com/animenotifier/notify.moe/pages/dashboard" @@ -24,7 +22,7 @@ import ( var app = aero.New() func main() { - app.SetStyle(components.BundledCSS) + app.SetStyle(components.CSS()) // app.Sessions = sessions.New(sessions.Config{ // Cookie: "sid", @@ -34,16 +32,11 @@ func main() { // DisableSubdomainPersistence: false, // }) - app.Sessions.Store = aero.NewMemoryStore() - - user, _ := arn.GetUserByNick("Akyoto") - user.CoverImage.URL = "https://www.pixelstalk.net/wp-content/uploads/2016/10/Hanyijie-sky-scenery-ship-anime-art-1920x1080.jpg" - user.CoverImage.Position.X = "50%" - user.CoverImage.Position.Y = "0%" - user.Save() - - // Background jobs - go jobs.AiringAnime() + // user, _ := arn.GetUserByNick("Akyoto") + // user.CoverImage.URL = "https://www.pixelstalk.net/wp-content/uploads/2016/10/Hanyijie-sky-scenery-ship-anime-art-1920x1080.jpg" + // user.CoverImage.Position.X = "50%" + // user.CoverImage.Position.Y = "0%" + // user.Save() scripts, _ := ioutil.ReadFile("temp/scripts.js") js := string(scripts) @@ -78,5 +71,9 @@ func main() { app.Ajax("/user/:nick", profile.Get) app.Ajax("/airing", airing.Get) + app.Ajax("/test", func(ctx *aero.Context) string { + return ctx.HTML(components.Test("Hello World")) + }) + app.Run() } diff --git a/pages/airing/airing.go b/pages/airing/airing.go index d7e0b6f3..190cb41e 100644 --- a/pages/airing/airing.go +++ b/pages/airing/airing.go @@ -4,12 +4,11 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" - "github.com/animenotifier/notify.moe/jobs" ) // Get ... func Get(ctx *aero.Context) string { - airingAnimeCache := new(jobs.AiringAnimeCache) + airingAnimeCache := new(arn.AiringAnimeCache) err := arn.GetObject("Cache", "airingAnime", airingAnimeCache) if err != nil { diff --git a/pages/genre/genre.go b/pages/genre/genre.go index 688ee084..db2a503d 100644 --- a/pages/genre/genre.go +++ b/pages/genre/genre.go @@ -12,7 +12,7 @@ func Get(ctx *aero.Context) string { genre, err := arn.GetGenre(genreName) if err != nil { - return err.Error() + return ctx.Error(404, "Genre not found", err) } return ctx.HTML(components.Genre(genre)) diff --git a/pages/test.pixy b/pages/test.pixy new file mode 100644 index 00000000..eff3ba4a --- /dev/null +++ b/pages/test.pixy @@ -0,0 +1,2 @@ +component Test(msg string) + h1= msg \ No newline at end of file diff --git a/styles/config.scarlet b/styles/config.scarlet new file mode 100644 index 00000000..90ad0f16 --- /dev/null +++ b/styles/config.scarlet @@ -0,0 +1 @@ +fade-speed = 290ms \ No newline at end of file diff --git a/styles/fade.scarlet b/styles/fade.scarlet new file mode 100644 index 00000000..a3c62d77 --- /dev/null +++ b/styles/fade.scarlet @@ -0,0 +1,7 @@ +.fade + opacity 1 + transition opacity fade-speed ease + will-change opacity + +.fade-out + opacity 0 \ No newline at end of file diff --git a/styles/animelist.styl b/styles/old/animelist.styl similarity index 100% rename from styles/animelist.styl rename to styles/old/animelist.styl diff --git a/styles/base.styl b/styles/old/base.styl similarity index 100% rename from styles/base.styl rename to styles/old/base.styl diff --git a/styles/colors.styl b/styles/old/colors.styl similarity index 100% rename from styles/colors.styl rename to styles/old/colors.styl diff --git a/styles/config.styl b/styles/old/config.styl similarity index 100% rename from styles/config.styl rename to styles/old/config.styl diff --git a/styles/elements.styl b/styles/old/elements.styl similarity index 100% rename from styles/elements.styl rename to styles/old/elements.styl diff --git a/styles/embedded.styl b/styles/old/embedded.styl similarity index 100% rename from styles/embedded.styl rename to styles/old/embedded.styl diff --git a/styles/fade.styl b/styles/old/fade.styl similarity index 100% rename from styles/fade.styl rename to styles/old/fade.styl diff --git a/styles/font-awesome.styl b/styles/old/font-awesome.styl similarity index 100% rename from styles/font-awesome.styl rename to styles/old/font-awesome.styl diff --git a/styles/forms.styl b/styles/old/forms.styl similarity index 100% rename from styles/forms.styl rename to styles/old/forms.styl diff --git a/styles/forum.styl b/styles/old/forum.styl similarity index 100% rename from styles/forum.styl rename to styles/old/forum.styl diff --git a/styles/grid.styl b/styles/old/grid.styl similarity index 100% rename from styles/grid.styl rename to styles/old/grid.styl diff --git a/styles/headers.styl b/styles/old/headers.styl similarity index 100% rename from styles/headers.styl rename to styles/old/headers.styl diff --git a/styles/layout.styl b/styles/old/layout.styl similarity index 100% rename from styles/layout.styl rename to styles/old/layout.styl diff --git a/styles/loading.styl b/styles/old/loading.styl similarity index 100% rename from styles/loading.styl rename to styles/old/loading.styl diff --git a/styles/mobile.styl b/styles/old/mobile.styl similarity index 100% rename from styles/mobile.styl rename to styles/old/mobile.styl diff --git a/styles/navigation.styl b/styles/old/navigation.styl similarity index 100% rename from styles/navigation.styl rename to styles/old/navigation.styl diff --git a/styles/reset.styl b/styles/old/reset.styl similarity index 100% rename from styles/reset.styl rename to styles/old/reset.styl diff --git a/styles/settings.styl b/styles/old/settings.styl similarity index 100% rename from styles/settings.styl rename to styles/old/settings.styl diff --git a/styles/staff.styl b/styles/old/staff.styl similarity index 100% rename from styles/staff.styl rename to styles/old/staff.styl diff --git a/styles/user.styl b/styles/old/user.styl similarity index 100% rename from styles/user.styl rename to styles/old/user.styl diff --git a/styles/video.styl b/styles/old/video.styl similarity index 100% rename from styles/video.styl rename to styles/old/video.styl diff --git a/styles/reset.scarlet b/styles/reset.scarlet new file mode 100644 index 00000000..a93e2791 --- /dev/null +++ b/styles/reset.scarlet @@ -0,0 +1,46 @@ +html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video, main + outline 0 + border 0 + font-size 100% + font inherit + vertical-align baseline + background transparent + +html + box-sizing border-box + +textarea + resize vertical + +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section + display block + +body + line-height 1 + -webkit-font-smoothing antialiased + -moz-osx-font-smoothing grayscale + +ol, ul + list-style none + +blockquote, q + quotes none + +blockquote:before, blockquote:after, q:before, q:after + content '' + content none + +table + border-collapse collapse + border-spacing 0 + +audio, canvas, img, video, input, select + vertical-align middle + +:focus + outline 0 + +* + margin 0 + padding 0 + box-sizing inherit \ No newline at end of file