Merge branch 'master' of github.com:r888888888/danbooru
This commit is contained in:
@@ -106,9 +106,9 @@
|
||||
}
|
||||
|
||||
var $post = $(post);
|
||||
var tags = String($post.data("tags")).match(/\S+/g) || [];
|
||||
var tags = String($post.attr("data-tags")).match(/\S+/g) || [];
|
||||
tags.push("rating:" + $post.data("rating"));
|
||||
tags.push("user:" + $post.data("user"));
|
||||
tags.push("user:" + $post.attr("data-uploader").toLowerCase().replace(/ /g, "_"));
|
||||
$.each(String($post.data("flags")).match(/\S+/g) || [], function(i, v) {
|
||||
tags.push("status:" + v);
|
||||
});
|
||||
|
||||
@@ -16,6 +16,14 @@ $(function() {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#hide-dmail-notice").click(function(e) {
|
||||
$dmail_notice = $("#dmail-notice")
|
||||
$dmail_notice.hide();
|
||||
var dmail_id = $dmail_notice.data("id");
|
||||
Danbooru.Cookie.put("hide_dmail_notice", dmail_id);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#close-notice-link").click(function(e) {
|
||||
$('#notice').fadeOut("fast");
|
||||
e.preventDefault();
|
||||
|
||||
@@ -126,9 +126,15 @@ Danbooru.Note = {
|
||||
if ((new Date).getTime() < Danbooru.Note.ignore_click_until) {
|
||||
return;
|
||||
}
|
||||
var is_hidden = document.getElementById('note-container').style.display == 'none';
|
||||
// Why does toggle() not work here?
|
||||
$("#note-container").toggle(is_hidden);
|
||||
var $note_container = $("#note-container");
|
||||
var is_hidden = ($note_container.css('visibility') === 'hidden');
|
||||
|
||||
if (is_hidden) {
|
||||
$note_container.css('visibility', 'visible');
|
||||
}
|
||||
else {
|
||||
$note_container.css('visibility', 'hidden');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -290,8 +296,9 @@ Danbooru.Note = {
|
||||
|
||||
$textarea = $('<textarea></textarea>');
|
||||
$textarea.css({
|
||||
width: "95%",
|
||||
height: "10em"
|
||||
width: "97%",
|
||||
height: "95%",
|
||||
resize: "none",
|
||||
});
|
||||
|
||||
if ($note_body.html() !== "<em>Click to edit</em>") {
|
||||
@@ -303,6 +310,7 @@ Danbooru.Note = {
|
||||
$dialog.data("id", $note_body.data("id"));
|
||||
$dialog.dialog({
|
||||
width: 360,
|
||||
height: 210,
|
||||
dialogClass: "note-edit-dialog",
|
||||
title: "Edit note",
|
||||
buttons: {
|
||||
@@ -473,7 +481,7 @@ Danbooru.Note = {
|
||||
Danbooru.Note.new(e.pageX - offset.left, e.pageY - offset.top);
|
||||
}
|
||||
Danbooru.Note.TranslationMode.stop();
|
||||
$("#note-container").show();
|
||||
$("#note-container").css('visibility', 'visible');
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
$("#c-pool-elements #a-new input[type=text]").autocomplete({
|
||||
source: function(req, resp) {
|
||||
$.getJSON(
|
||||
"/pools.json?search[name_matches]=" + req.term,
|
||||
"/pools.json?search[is_active]=true&search[name_matches]=" + req.term,
|
||||
function(data) {
|
||||
resp(data.map(function(x) {return x.name.replace(/_/g, " ");}));
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
Danbooru.Post.update_data(data);
|
||||
$("#post_" + data.id).effect("shake", {distance: 5, times: 1}, 100);
|
||||
Danbooru.notice("Post #" + data.id + " updated");
|
||||
$("#quick-edit-div").slideUp("fast");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -133,6 +133,29 @@
|
||||
$("#post_tag_string").trigger("focus");
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#copy-notes").click(function(e) {
|
||||
var current_post_id = $("meta[name=post-id]").attr("content");
|
||||
var other_post_id = prompt("Enter the ID of the post to copy all notes to:");
|
||||
|
||||
if (other_post_id !== null) {
|
||||
$.ajax("/posts/" + current_post_id + "/copy_notes", {
|
||||
type: "PUT",
|
||||
data: {
|
||||
other_post_id: other_post_id
|
||||
},
|
||||
complete: function(data) {
|
||||
if (data.status === 200) {
|
||||
Danbooru.notice("Successfully copied notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
|
||||
} else {
|
||||
Danbooru.error("There was an error copying notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
Danbooru.Post.initialize_post_relationship_previews = function() {
|
||||
@@ -341,7 +364,7 @@
|
||||
|
||||
Danbooru.Post.update_data = function(data) {
|
||||
var $post = $("#post_" + data.id);
|
||||
$post.data("tags", data.tag_string);
|
||||
$post.attr("data-tags", data.tag_string);
|
||||
$post.data("rating", data.rating);
|
||||
Danbooru.Post.initialize_title_for($post);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
tags.push([" none", 0]);
|
||||
} else if (Danbooru.RelatedTag.recent_artists.length === 1) {
|
||||
tags.push([Danbooru.RelatedTag.recent_artists[0].name, 1]);
|
||||
if (Danbooru.RelatedTag.recent_artists[0].is_banned === true) {
|
||||
tags.push(["BANNED_ARTIST", "banned"]);
|
||||
}
|
||||
$.each(Danbooru.RelatedTag.recent_artists[0].urls, function(i, url) {
|
||||
tags.push([" " + url.url, 0]);
|
||||
});
|
||||
@@ -226,7 +229,10 @@
|
||||
Danbooru.RelatedTag.process_artist(Danbooru.RelatedTag.recent_artist);
|
||||
}
|
||||
|
||||
$field.focus();
|
||||
if ($(window).scrollTop() <= $field.offset().top + $field.outerHeight()) {
|
||||
$field.focus();
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,26 +65,31 @@ a.blacklisted-active {
|
||||
|
||||
.category-1 a, a.tag-type-1 {
|
||||
color: #A00;
|
||||
}
|
||||
|
||||
.category-1 a:hover, a.tag-type-1:hover {
|
||||
color: #B66;
|
||||
&:hover {
|
||||
color: #B66;
|
||||
}
|
||||
}
|
||||
|
||||
.category-3 a, a.tag-type-3 {
|
||||
color: #A0A;
|
||||
}
|
||||
|
||||
.category-3 a:hover, a.tag-type-3:hover {
|
||||
color: #B6B;
|
||||
&:hover {
|
||||
color: #B6B;
|
||||
}
|
||||
}
|
||||
|
||||
.category-4 a, a.tag-type-4 {
|
||||
color: #0A0;
|
||||
|
||||
&:hover {
|
||||
color: #6B6;
|
||||
}
|
||||
}
|
||||
|
||||
.category-4 a:hover, a.tag-type-4:hover {
|
||||
color: #6B6;
|
||||
.category-banned a, a.tag-type-banned {
|
||||
color: black;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.post-count {
|
||||
|
||||
@@ -2,7 +2,7 @@ class ArtistVersionsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@artist_versions = ArtistVersion.search(params[:search]).order("id desc").paginate(params[:page], :search_count => params[:search])
|
||||
@artist_versions = ArtistVersion.search(params[:search]).order("id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@artist_versions) do |format|
|
||||
format.xml do
|
||||
render :xml => @artist_versions.to_xml(:root => "artist-versions")
|
||||
|
||||
@@ -32,7 +32,7 @@ class ArtistsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@artists = Artist.search(params[:search] || params).order("id desc").paginate(params[:page])
|
||||
@artists = Artist.search(params[:search] || params).order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@artists) do |format|
|
||||
format.xml do
|
||||
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
||||
|
||||
@@ -11,7 +11,7 @@ class BansController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = Ban.search(params[:search]).order("id desc")
|
||||
@bans = @search.paginate(params[:page])
|
||||
@bans = @search.paginate(params[:page], :limit => params[:limit])
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -83,7 +83,7 @@ private
|
||||
end
|
||||
|
||||
def index_by_comment
|
||||
@comments = Comment.search(params[:search]).order("comments.id DESC").paginate(params[:page], :search_count => params[:search])
|
||||
@comments = Comment.search(params[:search]).order("comments.id DESC").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@comments) do |format|
|
||||
format.html {render :action => "index_by_comment"}
|
||||
format.xml do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class DelayedJobsController < ApplicationController
|
||||
def index
|
||||
@delayed_jobs = Delayed::Job.order("created_at desc").paginate(params[:page])
|
||||
@delayed_jobs = Delayed::Job.order("created_at desc").paginate(params[:page], :limit => params[:limit])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class DmailsController < ApplicationController
|
||||
def index
|
||||
cookies[:dmail_folder] = params[:folder]
|
||||
@search = Dmail.visible.search(params[:search])
|
||||
@dmails = @search.order("dmails.created_at desc").paginate(params[:page])
|
||||
@dmails = @search.order("dmails.created_at desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@dmails) do |format|
|
||||
format.xml do
|
||||
render :xml => @dmails.to_xml(:root => "dmails")
|
||||
|
||||
@@ -21,7 +21,7 @@ class ForumPostsController < ApplicationController
|
||||
else
|
||||
@search = ForumPost.active.search(params[:search])
|
||||
end
|
||||
@forum_posts = @search.order("forum_posts.id DESC").paginate(params[:page], :search_count => params[:search])
|
||||
@forum_posts = @search.order("forum_posts.id DESC").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@forum_posts) do |format|
|
||||
format.xml do
|
||||
render :xml => @forum_posts.to_xml(:root => "forum-posts")
|
||||
|
||||
@@ -19,7 +19,7 @@ class ForumTopicsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = ForumTopic.active.search(params[:search])
|
||||
@forum_topics = @search.order("is_sticky DESC, updated_at DESC").paginate(params[:page], :search_count => params[:search])
|
||||
@forum_topics = @search.order("is_sticky DESC, updated_at DESC").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@forum_topics) do |format|
|
||||
format.xml do
|
||||
render :xml => @forum_topics.to_xml(:root => "forum-topics")
|
||||
|
||||
@@ -17,7 +17,7 @@ class IpBansController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = IpBan.search(params[:search])
|
||||
@ip_bans = @search.order("id desc").paginate(params[:page])
|
||||
@ip_bans = @search.order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -14,7 +14,7 @@ class JanitorTrialsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = JanitorTrial.search(params[:search])
|
||||
@janitor_trials = @search.order("id desc").paginate(params[:page])
|
||||
@janitor_trials = @search.order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@janitor_trials)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ModActionsController < ApplicationController
|
||||
def index
|
||||
@mod_actions = ModAction.search(params[:search]).order("id desc").paginate(params[:page])
|
||||
@mod_actions = ModAction.search(params[:search]).order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class NewsUpdatesController < ApplicationController
|
||||
respond_to :html
|
||||
|
||||
def index
|
||||
@news_updates = NewsUpdate.order("id desc").paginate(params[:page])
|
||||
@news_updates = NewsUpdate.order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@news_updates)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class NoteVersionsController < ApplicationController
|
||||
before_filter :member_only, :except => [:index, :show]
|
||||
|
||||
def index
|
||||
@note_versions = NoteVersion.search(params[:search]).order("note_versions.id desc").paginate(params[:page])
|
||||
@note_versions = NoteVersion.search(params[:search]).order("note_versions.id desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@note_versions) do |format|
|
||||
format.xml do
|
||||
render :xml => @note_versions.to_xml(:root => "note-versions")
|
||||
|
||||
@@ -6,7 +6,7 @@ class PoolVersionsController < ApplicationController
|
||||
@pool = Pool.find(params[:search][:pool_id])
|
||||
end
|
||||
|
||||
@pool_versions = PoolVersion.search(params[:search]).order("updated_at desc").paginate(params[:page], :search_count => params[:search])
|
||||
@pool_versions = PoolVersion.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@pool_versions) do |format|
|
||||
format.xml do
|
||||
render :xml => @pool_versions.to_xml(:root => "pool-versions")
|
||||
|
||||
@@ -15,7 +15,7 @@ class PoolsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@pools = Pool.active.search(params[:search]).order("updated_at desc").paginate(params[:page], :search_count => params[:search])
|
||||
@pools = Pool.active.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@pools) do |format|
|
||||
format.xml do
|
||||
render :xml => @pools.to_xml(:root => "pools")
|
||||
@@ -52,6 +52,7 @@ class PoolsController < ApplicationController
|
||||
raise User::PrivilegeError
|
||||
end
|
||||
@pool.update_attribute(:is_deleted, true)
|
||||
@pool.create_mod_action_for_delete
|
||||
respond_with(@pool, :notice => "Pool deleted")
|
||||
end
|
||||
|
||||
@@ -61,6 +62,7 @@ class PoolsController < ApplicationController
|
||||
raise User::PrivilegeError
|
||||
end
|
||||
@pool.update_attribute(:is_deleted, false)
|
||||
@pool.create_mod_action_for_undelete
|
||||
respond_with(@pool, :notice => "Pool undeleted")
|
||||
end
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class PostAppealsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = PostAppeal.order("id desc").search(params[:search])
|
||||
@post_appeals = @search.paginate(params[:page])
|
||||
@post_appeals = @search.paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@post_appeals) do |format|
|
||||
format.xml do
|
||||
render :xml => @post_appeals.to_xml(:root => "post-appeals")
|
||||
|
||||
@@ -10,7 +10,7 @@ class PostFlagsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = PostFlag.order("id desc").search(params[:search])
|
||||
@post_flags = @search.paginate(params[:page])
|
||||
@post_flags = @search.paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@post_flags) do |format|
|
||||
format.xml do
|
||||
render :xml => @post_flags.to_xml(:root => "post-flags")
|
||||
|
||||
@@ -3,7 +3,7 @@ class PostVersionsController < ApplicationController
|
||||
rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception
|
||||
|
||||
def index
|
||||
@post_versions = PostVersion.search(params[:search]).order("updated_at desc").paginate(params[:page], :search_count => params[:search])
|
||||
@post_versions = PostVersion.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@post_versions) do |format|
|
||||
format.xml do
|
||||
render :xml => @post_versions.to_xml(:root => "post-versions")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class PostsController < ApplicationController
|
||||
before_filter :member_only, :except => [:show, :show_seq, :index]
|
||||
before_filter :builder_only, :only => [:copy_notes]
|
||||
after_filter :save_recent_tags, :only => [:update]
|
||||
respond_to :html, :xml, :json
|
||||
rescue_from PostSets::SearchError, :with => :rescue_exception
|
||||
@@ -14,7 +15,7 @@ class PostsController < ApplicationController
|
||||
format.atom
|
||||
format.xml do
|
||||
render :xml => @posts.to_xml(:root => "posts") {|builder|
|
||||
builder.tag!(:total_count, @posts.total_count)
|
||||
builder.tag!("total-count", @posts.total_count)
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -76,6 +77,13 @@ class PostsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def copy_notes
|
||||
@post = Post.find(params[:id])
|
||||
@other_post = Post.find(params[:other_post_id].to_i)
|
||||
@post.copy_notes_to(@other_post)
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
private
|
||||
def tag_query
|
||||
params[:tags] || (params[:post] && params[:post][:tags])
|
||||
|
||||
@@ -17,7 +17,7 @@ class TagAliasesController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = TagAlias.search(params[:search])
|
||||
@tag_aliases = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page])
|
||||
@tag_aliases = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@tag_aliases) do |format|
|
||||
format.xml do
|
||||
render :xml => @tag_aliases.to_xml(:root => "tag-aliases")
|
||||
|
||||
@@ -9,7 +9,7 @@ class TagImplicationsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = TagImplication.search(params[:search])
|
||||
@tag_implications = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page])
|
||||
@tag_implications = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@tag_implications) do |format|
|
||||
format.xml do
|
||||
render :xml => @tag_implications.to_xml(:root => "tag-implications")
|
||||
|
||||
@@ -17,7 +17,7 @@ class TagSubscriptionsController < ApplicationController
|
||||
def index
|
||||
@user = CurrentUser.user
|
||||
@search = TagSubscription.owned_by(@user).order("name").search(params[:search])
|
||||
@tag_subscriptions = @search.paginate(params[:page])
|
||||
@tag_subscriptions = @search.paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@tag_subscriptions)
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class TagsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@tags = Tag.search(params[:search]).paginate(params[:page], :search_count => params[:search])
|
||||
@tags = Tag.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@tags) do |format|
|
||||
format.xml do
|
||||
render :xml => @tags.to_xml(:root => "tags")
|
||||
|
||||
@@ -18,7 +18,7 @@ class UploadsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = Upload.search(params[:search])
|
||||
@uploads = @search.order("id desc").paginate(params[:page])
|
||||
@uploads = @search.order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@uploads) do |format|
|
||||
format.xml do
|
||||
render :xml => @uploads.to_xml(:root => "uploads")
|
||||
|
||||
@@ -21,7 +21,7 @@ class UserFeedbacksController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = UserFeedback.search(params[:search])
|
||||
@user_feedbacks = @search.paginate(params[:page]).order("created_at desc")
|
||||
@user_feedbacks = @search.paginate(params[:page], :limit => params[:limit]).order("created_at desc")
|
||||
respond_with(@user_feedbacks) do |format|
|
||||
format.xml do
|
||||
render :xml => @user_feedbacks.to_xml(:root => "user-feedbacks")
|
||||
|
||||
@@ -28,7 +28,7 @@ class UserNameChangeRequestsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@change_requests = UserNameChangeRequest.order("id desc").paginate(params[:page])
|
||||
@change_requests = UserNameChangeRequest.order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
end
|
||||
|
||||
def approve
|
||||
|
||||
@@ -19,7 +19,7 @@ class UsersController < ApplicationController
|
||||
@user = User.find_by_name(params[:name])
|
||||
redirect_to user_path(@user)
|
||||
else
|
||||
@users = User.search(params[:search]).order("users.id desc").paginate(params[:page], :search_count => params[:search])
|
||||
@users = User.search(params[:search]).order("users.id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@users) do |format|
|
||||
format.xml do
|
||||
render :xml => @users.to_xml(:root => "users")
|
||||
|
||||
@@ -2,7 +2,7 @@ class WikiPageVersionsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@wiki_page_versions = WikiPageVersion.search(params[:search]).order("id desc").paginate(params[:page], :search_count => params[:search])
|
||||
@wiki_page_versions = WikiPageVersion.search(params[:search]).order("id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@wiki_page_versions) do |format|
|
||||
format.xml do
|
||||
render :xml => @wiki_page_versions.to_xml(:root => "wiki-page-versions")
|
||||
|
||||
@@ -17,7 +17,7 @@ class WikiPagesController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@wiki_pages = WikiPage.search(params[:search]).order("updated_at desc").paginate(params[:page], :search_count => params[:search])
|
||||
@wiki_pages = WikiPage.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@wiki_pages) do |format|
|
||||
format.html do
|
||||
if @wiki_pages.count == 1 && (params[:page].nil? || params[:page].to_i == 1)
|
||||
|
||||
@@ -6,10 +6,6 @@ module PostSets
|
||||
@params = params
|
||||
@user = ::User.find(user_id)
|
||||
@favorites = ::Favorite.for_user(user.id).paginate(page, :limit => limit).order("favorites.id desc")
|
||||
|
||||
if CurrentUser.user.hide_deleted_posts?
|
||||
@favorites = @favorites.where("is_deleted = false")
|
||||
end
|
||||
end
|
||||
|
||||
def limit
|
||||
|
||||
@@ -7,6 +7,10 @@ class ArtistVersion < ActiveRecord::Base
|
||||
where("updater_id = ?", user_id)
|
||||
end
|
||||
|
||||
def updater_name(name)
|
||||
where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.mb_chars.downcase)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
@@ -15,6 +19,10 @@ class ArtistVersion < ActiveRecord::Base
|
||||
q = q.where("name like ? escape E'\\\\'", params[:name].to_escaped_for_sql_like)
|
||||
end
|
||||
|
||||
if params[:updater_name].present?
|
||||
q = q.updater_name(params[:updater_name])
|
||||
end
|
||||
|
||||
if params[:updater_id].present?
|
||||
q = q.for_user(params[:updater_id].to_i)
|
||||
end
|
||||
|
||||
@@ -174,6 +174,20 @@ class Note < ActiveRecord::Base
|
||||
save!
|
||||
end
|
||||
|
||||
def copy_to(new_post)
|
||||
new_note = dup
|
||||
new_note.post_id = new_post.id
|
||||
|
||||
width_ratio = new_post.image_width.to_f / post.image_width
|
||||
height_ratio = new_post.image_height.to_f / post.image_height
|
||||
new_note.x = x * width_ratio
|
||||
new_note.y = y * height_ratio
|
||||
new_note.width = width * width_ratio
|
||||
new_note.height = height * height_ratio
|
||||
|
||||
new_note.save
|
||||
end
|
||||
|
||||
def self.undo_changes_by_user(user_id)
|
||||
transaction do
|
||||
notes = Note.joins(:versions).where(["note_versions.updater_id = ?", user_id]).select("DISTINCT notes.*").all
|
||||
|
||||
@@ -49,8 +49,13 @@ class Pool < ActiveRecord::Base
|
||||
q = q.where("is_active = false")
|
||||
end
|
||||
|
||||
if params[:sort] == "name"
|
||||
case params[:sort]
|
||||
when "name"
|
||||
q = q.order("name")
|
||||
when "created_at"
|
||||
q = q.order("created_at desc")
|
||||
when "post_count"
|
||||
q = q.order("post_count desc")
|
||||
else
|
||||
q = q.order("updated_at desc")
|
||||
end
|
||||
@@ -139,12 +144,24 @@ class Pool < ActiveRecord::Base
|
||||
post_ids =~ /(?:\A| )#{post_id}(?:\Z| )/
|
||||
end
|
||||
|
||||
def page_number(post_id)
|
||||
post_id_array.find_index(post_id) + 1
|
||||
end
|
||||
|
||||
def deletable_by?(user)
|
||||
user.is_janitor?
|
||||
end
|
||||
|
||||
def create_mod_action_for_delete
|
||||
ModAction.create(:description => "deleted pool ##{id} (name: #{name})")
|
||||
end
|
||||
|
||||
def create_mod_action_for_undelete
|
||||
ModAction.create(:description => "undeleted pool ##{id} (name: #{name})")
|
||||
end
|
||||
|
||||
def create_mod_action_for_destroy
|
||||
ModAction.create(:description => "deleted pool ##{id} name=#{name} post_ids=#{post_ids}")
|
||||
ModAction.create(:description => "permanently deleted pool ##{id} name=#{name} post_ids=#{post_ids}")
|
||||
end
|
||||
|
||||
def add!(post)
|
||||
|
||||
@@ -153,7 +153,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
module ImageMethods
|
||||
def has_large?
|
||||
image_width.present? && image_width > Danbooru.config.large_image_width
|
||||
is_image? && image_width.present? && image_width > Danbooru.config.large_image_width
|
||||
end
|
||||
|
||||
def has_large
|
||||
@@ -872,15 +872,7 @@ class Post < ActiveRecord::Base
|
||||
def create_version
|
||||
return if disable_versioning
|
||||
|
||||
if created_at == updated_at
|
||||
CurrentUser.increment!(:post_update_count)
|
||||
versions.create(
|
||||
:rating => rating,
|
||||
:source => source,
|
||||
:tags => tag_string,
|
||||
:parent_id => parent_id
|
||||
)
|
||||
elsif rating_changed? || source_changed? || parent_id_changed? || tag_string_changed?
|
||||
if new_record? || rating_changed? || source_changed? || parent_id_changed? || tag_string_changed?
|
||||
CurrentUser.increment!(:post_update_count)
|
||||
versions.create(
|
||||
:rating => rating,
|
||||
@@ -908,6 +900,12 @@ class Post < ActiveRecord::Base
|
||||
def last_noted_at_as_integer
|
||||
last_noted_at.to_i
|
||||
end
|
||||
|
||||
def copy_notes_to(other_post)
|
||||
notes.each do |note|
|
||||
note.copy_to(other_post)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ApiMethods
|
||||
|
||||
@@ -192,9 +192,9 @@ class Upload < ActiveRecord::Base
|
||||
self.tag_string = "#{tag_string} lowres".strip
|
||||
end
|
||||
|
||||
if image_width >= 1024 && image_width.to_f / image_height >= 3
|
||||
if image_width >= 1024 && image_width.to_f / image_height >= 4
|
||||
self.tag_string = "#{tag_string} wide_image".strip
|
||||
elsif image_height >= 1024 && image_height.to_f / image_width >= 3
|
||||
elsif image_height >= 1024 && image_height.to_f / image_width >= 4
|
||||
self.tag_string = "#{tag_string} tall_image".strip
|
||||
end
|
||||
end
|
||||
|
||||
@@ -519,7 +519,7 @@ class User < ActiveRecord::Base
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count]
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
|
||||
super(options)
|
||||
end
|
||||
|
||||
@@ -529,7 +529,7 @@ class User < ActiveRecord::Base
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count]
|
||||
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
|
||||
super(options, &block)
|
||||
end
|
||||
|
||||
@@ -563,6 +563,18 @@ class User < ActiveRecord::Base
|
||||
def comment_count
|
||||
Comment.for_creator(id).count
|
||||
end
|
||||
|
||||
def positive_feedback_count
|
||||
feedback.positive.count
|
||||
end
|
||||
|
||||
def neutral_feedback_count
|
||||
feedback.neutral.count
|
||||
end
|
||||
|
||||
def negative_feedback_count
|
||||
feedback.negative.count
|
||||
end
|
||||
end
|
||||
|
||||
module SearchMethods
|
||||
|
||||
@@ -3,6 +3,7 @@ class WikiPage < ActiveRecord::Base
|
||||
before_validation :initialize_creator, :on => :create
|
||||
before_validation :initialize_updater
|
||||
after_save :create_version
|
||||
before_destroy :create_mod_action_for_destroy
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :updater, :class_name => "User"
|
||||
validates_uniqueness_of :title, :case_sensitive => false
|
||||
@@ -159,4 +160,8 @@ class WikiPage < ActiveRecord::Base
|
||||
end
|
||||
end.map {|x| x.mb_chars.downcase.tr(" ", "_").to_s}
|
||||
end
|
||||
|
||||
def create_mod_action_for_destroy
|
||||
ModAction.create(:description => "permanently deleted wiki page [[#{title}]]")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,4 +32,8 @@ class WikiPageVersion < ActiveRecord::Base
|
||||
def pretty_title
|
||||
title.tr("_", " ")
|
||||
end
|
||||
|
||||
def category_name
|
||||
Tag.category_for(title)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -195,31 +195,31 @@ class PostPresenter < Presenter
|
||||
end
|
||||
|
||||
if @post.id != pool.post_id_array.first
|
||||
pool_html << template.link_to("«".html_safe, template.post_path(pool.post_id_array.first, :pool_id => pool.id), :class => "#{klass} first")
|
||||
pool_html << template.link_to("«".html_safe, template.post_path(pool.post_id_array.first, :pool_id => pool.id), :class => "#{klass} first", :title => "to page 1")
|
||||
else
|
||||
pool_html << '<span class="first">«</span>'
|
||||
end
|
||||
|
||||
if pool.neighbors(@post).previous
|
||||
pool_html << template.link_to("‹ prev".html_safe, template.post_path(pool.neighbors(@post).previous, :pool_id => pool.id), :rel => prev_rel, :class => "#{klass} prev")
|
||||
pool_html << template.link_to("‹ prev".html_safe, template.post_path(pool.neighbors(@post).previous, :pool_id => pool.id), :rel => prev_rel, :class => "#{klass} prev", :title => "to page #{pool.page_number(pool.neighbors(@post).previous)}")
|
||||
match_found = true
|
||||
else
|
||||
pool_html << '<span class="prev">‹ prev</span>'
|
||||
end
|
||||
|
||||
pool_html << ' <span class="pool-name ' + klass + '">'
|
||||
pool_html << template.link_to("Pool: #{pool.pretty_name}", template.pool_path(pool))
|
||||
pool_html << template.link_to("Pool: #{pool.pretty_name}", template.pool_path(pool), :title => "page #{pool.page_number(@post.id)}/#{pool.post_count}")
|
||||
pool_html << '</span> '
|
||||
|
||||
if pool.neighbors(@post).next
|
||||
pool_html << template.link_to("next ›".html_safe, template.post_path(pool.neighbors(@post).next, :pool_id => pool.id), :rel => next_rel, :class => "#{klass} next")
|
||||
pool_html << template.link_to("next ›".html_safe, template.post_path(pool.neighbors(@post).next, :pool_id => pool.id), :rel => next_rel, :class => "#{klass} next", :title => "to page #{pool.page_number(pool.neighbors(@post).next)}")
|
||||
match_found = true
|
||||
else
|
||||
pool_html << '<span class="next">next ›</span>'
|
||||
end
|
||||
|
||||
if @post.id != pool.post_id_array.last
|
||||
pool_html << template.link_to("»".html_safe, template.post_path(pool.post_id_array.last, :pool_id => pool.id), :class => "#{klass} last")
|
||||
pool_html << template.link_to("»".html_safe, template.post_path(pool.post_id_array.last, :pool_id => pool.id), :class => "#{klass} last", :title => "to page #{pool.post_count}")
|
||||
else
|
||||
pool_html << '<span class="last">»</span>'
|
||||
end
|
||||
|
||||
@@ -128,9 +128,9 @@ class UserPresenter
|
||||
end
|
||||
|
||||
def feedbacks(template)
|
||||
positive = UserFeedback.for_user(user.id).positive.count
|
||||
neutral = UserFeedback.for_user(user.id).neutral.count
|
||||
negative = UserFeedback.for_user(user.id).negative.count
|
||||
positive = user.positive_feedback_count
|
||||
neutral = user.neutral_feedback_count
|
||||
negative = user.negative_feedback_count
|
||||
|
||||
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id}))
|
||||
end
|
||||
|
||||
7
app/views/artist_versions/_secondary_links.html.erb
Normal file
7
app/views/artist_versions/_secondary_links.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "Artists", artists_path %></li>
|
||||
<li><%= link_to "New", new_artist_path %></li>
|
||||
<li><%= link_to "Search", search_artist_versions_path %></li>
|
||||
</menu>
|
||||
<% end %>
|
||||
@@ -51,7 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "artists/secondary_links" %>
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Artist Versions - <%= Danbooru.config.app_name %>
|
||||
|
||||
19
app/views/artist_versions/search.html.erb
Normal file
19
app/views/artist_versions/search.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<div id="c-artist-versions">
|
||||
<div id="a-search">
|
||||
<h1>Search Changes</h1>
|
||||
|
||||
<div id="search">
|
||||
<%= form_tag(artist_versions_path, :method => :get, :class => "simple_form") do %>
|
||||
<%= search_field "updater_name", :label => "User" %>
|
||||
<%= search_field "name", :label => "Name" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Search Artist Changes - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -15,6 +15,7 @@
|
||||
<th>From</th>
|
||||
<th>To</th>
|
||||
<th>Subject</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -24,6 +25,9 @@
|
||||
<td><%= link_to_user dmail.from %></td>
|
||||
<td><%= link_to_user dmail.to %></td>
|
||||
<td><%= link_to dmail.title, dmail_path(dmail) %></td>
|
||||
<td>
|
||||
<%= link_to "delete", dmail_path(dmail), :method => :delete, :confirm => "Are you sure you want to delete this Dmail?" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<%= render "users/ban_notice" %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.dmail_count.present? %>
|
||||
<% if CurrentUser.dmail_count.present? && CurrentUser.dmails.unread.present? && cookies[:hide_dmail_notice].to_i != CurrentUser.dmails.unread.first.id %>
|
||||
<%= render "users/dmail_notice" %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<th><label for="search_sort">Order</th>
|
||||
<td>
|
||||
<div class="input">
|
||||
<%= select "search", "sort", [["Last updated", "updated_at"], ["Name", "name"]], :selected => params[:search][:sort] %>
|
||||
<%= select "search", "sort", [["Last updated", "updated_at"], ["Name", "name"], ["Recently created", "created_at"], ["Post count", "post_count"]], :selected => params[:search][:sort] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<% end %>
|
||||
</h1>
|
||||
|
||||
<div id="description">
|
||||
<div id="description" class="prose">
|
||||
<%= format_text(@pool.description) %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, "data-user" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-score" => post.score, "data-fav-count" => post.fav_count) %>
|
||||
<%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, "data-uploader" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-score" => post.score, "data-fav-count" => post.fav_count) %>
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
<% else %>
|
||||
<li><%= link_to "Add note", "#", :id => "translate", :title => "Shortcut is N" %></li>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_builder? %>
|
||||
<li><%= link_to "Copy all notes", "#", :id => "copy-notes" %></li>
|
||||
<% end %>
|
||||
<li><%= link_to "Find similar", "http://danbooru.iqdb.org/db-search.php?url=http://#{Danbooru.config.hostname}#{post.preview_file_url}" %></li>
|
||||
|
||||
<% if post.is_status_locked? %>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
<%= render "posts/partials/show/notices", :post => @post %>
|
||||
|
||||
<section id="image-container" data-tags="<%= @post.tag_string %>" data-user="<%= @post.uploader_name %>" data-rating="<%= @post.rating %>" data-flags="<%= @post.status_flags %>">
|
||||
<section id="image-container" data-tags="<%= @post.tag_string %>" data-uploader="<%= @post.uploader_name %>" data-rating="<%= @post.rating %>" data-flags="<%= @post.status_flags %>">
|
||||
<div id="note-container"></div>
|
||||
<div id="note-preview"></div>
|
||||
<%= @post.presenter.image_html(self) %>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<div class="ui-corner-all ui-state-highlight" id="dmail-notice">
|
||||
<div class="ui-corner-all ui-state-highlight" id="dmail-notice" data-id="<%= CurrentUser.dmails.unread.first.id %>">
|
||||
<h1>You have <%= link_to "unread mail", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %>.</h1>
|
||||
<p><%= link_to "Close this", "#", :id => "hide-dmail-notice" %></p>
|
||||
</div>
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
<table width="100%" class="striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="2%"></th>
|
||||
<th width="2%"></th>
|
||||
<% if params[:search] && params[:search][:wiki_page_id] && @wiki_page_versions.length > 1 %>
|
||||
<th width="3%"></th>
|
||||
<th width="2%"></th>
|
||||
<th width="2%"></th>
|
||||
<% end %>
|
||||
<th>Title</th>
|
||||
<th width="5%"></th>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
@@ -20,19 +23,32 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @wiki_page_versions.each do |wiki_page_version| %>
|
||||
<% @wiki_page_versions.each_with_index do |wiki_page_version, i| %>
|
||||
<tr>
|
||||
<td>
|
||||
<% if params[:search] && params[:search][:wiki_page_id] %>
|
||||
<%= radio_button_tag "thispage", wiki_page_version.id %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if params[:search] && params[:search][:wiki_page_id] %>
|
||||
<%= radio_button_tag "otherpage", wiki_page_version.id %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %></td>
|
||||
<% if params[:search] && params[:search][:wiki_page_id] && @wiki_page_versions.length > 1 %>
|
||||
<td>
|
||||
<% if i < @wiki_page_versions.length - 1 %>
|
||||
<%= link_to "diff", diff_wiki_page_versions_path(:otherpage => wiki_page_version.id, :thispage => @wiki_page_versions[i + 1].id) %>
|
||||
<% else %>
|
||||
diff
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if i == 1 %>
|
||||
<%= radio_button_tag "thispage", wiki_page_version.id, :checked => true %>
|
||||
<% else %>
|
||||
<%= radio_button_tag "thispage", wiki_page_version.id %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if i == 0 %>
|
||||
<%= radio_button_tag "otherpage", wiki_page_version.id, :checked => true %>
|
||||
<% else %>
|
||||
<%= radio_button_tag "otherpage", wiki_page_version.id %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td class="category-<%= wiki_page_version.category_name %>"><%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %></td>
|
||||
<td><%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %></td>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<td>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<tbody>
|
||||
<% @wiki_pages.each do |wiki_page| %>
|
||||
<tr>
|
||||
<td class="tag-category-<%= wiki_page.category_name %>"><%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :noredirect => 1) %></td>
|
||||
<td class="category-<%= wiki_page.category_name %>"><%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :noredirect => 1) %></td>
|
||||
<td><%= wiki_page.updated_at.strftime("%Y-%m-%d %I:%M") %> by <%= h link_to_user wiki_page.updater %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<%= render "sidebar" %>
|
||||
|
||||
<section id="content">
|
||||
<h1 id="wiki-page-title"><%= params[:title] %></h1>
|
||||
<h1 id="wiki-page-title"><%= @wiki_page.pretty_title %></h1>
|
||||
<div id="wiki-page-body" class="prose">
|
||||
<p>This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user