<%= params[:title] %>
+<%= @wiki_page.pretty_title %>
This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.
diff --git a/app/assets/javascripts/blacklists.js b/app/assets/javascripts/blacklists.js index 2be852410..09db6e927 100644 --- a/app/assets/javascripts/blacklists.js +++ b/app/assets/javascripts/blacklists.js @@ -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); }); diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index 19de27ca6..f134a93df 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -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(); diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 07af4ca0a..1d626cc4b 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -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.css({ - width: "95%", - height: "10em" + width: "97%", + height: "95%", + resize: "none", }); if ($note_body.html() !== "Click to edit") { @@ -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(); diff --git a/app/assets/javascripts/pools.js b/app/assets/javascripts/pools.js index 832b4cab6..f078dc33f 100644 --- a/app/assets/javascripts/pools.js +++ b/app/assets/javascripts/pools.js @@ -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, " ");})); } diff --git a/app/assets/javascripts/post_mode_menu.js b/app/assets/javascripts/post_mode_menu.js index 85a614cae..777d025bc 100644 --- a/app/assets/javascripts/post_mode_menu.js +++ b/app/assets/javascripts/post_mode_menu.js @@ -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"); } }); diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index fef5bd3bb..27a0cdb6b 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -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 post #" + other_post_id + ""); + } else { + Danbooru.error("There was an error copying notes to post #" + other_post_id + ""); + } + }, + }); + } + + 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); } diff --git a/app/assets/javascripts/related_tag.js b/app/assets/javascripts/related_tag.js index 645184b74..8e299a295 100644 --- a/app/assets/javascripts/related_tag.js +++ b/app/assets/javascripts/related_tag.js @@ -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(); } diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss index 4aabf1385..a26e8ccb8 100644 --- a/app/assets/stylesheets/specific/posts.css.scss +++ b/app/assets/stylesheets/specific/posts.css.scss @@ -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 { diff --git a/app/controllers/artist_versions_controller.rb b/app/controllers/artist_versions_controller.rb index b4f42e1a0..914f9f79b 100644 --- a/app/controllers/artist_versions_controller.rb +++ b/app/controllers/artist_versions_controller.rb @@ -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") diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index f6fcc5e15..24269e01b 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -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") diff --git a/app/controllers/bans_controller.rb b/app/controllers/bans_controller.rb index d31787883..efd5419a1 100644 --- a/app/controllers/bans_controller.rb +++ b/app/controllers/bans_controller.rb @@ -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 diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index a46c85ae6..6f64a7e3c 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -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 diff --git a/app/controllers/delayed_jobs_controller.rb b/app/controllers/delayed_jobs_controller.rb index 90d6f03c3..5897ac68b 100644 --- a/app/controllers/delayed_jobs_controller.rb +++ b/app/controllers/delayed_jobs_controller.rb @@ -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 diff --git a/app/controllers/dmails_controller.rb b/app/controllers/dmails_controller.rb index 30759c3c5..19231a5af 100644 --- a/app/controllers/dmails_controller.rb +++ b/app/controllers/dmails_controller.rb @@ -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") diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index a53a72a20..65e571ff4 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -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") diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 956db790f..0ff5a0c4c 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -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") diff --git a/app/controllers/ip_bans_controller.rb b/app/controllers/ip_bans_controller.rb index 9873ee26f..e28b006c3 100644 --- a/app/controllers/ip_bans_controller.rb +++ b/app/controllers/ip_bans_controller.rb @@ -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 diff --git a/app/controllers/janitor_trials_controller.rb b/app/controllers/janitor_trials_controller.rb index d2f35e324..21fa74fd0 100644 --- a/app/controllers/janitor_trials_controller.rb +++ b/app/controllers/janitor_trials_controller.rb @@ -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 diff --git a/app/controllers/mod_actions_controller.rb b/app/controllers/mod_actions_controller.rb index 4197e2718..0533d7e34 100644 --- a/app/controllers/mod_actions_controller.rb +++ b/app/controllers/mod_actions_controller.rb @@ -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 diff --git a/app/controllers/news_updates_controller.rb b/app/controllers/news_updates_controller.rb index 784186b02..f9a85fb30 100644 --- a/app/controllers/news_updates_controller.rb +++ b/app/controllers/news_updates_controller.rb @@ -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 diff --git a/app/controllers/note_versions_controller.rb b/app/controllers/note_versions_controller.rb index be3ef428f..cfc9c8414 100644 --- a/app/controllers/note_versions_controller.rb +++ b/app/controllers/note_versions_controller.rb @@ -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") diff --git a/app/controllers/pool_versions_controller.rb b/app/controllers/pool_versions_controller.rb index 332d90edf..e89296fdc 100644 --- a/app/controllers/pool_versions_controller.rb +++ b/app/controllers/pool_versions_controller.rb @@ -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") diff --git a/app/controllers/pools_controller.rb b/app/controllers/pools_controller.rb index 7c3aeb6e5..e424bf807 100644 --- a/app/controllers/pools_controller.rb +++ b/app/controllers/pools_controller.rb @@ -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 diff --git a/app/controllers/post_appeals_controller.rb b/app/controllers/post_appeals_controller.rb index ddf1fc646..7ed567cf3 100644 --- a/app/controllers/post_appeals_controller.rb +++ b/app/controllers/post_appeals_controller.rb @@ -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") diff --git a/app/controllers/post_flags_controller.rb b/app/controllers/post_flags_controller.rb index b7738bc74..709212a12 100644 --- a/app/controllers/post_flags_controller.rb +++ b/app/controllers/post_flags_controller.rb @@ -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") diff --git a/app/controllers/post_versions_controller.rb b/app/controllers/post_versions_controller.rb index e87cd1b04..89a606214 100644 --- a/app/controllers/post_versions_controller.rb +++ b/app/controllers/post_versions_controller.rb @@ -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") diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 2c46e52d8..5ac7ba684 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -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]) diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 7f66b7d88..735f41ead 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -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") diff --git a/app/controllers/tag_implications_controller.rb b/app/controllers/tag_implications_controller.rb index d60d9d7b7..49079634a 100644 --- a/app/controllers/tag_implications_controller.rb +++ b/app/controllers/tag_implications_controller.rb @@ -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") diff --git a/app/controllers/tag_subscriptions_controller.rb b/app/controllers/tag_subscriptions_controller.rb index b1023451f..2eaa73e06 100644 --- a/app/controllers/tag_subscriptions_controller.rb +++ b/app/controllers/tag_subscriptions_controller.rb @@ -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 diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 32f0bbaed..3a5c50838 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -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") diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 0b4f5ac3e..6f9716922 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -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") diff --git a/app/controllers/user_feedbacks_controller.rb b/app/controllers/user_feedbacks_controller.rb index e08ab3e03..4283faf7d 100644 --- a/app/controllers/user_feedbacks_controller.rb +++ b/app/controllers/user_feedbacks_controller.rb @@ -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") diff --git a/app/controllers/user_name_change_requests_controller.rb b/app/controllers/user_name_change_requests_controller.rb index 4563f3000..2d9ff126a 100644 --- a/app/controllers/user_name_change_requests_controller.rb +++ b/app/controllers/user_name_change_requests_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 31219a2a6..4bc03021b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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") diff --git a/app/controllers/wiki_page_versions_controller.rb b/app/controllers/wiki_page_versions_controller.rb index 685be53a1..b5fb6221a 100644 --- a/app/controllers/wiki_page_versions_controller.rb +++ b/app/controllers/wiki_page_versions_controller.rb @@ -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") diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index a3ca8ee28..153b5f8ad 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -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) diff --git a/app/logical/post_sets/favorite.rb b/app/logical/post_sets/favorite.rb index f5bae6a00..b0d051260 100644 --- a/app/logical/post_sets/favorite.rb +++ b/app/logical/post_sets/favorite.rb @@ -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 diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 0be013811..25e115a26 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -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 diff --git a/app/models/note.rb b/app/models/note.rb index 80c0a1ec4..ccbec9de2 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -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 diff --git a/app/models/pool.rb b/app/models/pool.rb index 42574de2f..2fc12ba5d 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -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) diff --git a/app/models/post.rb b/app/models/post.rb index 1ef54ddf6..bea98c35c 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/models/upload.rb b/app/models/upload.rb index fbfae20ef..cac56aca2 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 5f07a402d..6c9c3cce9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index f2b9a130f..a9df27a6d 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -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 diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index c39f1c258..c0ffa762c 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -32,4 +32,8 @@ class WikiPageVersion < ActiveRecord::Base def pretty_title title.tr("_", " ") end + + def category_name + Tag.category_for(title) + end end diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 9bdac970f..c8179944c 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -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 << '«' 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 << '‹ prev' end pool_html << ' ' - 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 << ' ' 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 << 'next ›' 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 << '»' end diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 79faeb971..83fce11f9 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -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 diff --git a/app/views/artist_versions/_secondary_links.html.erb b/app/views/artist_versions/_secondary_links.html.erb new file mode 100644 index 000000000..617172378 --- /dev/null +++ b/app/views/artist_versions/_secondary_links.html.erb @@ -0,0 +1,7 @@ +<% content_for(:secondary_links) do %> +
+<% end %> diff --git a/app/views/artist_versions/index.html.erb b/app/views/artist_versions/index.html.erb index 515c0d390..6d092e284 100644 --- a/app/views/artist_versions/index.html.erb +++ b/app/views/artist_versions/index.html.erb @@ -51,7 +51,7 @@ -<%= render "artists/secondary_links" %> +<%= render "secondary_links" %> <% content_for(:page_title) do %> Artist Versions - <%= Danbooru.config.app_name %> diff --git a/app/views/artist_versions/search.html.erb b/app/views/artist_versions/search.html.erb new file mode 100644 index 000000000..681a7892f --- /dev/null +++ b/app/views/artist_versions/search.html.erb @@ -0,0 +1,19 @@ +<%= link_to "Close this", "#", :id => "hide-dmail-notice" %>
| - | + <% if params[:search] && params[:search][:wiki_page_id] && @wiki_page_versions.length > 1 %> + | + | + | + <% end %> | Title | <% if CurrentUser.is_admin? %> @@ -20,19 +23,32 @@ | ||
|---|---|---|---|---|---|---|---|---|
| - <% if params[:search] && params[:search][:wiki_page_id] %> - <%= radio_button_tag "thispage", wiki_page_version.id %> - <% end %> - | -- <% if params[:search] && params[:search][:wiki_page_id] %> - <%= radio_button_tag "otherpage", wiki_page_version.id %> - <% end %> - | -<%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %> | + <% if params[:search] && params[:search][:wiki_page_id] && @wiki_page_versions.length > 1 %> ++ <% 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 %> + | ++ <% if i == 1 %> + <%= radio_button_tag "thispage", wiki_page_version.id, :checked => true %> + <% else %> + <%= radio_button_tag "thispage", wiki_page_version.id %> + <% end %> + | ++ <% if i == 0 %> + <%= radio_button_tag "otherpage", wiki_page_version.id, :checked => true %> + <% else %> + <%= radio_button_tag "otherpage", wiki_page_version.id %> + <% end %> + | + <% end %> +<%= link_to wiki_page_version.title, wiki_page_version_path(wiki_page_version) %> | <%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %> | <% if CurrentUser.is_admin? %>diff --git a/app/views/wiki_pages/index.html.erb b/app/views/wiki_pages/index.html.erb index 354f6c98d..cba73e06c 100644 --- a/app/views/wiki_pages/index.html.erb +++ b/app/views/wiki_pages/index.html.erb @@ -15,7 +15,7 @@ |
| <%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :noredirect => 1) %> | +<%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :noredirect => 1) %> | <%= wiki_page.updated_at.strftime("%Y-%m-%d %I:%M") %> by <%= h link_to_user wiki_page.updater %> |