/wiki_page_versions: various usability improvements.
Changes to the /wiki_page_versions global listing: * Add "diff" links that show you what changed in the given edit. * Add "?" links that take you to the current version of the wiki. * Add "»" links next to wiki page titles that take you to the wiki's full edit history. * Add "»" links next to usernames that take you to the user's full edit history. * Add a "Status" column that shows whether the wiki page was created, deleted, undeleted, or renamed. * Link to /wiki_page_versions in sidebar, not /wiki_pages?order=time.
This commit is contained in:
@@ -1,4 +1,17 @@
|
|||||||
module WikiPageVersionsHelper
|
module WikiPageVersionsHelper
|
||||||
|
def wiki_page_version_status_diff(wiki_page_version)
|
||||||
|
cur = wiki_page_version
|
||||||
|
prev = wiki_page_version.previous
|
||||||
|
|
||||||
|
return "New" if prev.blank?
|
||||||
|
|
||||||
|
status = []
|
||||||
|
status += ["Renamed"] if cur.title != prev.title
|
||||||
|
status += ["Deleted"] if cur.is_deleted? && !prev.is_deleted?
|
||||||
|
status += ["Undeleted"] if !cur.is_deleted? && prev.is_deleted?
|
||||||
|
status.join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
def wiki_page_diff(thispage, otherpage)
|
def wiki_page_diff(thispage, otherpage)
|
||||||
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
||||||
other_names_pattern = Regexp.new('\S+|\s+')
|
other_names_pattern = Regexp.new('\S+|\s+')
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ class WikiPageVersion < ApplicationRecord
|
|||||||
belongs_to :artist, optional: true
|
belongs_to :artist, optional: true
|
||||||
delegate :visible?, :to => :wiki_page
|
delegate :visible?, :to => :wiki_page
|
||||||
|
|
||||||
extend Memoist
|
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def for_user(user_id)
|
def for_user(user_id)
|
||||||
where("updater_id = ?", user_id)
|
where("updater_id = ?", user_id)
|
||||||
@@ -41,7 +39,6 @@ class WikiPageVersion < ApplicationRecord
|
|||||||
def previous
|
def previous
|
||||||
WikiPageVersion.where("wiki_page_id = ? and id < ?", wiki_page_id, id).order("id desc").first
|
WikiPageVersion.where("wiki_page_id = ? and id < ?", wiki_page_id, id).order("id desc").first
|
||||||
end
|
end
|
||||||
memoize :previous
|
|
||||||
|
|
||||||
def category_name
|
def category_name
|
||||||
Tag.category_for(title)
|
Tag.category_for(title)
|
||||||
|
|||||||
@@ -2,34 +2,32 @@
|
|||||||
<table width="100%" class="striped">
|
<table width="100%" class="striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="3%"></th>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th width="3%">Del</th>
|
<th width="5%">Status</th>
|
||||||
<th width="5%"></th>
|
|
||||||
<% if CurrentUser.is_moderator? %>
|
|
||||||
<th width="10%">IP Address</th>
|
|
||||||
<% end %>
|
|
||||||
<th width="26%">Last edited</th>
|
<th width="26%">Last edited</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @wiki_page_versions.each do |wiki_page_version| %>
|
<% @wiki_page_versions.each do |wiki_page_version| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="category-<%= wiki_page_version.category_name %>">
|
<td>
|
||||||
<%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %>
|
<%= link_to_if wiki_page_version.previous.present?, "diff", diff_wiki_page_versions_path(otherpage: wiki_page_version.previous.try(:id), thispage: wiki_page_version.id) %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= wiki_page_version.is_deleted? ? "Y" : "" %></td>
|
<td class="category-<%= wiki_page_version.category_name %>">
|
||||||
<td><%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %></td>
|
<%= link_to "?", wiki_page_path(wiki_page_version.wiki_page_id) %>
|
||||||
<% if CurrentUser.is_moderator? %>
|
<%= link_to wiki_page_version.title, wiki_page_version %>
|
||||||
<td>
|
<%= link_to "»", wiki_page_versions_path(search: { wiki_page_id: wiki_page_version.wiki_page_id }) %>
|
||||||
<%= link_to_ip wiki_page_version.updater_ip_addr %>
|
</td>
|
||||||
</td>
|
<td><%= wiki_page_version_status_diff(wiki_page_version) %></td>
|
||||||
<% end %>
|
|
||||||
<td>
|
<td>
|
||||||
<%= compact_time(wiki_page_version.updated_at) %>
|
<%= compact_time(wiki_page_version.updated_at) %>
|
||||||
<% if wiki_page_version.updater %>
|
by
|
||||||
by
|
<%= link_to_user wiki_page_version.updater %>
|
||||||
<%= link_to_user wiki_page_version.updater %>
|
<% if CurrentUser.is_moderator? %>
|
||||||
|
(<%= link_to_ip wiki_page_version.updater_ip_addr %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= link_to "»", wiki_page_versions_path(search: { updater_id: wiki_page_version.updater.id }) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -6,13 +6,8 @@
|
|||||||
<th width="3%"></th>
|
<th width="3%"></th>
|
||||||
<th width="2%"></th>
|
<th width="2%"></th>
|
||||||
<th width="2%"></th>
|
<th width="2%"></th>
|
||||||
|
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th width="3%">Del</th>
|
<th width="5%">Status</th>
|
||||||
<th width="5%"></th>
|
|
||||||
<% if CurrentUser.is_moderator? %>
|
|
||||||
<th width="10%">IP Address</th>
|
|
||||||
<% end %>
|
|
||||||
<th width="26%">Last edited</th>
|
<th width="26%">Last edited</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -30,21 +25,18 @@
|
|||||||
<td><%= radio_button_tag "otherpage", wiki_page_version.id, (i == 0) %></td>
|
<td><%= radio_button_tag "otherpage", wiki_page_version.id, (i == 0) %></td>
|
||||||
|
|
||||||
<td class="category-<%= wiki_page_version.category_name %>">
|
<td class="category-<%= wiki_page_version.category_name %>">
|
||||||
<%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %>
|
<%= link_to "?", wiki_page_path(wiki_page_version.wiki_page_id) %>
|
||||||
|
<%= link_to wiki_page_version.title, wiki_page_version %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= wiki_page_version.is_deleted? ? "Y" : "" %></td>
|
<td><%= wiki_page_version_status_diff(wiki_page_version) %></td>
|
||||||
<td><%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %></td>
|
|
||||||
<% if CurrentUser.is_moderator? %>
|
|
||||||
<td>
|
|
||||||
<%= link_to_ip wiki_page_version.updater_ip_addr %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
<td>
|
<td>
|
||||||
<%= compact_time(wiki_page_version.updated_at) %>
|
<%= compact_time(wiki_page_version.updated_at) %>
|
||||||
<% if wiki_page_version.updater %>
|
by
|
||||||
by
|
<%= link_to_user wiki_page_version.updater %>
|
||||||
<%= link_to_user wiki_page_version.updater %>
|
<% if CurrentUser.is_moderator? %>
|
||||||
|
(<%= link_to_ip wiki_page_version.updater_ip_addr %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= link_to "»", wiki_page_versions_path(search: { updater_id: wiki_page_version.updater.id }) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<%= render "wiki_pages/sidebar" %>
|
<%= render "wiki_pages/sidebar" %>
|
||||||
|
|
||||||
<section id="content">
|
<section id="content">
|
||||||
<h1>Wiki Pages</h1>
|
<h1>Wiki Page History</h1>
|
||||||
|
|
||||||
<% if params.dig(:search, :wiki_page_id).present? %>
|
<% if params.dig(:search, :wiki_page_id).present? %>
|
||||||
<%= render "page_listing" %>
|
<%= render "page_listing" %>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<section>
|
<section>
|
||||||
<h1>Recent Changes (<%= link_to "all", wiki_pages_path(:order => "time") %>)</h1>
|
<h1>Recent Changes (<%= link_to "all", wiki_page_versions_path %>)</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<% WikiPage.recent.each do |page| %>
|
<% WikiPage.recent.each do |page| %>
|
||||||
<li class="category-<%= page.category_name %>"><%= link_to page.pretty_title, wiki_page_path(page) %></li>
|
<li class="category-<%= page.category_name %>"><%= link_to page.pretty_title, wiki_page_path(page) %></li>
|
||||||
|
|||||||
Reference in New Issue
Block a user