Added extra navigation and new pages

This commit is contained in:
Eduard Urbach 2017-06-18 17:16:40 +02:00
parent 1a7fb673c0
commit e99225ce10
11 changed files with 141 additions and 10 deletions

7
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

View File

@ -8,6 +8,7 @@ import (
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/layout"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/pages/admin"
"github.com/animenotifier/notify.moe/pages/airing"
"github.com/animenotifier/notify.moe/pages/anime"
"github.com/animenotifier/notify.moe/pages/awards"
@ -17,6 +18,7 @@ import (
"github.com/animenotifier/notify.moe/pages/posts"
"github.com/animenotifier/notify.moe/pages/profile"
"github.com/animenotifier/notify.moe/pages/search"
"github.com/animenotifier/notify.moe/pages/settings"
"github.com/animenotifier/notify.moe/pages/threads"
"github.com/animenotifier/notify.moe/pages/users"
"github.com/animenotifier/notify.moe/utils"
@ -48,6 +50,8 @@ func main() {
app.Ajax("/posts/:id", posts.Get)
app.Ajax("/user/:nick", profile.Get)
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
app.Ajax("/settings", settings.Get)
app.Ajax("/admin", admin.Get)
app.Ajax("/users", users.Get)
app.Ajax("/airing", airing.Get)
app.Ajax("/awards", awards.Get)

View File

@ -39,8 +39,9 @@ func Log() aero.Middleware {
err.Error(http.StatusText(ctx.StatusCode), ctx.RealIP(), ctx.StatusCode, responseTimeString, ctx.URI())
}
// Notify us about long requests
if responseTime >= 200*time.Millisecond {
// Notify us about long requests.
// However ignore requests under /auth/ because those depend on 3rd party servers.
if responseTime >= 200*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") {
err.Error("Long response time", ctx.RealIP(), ctx.StatusCode, responseTimeString, ctx.URI())
}
}

View File

@ -2,7 +2,7 @@ component Navigation(user *arn.User)
if user == nil
LoggedOutMenu
else
LoggedInMenu
LoggedInMenu(user)
component LoggedOutMenu
nav#navigation
@ -12,14 +12,21 @@ component LoggedOutMenu
NavigationButton("Users", "/users", "globe")
NavigationButton("Airing", "/airing", "rss")
component LoggedInMenu
component LoggedInMenu(user *arn.User)
nav#navigation
NavigationButton("Dash", "/", "inbox")
NavigationButton("Anime", "/anime", "television")
NavigationButton("Forum", "/forum", "comment")
NavigationButton("Users", "/users", "globe")
NavigationButton("Airing", "/airing", "rss")
NavigationButtonNoAJAX("Logout", "/logout", "sign-out")
NavigationButton("Settings", "/settings", "cog")
.extra-navigation
ExtraNavigationButton("Users", "/users", "globe")
if user.Role == "admin"
ExtraNavigationButton("Admin", "/admin", "wrench")
NavigationButtonNoAJAX("Logout", "/logout", "sign-out")
component NavigationButton(name string, target string, icon string)
a.navigation-link.ajax(href=target, aria-label=name)
@ -27,6 +34,12 @@ component NavigationButton(name string, target string, icon string)
Icon(icon)
span.navigation-text= name
component ExtraNavigationButton(name string, target string, icon string)
a.navigation-link.ajax(href=target, aria-label=name, title=name)
.navigation-button
Icon(icon)
span.navigation-text= name
component NavigationButtonNoAJAX(name string, target string, icon string)
a.navigation-link(href=target, aria-label=name)
.navigation-button

18
pages/admin/admin.go Normal file
View File

@ -0,0 +1,18 @@
package admin
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get admin page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil || user.Role != "admin" {
return ctx.Redirect("/")
}
return ctx.HTML(components.Admin(user))
}

6
pages/admin/admin.pixy Normal file
View File

@ -0,0 +1,6 @@
component Admin(user *arn.User)
h2.page-title Admin
table
tr
td Go version:
td= runtime.Version()

View File

@ -127,9 +127,6 @@ component Anime(anime *arn.Anime)
h3.anime-section-name Tracks
p Coming soon.
h3.anime-section-name Artwork
p Coming soon.
h3.anime-section-name Reviews
p Coming soon.

View File

@ -0,0 +1,18 @@
package settings
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get user settings page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil {
return ctx.Redirect("/")
}
return ctx.HTML(components.Settings(user))
}

View File

@ -0,0 +1,3 @@
component Settings(user *arn.User)
h2.page-title Settings
input(type="text", value=user.Nick)

46
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

View File

@ -42,6 +42,16 @@
.navigation-text
display none
.extra-navigation
display none
.navigation-text
display none
.navigation-button
.icon
margin-right 0
> 330px
.navigation-button
font-size 1.3em
@ -58,6 +68,11 @@
.navigation-text
display inline-block
.extra-navigation
horizontal
justify-content flex-end
flex 1
< 400px height
#navigation
@ -66,4 +81,7 @@
padding content-padding 0
#container
horizontal
horizontal
.extra-navigation
display none