fixes #1126, raw tag search is accessible via tag alias correction page, can manually tack on raw=true to parameters in post searches to disable tag aliases

This commit is contained in:
r888888888
2013-06-13 14:35:26 -07:00
parent 1757cba4aa
commit d70a7c4ef8
3 changed files with 10 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ class PostsController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, :with => :rescue_exception
def index
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit] || CurrentUser.user.per_page)
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit] || CurrentUser.user.per_page, params[:raw])
@posts = @post_set.posts
respond_with(@posts) do |format|
format.atom

View File

@@ -1,12 +1,13 @@
module PostSets
class Post < Base
attr_reader :tag_array, :page, :per_page
attr_reader :tag_array, :page, :per_page, :raw
def initialize(tags, page = 1, per_page = nil)
def initialize(tags, page = 1, per_page = nil, raw = false)
@tag_array = Tag.scan_query(tags)
@page = page
@per_page = (per_page || CurrentUser.per_page).to_i
@per_page = 200 if @per_page > 200
@raw = raw.present?
end
def tag_string
@@ -43,7 +44,11 @@ module PostSets
end
@posts ||= begin
temp = ::Post.tag_match(tag_string).paginate(page, :count => ::Post.fast_count(tag_string), :limit => per_page)
if raw
temp = ::Post.raw_tag_match(tag_string).paginate(page, :count => ::Post.fast_count(tag_string), :limit => per_page)
else
temp = ::Post.tag_match(tag_string).paginate(page, :count => ::Post.fast_count(tag_string), :limit => per_page)
end
temp.all
temp
end

View File

@@ -6,7 +6,7 @@
<div style="margin-bottom: 1em;">
<h2>Server: <%= server.hostname %></h2>
<ul>
<li><strong><%= server.antecedent_name %></strong> aliased to <strong><%= server.statistics_hash["antecedent_cache"] %></strong> in cache</li>
<li><strong><%= link_to server.antecedent_name, posts_path(:tags => server.antecedent_name, :raw => true) %></strong> aliased to <strong><%= server.statistics_hash["antecedent_cache"] %></strong> in cache</li>
<li><strong><%= server.consequent_name %></strong> aliased to <strong><%= server.statistics_hash["consequent_cache"] %></strong> in cache</li>
<li><strong><%= server.antecedent_name %></strong> count is <%= server.statistics_hash["antecedent_count"] %></li>
<li><strong><%= server.consequent_name %></strong> count is <%= server.statistics_hash["consequent_count"] %></li>