radar/forem — pull request #409 by funkdified (2013-04-13 05:35:00+00:00)
Title: Modified gem to allow page number rendering in reply_to links

Added @post_positions to topics show action:

```ruby
def show
if find_topic
register_view
@posts = @topic.posts
unless forem_admin_or_moderator?(@forum)
@posts = @posts.approved_or_pending_review_for(forem_user)
end
@posts = @posts.page(params[:page]).per(Forem.per_page)
#Provides ids of posts and their positions
post_positions = @topic.posts.flatten.collect{|p| p.id}.each_with_index.to_a
@post_positions = post_positions.map{|a| {:id=>a[0], :position=>a[1]+1}}
end
end
```

Modified posts/_post.html.erb view:
```ruby
<% if post.reply_to %>

<% position = @post_positions.select{|p| p[:id].equal? post.reply_to.id}.first[:position] %>
<% page = Integer(Float(position-1)/Float(Forem.per_page)+1) %>
<%= link_to "#{t("forem.post.in_reply_to")} #{post.reply_to.user}", "?page=#{page}#post-#{post.reply_to.id}" %>

<% end %>
```

Modified topics/show.html.erb to pass data to partial:

```ruby

<%= render :partial => "forem/posts/post", :collection => @posts, :locals => {:post_positions=>@post_positions} %>

```