Upgrading posts to new data structure

This commit is contained in:
Eduard Urbach 2018-10-29 08:12:34 +09:00
parent 84f650a636
commit 681177b28e
4 changed files with 26 additions and 5 deletions

View File

@ -4,4 +4,4 @@ component Post(post *arn.Post, user *arn.User)
Postable(post.ToPostable(), user, "")
.side-note.mountable
a(href=post.Thread().Link())= post.Thread().Title
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)

View File

@ -72,6 +72,7 @@ func Characters(ctx *aero.Context) string {
func Forum(ctx *aero.Context) string {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
var posts []*arn.Post
var threads []*arn.Thread
@ -82,7 +83,7 @@ func Forum(ctx *aero.Context) string {
threads = search.Threads(term, maxThreads)
})
return ctx.HTML(components.ForumSearchResults(posts, threads))
return ctx.HTML(components.ForumSearchResults(posts, threads, user))
}
// SoundTracks search.

View File

@ -24,7 +24,7 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
span Forum
#forum-search-results
ForumSearchResults(posts, threads)
ForumSearchResults(posts, threads, user)
.widget
h3.widget-title
@ -76,7 +76,7 @@ component CharacterSearchResults(characters []*arn.Character, user *arn.User)
.mountable(data-mountable-type="character")
CharacterSmall(character, user)
component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread)
component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread, user *arn.User)
if len(posts) == 0 && len(threads) == 0
p.no-search-results.mountable No posts found.
else
@ -92,7 +92,7 @@ component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread)
each post in posts
.forum-search-result.mountable(data-mountable-type="forum")
.forum-search-result-header
a.forum-search-result-title(href=post.Link(), data-mountable-type="forum")= post.Thread().Title
a.forum-search-result-title(href=post.Link(), data-mountable-type="forum")= post.Parent().TitleByUser(user)
if post.Creator().HasNick()
.forum-search-result-author= post.Creator().Nick
.forum-search-result-sample= post.Text

View File

@ -0,0 +1,20 @@
package main
import (
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Updating post structure")
defer color.Green("Finished.")
defer arn.Node.Close()
// Iterate over the stream
for post := range arn.StreamPosts() {
post.ParentID = post.ThreadID
post.ParentType = "Thread"
post.Save()
}
}