Implemented forum overview
This commit is contained in:
parent
e23f843450
commit
b5be7e9cef
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,6 +29,7 @@ _testmain.go
|
|||||||
# external packages folder
|
# external packages folder
|
||||||
vendor/
|
vendor/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
tmp/
|
||||||
|
|
||||||
# debugger
|
# debugger
|
||||||
debug
|
debug
|
||||||
|
15
api.go
15
api.go
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
@ -11,7 +10,6 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
app.Get("/all/anime", func(ctx *aero.Context) string {
|
app.Get("/all/anime", func(ctx *aero.Context) string {
|
||||||
start := time.Now()
|
|
||||||
var titles []string
|
var titles []string
|
||||||
|
|
||||||
results := make(chan *arn.Anime)
|
results := make(chan *arn.Anime)
|
||||||
@ -22,7 +20,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
sort.Strings(titles)
|
sort.Strings(titles)
|
||||||
|
|
||||||
return ctx.Text(s(len(titles)) + " anime fetched in " + s(time.Since(start)) + "\n\n" + strings.Join(titles, "\n"))
|
return ctx.Text(toString(len(titles)) + "\n\n" + strings.Join(titles, "\n"))
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/api/anime/:id", func(ctx *aero.Context) string {
|
app.Get("/api/anime/:id", func(ctx *aero.Context) string {
|
||||||
@ -46,4 +44,15 @@ func init() {
|
|||||||
|
|
||||||
return ctx.JSON(user)
|
return ctx.JSON(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.Get("/api/threads/:id", func(ctx *aero.Context) string {
|
||||||
|
id := ctx.Get("id")
|
||||||
|
thread, err := arn.GetThread(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Text("Thread not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.JSON(thread)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// Converts anything into a string
|
// Converts anything into a string
|
||||||
func s(v interface{}) string {
|
func toString(v interface{}) string {
|
||||||
return fmt.Sprint(v)
|
return fmt.Sprint(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,14 @@ component Content(content string)
|
|||||||
|
|
||||||
component Navigation
|
component Navigation
|
||||||
nav#navigation
|
nav#navigation
|
||||||
a.navigation-link.navigation-link-left.ajax(href="/")
|
NavigationButton("Dash", "/", "dashboard")
|
||||||
|
NavigationButton("Forum", "/forum", "comment")
|
||||||
|
|
||||||
|
component NavigationButton(name string, target string, icon string)
|
||||||
|
a.navigation-link.navigation-link-left.ajax(href=target)
|
||||||
.navigation-button
|
.navigation-button
|
||||||
i.fa.fa-dashboard
|
i(class="fa fa-" + icon)
|
||||||
span.navigation-text Dash
|
span.navigation-text= name
|
||||||
|
|
||||||
component LoadingAnimation
|
component LoadingAnimation
|
||||||
#loading-animation.sk-cube-grid.fade
|
#loading-animation.sk-cube-grid.fade
|
12
mixins/Avatar.pixy
Normal file
12
mixins/Avatar.pixy
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
component Avatar(user *arn.User)
|
||||||
|
a.user.ajax(href="/+" + user.Nick, title=user.Nick)
|
||||||
|
if user.Avatar != ""
|
||||||
|
if strings.Contains(user.Avatar, "gravatar.com")
|
||||||
|
img.user-image(src=user.Avatar + "?s=100&r=x&d=mm", alt=user.Nick)
|
||||||
|
else
|
||||||
|
img.user-image(src=user.Avatar, alt=user.Nick)
|
||||||
|
else
|
||||||
|
svg.user-image(width="50", height="50")
|
||||||
|
circle.head(cx="25", cy="19", r="10", fill="rgb(32, 32, 32)")
|
||||||
|
circle.body(cx="25", cy="50", r="20")
|
||||||
|
//- text(x="25", y="44", text-anchor="middle") TODO
|
@ -49,7 +49,7 @@ component Anime(anime *arn.Anime)
|
|||||||
h3.anime-header Studios
|
h3.anime-header Studios
|
||||||
.light-button-group
|
.light-button-group
|
||||||
each studio in anime.Studios
|
each studio in anime.Studios
|
||||||
a.light-button(href="https://anilist.co/studio/" + s(studio.ID), target="_blank")
|
a.light-button(href="https://anilist.co/studio/" + toString(studio.ID), target="_blank")
|
||||||
i.fa.fa-building.fa-fw
|
i.fa.fa-building.fa-fw
|
||||||
span= studio.Name
|
span= studio.Name
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ component Anime(anime *arn.Anime)
|
|||||||
a.light-button(href=link.URL, target="_blank")= link.Title
|
a.light-button(href=link.URL, target="_blank")= link.Title
|
||||||
|
|
||||||
if anime.CreatedBy == ""
|
if anime.CreatedBy == ""
|
||||||
a.light-button(href="https://anilist.co/anime/" + s(anime.ID), target="_blank") AniList
|
a.light-button(href="https://anilist.co/anime/" + toString(anime.ID), target="_blank") AniList
|
||||||
|
|
||||||
//- if providers.HummingBird
|
//- if providers.HummingBird
|
||||||
//- a.light-button(href="https://hummingbird.me/anime/" + providers.HummingBird.providerId, target="_blank") HummingBird
|
//- a.light-button(href="https://hummingbird.me/anime/" + providers.HummingBird.providerId, target="_blank") HummingBird
|
35
pages/forum/forum.pixy
Normal file
35
pages/forum/forum.pixy
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
component Forum(threads []*arn.Thread)
|
||||||
|
h2 Forum
|
||||||
|
ForumHeader
|
||||||
|
each thread in threads
|
||||||
|
ThreadLink(thread)
|
||||||
|
|
||||||
|
component ForumHeader
|
||||||
|
.forum-tags
|
||||||
|
a.ajax(href="/forum") All
|
||||||
|
span |
|
||||||
|
a.ajax(href="/forum/general") General
|
||||||
|
span |
|
||||||
|
a.ajax(href="/forum/news") News
|
||||||
|
span |
|
||||||
|
a.ajax(href="/forum/anime") Anime
|
||||||
|
span |
|
||||||
|
a.ajax(href="/forum/update") Updates
|
||||||
|
span |
|
||||||
|
a.ajax(href="/forum/suggestion") Suggestions
|
||||||
|
span |
|
||||||
|
a.ajax(href="/forum/bug") Bugs
|
||||||
|
|
||||||
|
component ThreadLink(thread *arn.Thread)
|
||||||
|
.thread(data-stick=toString(thread.Sticky))
|
||||||
|
.post-author.thread-author
|
||||||
|
Avatar(thread.Author)
|
||||||
|
.thread-content-container
|
||||||
|
.post-content.thread-content
|
||||||
|
if thread.Sticky
|
||||||
|
i.fa.fa-thumb-tack.fa-fw.thread-icon
|
||||||
|
a.thread-title.ajax(href="/threads/" + thread.ID)= thread.Title
|
||||||
|
//- .thread-icons
|
||||||
|
//- each icon in thread.Icons
|
||||||
|
//- i(class='fa fa-' + icon + ' fa-fw thread-icon')
|
||||||
|
//- .thread-reply-count= 25
|
37
pages/forum/forum.styl
Normal file
37
pages/forum/forum.styl
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
.forum-tags
|
||||||
|
text-align left
|
||||||
|
margin-bottom 1.5rem
|
||||||
|
|
||||||
|
.thread
|
||||||
|
display flex
|
||||||
|
flex-flow row
|
||||||
|
width 100%
|
||||||
|
|
||||||
|
.thread-icons
|
||||||
|
.thread-reply-count
|
||||||
|
flex 1
|
||||||
|
text-align right
|
||||||
|
opacity 0.5
|
||||||
|
|
||||||
|
.thread-reply-count
|
||||||
|
&:after
|
||||||
|
content " replies"
|
||||||
|
|
||||||
|
.thread-content-container
|
||||||
|
display flex
|
||||||
|
align-items center
|
||||||
|
width 100%
|
||||||
|
|
||||||
|
.thread-content
|
||||||
|
display flex
|
||||||
|
align-items center
|
||||||
|
justify-content flex-start
|
||||||
|
text-align left
|
||||||
|
min-height 80%
|
||||||
|
a
|
||||||
|
color rgb(32, 32, 32) !important
|
||||||
|
&:hover
|
||||||
|
color linkHoverColor !important
|
||||||
|
|
||||||
|
.thread-icon
|
||||||
|
font-size 0.9em
|
@ -11,5 +11,5 @@ component AnimeInGenre(genre string, animeList []*arn.Anime)
|
|||||||
h2.genre-header= arn.Capitalize(genre)
|
h2.genre-header= arn.Capitalize(genre)
|
||||||
.genre-anime-list
|
.genre-anime-list
|
||||||
each anime in animeList
|
each anime in animeList
|
||||||
a.genre-anime-link.ajax(href="/anime/" + s(anime.ID))
|
a.genre-anime-link.ajax(href="/anime/" + toString(anime.ID))
|
||||||
img.anime-image.genre-anime-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + s(anime.Watching) + ")")
|
img.anime-image.genre-anime-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching) + ")")
|
20
router.go
20
router.go
@ -38,4 +38,24 @@ func init() {
|
|||||||
|
|
||||||
return ctx.HTML(components.AnimeInGenre(genreInfo.Genre, genreInfo.AnimeList))
|
return ctx.HTML(components.AnimeInGenre(genreInfo.Genre, genreInfo.AnimeList))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const threadsPerPage = 12
|
||||||
|
|
||||||
|
forumHandler := func(ctx *aero.Context) string {
|
||||||
|
tag := ctx.Get("tag")
|
||||||
|
threads, _ := arn.GetThreadsByTag(tag)
|
||||||
|
|
||||||
|
if len(threads) > threadsPerPage {
|
||||||
|
threads = threads[:threadsPerPage]
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, thread := range threads {
|
||||||
|
thread.Author, _ = arn.GetUser(thread.AuthorID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.Forum(threads))
|
||||||
|
}
|
||||||
|
|
||||||
|
app.Ajax("/forum", forumHandler)
|
||||||
|
app.Ajax("/forum/:tag", forumHandler)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,6 @@
|
|||||||
& > div
|
& > div
|
||||||
float left
|
float left
|
||||||
width 100%
|
width 100%
|
||||||
text-align center
|
|
||||||
|
|
||||||
.header-logged-in
|
.header-logged-in
|
||||||
background-image none !important
|
background-image none !important
|
||||||
|
Loading…
Reference in New Issue
Block a user