Changesets can be listed by changeset number.
The Git repository is here.
Changeset 367
Final file in the Instiki changes for 0.19.1 and ROOL customisation;
looks like this got missed out in Changeset #344/Changeset #345. It
is part of the original 0.19.1 distribution.
- Comitted by: rool
- Date: Saturday March 19 22:08:12 2011 (over 13 years ago)
Affected files:
rool/rails/instiki/trunk/lib/page_renderer.rb:
prev. | current | |
@display_published ||= render(:mode => :publish) | ||
end | ||
40 | require 'hpricot' | |
41 | ||
def display_diff | ||
previous_revision = @revision.page.previous_revision(@revision) | ||
if previous_revision | ||
46 | # Pass one: Normal Instiki behaviour | |
47 | ||
previous_content = "<div>" + WikiContent.new(previous_revision, @@url_generator).render!.to_s + "</div>" | ||
45 | | |
49 | current_content = "<div>" + display_content.to_s + "</div>" | |
diff_doc = REXML::Document.new | ||
div = REXML::Element.new('div', nil, {:respect_whitespace =>:all}) | ||
div.attributes['class'] = 'xhtmldiff_wrapper' | ||
diff_doc << div | ||
50 | | |
52 | | |
53 | | |
54 | | |
55 | | |
56 | | |
55 | begin | |
58 | | |
59 | | |
60 | | |
57 | # Allow exceptions here. We expect them from REXML. | |
58 | ||
59 | parsed_previous_revision = REXML::HashableElementDelegator.new( | |
60 | REXML::XPath.first(REXML::Document.new(previous_content), '/div')) | |
61 | parsed_display_content = REXML::HashableElementDelegator.new( | |
62 | REXML::XPath.first(REXML::Document.new(current_content), '/div')) | |
63 | ||
64 | hd = XHTMLDiff.new(div) | |
65 | Diff::LCS.traverse_balanced(parsed_previous_revision, parsed_display_content, hd) | |
66 | ||
67 | diffs = '' | |
68 | diff_doc.write(diffs, -1, true, true) | |
69 | diffs.gsub(/\A<div class='xhtmldiff_wrapper'>(.*)<\/div>\Z/m, '\1').html_safe | |
70 | ||
71 | rescue | |
72 | ||
73 | # To reach here, REXML probably complained. Users probably wrote HTML | |
74 | # in the page, but the markup was invalid XHTML - forgetting to close | |
75 | # "<li>" tags is a common example. So, try the diff again, this time | |
76 | # using Hpricot as a wrapper around the post-processed content to try | |
77 | # and sanitise the markup at the possible expense of correctness. | |
78 | ||
79 | begin | |
80 | ||
81 | previous_content = "<div>" + Hpricot(WikiContent.new(previous_revision, @@url_generator).render!.to_s).to_s + "</div>" | |
82 | current_content = "<div>" + Hpricot(display_content.to_s).to_s + "</div>" | |
83 | ||
84 | parsed_previous_revision = REXML::HashableElementDelegator.new( | |
85 | REXML::XPath.first(REXML::Document.new(previous_content), '/div')) | |
86 | parsed_display_content = REXML::HashableElementDelegator.new( | |
87 | REXML::XPath.first(REXML::Document.new(current_content), '/div')) | |
88 | ||
89 | hd = XHTMLDiff.new(div) | |
90 | Diff::LCS.traverse_balanced(parsed_previous_revision, parsed_display_content, hd) | |
91 | ||
92 | diffs = "<p><ins class=\"diffins\"><strong>Warning: The current and/or previous revision contained markup errors which prevented proper diff analysis. A guess at markup correction has been made but the diff may not be a truly accurate reflection of the real changes.</strong></ins></p>" | |
93 | diff_doc.write(diffs, -1, true, true) | |
94 | diffs.gsub(/\A<div class='xhtmldiff_wrapper'>(.*)<\/div>\Z/m, '\1').html_safe | |
95 | ||
96 | rescue | |
97 | ||
98 | # Further exceptions indicate a lost cause! | |
99 | "<p><ins class=\"diffins\"><strong>The current and/or previous revision contain invalid markup which is too broken for the diff parser to understand.</strong></ins></p>".html_safe | |
100 | ||
101 | end | |
102 | end | |
else | ||
display_content | ||
end | ||
... | ... | |
# Returns an array of all the WikiWords present in the content of this revision. | ||
def wiki_words | ||
98 | | |
140 | @wiki_words_cache ||= find_wiki_words(display_content) | |
end | ||
def find_wiki_words(rendering_result) |