posts index: clean up limit:<n> / order:random parsing (#2894)

* Move the limit:<n> / order:random metatag parsing from the controller
  to the post set.

* Introduce `Tag.has_metatag?` and use it to parse these metatags
  instead of using a regex (#2894).
This commit is contained in:
evazion
2018-09-20 12:57:43 -05:00
parent 235271706b
commit 6fe883c316
6 changed files with 44 additions and 8 deletions

View File

@@ -10,9 +10,7 @@ class PostsController < ApplicationController
format.html { redirect_to(@post) }
end
else
limit = params[:limit] || (params[:tags] =~ /(?:^|\s)limit:(\d+)(?:$|\s)/ && $1) || CurrentUser.user.per_page
@random = params[:random] || params[:tags] =~ /(?:^|\s)order:random(?:$|\s)/
@post_set = PostSets::Post.new(tag_query, params[:page], limit, raw: params[:raw], random: @random, format: params[:format], read_only: params[:ro])
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit], raw: params[:raw], random: params[:random], format: params[:format], read_only: params[:ro])
@posts = @post_set.posts
respond_with(@posts) do |format|
format.atom