diff --git a/app/assets/javascripts/autocomplete.js b/app/assets/javascripts/autocomplete.js index 4cdf8c322..9fb1b7405 100644 --- a/app/assets/javascripts/autocomplete.js +++ b/app/assets/javascripts/autocomplete.js @@ -267,7 +267,8 @@ "mpixels", "mpixels_asc", "portrait", "landscape", "filesize", "filesize_asc", - "rank" + "rank", + "random" ], status: [ "any", "deleted", "active", "pending", "flagged", "banned" diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 0c4ecad4c..422a372b9 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -14,7 +14,8 @@ class PostsController < ApplicationController redirect_to post_path(@post) else limit = params[:limit] || (params[:tags] =~ /(?:^|\s)limit:(\d+)(?:$|\s)/ && $1) || CurrentUser.user.per_page - @post_set = PostSets::Post.new(tag_query, params[:page], limit, params[:raw], params[:random]) + @random = params[:random] || params[:tags] =~ /(?:^|\s)order:random(?:$|\s)/ + @post_set = PostSets::Post.new(tag_query, params[:page], limit, params[:raw], @random) @posts = @post_set.posts respond_with(@posts) do |format| format.atom diff --git a/app/views/posts/partials/index/_posts.html.erb b/app/views/posts/partials/index/_posts.html.erb index c33b91acd..d71e5912a 100644 --- a/app/views/posts/partials/index/_posts.html.erb +++ b/app/views/posts/partials/index/_posts.html.erb @@ -9,7 +9,7 @@ <% end %> - <% unless params[:random].present? %> + <% unless @random.present? %> <%= numbered_paginator(post_set.posts) %> <% end %>