Slowly moving away from stylus to scarlet

This commit is contained in:
Eduard Urbach 2016-11-27 23:28:22 +09:00
parent 105cf0d128
commit adb6ca1e0c
31 changed files with 92 additions and 28 deletions

View File

@ -7,6 +7,7 @@
"styles": [
"reset",
"font-awesome",
"config",
"base",
"elements",
"layout",

View File

@ -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,
})

18
jobs/main.go Normal file
View File

@ -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)
}
}

23
main.go
View File

@ -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()
}

View File

@ -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 {

View File

@ -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))

2
pages/test.pixy Normal file
View File

@ -0,0 +1,2 @@
component Test(msg string)
h1= msg

1
styles/config.scarlet Normal file
View File

@ -0,0 +1 @@
fade-speed = 290ms

7
styles/fade.scarlet Normal file
View File

@ -0,0 +1,7 @@
.fade
opacity 1
transition opacity fade-speed ease
will-change opacity
.fade-out
opacity 0

46
styles/reset.scarlet Normal file
View File

@ -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