Merge pull request #6518 from opf/fix/wiki-history-and-annotate

[28185] Fix wiki history and annotate

[ci skip]
pull/6519/head
Oliver Günther 6 years ago committed by GitHub
commit 3d8e95cc15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/models/journal/base_journal.rb
  2. 6
      app/models/wiki_page.rb
  3. 10
      app/views/wiki/history.html.erb

@ -30,6 +30,7 @@ class Journal::BaseJournal < ActiveRecord::Base
self.abstract_class = true
belongs_to :journal
belongs_to :author, class_name: 'User', foreign_key: :author_id
def journaled_attributes
attributes.symbolize_keys.select { |k, _| self.class.journaled_attributes.include? k }

@ -284,19 +284,19 @@ class WikiAnnotate
def initialize(content)
@content = content
current = content
current_lines = current.journable.text.split(/\r?\n/)
current_lines = current.data.text.split(/\r?\n/)
@lines = current_lines.map { |t| [nil, nil, t] }
positions = []
current_lines.size.times do |i| positions << i end
while current.previous
d = current.previous.journable.text.split(/\r?\n/).diff(current.journable.text.split(/\r?\n/)).diffs.flatten
d = current.previous.data.text.split(/\r?\n/).diff(current.data.text.split(/\r?\n/)).diffs.flatten
d.each_slice(3) do |s|
sign = s[0]
line = s[1]
if sign == '+' && positions[line] && positions[line] != -1
if @lines[positions[line]][0].nil?
@lines[positions[line]][0] = current.version
@lines[positions[line]][1] = current.journable.author
@lines[positions[line]][1] = current.data.author
end
end
end

@ -122,9 +122,10 @@ See docs/COPYRIGHT.rdoc for more details.
<%= radio_button_tag 'version',
ver.version,
(line_num==1),
class: 'history-cb-from',
data: { 'select-to': "#cbto-#{line_num + 1}" },
id: "cb-#{line_num}" %>
<% end %>
<% csp_onclick("jQuery('#cbto-#{line_num+1}').attr('checked', true);", "#cb-#{line_num}") %>
</td>
<td class="checkbox">
<% if show_diff && (line_num > 1) %>
@ -148,5 +149,12 @@ See docs/COPYRIGHT.rdoc for more details.
<%= submit_tag l(:label_view_diff), class: 'button -highlight -small' if show_diff %>
</div>
<%= nonced_javascript_tag do -%>
jQuery(function($) {
$('.history-cb-from').click(function() {
var target = $($(this).data('selectTo')).prop('checked', true);
});
});
<% end -%>
<%= pagination_links_full @versions %>
<% end %>

Loading…
Cancel
Save