From 98b8e6a3e6e72fa745e5eb2da823df99c484e055 Mon Sep 17 00:00:00 2001 From: ghostrigger Date: Sat, 4 May 2013 15:38:28 +0800 Subject: [PATCH 01/34] fixes #1523 hopefully added missing document title for delayed jobs --- app/views/delayed_jobs/index.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/delayed_jobs/index.html.erb b/app/views/delayed_jobs/index.html.erb index 67710abc0..c7fcb03db 100644 --- a/app/views/delayed_jobs/index.html.erb +++ b/app/views/delayed_jobs/index.html.erb @@ -34,3 +34,7 @@ <%= numbered_paginator(@delayed_jobs) %> + +<% content_for(:page_title) do %> + Delayed Jobs - <%= Danbooru.config.app_name %> +<% end %> From b6a0765d10f22ece4a88d59f8569ca7ac4500f2e Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 4 May 2013 09:24:37 -0400 Subject: [PATCH 02/34] fix for pool id (#1402) --- app/presenters/post_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 5c2a704c3..d3678c13d 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -181,7 +181,7 @@ class PostPresenter < Presenter end def pool_link_html(template, pool, options = {}) - pool_html = ['
  • <%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %>
  • <% if CurrentUser.is_admin? %> - <%= link_to "Ban", ban_artist_path(@artist), :method => :put %> + <%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %> <% end %> <% end %> From 6c62ed8ba1830660d2662d251ee5fa135ce9e1dd Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 4 May 2013 14:12:36 -0400 Subject: [PATCH 08/34] fix close notice link --- app/assets/javascripts/common.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index 6fcd92c5c..19de27ca6 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -18,6 +18,7 @@ $(function() { $("#close-notice-link").click(function(e) { $('#notice').fadeOut("fast"); + e.preventDefault(); }); }); From 537d6ee8eb497f99f6500d859092d3697135c799 Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 4 May 2013 17:50:20 -0400 Subject: [PATCH 09/34] fixes #1316 --- app/assets/javascripts/posts.js | 35 +++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index bc8fc85c1..600348ae8 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -4,7 +4,7 @@ Danbooru.Post.pending_update_count = 0; Danbooru.Post.initialize_all = function() { - this.initialize_titles(); + this.initialize_post_previews(); if ($("#c-posts").length) { if (Danbooru.meta("enable-js-navigation") === "true") { @@ -182,9 +182,10 @@ }); } - Danbooru.Post.initialize_titles = function() { + Danbooru.Post.initialize_post_previews = function() { $(".post-preview").each(function(i, v) { Danbooru.Post.initialize_title_for(v); + Danbooru.Post.initialize_preview_borders_for(v); }); } @@ -194,6 +195,36 @@ $img.attr("title", $post.attr("data-tags") + " user:" + $post.attr("data-uploader") + " rating:" + $post.data("rating") + " score:" + $post.data("score")); } + Danbooru.Post.initialize_preview_borders_for = function(post) { + var $post = $(post); + var $img = $post.find("img"); + + var border_colors = []; + + if ($post.hasClass("post-status-has-children")) { + border_colors.push("#0F0"); + } + if ($post.hasClass("post-status-has-parent")) { + border_colors.push("#CC0"); + } + if ($post.hasClass("post-status-deleted")) { + border_colors.push("#000"); + } else if ($post.hasClass("post-status-pending")) { + border_colors.push("#00F"); + } else if ($post.hasClass("post-status-flagged")) { + border_colors.push("#F00"); + } + + if (border_colors.length > 1) { + $img.css("border", "2px solid"); + if (border_colors.length === 3) { + $img.css("border-color", border_colors[0] + " " + border_colors[2] + " " + border_colors[1]); + } else if (border_colors.length === 2) { + $img.css("border-color", border_colors[0] + " " + border_colors[1]); + } + } + } + Danbooru.Post.initialize_post_image_resize_links = function() { $("#image-resize-link").click(function(e) { var $link = $(e.target); From e8ad3f643d6466b4731a7499b0cd375e47f334a6 Mon Sep 17 00:00:00 2001 From: Sal-N Date: Sun, 5 May 2013 01:26:34 +0300 Subject: [PATCH 10/34] Less awkward English --- app/views/wiki_pages/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb index e68a96c90..0e7217d9f 100644 --- a/app/views/wiki_pages/show.html.erb +++ b/app/views/wiki_pages/show.html.erb @@ -24,11 +24,11 @@ <% end %> <% if @wiki_page.presenter.antecedent_tag_implications.any? %> -

    This tag has been implicated to <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.

    +

    This tag implicates <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.

    <% end %> <% if @wiki_page.presenter.consequent_tag_implications.any? %> -

    The following tags are implicated to this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    +

    The following tags implicate this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    <% end %> From 2ad34653f7160e63e0d132bba968b999fded6550 Mon Sep 17 00:00:00 2001 From: ToksT Date: Sat, 4 May 2013 19:32:56 -0300 Subject: [PATCH 11/34] consistency fix --- app/views/wiki_pages/new.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index da8a31d80..70da40f21 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -22,11 +22,11 @@ <% end %> <% if @wiki_page.presenter.antecedent_tag_implications.any? %> -

    This tag has been implicated to <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.

    +

    This tag implicates <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.

    <% end %> <% if @wiki_page.presenter.consequent_tag_implications.any? %> -

    The following tags are implicated to this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    +

    The following tags implicate this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    <% end %>
    From 4fe7437b9c9f500f4b2118a3b5c428f5a10dea7d Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 4 May 2013 19:09:42 -0400 Subject: [PATCH 12/34] simplify alias/implication list code for wiki pages --- app/helpers/wiki_pages_helper.rb | 34 ++++++++++++++++++++++++++++++ app/views/wiki_pages/new.html.erb | 16 +------------- app/views/wiki_pages/show.html.erb | 16 +------------- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/app/helpers/wiki_pages_helper.rb b/app/helpers/wiki_pages_helper.rb index 283018a93..9fbc3862c 100644 --- a/app/helpers/wiki_pages_helper.rb +++ b/app/helpers/wiki_pages_helper.rb @@ -1,2 +1,36 @@ module WikiPagesHelper + def wiki_page_alias_and_implication_list(wiki_page) + antecedent_alias = wiki_page.presenter.antecedent_tag_alias + consequent_aliases = wiki_page.presenter.consequent_tag_aliases + antecedent_implications = wiki_page.presenter.antecedent_tag_implications + consequent_implications = wiki_page.presenter.consequent_tag_implications + + html = "" + + if antecedent_alias + html << "

    This tag has been aliased to " + html << link_to(antecedent_alias.consequent_name, show_or_new_wiki_pages_path(:title => antecedent_alias.consequent_name)) + html << ".

    " + end + + if consequent_aliases.any? + html << "

    The following tags are aliased to this tag: " + html << raw(consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) + html << ".

    " + end + + if antecedent_implications.any? + html << "

    This tag implicates " + html << raw(antecedent_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ")) + html << ".

    " + end + + if consequent_implications.any? + html << "

    The following tags implicate this tag: " + html << raw(consequent_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) + html << ".

    " + end + + html.html_safe + end end diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index 70da40f21..0d56f5858 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -13,21 +13,7 @@ <%= render "form" %> - <% if @wiki_page.presenter.antecedent_tag_alias %> -

    This tag has been aliased to <%= link_to @wiki_page.presenter.antecedent_tag_alias.consequent_name, show_or_new_wiki_pages_path(:title => @wiki_page.presenter.antecedent_tag_alias.consequent_name) %>.

    - <% end %> - - <% if @wiki_page.presenter.consequent_tag_aliases.any? %> -

    The following tags are aliased to this tag: <%= raw @wiki_page.presenter.consequent_tag_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    - <% end %> - - <% if @wiki_page.presenter.antecedent_tag_implications.any? %> -

    This tag implicates <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.

    - <% end %> - - <% if @wiki_page.presenter.consequent_tag_implications.any? %> -

    The following tags implicate this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    - <% end %> + <%= wiki_page_alias_and_implication_list(@wiki_page)%>
    <% if Post.fast_count(@wiki_page.title) > 0 %> diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb index 0e7217d9f..74b051b81 100644 --- a/app/views/wiki_pages/show.html.erb +++ b/app/views/wiki_pages/show.html.erb @@ -15,21 +15,7 @@
    <%= format_text(@wiki_page.body) %> - <% if @wiki_page.presenter.antecedent_tag_alias %> -

    This tag has been aliased to <%= link_to @wiki_page.presenter.antecedent_tag_alias.consequent_name, show_or_new_wiki_pages_path(:title => @wiki_page.presenter.antecedent_tag_alias.consequent_name) %>.

    - <% end %> - - <% if @wiki_page.presenter.consequent_tag_aliases.any? %> -

    The following tags are aliased to this tag: <%= raw @wiki_page.presenter.consequent_tag_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    - <% end %> - - <% if @wiki_page.presenter.antecedent_tag_implications.any? %> -

    This tag implicates <%= raw @wiki_page.presenter.antecedent_tag_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ") %>.

    - <% end %> - - <% if @wiki_page.presenter.consequent_tag_implications.any? %> -

    The following tags implicate this tag: <%= raw @wiki_page.presenter.consequent_tag_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ") %>.

    - <% end %> + <%= wiki_page_alias_and_implication_list(@wiki_page) %>
    From 26c774bd84886bf41139862cc69b2c457bb56969 Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 4 May 2013 20:19:44 -0400 Subject: [PATCH 13/34] fixes #1542; fix typo; link to news update creator --- app/assets/stylesheets/specific/news_updates.css.scss | 7 +++++++ app/models/news_update.rb | 2 +- app/views/news_updates/index.html.erb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/specific/news_updates.css.scss diff --git a/app/assets/stylesheets/specific/news_updates.css.scss b/app/assets/stylesheets/specific/news_updates.css.scss new file mode 100644 index 000000000..8ca16154d --- /dev/null +++ b/app/assets/stylesheets/specific/news_updates.css.scss @@ -0,0 +1,7 @@ +div#c-news-updates { + div#a-edit, div#a-new { + .hint { + display: block; + } + } +} diff --git a/app/models/news_update.rb b/app/models/news_update.rb index 5fa37bbc0..29755564b 100644 --- a/app/models/news_update.rb +++ b/app/models/news_update.rb @@ -1,6 +1,6 @@ class NewsUpdate < ActiveRecord::Base belongs_to :creator, :class_name => "User" - belongs_to :udpater, :class_name => "User" + belongs_to :updater, :class_name => "User" scope :recent, order("created_at desc").limit(5) before_validation :initialize_creator, :on => :create before_validation :initialize_updater diff --git a/app/views/news_updates/index.html.erb b/app/views/news_updates/index.html.erb index 5fa51b201..be2a1872a 100644 --- a/app/views/news_updates/index.html.erb +++ b/app/views/news_updates/index.html.erb @@ -13,7 +13,7 @@ <% @news_updates.each do |news_update| %> - <%= news_update.creator.name %> + <%= link_to_user news_update.creator %> <%= news_update.message %> <%= link_to "Edit", edit_news_update_path(news_update) %> | <%= link_to "Delete", news_update_path(news_update), :method => :delete %> From 7fc3d20f6f4a9f0a4b7b6aa6dd624c208496e76e Mon Sep 17 00:00:00 2001 From: zatchii Date: Sun, 5 May 2013 00:57:09 +0000 Subject: [PATCH 14/34] Ignore click event when adding note Instead of double-toggling, ignore click events for some milliseconds after adding a note. --- app/assets/javascripts/notes.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 2d49d888e..3e004be7a 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -107,6 +107,10 @@ Danbooru.Note = { }, toggle_all: function() { + // Ignore the click event when adding a note + if ((new Date).getTime() < Danbooru.Note.ignore_click_until) { + return; + } $(".note-box").toggle(); } }, @@ -419,7 +423,6 @@ Danbooru.Note = { Danbooru.Note.TranslationMode.active = true; $("#original-file-link").click(); - $("#image").one("click", function() { $(".note-box").show() }); /* override the 'hide all note boxes' click event */ $("#image").one("mousedown", Danbooru.Note.TranslationMode.Drag.start); $(window).bind("mouseup", Danbooru.Note.TranslationMode.Drag.stop); Danbooru.notice('Click or drag on the image to create a note (shortcut is n)'); @@ -444,6 +447,10 @@ Danbooru.Note = { $(".note-box").show(); e.stopPropagation(); e.preventDefault(); + + // Hack to ignore clicks for some milliseconds + // The mouseup event is executed before the click event, so it's hard to do this properly + Danbooru.Note.ignore_click_until = (new Date).getTime() + 200; }, Drag: { @@ -541,6 +548,7 @@ Danbooru.Note = { editing: false, timeouts: [], pending: {}, + ignore_click_until: 0, add: function(id, x, y, w, h, text) { var $note_box = Danbooru.Note.Box.create(id); From bfb58f94557022633841d4c50e9a32d1f8a2ca5f Mon Sep 17 00:00:00 2001 From: zatchii Date: Sun, 5 May 2013 01:11:44 +0000 Subject: [PATCH 15/34] Toggle note container instead of note boxes --- app/assets/javascripts/notes.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 3e004be7a..003cf4be2 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -111,7 +111,9 @@ Danbooru.Note = { if ((new Date).getTime() < Danbooru.Note.ignore_click_until) { return; } - $(".note-box").toggle(); + var is_hidden = document.getElementById('note-container').style.display == 'none'; + // Why does toggle() not work here? + $("#note-container").toggle(is_hidden); } }, From 9903d153dfa40bde60600e8f88c0a338349dc603 Mon Sep 17 00:00:00 2001 From: zatchii Date: Sun, 5 May 2013 01:14:21 +0000 Subject: [PATCH 16/34] Hide notes in scale_all --- app/assets/javascripts/notes.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 003cf4be2..18c28487a 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -101,9 +101,14 @@ Danbooru.Note = { }, scale_all: function() { + var container = document.getElementById('note-container'); + // Hide notes while rescaling, to prevent unnecessary reflowing + var was_visible = container.style.display != 'none'; + if (was_visible) container.style.display = 'none'; $(".note-box").each(function(i, v) { Danbooru.Note.Box.scale($(v)); }); + if (was_visible) container.style.display = 'block'; }, toggle_all: function() { From 7d495e28a13d255ea165fc0ee8f40bace64287f8 Mon Sep 17 00:00:00 2001 From: zatchii Date: Sun, 5 May 2013 01:17:28 +0000 Subject: [PATCH 17/34] Use document fragment when loading notes --- app/assets/javascripts/notes.js | 49 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 18c28487a..78bcf773d 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -89,13 +89,13 @@ Danbooru.Note = { scale: function($note_box) { var $image = $("#image"); - var ratio = $image.width() / parseFloat($("#image").data("original-width")); - var $note = $("#notes > article[data-id=" + $note_box.data("id") + "]"); + var ratio = $image.width() / parseFloat($image.data("original-width")); + var MIN_SIZE = 5; $note_box.css({ - top: Math.ceil(parseFloat($note.data("y")) * ratio), - left: Math.ceil(parseFloat($note.data("x")) * ratio), - width: Math.ceil(parseFloat($note.data("width")) * ratio), - height: Math.ceil(parseFloat($note.data("height")) * ratio) + top: Math.ceil(parseFloat($note_box.data("y")) * ratio), + left: Math.ceil(parseFloat($note_box.data("x")) * ratio), + width: Math.max(MIN_SIZE, Math.ceil(parseFloat($note_box.data("width")) * ratio)), + height: Math.max(MIN_SIZE, Math.ceil(parseFloat($note_box.data("height")) * ratio)) }); Danbooru.Note.Box.resize_inner_border($note_box); }, @@ -139,6 +139,10 @@ Danbooru.Note = { top: $note_box.position().top + $note_box.height() + 5, left: $note_box.position().left }); + if (!$note_body.data('resized')) { + Danbooru.Note.Body.resize($note_body); + $note_body.data('resized', 'true'); + } Danbooru.Note.Body.bound_position($note_body); }, @@ -169,8 +173,8 @@ Danbooru.Note = { Danbooru.Note.Body.hide_all(); Danbooru.Note.clear_timeouts(); var $note_body = Danbooru.Note.Body.find(id); - $note_body.show(); Danbooru.Note.Body.initialize($note_body); + $note_body.show(); }, find: function(id) { @@ -223,7 +227,7 @@ Danbooru.Note = { } } while ((hi - lo) > 4) if ($note_body.height() > h) { - $note_body.css("minWidth", hi); + $note_body.css("min-width", hi); } } }, @@ -557,23 +561,19 @@ Danbooru.Note = { pending: {}, ignore_click_until: 0, - add: function(id, x, y, w, h, text) { + add: function(container, id, x, y, w, h, text) { var $note_box = Danbooru.Note.Box.create(id); var $note_body = Danbooru.Note.Body.create(id); - $note_box.css({ - left: x, - top: y, - width: w, - height: h, - display: 'none' - }); - - $("#note-container").append($note_box); - $("#note-container").append($note_body); + $note_box.data('x', x); + $note_box.data('y', y); + $note_box.data('width', w); + $note_box.data('height', h); + container.appendChild($note_box[0]); + container.appendChild($note_body[0]); $note_body.data("original-body", text); Danbooru.Note.Box.scale($note_box); - Danbooru.Note.Body.set_text($note_body, text); + Danbooru.Note.Body.display_text($note_body, text); }, new: function(x, y, w, h) { @@ -603,9 +603,11 @@ Danbooru.Note = { }, load_all: function() { + var fragment = document.createDocumentFragment(); $.each($("#notes article"), function(i, article) { var $article = $(article); Danbooru.Note.add( + fragment, $article.data("id"), $article.data("x"), $article.data("y"), @@ -614,12 +616,7 @@ Danbooru.Note = { $article.html() ); }); - - $('#note-container').css('display','none'); - $('.note-box').each(function(i, v) { - $(v).css('display','block') - }); - $('#note-container').css('display','block'); + $("#note-container").append(fragment); } } From acfbf260aa5026641d706e38634235dfbbbf4113 Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 07:36:07 -0400 Subject: [PATCH 18/34] fixes #1410; fix user argument for favorite post set --- app/controllers/favorites_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index 73b111724..6dce03186 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -1,13 +1,18 @@ class FavoritesController < ApplicationController before_filter :member_only + respond_to :html, :xml, :json def index if params[:tags] redirect_to(posts_path(:tags => params[:tags])) - elsif params[:user_id] - @favorite_set = PostSets::Favorite.new(User.find(params[:user_id]), params[:page], params) else - @favorite_set = PostSets::Favorite.new(CurrentUser.user, params[:page], params) + user_id = params[:user_id] || CurrentUser.user.id + @favorite_set = PostSets::Favorite.new(user_id, params[:page], params) + respond_with(@favorite_set.posts) do |format| + format.xml do + render :xml => @favorite_set.posts.to_xml(:root => "posts") + end + end end end From 2e6cb69ff2e693aa7a82e1e0531bfac73789a664 Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 07:43:25 -0400 Subject: [PATCH 19/34] fixes #1322; unhides created at and base upload limit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index d84a31b07..a484d3549 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -510,7 +510,7 @@ class User < ActiveRecord::Base module ApiMethods def hidden_attributes - super + [:password_hash, :bcrypt_password_hash, :email, :email_verification_key, :time_zone, :created_at, :updated_at, :receive_email_notifications, :last_logged_in_at, :last_forum_read_at, :has_mail, :default_image_size, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :base_upload_limit, :recent_tags, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :enable_sequential_post_navigation, :hide_deleted_posts, :per_page, :style_usernames] + super + [:password_hash, :bcrypt_password_hash, :email, :email_verification_key, :time_zone, :updated_at, :receive_email_notifications, :last_logged_in_at, :last_forum_read_at, :has_mail, :default_image_size, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :recent_tags, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :enable_sequential_post_navigation, :hide_deleted_posts, :per_page, :style_usernames] end def serializable_hash(options = {}) From b6b3f248230f3c792d030554fd7bbe546ebf4143 Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 09:36:37 -0400 Subject: [PATCH 20/34] fix artist url normalization test --- test/unit/artist_url_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/artist_url_test.rb b/test/unit/artist_url_test.rb index 5537ea906..aaeb62112 100644 --- a/test/unit/artist_url_test.rb +++ b/test/unit/artist_url_test.rb @@ -40,8 +40,8 @@ class ArtistUrlTest < ActiveSupport::TestCase end should "normalize pixiv urls" do - url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/monet") - assert_equal("http://img55.pixiv.net/monet", url.url) + url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/img/monet") + assert_equal("http://img55.pixiv.net/img/monet", url.url) assert_equal("http://img.pixiv.net/monet/", url.normalized_url) end end From e6e3d315226e965e985b58da45e1560cb145d6e1 Mon Sep 17 00:00:00 2001 From: zatchii Date: Sun, 5 May 2013 13:40:42 +0000 Subject: [PATCH 21/34] Fix note bounding on left edge bound_position must be called after the body is shown, while resize must be called before. --- app/assets/javascripts/notes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 78bcf773d..bf0594b6a 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -139,10 +139,6 @@ Danbooru.Note = { top: $note_box.position().top + $note_box.height() + 5, left: $note_box.position().left }); - if (!$note_body.data('resized')) { - Danbooru.Note.Body.resize($note_body); - $note_body.data('resized', 'true'); - } Danbooru.Note.Body.bound_position($note_body); }, @@ -173,8 +169,12 @@ Danbooru.Note = { Danbooru.Note.Body.hide_all(); Danbooru.Note.clear_timeouts(); var $note_body = Danbooru.Note.Body.find(id); - Danbooru.Note.Body.initialize($note_body); + if (!$note_body.data('resized')) { + Danbooru.Note.Body.resize($note_body); + $note_body.data('resized', 'true'); + } $note_body.show(); + Danbooru.Note.Body.initialize($note_body); }, find: function(id) { From 4fe75a5e5d170b02a4c98abacd9088773758a53a Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 13:39:00 -0400 Subject: [PATCH 22/34] rearrange border colors for #1316 --- app/assets/javascripts/posts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 600348ae8..1b54c627d 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -218,9 +218,9 @@ if (border_colors.length > 1) { $img.css("border", "2px solid"); if (border_colors.length === 3) { - $img.css("border-color", border_colors[0] + " " + border_colors[2] + " " + border_colors[1]); + $img.css("border-color", border_colors[0] + " " + border_colors[2] + " " + border_colors[2] + " " + border_colors[1]); } else if (border_colors.length === 2) { - $img.css("border-color", border_colors[0] + " " + border_colors[1]); + $img.css("border-color", border_colors[0] + " " + border_colors[1] + " " + border_colors[1] + " " + border_colors[0]); } } } From a8409c20e689c87aebdfca8328f38c0475742222 Mon Sep 17 00:00:00 2001 From: Lightforger Date: Mon, 6 May 2013 00:15:13 +0300 Subject: [PATCH 23/34] fixes #1544 There may be a shorter way to do this? --- app/assets/javascripts/notes.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 2d49d888e..cd15da39e 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -433,9 +433,14 @@ Danbooru.Note = { Danbooru.Note.TranslationMode.active = false; var offset = $("#image").offset(); - if(dragged) { - if(w > 9 && h > 9) { /* minimum note size: 10px */ - Danbooru.Note.new(x-offset.left,y-offset.top,w,h); + if (dragged) { + if (w > 9 || h > 9) { /* minimum note size: 10px */ + if (w <= 9) { + w = 10; + } else if (h <= 9) { + h = 10; + } + Danbooru.Note.new(x - offset.left, y - offset.top, w, h); } } else { Danbooru.Note.new(e.pageX - offset.left, e.pageY - offset.top); From 9c410dee4af6bcf4352c547eb3d05626234cbdbb Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 17:34:41 -0400 Subject: [PATCH 24/34] partial fix for #1323 --- app/models/user.rb | 25 +++++++++++++++++++++++++ app/presenters/user_presenter.rb | 10 +++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index a484d3549..b258f0f00 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -517,6 +517,8 @@ class User < ActiveRecord::Base options ||= {} 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] super(options) end @@ -538,6 +540,28 @@ class User < ActiveRecord::Base end end + module CountMethods + def wiki_page_version_count + WikiPageVersion.for_user(id).count + end + + def artist_version_count + ArtistVersion.for_user(id).count + end + + def pool_version_count + PoolVersion.for_user(id).count + end + + def forum_post_count + ForumPost.for_user(id).count + end + + def comment_count + Comment.for_creator(id).count + end + end + module SearchMethods def named(name) where("lower(name) = ?", name) @@ -628,6 +652,7 @@ class User < ActiveRecord::Base include LimitMethods include InvitationMethods include ApiMethods + include CountMethods extend SearchMethods def initialize_default_image_size diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 711a908c1..608b01baa 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -80,7 +80,7 @@ class UserPresenter end def comment_count(template) - template.link_to(Comment.for_creator(user.id).count, template.comments_path(:search => {:creator_id => user.id}, :group_by => "comment")) + template.link_to(user.comment_count, template.comments_path(:search => {:creator_id => user.id}, :group_by => "comment")) end def commented_posts_count(template) @@ -100,19 +100,19 @@ class UserPresenter end def wiki_page_version_count(template) - template.link_to(WikiPageVersion.for_user(user.id).count, template.wiki_page_versions_path(:search => {:updater_id => user.id})) + template.link_to(user.wiki_page_version_count, template.wiki_page_versions_path(:search => {:updater_id => user.id})) end def artist_version_count(template) - template.link_to(ArtistVersion.for_user(user.id).count, template.artist_versions_path(:search => {:updater_id => user.id})) + template.link_to(user.artist_version_count, template.artist_versions_path(:search => {:updater_id => user.id})) end def forum_post_count(template) - template.link_to(ForumPost.for_user(user.id).count, template.forum_posts_path(:search => {:creator_id => user.id})) + template.link_to(user.forum_post_count, template.forum_posts_path(:search => {:creator_id => user.id})) end def pool_version_count(template) - template.link_to(PoolVersion.for_user(user.id).count, template.pool_versions_path(:search => {:updater_id => user.id})) + template.link_to(user.pool_version_count, template.pool_versions_path(:search => {:updater_id => user.id})) end def inviter(template) From 357332a5068d744f17b7c056672177be2d384690 Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 17:50:32 -0400 Subject: [PATCH 25/34] fix xml for #13235 --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index b258f0f00..bf9d87e89 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -527,6 +527,8 @@ class User < ActiveRecord::Base options ||= {} 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] super(options, &block) end From c1371eb0a2f18e2df0398b266b405b4871c070c4 Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 5 May 2013 20:31:07 -0400 Subject: [PATCH 26/34] escape html for related tags form --- app/assets/javascripts/blacklists.js | 2 +- app/assets/javascripts/related_tag.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/blacklists.js b/app/assets/javascripts/blacklists.js index ac8f2cafc..af2320f1b 100644 --- a/app/assets/javascripts/blacklists.js +++ b/app/assets/javascripts/blacklists.js @@ -57,7 +57,7 @@ var link = $(""); var count = $(""); - link.html(entry.tags); + link.text(entry.tags); link.click(Danbooru.Blacklist.toggle_entry); count.html(entry.hits); item.append(link); diff --git a/app/assets/javascripts/related_tag.js b/app/assets/javascripts/related_tag.js index 39cd2d7de..b4586cc34 100644 --- a/app/assets/javascripts/related_tag.js +++ b/app/assets/javascripts/related_tag.js @@ -164,7 +164,7 @@ var $ul = $("