Merge pull request #3737 from r888888888/inline-dead-artist-urls
Inline disabling of artist URLs
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
$("#related-tags-container").hide();
|
$("#related-tags-container").hide();
|
||||||
$("#artist-tags-container").hide();
|
$("#artist-tags-container").hide();
|
||||||
$("#upload_tag_string,#post_tag_string").keyup(Danbooru.RelatedTag.update_selected);
|
$("#upload_tag_string,#post_tag_string").keyup(Danbooru.RelatedTag.update_selected);
|
||||||
|
$("body").on("click", "#artist-related-tags-column a.del", Danbooru.RelatedTag.disable_artist_url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,19 +237,26 @@
|
|||||||
if (desc.length > 30) {
|
if (desc.length > 30) {
|
||||||
desc = desc.substring(0, 30) + "...";
|
desc = desc.substring(0, 30) + "...";
|
||||||
}
|
}
|
||||||
var $del = $("<del/>").text(desc);
|
$ul.append(
|
||||||
$ul.append($("<li/>").html($del));
|
$("<li>").append(
|
||||||
|
$("<del>").text(desc)
|
||||||
|
)
|
||||||
|
);
|
||||||
} else if (text.match(/^ http/)) {
|
} else if (text.match(/^ http/)) {
|
||||||
text = text.substring(1, 1000);
|
text = text.substring(1, 1000);
|
||||||
var $url = $("<a/>");
|
|
||||||
var desc = text.replace(/^https?:\/\//, "");
|
var desc = text.replace(/^https?:\/\//, "");
|
||||||
if (desc.length > 30) {
|
if (desc.length > 30) {
|
||||||
desc = desc.substring(0, 30) + "...";
|
desc = desc.substring(0, 30) + "...";
|
||||||
}
|
}
|
||||||
$url.text(desc);
|
$ul.append(
|
||||||
$url.attr("href", text);
|
$("<li>").append([
|
||||||
$url.attr("target", "_blank");
|
$("<a>").text(desc).attr("href", text).attr("target", "_blank"),
|
||||||
$ul.append($("<li/>").html($url));
|
" ",
|
||||||
|
$("<a>").attr("href", text).addClass("del").append(
|
||||||
|
$("<i>").addClass("fas fa-minus-circle")
|
||||||
|
)
|
||||||
|
])
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$ul.append($("<li/>").text(text));
|
$ul.append($("<li/>").text(text));
|
||||||
}
|
}
|
||||||
@@ -286,7 +294,9 @@
|
|||||||
var url = $("#upload_source,#post_source");
|
var url = $("#upload_source,#post_source");
|
||||||
var referer_url = $("#upload_referer_url");
|
var referer_url = $("#upload_referer_url");
|
||||||
$.get("/artists/finder.json", {"url": url.val(), "referer_url": referer_url.val()}, Danbooru.RelatedTag.process_artist);
|
$.get("/artists/finder.json", {"url": url.val(), "referer_url": referer_url.val()}, Danbooru.RelatedTag.process_artist);
|
||||||
e.preventDefault();
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.RelatedTag.process_artist = function(data) {
|
Danbooru.RelatedTag.process_artist = function(data) {
|
||||||
@@ -314,6 +324,27 @@
|
|||||||
$("#related-tags").hide();
|
$("#related-tags").hide();
|
||||||
$("#toggle-related-tags-link").text("»");
|
$("#toggle-related-tags-link").text("»");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Danbooru.RelatedTag.disable_artist_url = function(e) {
|
||||||
|
var url = e.currentTarget.href;
|
||||||
|
$.each(Danbooru.RelatedTag.recent_artists[0].sorted_urls, function(k, v) {
|
||||||
|
if (v["normalized_url"] === url || v["url"] === url) {
|
||||||
|
if (!confirm("This will mark the URL as inactive. Continue?")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax("/artist_urls/" + v["id"], {
|
||||||
|
method: "PUT",
|
||||||
|
data: {
|
||||||
|
artist_url: {
|
||||||
|
is_active: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).done(Danbooru.RelatedTag.find_artist);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ div.related-tags {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
margin-top: 2px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
min-width: 3em;
|
min-width: 3em;
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/controllers/artist_urls_controller.rb
Normal file
18
app/controllers/artist_urls_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
class ArtistUrlsController < ApplicationController
|
||||||
|
respond_to :json
|
||||||
|
before_action :member_only
|
||||||
|
|
||||||
|
def update
|
||||||
|
@artist_url = ArtistUrl.find(params[:id])
|
||||||
|
@artist_url.update(artist_url_params)
|
||||||
|
respond_with(@artist_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def artist_url_params
|
||||||
|
permitted_params = %i[is_active]
|
||||||
|
|
||||||
|
params.fetch(:artist_url, {}).permit(permitted_params)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
class ArtistsController < ApplicationController
|
class ArtistsController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json, :js
|
||||||
before_action :member_only, :except => [:index, :show, :show_or_new, :banned]
|
before_action :member_only, :except => [:index, :show, :show_or_new, :banned]
|
||||||
before_action :builder_only, :only => [:destroy]
|
before_action :builder_only, :only => [:destroy]
|
||||||
before_action :admin_only, :only => [:ban, :unban]
|
before_action :admin_only, :only => [:ban, :unban]
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class PopularSearchService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_data
|
def fetch_data
|
||||||
|
return [] unless self.class.enabled?
|
||||||
|
|
||||||
dates = date.strftime("%Y-%m-%d")
|
dates = date.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
Cache.get("ps-day-#{dates}", 1.minute) do
|
Cache.get("ps-day-#{dates}", 1.minute) do
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<% if @artist.is_active? %>
|
<% if @artist.is_active? %>
|
||||||
<li id="artist-delete"><%= link_to "Delete", artist_path(@artist), method: :delete, data: {confirm: "Are you sure you want to delete this artist?"} %></li>
|
<li id="artist-delete"><%= link_to "Delete", artist_path(@artist), method: :delete, data: {confirm: "Are you sure you want to delete this artist?"} %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Undelete", artist_path(@artist), method: :put, data: {confirm: "Are you sure you want to undelete this artist?", params: {"artist[is_active]" => true}} %></li>
|
<li><%= link_to "Undelete", artist_path(@artist, format: "js"), method: :put, data: {confirm: "Are you sure you want to undelete this artist?", params: "artist[is_active]=true"}, remote: true %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
|
|||||||
1
app/views/artists/update.js.erb
Normal file
1
app/views/artists/update.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
location.reload();
|
||||||
@@ -6,7 +6,8 @@ RUN apt-get -y install wget
|
|||||||
RUN wget -q https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
RUN wget -q https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||||
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||||
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
|
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
|
||||||
RUN apt-get -y install -qq apt-utils build-essential automake libssl-dev libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev imagemagick libmagickcore-dev libmagickwand-dev sendmail-bin sendmail postgresql-client libpq-dev nginx ssh coreutils ffmpeg mkvtoolnix emacs24-nox telnet libvips42 libvips-tools libvips-dev > /dev/null
|
RUN apt-get -y install -qq apt-utils build-essential automake libssl-dev libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev imagemagick libmagickcore-dev libmagickwand-dev sendmail-bin sendmail postgresql-client libpq-dev nginx ssh coreutils ffmpeg mkvtoolnix emacs24-nox telnet libvips42 libvips-tools libvips-dev && \
|
||||||
|
apt-get clean
|
||||||
RUN useradd -ms /bin/bash danbooru -u 1000
|
RUN useradd -ms /bin/bash danbooru -u 1000
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
RUN mkdir -p /var/www/danbooru/shared/data
|
RUN mkdir -p /var/www/danbooru/shared/data
|
||||||
@@ -22,7 +23,7 @@ USER danbooru
|
|||||||
RUN echo 'gem: --no-document' > ~/.gemrc
|
RUN echo 'gem: --no-document' > ~/.gemrc
|
||||||
RUN gem install bundler --quiet
|
RUN gem install bundler --quiet
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN bundle install > /dev/null
|
RUN bundle install
|
||||||
COPY script/install/database.yml.templ /app/config/database.yml
|
COPY script/install/database.yml.templ /app/config/database.yml
|
||||||
COPY script/install/danbooru_local_config.rb.templ /app/config/danbooru_local_config.rb
|
COPY script/install/danbooru_local_config.rb.templ /app/config/danbooru_local_config.rb
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ Rails.application.routes.draw do
|
|||||||
get :finder
|
get :finder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resources :artist_urls, only: [:update]
|
||||||
resources :artist_versions, :only => [:index] do
|
resources :artist_versions, :only => [:index] do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
should "undelete an artist" do
|
should "undelete an artist" do
|
||||||
@builder = create(:builder_user)
|
@builder = create(:builder_user)
|
||||||
post_auth undelete_artist_path(@artist.id), @builder
|
put_auth artist_path(@artist.id), @builder, params: {artist: {is_active: true}}
|
||||||
assert_redirected_to(artist_path(@artist.id))
|
assert_redirected_to(artist_path(@artist.id))
|
||||||
assert_equal(true, @artist.reload.is_active)
|
assert_equal(true, @artist.reload.is_active)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ require "test_helper"
|
|||||||
class PostsControllerTest < ActionDispatch::IntegrationTest
|
class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||||
context "The posts controller" do
|
context "The posts controller" do
|
||||||
setup do
|
setup do
|
||||||
|
PopularSearchService.stubs(:enabled?).returns(false)
|
||||||
|
|
||||||
@user = travel_to(1.month.ago) {create(:user)}
|
@user = travel_to(1.month.ago) {create(:user)}
|
||||||
as_user do
|
as_user do
|
||||||
@post = create(:post, :tag_string => "aaaa")
|
@post = create(:post, :tag_string => "aaaa")
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class PostReplacementTest < ActiveSupport::TestCase
|
|||||||
assert_equal("cad1da177ef309bf40a117c17b8eecf5", Digest::MD5.file(@post.file).hexdigest)
|
assert_equal("cad1da177ef309bf40a117c17b8eecf5", Digest::MD5.file(@post.file).hexdigest)
|
||||||
|
|
||||||
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @post.source)
|
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @post.source)
|
||||||
assert_equal([{"delay_msec"=>125}, {"delay_msec"=>125}], @post.pixiv_ugoira_frame_data.data)
|
assert_equal([{"delay"=>125, "file"=>"000001.jpg"}, {"delay"=>125,"file"=>"000002.jpg"}], @post.pixiv_ugoira_frame_data.data)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
skip "Remote connection to Pixiv failed"
|
skip "Remote connection to Pixiv failed"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user