Pool versions diff: Use diff builder to highlight description changes
- Add highlights for name changes - Separate and name the sections
This commit is contained in:
@@ -18,4 +18,9 @@ module PoolVersionsHelper
|
||||
status += ["Deactivated"] if !cur.is_active? && prev.is_active?
|
||||
status.join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
def pool_page_diff(pool_version, other_version)
|
||||
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
||||
DiffBuilder.new(other_version.description, pool_version.description, pattern).build
|
||||
end
|
||||
end
|
||||
13
app/javascript/src/styles/specific/pool_versions.scss
Normal file
13
app/javascript/src/styles/specific/pool_versions.scss
Normal file
@@ -0,0 +1,13 @@
|
||||
div#c-pool-versions {
|
||||
#a-diff {
|
||||
del {
|
||||
background: var(--wiki-page-versions-diff-del-background);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
ins {
|
||||
background: var(--wiki-page-versions-diff-ins-background);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,33 @@
|
||||
<div id="a-diff">
|
||||
<h1>Pool Version Comparison: <%= @pool_version.name %></h1>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Posts</strong>:
|
||||
<%= render "pool_versions/diff", diff: @pool_version.build_diff(@other_version) %>
|
||||
</li>
|
||||
<% if @other_version %>
|
||||
<li><strong>Old Desc</strong>: <%= @other_version.description %></li>
|
||||
<% end %>
|
||||
<li><strong>New Desc</strong>: <%= @pool_version.description %></li>
|
||||
</ul>
|
||||
<% if @other_version.present? %>
|
||||
<p>Showing differences between <%= compact_time @pool_version.updated_at %> (<%= link_to_user @pool_version.updater %>) and <%= compact_time @other_version.updated_at %> (<%= link_to_user @other_version.updater %>)</p>
|
||||
<div>
|
||||
<h2>Name:</h2>
|
||||
<p>
|
||||
<% if @pool_version.name != @other_version.name %>
|
||||
<del><%= @other_version.name %></del> -> <ins><%= @pool_version.name %></ins>
|
||||
<% else %>
|
||||
<%= @pool_version.name %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Posts:</h2>
|
||||
<p><%= render "pool_versions/diff", diff: @pool_version.build_diff(@other_version) %></p>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Description:</h2>
|
||||
<p>
|
||||
<% if @pool_version.description != @other_version.description %>
|
||||
<%= pool_page_diff(@pool_version, @other_version) %>
|
||||
<% else %>
|
||||
<i>Unchanged.</i>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user