Upgrading posts to new data structure
This commit is contained in:
parent
84f650a636
commit
681177b28e
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
20
patches/update-post-structure/update-post-structure.go
Normal file
20
patches/update-post-structure/update-post-structure.go
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user