Kill trailing whitespace in ruby files
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class ForumTopicPresenter < Presenter
|
||||
attr_reader :forum_topic, :forum_posts
|
||||
|
||||
|
||||
def initialize(forum_topic, forum_posts)
|
||||
@forum_posts = forum_posts
|
||||
@forum_topic = forum_topic
|
||||
|
||||
@@ -2,8 +2,8 @@ class NotePresenter
|
||||
def initialize(note)
|
||||
@note = note
|
||||
end
|
||||
|
||||
|
||||
def formatted_body
|
||||
note.body.gsub(/<tn>(.+?)<\/tn>/m, '<br><p class="tn">\1</p>').gsub(/\n/, '<br>')
|
||||
note.body.gsub(/<tn>(.+?)<\/tn>/m, '<br><p class="tn">\1</p>').gsub(/\n/, '<br>')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,18 +3,18 @@ class PostPresenter < Presenter
|
||||
if post.is_deleted? && !CurrentUser.is_privileged?
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
unless Danbooru.config.can_user_see_post?(CurrentUser.user, post)
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
flags = []
|
||||
flags << "pending" if post.is_pending?
|
||||
flags << "flagged" if post.is_flagged?
|
||||
flags << "deleted" if post.is_deleted?
|
||||
|
||||
|
||||
path = options[:path_prefix] || "/posts"
|
||||
|
||||
|
||||
html = %{<article class="post-preview" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{flags.join(' ')}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}" data-score="#{post.score}">}
|
||||
if options[:tags].present?
|
||||
tag_param = "?tags=#{CGI::escape(options[:tags])}"
|
||||
@@ -29,43 +29,43 @@ class PostPresenter < Presenter
|
||||
html << %{</article>}
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def initialize(post)
|
||||
@post = post
|
||||
end
|
||||
|
||||
|
||||
def preview_html
|
||||
PostPresenter.preview(@post)
|
||||
end
|
||||
|
||||
|
||||
def humanized_tag_string
|
||||
@post.tag_string.split(/ /).slice(0, 25).join(", ").tr("_", " ")
|
||||
end
|
||||
|
||||
|
||||
def humanized_essential_tag_string
|
||||
string = []
|
||||
|
||||
|
||||
if @post.character_tags.any?
|
||||
string << @post.character_tags.slice(0, 5).to_sentence
|
||||
end
|
||||
|
||||
|
||||
if @post.copyright_tags.any?
|
||||
string << "from"
|
||||
string << @post.copyright_tags.slice(0, 5).to_sentence
|
||||
end
|
||||
|
||||
|
||||
if @post.artist_tags.any?
|
||||
string << "drawn by"
|
||||
string << @post.artist_tags.to_sentence
|
||||
end
|
||||
|
||||
|
||||
string.join(" ").tr("_", " ")
|
||||
end
|
||||
|
||||
|
||||
def image_html(template)
|
||||
return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_privileged?
|
||||
return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
||||
|
||||
|
||||
if @post.is_flash?
|
||||
template.render("posts/partials/show/flash", :post => @post)
|
||||
elsif !@post.is_image?
|
||||
@@ -74,21 +74,21 @@ class PostPresenter < Presenter
|
||||
template.render("posts/partials/show/image", :post => @post)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def tag_list_html(template, options = {})
|
||||
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
||||
@tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
|
||||
end
|
||||
|
||||
|
||||
def split_tag_list_html(template, options = {})
|
||||
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
||||
@tag_set_presenter.split_tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
|
||||
end
|
||||
|
||||
|
||||
def has_nav_links?(template)
|
||||
(CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /order:/) || @post.pools.active.any?
|
||||
end
|
||||
|
||||
|
||||
def post_footer_for_pool_html(template)
|
||||
if template.params[:pool_id]
|
||||
pool = Pool.where(:id => template.params[:pool_id]).first
|
||||
@@ -99,15 +99,15 @@ class PostPresenter < Presenter
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def pool_html(template)
|
||||
html = ["<ul>"]
|
||||
|
||||
|
||||
if template.params[:pool_id].present?
|
||||
pool = Pool.where(:id => template.params[:pool_id]).first
|
||||
return if pool.nil?
|
||||
html += pool_link_html(template, pool, :include_rel => true)
|
||||
|
||||
|
||||
@post.pools.active.where("id <> ?", template.params[:pool_id]).each do |other_pool|
|
||||
html += pool_link_html(template, other_pool)
|
||||
end
|
||||
@@ -122,15 +122,15 @@ class PostPresenter < Presenter
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
html << "</ul>"
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
|
||||
def pool_link_html(template, pool, options = {})
|
||||
pool_html = ["<li>"]
|
||||
match_found = false
|
||||
|
||||
|
||||
if options[:include_rel]
|
||||
prev_rel = "prev"
|
||||
next_rel = "next"
|
||||
@@ -140,14 +140,14 @@ class PostPresenter < Presenter
|
||||
next_rel = nil
|
||||
klass = ""
|
||||
end
|
||||
|
||||
|
||||
if pool.neighbors(@post).previous
|
||||
pool_html << template.link_to("«prev".html_safe, template.post_path(pool.neighbors(@post).previous, :pool_id => pool.id), :rel => prev_rel, :class => "#{klass} prev")
|
||||
match_found = true
|
||||
else
|
||||
pool_html << '<span class="prev">«prev</span>'
|
||||
end
|
||||
|
||||
|
||||
pool_html << ' <span class="pool-name ' + klass + '">'
|
||||
pool_html << template.link_to("Pool: #{pool.pretty_name}", template.pool_path(pool))
|
||||
pool_html << '</span> '
|
||||
@@ -158,7 +158,7 @@ class PostPresenter < Presenter
|
||||
else
|
||||
pool_html << '<span class="next">next»</span>'
|
||||
end
|
||||
|
||||
|
||||
pool_html << "</li>"
|
||||
pool_html
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ module PostSetPresenters
|
||||
def posts
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
|
||||
def post_previews_html(template)
|
||||
html = ""
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ module PostSetPresenters
|
||||
).map {|x| x[0]}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
def tag_list_html(template)
|
||||
tag_set_presenter.tag_list_html(template)
|
||||
end
|
||||
|
||||
|
||||
def posts
|
||||
@posts ||= favorite_set.posts
|
||||
end
|
||||
|
||||
@@ -11,11 +11,11 @@ module PostSetPresenters
|
||||
).map {|x| x[0]}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
def tag_list_html(template)
|
||||
tag_set_presenter.tag_list_html(template)
|
||||
end
|
||||
|
||||
|
||||
def post_previews_html(template)
|
||||
html = ""
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module PostSetPresenters
|
||||
class Popular < Base
|
||||
attr_accessor :post_set, :tag_set_presenter
|
||||
delegate :posts, :date, :min_date, :max_date, :to => :post_set
|
||||
|
||||
|
||||
def initialize(post_set)
|
||||
@post_set = post_set
|
||||
end
|
||||
@@ -10,42 +10,42 @@ module PostSetPresenters
|
||||
def prev_day
|
||||
date - 1.day
|
||||
end
|
||||
|
||||
|
||||
def next_day
|
||||
date + 1.day
|
||||
end
|
||||
|
||||
|
||||
def prev_week
|
||||
date - 7.days
|
||||
end
|
||||
|
||||
|
||||
def next_week
|
||||
date + 7.days
|
||||
end
|
||||
|
||||
|
||||
def prev_month
|
||||
1.month.ago(date)
|
||||
end
|
||||
|
||||
|
||||
def next_month
|
||||
1.month.since(date)
|
||||
end
|
||||
|
||||
|
||||
def link_rel_for_scale?(template, scale)
|
||||
(template.params[:scale].blank? && scale == "day") || template.params[:scale].to_s.include?(scale)
|
||||
end
|
||||
|
||||
|
||||
def next_date_for_scale(scale)
|
||||
case scale
|
||||
when "Day"
|
||||
next_day
|
||||
|
||||
|
||||
when "Week"
|
||||
next_week
|
||||
|
||||
|
||||
when "Month"
|
||||
next_month
|
||||
|
||||
|
||||
else
|
||||
nil
|
||||
end
|
||||
@@ -55,41 +55,41 @@ module PostSetPresenters
|
||||
case scale
|
||||
when "Day"
|
||||
prev_day
|
||||
|
||||
|
||||
when "Week"
|
||||
prev_week
|
||||
|
||||
|
||||
when "Month"
|
||||
prev_month
|
||||
|
||||
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def nav_links_for_scale(template, scale)
|
||||
html = []
|
||||
html << '<span class="period">'
|
||||
html << template.link_to(
|
||||
"«prev".html_safe,
|
||||
"«prev".html_safe,
|
||||
template.popular_explore_posts_path(
|
||||
:date => prev_date_for_scale(scale),
|
||||
:date => prev_date_for_scale(scale),
|
||||
:scale => scale.downcase
|
||||
),
|
||||
:rel => (link_rel_for_scale?(template, scale.downcase) ? "prev" : nil)
|
||||
)
|
||||
html << template.link_to(
|
||||
scale,
|
||||
scale,
|
||||
template.popular_explore_posts_path(
|
||||
:date => date,
|
||||
:date => date,
|
||||
:scale => scale.downcase
|
||||
),
|
||||
),
|
||||
:class => "desc"
|
||||
)
|
||||
html << template.link_to(
|
||||
"next»".html_safe,
|
||||
"next»".html_safe,
|
||||
template.popular_explore_posts_path(
|
||||
:date => next_date_for_scale(scale),
|
||||
:date => next_date_for_scale(scale),
|
||||
:scale => scale.downcase
|
||||
),
|
||||
:rel => (link_rel_for_scale?(template, scale.downcase) ? "next" : nil)
|
||||
@@ -97,7 +97,7 @@ module PostSetPresenters
|
||||
html << '</span>'
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
|
||||
def nav_links(template)
|
||||
html = []
|
||||
html << '<p id="popular-nav-links">'
|
||||
@@ -107,7 +107,7 @@ module PostSetPresenters
|
||||
html << '</p>'
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
|
||||
def range_text
|
||||
if min_date == max_date
|
||||
date.strftime("%B %d, %Y")
|
||||
|
||||
@@ -7,7 +7,7 @@ module PostSetPresenters
|
||||
@post_set = post_set
|
||||
@tag_set_presenter = TagSetPresenter.new(related_tags)
|
||||
end
|
||||
|
||||
|
||||
def related_tags
|
||||
if post_set.is_pattern_search?
|
||||
pattern_tags
|
||||
@@ -21,28 +21,28 @@ module PostSetPresenters
|
||||
related_tags_for_group
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def popular_tags
|
||||
n = 1
|
||||
results = []
|
||||
|
||||
|
||||
while results.empty? && n < 256
|
||||
query = n.days.ago.strftime("date:>%Y-%m-%d")
|
||||
results = RelatedTagCalculator.calculate_from_sample_to_array(query).map(&:first)
|
||||
n *= 2
|
||||
end
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
def related_tags_for_single
|
||||
tag = Tag.find_by_name(post_set.tag_string)
|
||||
|
||||
@@ -53,7 +53,7 @@ module PostSetPresenters
|
||||
tag.related_tag_array.map(&:first)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def tag_list_html(template)
|
||||
tag_set_presenter.tag_list_html(template)
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ module PostSetPresenters
|
||||
rescue ActiveRecord::StatementInvalid, PGError
|
||||
[]
|
||||
end
|
||||
|
||||
|
||||
def post_previews_html(template)
|
||||
result = super(template)
|
||||
if result =~ /Nobody here but us chickens/
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class PostVersionPresenter < Presenter
|
||||
attr_reader :post_version
|
||||
|
||||
|
||||
def initialize(post_version)
|
||||
@post_version = post_version
|
||||
end
|
||||
|
||||
|
||||
def changes
|
||||
html = []
|
||||
html << post_version.tag_array
|
||||
@@ -13,7 +13,7 @@ class PostVersionPresenter < Presenter
|
||||
html << "<ins>parent:#{post_version.parent_id}</ins>" if post_version.parent_id
|
||||
html.join(" ").html_safe
|
||||
end
|
||||
|
||||
|
||||
def updater_name
|
||||
User.id_to_name(post_version.updater_id)
|
||||
end
|
||||
|
||||
@@ -2,15 +2,15 @@ class Presenter
|
||||
def self.h(s)
|
||||
CGI.escapeHTML(s)
|
||||
end
|
||||
|
||||
|
||||
def self.u(s)
|
||||
URI.escape(s)
|
||||
end
|
||||
|
||||
|
||||
def h(s)
|
||||
CGI.escapeHTML(s)
|
||||
end
|
||||
|
||||
|
||||
def u(s)
|
||||
CGI::escape(s)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=begin rdoc
|
||||
A tag set represents a set of tags that are displayed together.
|
||||
This class makes it easy to fetch the categories for all the
|
||||
This class makes it easy to fetch the categories for all the
|
||||
tags in one call instead of fetching them sequentially.
|
||||
=end
|
||||
|
||||
@@ -8,7 +8,7 @@ class TagSetPresenter < Presenter
|
||||
def initialize(tags)
|
||||
@tags = tags
|
||||
end
|
||||
|
||||
|
||||
def tag_list_html(template, options = {})
|
||||
html = ""
|
||||
if @tags.present?
|
||||
@@ -21,10 +21,10 @@ class TagSetPresenter < Presenter
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def split_tag_list_html(template, options = {})
|
||||
html = ""
|
||||
|
||||
|
||||
if copyright_tags.any?
|
||||
html << '<h2>Copyrights</h2>'
|
||||
html << "<ul>"
|
||||
@@ -33,7 +33,7 @@ class TagSetPresenter < Presenter
|
||||
end
|
||||
html << "</ul>"
|
||||
end
|
||||
|
||||
|
||||
if character_tags.any?
|
||||
html << '<h2>Characters</h2>'
|
||||
html << "<ul>"
|
||||
@@ -42,7 +42,7 @@ class TagSetPresenter < Presenter
|
||||
end
|
||||
html << "</ul>"
|
||||
end
|
||||
|
||||
|
||||
if artist_tags.any?
|
||||
html << '<h2>Artist</h2>'
|
||||
html << "<ul>"
|
||||
@@ -51,7 +51,7 @@ class TagSetPresenter < Presenter
|
||||
end
|
||||
html << "</ul>"
|
||||
end
|
||||
|
||||
|
||||
if general_tags.any?
|
||||
html << '<h1>Tags</h1>'
|
||||
html << "<ul>"
|
||||
@@ -68,15 +68,15 @@ private
|
||||
def general_tags
|
||||
@general_tags ||= categories.select {|k, v| v == Tag.categories.general}
|
||||
end
|
||||
|
||||
|
||||
def copyright_tags
|
||||
@copyright_tags ||= categories.select {|k, v| v == Tag.categories.copyright}
|
||||
end
|
||||
|
||||
|
||||
def character_tags
|
||||
@character_tags ||= categories.select {|k, v| v == Tag.categories.character}
|
||||
end
|
||||
|
||||
|
||||
def artist_tags
|
||||
@artist_tags ||= categories.select {|k, v| v == Tag.categories.artist}
|
||||
end
|
||||
@@ -84,23 +84,23 @@ private
|
||||
def categories
|
||||
@categories ||= Tag.categories_for(@tags)
|
||||
end
|
||||
|
||||
|
||||
def counts
|
||||
@counts ||= Tag.counts_for(@tags).inject({}) do |hash, x|
|
||||
hash[x["name"]] = x["post_count"]
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def is_index?(template)
|
||||
template.params[:action] == "index"
|
||||
end
|
||||
|
||||
|
||||
def build_list_item(tag, template, options)
|
||||
html = ""
|
||||
html << %{<li class="category-#{categories[tag]}">}
|
||||
current_query = template.params[:tags] || ""
|
||||
|
||||
|
||||
unless options[:name_only]
|
||||
if categories[tag] == Tag.categories.artist
|
||||
html << %{<a class="wiki-link" href="/artists/show_or_new?name=#{u(tag)}">?</a> }
|
||||
@@ -113,21 +113,21 @@ private
|
||||
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">–</a> }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
humanized_tag = tag.tr("_", " ")
|
||||
path = options[:path_prefix] || "/posts"
|
||||
html << %{<a class="search-tag" href="#{path}?tags=#{u(tag)}">#{h(humanized_tag)}</a> }
|
||||
|
||||
|
||||
unless options[:name_only]
|
||||
if counts[tag].to_i > 1_000
|
||||
post_count = "#{counts[tag].to_i / 1_000}k"
|
||||
else
|
||||
post_count = counts[tag].to_s
|
||||
end
|
||||
|
||||
|
||||
html << %{<span class="post-count">#{post_count}</span>}
|
||||
end
|
||||
|
||||
|
||||
html << "</li>"
|
||||
html
|
||||
end
|
||||
|
||||
@@ -2,13 +2,13 @@ class UploadPresenter < Presenter
|
||||
def initialize(upload)
|
||||
@upload = upload
|
||||
end
|
||||
|
||||
|
||||
def status(template)
|
||||
case @upload.status
|
||||
when /duplicate: (\d+)/
|
||||
dup_post_id = $1
|
||||
template.link_to(@upload.status.gsub(/error: RuntimeError - /, ""), template.__send__(:post_path, dup_post_id))
|
||||
|
||||
|
||||
else
|
||||
@upload.status
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class UserPresenter
|
||||
attr_reader :user
|
||||
|
||||
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
@@ -8,15 +8,15 @@ class UserPresenter
|
||||
def name
|
||||
user.pretty_name
|
||||
end
|
||||
|
||||
|
||||
def join_date
|
||||
user.created_at.strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
|
||||
def level
|
||||
user.level_string
|
||||
end
|
||||
|
||||
|
||||
def ban_reason
|
||||
if user.is_banned?
|
||||
"#{user.ban.reason}; expires #{user.ban.expires_at}"
|
||||
@@ -24,24 +24,24 @@ class UserPresenter
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def posts_for_subscription(subscription)
|
||||
Post.where("id in (?)", subscription.post_id_array.slice(0, 6).map(&:to_i)).order("id desc")
|
||||
end
|
||||
|
||||
|
||||
def tag_links_for_subscription(template, subscription)
|
||||
subscription.tag_query_array.map {|x| template.link_to(x.tr("_", " "), template.posts_path(:tags => x))}.join(", ").html_safe
|
||||
end
|
||||
|
||||
|
||||
def upload_limit
|
||||
if user.is_contributor?
|
||||
return "none"
|
||||
end
|
||||
|
||||
|
||||
deleted_count = Post.for_user(user.id).deleted.count
|
||||
pending_count = Post.for_user(user.id).pending.count
|
||||
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ?", user.id).count
|
||||
|
||||
|
||||
if user.base_upload_limit
|
||||
limit = user.base_upload_limit - pending_count
|
||||
string = "base:#{user.base_upload_limit} - pending:#{pending_count}"
|
||||
@@ -49,7 +49,7 @@ class UserPresenter
|
||||
limit = 10 + (approved_count / 10) - (deleted_count / 4) - pending_count
|
||||
string = "base:10 + approved:(#{approved_count} / 10) - deleted:(#{deleted_count}) / 4 - pending:#{pending_count}"
|
||||
end
|
||||
|
||||
|
||||
if limit < 0
|
||||
limit = 0
|
||||
string += " = 0"
|
||||
@@ -59,59 +59,59 @@ class UserPresenter
|
||||
|
||||
return string
|
||||
end
|
||||
|
||||
|
||||
def uploads
|
||||
@uploads ||= Post.where("uploader_id = ?", user.id).order("id desc").limit(6)
|
||||
end
|
||||
|
||||
|
||||
def has_uploads?
|
||||
user.post_upload_count > 0
|
||||
end
|
||||
|
||||
|
||||
def favorites
|
||||
@favorites ||= user.favorites.limit(6).includes(:post).reorder("favorites.id desc").map(&:post)
|
||||
end
|
||||
|
||||
|
||||
def has_favorites?
|
||||
user.favorite_count > 0
|
||||
end
|
||||
|
||||
|
||||
def upload_count(template)
|
||||
template.link_to(user.post_upload_count, template.posts_path(:tags => "user:#{user.name}"))
|
||||
end
|
||||
|
||||
|
||||
def deleted_upload_count(template)
|
||||
template.link_to(Post.for_user(user.id).deleted.count, template.posts_path(:tags => "status:deleted user:#{user.name}"))
|
||||
end
|
||||
|
||||
|
||||
def favorite_count(template)
|
||||
template.link_to(user.favorite_count, template.posts_path(:tags => "fav:#{user.name}"))
|
||||
end
|
||||
|
||||
|
||||
def comment_count(template)
|
||||
template.link_to(Comment.for_creator(user.id).count, template.comments_path(:search => {:creator_id => user.id}, :group_by => "comment"))
|
||||
end
|
||||
|
||||
|
||||
def post_version_count(template)
|
||||
template.link_to(user.post_update_count, template.post_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
|
||||
def note_version_count(template)
|
||||
template.link_to(user.note_update_count, template.note_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
|
||||
def wiki_page_version_count(template)
|
||||
template.link_to(WikiPageVersion.for_user(user.id).count, template.wiki_page_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
|
||||
def forum_post_count(template)
|
||||
template.link_to(ForumPost.for_user(user.id).count, template.forum_posts_path(:search => {:creator_id => user.id}))
|
||||
end
|
||||
|
||||
|
||||
def pool_version_count(template)
|
||||
template.link_to(PoolVersion.for_user(user.id).count, template.pool_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
|
||||
def inviter(template)
|
||||
if user.inviter_id
|
||||
template.link_to(user.inviter.name, template.user_path(user.inviter_id))
|
||||
@@ -119,19 +119,19 @@ class UserPresenter
|
||||
"None"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def approval_count(template)
|
||||
template.link_to(Post.where("approver_id = ?", user.id).count, template.posts_path(:tags => "approver:#{user.name}"))
|
||||
end
|
||||
|
||||
|
||||
def feedbacks(template)
|
||||
positive = UserFeedback.for_user(user.id).positive.count
|
||||
neutral = UserFeedback.for_user(user.id).neutral.count
|
||||
negative = UserFeedback.for_user(user.id).negative.count
|
||||
|
||||
|
||||
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id}))
|
||||
end
|
||||
|
||||
|
||||
def subscriptions
|
||||
if CurrentUser.user.id == user.id
|
||||
user.subscriptions
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
class WikiPagePresenter
|
||||
attr_reader :wiki_page
|
||||
|
||||
|
||||
def initialize(wiki_page)
|
||||
@wiki_page = wiki_page
|
||||
end
|
||||
|
||||
|
||||
def excerpt
|
||||
wiki_page.body
|
||||
end
|
||||
|
||||
|
||||
def blurb
|
||||
excerpt.try(:gsub, /<.+?>/, "")
|
||||
end
|
||||
|
||||
|
||||
def consequent_tag_aliases
|
||||
@consequent_tag_aliases ||= TagAlias.where("consequent_name = ?", wiki_page.title)
|
||||
end
|
||||
|
||||
|
||||
def antecedent_tag_alias
|
||||
@antecedent_tag_alias ||= TagAlias.find_by_antecedent_name(wiki_page.title)
|
||||
end
|
||||
|
||||
|
||||
# Produce a formatted page that shows the difference between two versions of a page.
|
||||
def diff(other_version)
|
||||
pattern = Regexp.new('(?:<.+?>)|(?:[0-9_A-Za-z\x80-\xff]+[\x09\x20]?)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
||||
|
||||
Reference in New Issue
Block a user