add diff link on wiki page versions (#1622)
This commit is contained in:
@@ -4,6 +4,8 @@ class WikiPageVersion < ApplicationRecord
|
||||
belongs_to :artist, optional: true
|
||||
delegate :visible?, :to => :wiki_page
|
||||
|
||||
extend Memoist
|
||||
|
||||
module SearchMethods
|
||||
def for_user(user_id)
|
||||
where("updater_id = ?", user_id)
|
||||
@@ -35,6 +37,11 @@ class WikiPageVersion < ApplicationRecord
|
||||
title.tr("_", " ")
|
||||
end
|
||||
|
||||
def previous
|
||||
WikiPageVersion.where("wiki_page_id = ? and id < ?", wiki_page_id, id).order("id desc").first
|
||||
end
|
||||
memoize :previous
|
||||
|
||||
def category_name
|
||||
Tag.category_for(title)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= render "wiki_pages/quick_search" %></li>
|
||||
|
||||
<%= subnav_link_to "Listing", wiki_pages_path %>
|
||||
|
||||
<%= subnav_link_to "Search", search_wiki_pages_path %>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
@@ -12,20 +14,33 @@
|
||||
|
||||
<% if @wiki_page && @wiki_page.new_record? && @wiki_page.try(:tag).present? %>
|
||||
<li>|</li>
|
||||
|
||||
<%= subnav_link_to "Posts (#{@wiki_page.tag.post_count})", posts_path(:tags => @wiki_page.title) %>
|
||||
|
||||
<% elsif @wiki_page && !@wiki_page.new_record? %>
|
||||
<li>|</li>
|
||||
|
||||
<%= subnav_link_to "Posts (#{@wiki_page.tag.try(:post_count) || 0})", posts_path(:tags => @wiki_page.title) %>
|
||||
|
||||
<%= subnav_link_to "History", wiki_page_versions_path(:search => {:wiki_page_id => @wiki_page.id}) %>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
<%= subnav_link_to "Edit", edit_wiki_page_path(@wiki_page), "data-shortcut": "e" %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_builder? && !@wiki_page.is_deleted? %>
|
||||
<%= subnav_link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :"data-shortcut" => "shift+d", :"data-confirm" => "Are you sure you want to delete this wiki page?" %>
|
||||
<% end %>
|
||||
|
||||
<% elsif @wiki_page_version %>
|
||||
<li>|</li>
|
||||
|
||||
<%= subnav_link_to "Newest", wiki_page_path(@wiki_page_version.wiki_page_id) %>
|
||||
|
||||
<% if @wiki_page_version.previous %>
|
||||
<%= subnav_link_to "Diff", diff_wiki_page_versions_path(:otherpage => @wiki_page_version.id, :thispage => @wiki_page_version.previous.id) %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
<%= subnav_link_to "Revert to", revert_wiki_page_path(@wiki_page_version.wiki_page_id, :version_id => @wiki_page_version.id), :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
|
||||
<% end %>
|
||||
|
||||
@@ -51,4 +51,4 @@ Disallow: /users
|
||||
Disallow: /wiki_page_versions
|
||||
Disallow: /wiki_pages/new
|
||||
Disallow: /wiki_pages/revert
|
||||
Disallow: /wiki_pages/show_or_new
|
||||
Disallow: /wiki_pages/show_or_new
|
||||
Reference in New Issue
Block a user