* Reworked how post versioning works, now more closely resembles the 1.18 strategy

This commit is contained in:
albert
2011-01-26 18:10:49 -05:00
parent 683d4583ac
commit f7e2344b9f
21 changed files with 292 additions and 308 deletions

View File

@@ -1,25 +0,0 @@
class PostHistoryRevisionPresenter < Presenter
attr_reader :revision
def initialize(revision)
@revision = revision
end
def changes
html = []
html << revision.diff[:del].map {|x| "<del>#{h(x)}</del>"}
html << revision.diff[:add].map {|x| "<ins>#{h(x)}</ins>"}
html << "<ins>source:#{h(revision.diff[:source])}</ins>" if revision.diff[:source].present?
html << "<ins>rating:#{h(revision.diff[:rating])}</ins>" if revision.diff[:rating].present?
html << "<ins>parent:#{revision.diff[:parent_id]}</ins>" if revision.diff[:parent_id].present?
html.join(" ").html_safe
end
def updated_at
Time.parse(revision.updated_at)
end
def updater_name
User.id_to_name(revision.user_id)
end
end

View File

@@ -0,0 +1,21 @@
class PostVersionPresenter < Presenter
attr_reader :post_version
def initialize(post_version)
@post_version = post_version
end
def changes
html = []
html << post_version.del_tag_array.map {|x| "<del>#{h(x)}</del>"}
html << post_version.add_tag_array.map {|x| "<ins>#{h(x)}</ins>"}
html << "<ins>source:#{h(post_version.source)}</ins>" if post_version.source
html << "<ins>rating:#{h(post_version.rating)}</ins>" if post_version.rating
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
end