add favgroup excerpt
This commit is contained in:
@@ -55,6 +55,18 @@ module PostSets
|
|||||||
::Pool.find_by_name(pool_name)
|
::Pool.find_by_name(pool_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def favgroup_name
|
||||||
|
tag_string.match(/^favgroup:(\S+)$/i).try(:[], 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_favgroup?
|
||||||
|
is_single_tag? && favgroup_name && favgroup
|
||||||
|
end
|
||||||
|
|
||||||
|
def favgroup
|
||||||
|
::FavoriteGroup.find_by_name(favgroup_name)
|
||||||
|
end
|
||||||
|
|
||||||
def has_deleted?
|
def has_deleted?
|
||||||
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
|
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -84,8 +84,22 @@ class FavoriteGroup < ActiveRecord::Base
|
|||||||
self.post_ids = post_ids.scan(/\d+/).uniq.join(" ")
|
self.post_ids = post_ids.scan(/\d+/).uniq.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.normalize_name(name)
|
||||||
|
name.gsub(/\s+/, "_")
|
||||||
|
end
|
||||||
|
|
||||||
def normalize_name
|
def normalize_name
|
||||||
self.name = name.gsub(/\s+/, "_")
|
self.name = FavoriteGroup.normalize_name(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.find_by_name(name)
|
||||||
|
if name =~ /^\d+$/
|
||||||
|
where("id = ?", name.to_i).first
|
||||||
|
elsif name
|
||||||
|
where("lower(name) = ?", normalize_name(name).mb_chars.downcase).first
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
|
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
|
||||||
<% elsif @post_set.has_pool? %>
|
<% elsif @post_set.has_pool? %>
|
||||||
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
|
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
|
||||||
|
<% elsif @post_set.has_favgroup? %>
|
||||||
|
<li><%= link_to "Favorite Group", favorite_group_path(@post_set.favgroup), :id => "show-excerpt-link" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><%= link_to "View pool", pool_path(post_set.pool.id) %></p>
|
<p><%= link_to "View pool", pool_path(post_set.pool.id) %></p>
|
||||||
|
<% elsif post_set.has_favgroup? %>
|
||||||
|
<h4>
|
||||||
|
Favorite Group:
|
||||||
|
<%= link_to post_set.favgroup.pretty_name, favorite_group_path(post_set.favgroup) %>
|
||||||
|
</h4>
|
||||||
|
Creator: <%= link_to_user post_set.favgroup.creator %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if post_set.tag_string.present? %>
|
<% if post_set.tag_string.present? %>
|
||||||
<p>There is currently no wiki page for the tag "<%= post_set.tag_string %>". You can <%= link_to "create one", new_wiki_page_path(:wiki_page => {:title => post_set.tag_string}) %>.</p>
|
<p>There is currently no wiki page for the tag "<%= post_set.tag_string %>". You can <%= link_to "create one", new_wiki_page_path(:wiki_page => {:title => post_set.tag_string}) %>.</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user