This commit is contained in:
albert
2012-01-14 17:19:42 -05:00
parent 57e93f8e69
commit 914d2d5b4e
4 changed files with 13 additions and 3 deletions

View File

@@ -47,6 +47,10 @@ module PostSets
tag_array.size == 0
end
def is_pattern_search?
tag_string =~ /\*/
end
def current_page
[page.to_i, 1].max
end

View File

@@ -195,7 +195,7 @@ class Tag < ActiveRecord::Base
output[:include] << tag[1..-1]
elsif tag =~ /\*/
matches = Tag.name_matches(tag).all(:select => "name", :limit => 25, :order => "post_count DESC").map(&:name)
matches = Tag.name_matches(tag).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
matches = ["~no_matches~"] if matches.empty?
output[:include] += matches

View File

@@ -9,7 +9,9 @@ module PostSetPresenters
end
def related_tags
if post_set.is_single_tag?
if post_set.is_pattern_search?
pattern_tags
elsif post_set.is_single_tag?
related_tags_for_single
elsif post_set.is_empty_tag?
popular_tags
@@ -31,6 +33,10 @@ module PostSetPresenters
results
end
def pattern_tags
Tag.name_matches(post_set.tag_string).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
end
def related_tags_for_group
RelatedTagCalculator.calculate_from_sample_to_array(post_set.tag_string).map(&:first)
end

View File

@@ -12,7 +12,7 @@ class TagSetPresenter < Presenter
def tag_list_html(template, options = {})
html = ""
html << "<ul>"
@tags.each do |tag|
Array(@tags).each do |tag|
html << build_list_item(tag, template, options)
end
html << "</ul>"