Merge branch 'master' of github.com:r888888888/danbooru
This commit is contained in:
@@ -243,7 +243,7 @@ div#c-posts {
|
|||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pool-nav, #search-seq-nav, #nav-help {
|
#pool-nav, #search-seq-nav {
|
||||||
li {
|
li {
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -13,4 +13,12 @@ class PostVersionsController < ApplicationController
|
|||||||
|
|
||||||
def search
|
def search
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def undo
|
||||||
|
@post_version = PostVersion.find(params[:id])
|
||||||
|
@post_version.undo!
|
||||||
|
respond_with(@post_version) do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ class PostsController < ApplicationController
|
|||||||
respond_with(@posts) do |format|
|
respond_with(@posts) do |format|
|
||||||
format.atom
|
format.atom
|
||||||
format.xml do
|
format.xml do
|
||||||
render :xml => @posts.to_xml(:root => "posts") {|builder|
|
render :xml => @posts.to_xml(:root => "posts")
|
||||||
builder.tag!("total-count", @posts.total_count)
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -112,4 +112,31 @@ class PostVersion < ActiveRecord::Base
|
|||||||
def truncated_source
|
def truncated_source
|
||||||
source.gsub(/^http:\/\//, "").sub(/\/.+/, "")
|
source.gsub(/^http:\/\//, "").sub(/\/.+/, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def undo
|
||||||
|
changes = diff(previous)
|
||||||
|
added = changes[:added_tags] - changes[:obsolete_added_tags]
|
||||||
|
removed = changes[:removed_tags] - changes[:obsolete_removed_tags]
|
||||||
|
|
||||||
|
added.each do |tag|
|
||||||
|
if tag =~ /^source:/
|
||||||
|
post.source = ""
|
||||||
|
else
|
||||||
|
escaped_tag = Regexp.escape(tag)
|
||||||
|
post.tag_string = post.tag_string.sub(/(?:\A| )#{escaped_tag}(?:\Z| )/, " ").strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
removed.each do |tag|
|
||||||
|
if tag =~ /^source:(.+)$/
|
||||||
|
post.source = $1
|
||||||
|
else
|
||||||
|
post.tag_string = "#{post.tag_string} #{tag}".strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def undo!
|
||||||
|
undo
|
||||||
|
post.save!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
<td><%= post_version_diff(post_version) %></td>
|
<td><%= post_version_diff(post_version) %></td>
|
||||||
<% if CurrentUser.is_member? %>
|
<% if CurrentUser.is_member? %>
|
||||||
<td>
|
<td>
|
||||||
|
<% if post_version.id != post_version.post.versions.first.id %>
|
||||||
|
<%= link_to "Undo", undo_post_version_path(post_version), :method => :put, :remote => true %> |
|
||||||
|
<% end %>
|
||||||
<%= link_to "Revert to", revert_post_path(post_version.post_id, :version_id => post_version.id), :method => :put, :remote => true %>
|
<%= link_to "Revert to", revert_post_path(post_version.post_id, :version_id => post_version.id), :method => :put, :remote => true %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
1
app/views/post_versions/undo.js.erb
Normal file
1
app/views/post_versions/undo.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
location.reload();
|
||||||
@@ -159,6 +159,9 @@ Danbooru::Application.routes.draw do
|
|||||||
resources :post_appeals
|
resources :post_appeals
|
||||||
resources :post_flags
|
resources :post_flags
|
||||||
resources :post_versions, :only => [:index, :search] do
|
resources :post_versions, :only => [:index, :search] do
|
||||||
|
member do
|
||||||
|
put :undo
|
||||||
|
end
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user