Migration to new track title struct

This commit is contained in:
Eduard Urbach 2018-04-08 22:44:21 +02:00
parent 1ba0da36e2
commit ea03c6cc17
9 changed files with 177 additions and 186 deletions

View File

@ -15,7 +15,7 @@ component SoundTrackMedia(track *arn.SoundTrack)
if track.File != ""
.soundtrack-media
.soundtrack-play-area.action(data-action="toggleAudio", data-trigger="click", data-audio-src="https://notify.moe/audio/" + track.File, data-soundtrack-id=track.ID)
img.soundtrack-image.lazy(data-src="https://img.youtube.com/vi/" + track.MediaByService("Youtube")[0].ServiceID + "/0.jpg", alt=track.Title)
img.soundtrack-image.lazy(data-src="https://img.youtube.com/vi/" + track.MediaByService("Youtube")[0].ServiceID + "/0.jpg", alt=track.NewTitle)
button.soundtrack-play-button
RawIcon("play")

View File

@ -67,7 +67,7 @@ func Get(ctx *aero.Context) string {
})
sort.Slice(tracks, func(i, j int) bool {
return tracks[i].Title < tracks[j].Title
return tracks[i].Title.ByUser(user) < tracks[j].Title.ByUser(user)
})
// Anime list item

View File

@ -1,97 +1,97 @@
package dashboard
import (
"net/http"
"sort"
// import (
// "net/http"
// "sort"
"github.com/aerogo/aero"
"github.com/aerogo/flow"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// "github.com/aerogo/aero"
// "github.com/aerogo/flow"
// "github.com/animenotifier/arn"
// "github.com/animenotifier/notify.moe/components"
// "github.com/animenotifier/notify.moe/utils"
// )
const maxForumActivity = 5
const maxFollowing = 5
const maxSoundTracks = 5
const maxScheduleItems = 5
// const maxForumActivity = 5
// const maxFollowing = 5
// const maxSoundTracks = 5
// const maxScheduleItems = 5
// Get the dashboard.
func Get(ctx *aero.Context) string {
var forumActivity []arn.Postable
var followingList []*arn.User
var soundTracks []*arn.SoundTrack
var upcomingEpisodes []*arn.UpcomingEpisode
// // Get the dashboard.
// func Get(ctx *aero.Context) string {
// var forumActivity []arn.Postable
// var followingList []*arn.User
// var soundTracks []*arn.SoundTrack
// var upcomingEpisodes []*arn.UpcomingEpisode
user := utils.GetUser(ctx)
// user := utils.GetUser(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
}
// if user == nil {
// return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
// }
flow.Parallel(func() {
posts := arn.AllPosts()
threads := arn.AllThreads()
// flow.Parallel(func() {
// posts := arn.AllPosts()
// threads := arn.AllThreads()
arn.SortPostsLatestFirst(posts)
arn.SortThreadsLatestFirst(threads)
// arn.SortPostsLatestFirst(posts)
// arn.SortThreadsLatestFirst(threads)
posts = arn.FilterPostsWithUniqueThreads(posts, maxForumActivity)
// posts = arn.FilterPostsWithUniqueThreads(posts, maxForumActivity)
postPostables := arn.ToPostables(posts)
threadPostables := arn.ToPostables(threads)
// postPostables := arn.ToPostables(posts)
// threadPostables := arn.ToPostables(threads)
allPostables := append(postPostables, threadPostables...)
// allPostables := append(postPostables, threadPostables...)
arn.SortPostablesLatestFirst(allPostables)
forumActivity = arn.FilterPostablesWithUniqueThreads(allPostables, maxForumActivity)
}, func() {
animeList, err := arn.GetAnimeList(user.ID)
// arn.SortPostablesLatestFirst(allPostables)
// forumActivity = arn.FilterPostablesWithUniqueThreads(allPostables, maxForumActivity)
// }, func() {
// animeList, err := arn.GetAnimeList(user.ID)
if err != nil {
return
}
// if err != nil {
// return
// }
animeList = animeList.Watching()
animeList.Lock()
// animeList = animeList.Watching()
// animeList.Lock()
for _, item := range animeList.Items {
futureEpisodes := item.Anime().UpcomingEpisodes()
// for _, item := range animeList.Items {
// futureEpisodes := item.Anime().UpcomingEpisodes()
if len(futureEpisodes) == 0 {
continue
}
// if len(futureEpisodes) == 0 {
// continue
// }
upcomingEpisodes = append(upcomingEpisodes, futureEpisodes...)
}
// upcomingEpisodes = append(upcomingEpisodes, futureEpisodes...)
// }
animeList.Unlock()
// animeList.Unlock()
sort.Slice(upcomingEpisodes, func(i, j int) bool {
return upcomingEpisodes[i].Episode.AiringDate.Start < upcomingEpisodes[j].Episode.AiringDate.Start
})
// sort.Slice(upcomingEpisodes, func(i, j int) bool {
// return upcomingEpisodes[i].Episode.AiringDate.Start < upcomingEpisodes[j].Episode.AiringDate.Start
// })
if len(upcomingEpisodes) >= maxScheduleItems {
upcomingEpisodes = upcomingEpisodes[:maxScheduleItems]
}
}, func() {
soundTracks = arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && len(track.Media) > 0
})
// if len(upcomingEpisodes) >= maxScheduleItems {
// upcomingEpisodes = upcomingEpisodes[:maxScheduleItems]
// }
// }, func() {
// soundTracks = arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
// return !track.IsDraft && len(track.Media) > 0
// })
arn.SortSoundTracksLatestFirst(soundTracks)
// arn.SortSoundTracksLatestFirst(soundTracks)
if len(soundTracks) > maxSoundTracks {
soundTracks = soundTracks[:maxSoundTracks]
}
}, func() {
followingList = user.Follows().Users()
arn.SortUsersLastSeen(followingList)
// if len(soundTracks) > maxSoundTracks {
// soundTracks = soundTracks[:maxSoundTracks]
// }
// }, func() {
// followingList = user.Follows().Users()
// arn.SortUsersLastSeen(followingList)
if len(followingList) > maxFollowing {
followingList = followingList[:maxFollowing]
}
})
// if len(followingList) > maxFollowing {
// followingList = followingList[:maxFollowing]
// }
// })
return ctx.HTML(components.Dashboard(upcomingEpisodes, forumActivity, soundTracks, followingList, user))
}
// return ctx.HTML(components.Dashboard(upcomingEpisodes, forumActivity, soundTracks, followingList, user))
// }

View File

@ -1,101 +1,101 @@
component Dashboard(schedule []*arn.UpcomingEpisode, posts []arn.Postable, soundTracks []*arn.SoundTrack, following []*arn.User, user *arn.User)
h1.page-title Dashboard
//- h1.page-title Dashboard
.dashboard
.widget.mountable
h3.widget-title Schedule
//- .dashboard
//- .widget.mountable
//- h3.widget-title Schedule
for i := 0; i <= 4; i++
if i < len(schedule)
.widget-ui-element
.widget-ui-element-text
a.schedule-item-link(href=schedule[i].Anime.Link())
Icon("calendar-o")
.schedule-item-title= schedule[i].Anime.Title.ByUser(user)
.spacer
.schedule-item-date.utc-airing-date(data-start-date=schedule[i].Episode.AiringDate.Start, data-end-date=schedule[i].Episode.AiringDate.End, data-episode-number=schedule[i].Episode.Number)
else
.widget-ui-element
.widget-ui-element-text
Icon("calendar-o")
span ...
//- for i := 0; i <= 4; i++
//- if i < len(schedule)
//- .widget-ui-element
//- .widget-ui-element-text
//- a.schedule-item-link(href=schedule[i].Anime.Link())
//- Icon("calendar-o")
//- .schedule-item-title= schedule[i].Anime.Title.ByUser(user)
//- .spacer
//- .schedule-item-date.utc-airing-date(data-start-date=schedule[i].Episode.AiringDate.Start, data-end-date=schedule[i].Episode.AiringDate.End, data-episode-number=schedule[i].Episode.Number)
//- else
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("calendar-o")
//- span ...
.widget.mountable
h3.widget-title Forums
//- .widget.mountable
//- h3.widget-title Forums
each post in posts
a.widget-ui-element(href=post.Thread().Link())
.widget-ui-element-text
Icon(arn.GetForumIcon(post.Thread().Tags[0]))
span= post.Thread().Title
//- each post in posts
//- a.widget-ui-element(href=post.Thread().Link())
//- .widget-ui-element-text
//- Icon(arn.GetForumIcon(post.Thread().Tags[0]))
//- span= post.Thread().Title
.widget.mountable
h3.widget-title Artworks
//- .widget.mountable
//- h3.widget-title Artworks
for i := 1; i <= 5; i++
.widget-ui-element
.widget-ui-element-text
Icon("paint-brush")
span ...
//- for i := 1; i <= 5; i++
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("paint-brush")
//- span ...
.widget.mountable
h3.widget-title Soundtracks
//- .widget.mountable
//- h3.widget-title Soundtracks
for i := 0; i <= 4; i++
if i < len(soundTracks)
a.widget-ui-element(href=soundTracks[i].Link())
.widget-ui-element-text
Icon("music")
if soundTracks[i].Title == ""
span untitled
else
span= soundTracks[i].Title
else
.widget-ui-element
.widget-ui-element-text
Icon("music")
span ...
//- for i := 0; i <= 4; i++
//- if i < len(soundTracks)
//- a.widget-ui-element(href=soundTracks[i].Link())
//- .widget-ui-element-text
//- Icon("music")
//- if soundTracks[i].Title == ""
//- span untitled
//- else
//- span= soundTracks[i].Title
//- else
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("music")
//- span ...
.widget.mountable
h3.widget-title AMVs
//- .widget.mountable
//- h3.widget-title AMVs
for i := 1; i <= 5; i++
.widget-ui-element
.widget-ui-element-text
Icon("video-camera")
span ...
//- for i := 1; i <= 5; i++
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("video-camera")
//- span ...
.widget.mountable
h3.widget-title Reviews
//- .widget.mountable
//- h3.widget-title Reviews
for i := 1; i <= 5; i++
.widget-ui-element
.widget-ui-element-text
Icon("book")
span ...
//- for i := 1; i <= 5; i++
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("book")
//- span ...
.widget.mountable
h3.widget-title Groups
//- .widget.mountable
//- h3.widget-title Groups
for i := 1; i <= 5; i++
.widget-ui-element
.widget-ui-element-text
Icon("group")
span ...
//- for i := 1; i <= 5; i++
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("group")
//- span ...
.widget.mountable
h3.widget-title Contacts
//- .widget.mountable
//- h3.widget-title Contacts
for i := 0; i <= 4; i++
if i < len(following)
a.widget-ui-element(href="/+" + following[i].Nick)
.widget-ui-element-text
Icon("address-card")
span= following[i].Nick
else
.widget-ui-element
.widget-ui-element-text
Icon("address-card")
span ...
//- for i := 0; i <= 4; i++
//- if i < len(following)
//- a.widget-ui-element(href="/+" + following[i].Nick)
//- .widget-ui-element-text
//- Icon("address-card")
//- span= following[i].Nick
//- else
//- .widget-ui-element
//- .widget-ui-element-text
//- Icon("address-card")
//- span ...
Footer
//- Footer

View File

@ -1,20 +1,20 @@
.schedule-item-link,
.schedule-item-title
clip-long-text
// .schedule-item-link,
// .schedule-item-title
// clip-long-text
.schedule-item-link
horizontal
align-items center
// .schedule-item-link
// horizontal
// align-items center
.schedule-item-date
text-align right
// .schedule-item-date
// text-align right
.footer-element
:after
content " | "
color text-color
opacity 0.5
:last-child
:after
display none

View File

@ -93,11 +93,6 @@ func Configure(app *aero.Application) {
l.Page("/api/"+strings.ToLower(name), apidocs.ByType(name))
}
// l.Ajax("/dashboard", dashboard.Get)
// l.Ajax("/best/anime", best.Get)
// l.Ajax("/artworks", artworks.Get)
// l.Ajax("/amvs", amvs.Get)
// Forum
l.Page("/forum", forum.Get)
l.Page("/forum/:tag", forum.Get)

View File

@ -23,7 +23,7 @@ func Edit(ctx *aero.Context) string {
ctx.Data = &arn.OpenGraph{
Tags: map[string]string{
"og:title": track.NewTitle.ByUser(user),
"og:title": track.Title.ByUser(user),
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": "notify.moe",
"og:type": "music.song",

View File

@ -32,7 +32,7 @@ func Get(ctx *aero.Context) string {
openGraph := &arn.OpenGraph{
Tags: map[string]string{
"og:title": track.NewTitle.ByUser(user),
"og:title": track.Title.ByUser(user),
"og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")",
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": ctx.App.Config.Domain,

View File

@ -1,19 +1,15 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
defer arn.Node.Close()
// defer arn.Node.Close()
for track := range arn.StreamSoundTracks() {
if arn.ContainsUnicodeLetters(track.Title) {
track.NewTitle.Native = track.Title
} else {
track.NewTitle.Canonical = track.Title
}
// for track := range arn.StreamSoundTracks() {
// if arn.ContainsUnicodeLetters(track.Title) {
// track.NewTitle.Native = track.Title
// } else {
// track.NewTitle.Canonical = track.Title
// }
track.Save()
}
// track.Save()
// }
}