deprecate tag subscriptions with warnings
This commit is contained in:
@@ -89,7 +89,7 @@
|
|||||||
Danbooru.Autocomplete.initialize_tag_autocomplete = function() {
|
Danbooru.Autocomplete.initialize_tag_autocomplete = function() {
|
||||||
var $fields_multiple = $(
|
var $fields_multiple = $(
|
||||||
"#tags,#post_tag_string,#upload_tag_string,#tag-script-field,#c-moderator-post-queues #query," +
|
"#tags,#post_tag_string,#upload_tag_string,#tag-script-field,#c-moderator-post-queues #query," +
|
||||||
"#user_blacklisted_tags,#user_favorite_tags,#tag_subscription_tag_query,#search_post_tags_match"
|
"#user_blacklisted_tags,#user_favorite_tags,#search_post_tags_match"
|
||||||
);
|
);
|
||||||
var $fields_single = $(
|
var $fields_single = $(
|
||||||
"#c-tags #search_name_matches,#c-tag-aliases #query,#c-tag-implications #query," +
|
"#c-tags #search_name_matches,#c-tag-aliases #query,#c-tag-implications #query," +
|
||||||
@@ -184,9 +184,6 @@
|
|||||||
case "ordfav":
|
case "ordfav":
|
||||||
Danbooru.Autocomplete.user_source(term, resp, metatag);
|
Danbooru.Autocomplete.user_source(term, resp, metatag);
|
||||||
break;
|
break;
|
||||||
case "sub":
|
|
||||||
Danbooru.Autocomplete.subscription_source(term, resp);
|
|
||||||
break;
|
|
||||||
case "pool":
|
case "pool":
|
||||||
case "-pool":
|
case "-pool":
|
||||||
case "ordpool":
|
case "ordpool":
|
||||||
@@ -391,34 +388,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Autocomplete.subscription_source = function(term, resp) {
|
|
||||||
var match = term.match(/^(.+?):(.*)$/);
|
|
||||||
if (match) {
|
|
||||||
var user_name = match[1];
|
|
||||||
var subscription_name = match[2];
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: "/tag_subscriptions.json",
|
|
||||||
data: {
|
|
||||||
"search[creator_name]": user_name,
|
|
||||||
"search[name_matches]": subscription_name + "*",
|
|
||||||
"limit": 10
|
|
||||||
},
|
|
||||||
method: "get",
|
|
||||||
success: function(data) {
|
|
||||||
resp($.map(data, function(subscription) {
|
|
||||||
return {
|
|
||||||
label: subscription.name.replace(/_/g, " "),
|
|
||||||
value: "sub:" + user_name + ":" + subscription.name
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Danbooru.Autocomplete.user_source(term, resp, "sub");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Danbooru.Autocomplete.pool_source = function(term, resp, metatag) {
|
Danbooru.Autocomplete.pool_source = function(term, resp, metatag) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/pools.json",
|
url: "/pools.json",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class TagSubscriptionsController < ApplicationController
|
class TagSubscriptionsController < ApplicationController
|
||||||
|
before_filter :disable_feature, :only => [:create]
|
||||||
before_filter :member_only, :only => [:new, :edit, :create, :update, :destroy, :migrate]
|
before_filter :member_only, :only => [:new, :edit, :create, :update, :destroy, :migrate]
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
|
|
||||||
@@ -70,6 +71,12 @@ class TagSubscriptionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def disable_feature
|
||||||
|
flash[:notice] = "Tag subscriptions are disabled"
|
||||||
|
redirect_to tag_subscriptions_path
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def check_privilege(tag_subscription)
|
def check_privilege(tag_subscription)
|
||||||
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)
|
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ class DailyMaintenance
|
|||||||
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
|
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
|
||||||
PostVote.prune!
|
PostVote.prune!
|
||||||
CommentVote.prune!
|
CommentVote.prune!
|
||||||
#TagSubscription.process_all
|
|
||||||
ApiCacheGenerator.new.generate_tag_cache
|
ApiCacheGenerator.new.generate_tag_cache
|
||||||
PostDisapproval.prune!
|
PostDisapproval.prune!
|
||||||
ForumSubscription.process_all!
|
ForumSubscription.process_all!
|
||||||
|
|||||||
@@ -80,27 +80,6 @@ class PostQueryBuilder
|
|||||||
relation
|
relation
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_tag_subscription_relation(subscriptions, relation)
|
|
||||||
subscriptions.each do |subscription|
|
|
||||||
if subscription =~ /^(.+?):(.+)$/
|
|
||||||
user_name = $1
|
|
||||||
subscription_name = $2
|
|
||||||
user = User.find_by_name(user_name)
|
|
||||||
return relation if user.nil?
|
|
||||||
post_ids = TagSubscription.find_post_ids(user.id, subscription_name)
|
|
||||||
else
|
|
||||||
user = User.find_by_name(subscription)
|
|
||||||
return relation if user.nil?
|
|
||||||
post_ids = TagSubscription.find_post_ids(user.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
post_ids = [0] if post_ids.empty?
|
|
||||||
relation = relation.where(["posts.id IN (?)", post_ids])
|
|
||||||
end
|
|
||||||
|
|
||||||
relation
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_saved_search_relation(saved_searches, relation)
|
def add_saved_search_relation(saved_searches, relation)
|
||||||
if SavedSearch.enabled?
|
if SavedSearch.enabled?
|
||||||
saved_searches.each do |saved_search|
|
saved_searches.each do |saved_search|
|
||||||
@@ -228,11 +207,6 @@ class PostQueryBuilder
|
|||||||
relation = relation.where("posts.pool_string != ''")
|
relation = relation.where("posts.pool_string != ''")
|
||||||
end
|
end
|
||||||
|
|
||||||
if q[:subscriptions]
|
|
||||||
relation = add_tag_subscription_relation(q[:subscriptions], relation)
|
|
||||||
has_constraints!
|
|
||||||
end
|
|
||||||
|
|
||||||
if q[:saved_searches]
|
if q[:saved_searches]
|
||||||
relation = add_saved_search_relation(q[:saved_searches], relation)
|
relation = add_saved_search_relation(q[:saved_searches], relation)
|
||||||
has_constraints!
|
has_constraints!
|
||||||
|
|||||||
@@ -166,22 +166,10 @@ module PostSets
|
|||||||
[page.to_i, 1].max
|
[page.to_i, 1].max
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_tag_subscription?
|
|
||||||
tag_subscription.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_saved_search?
|
def is_saved_search?
|
||||||
tag_string =~ /search:/
|
tag_string =~ /search:/
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_subscription
|
|
||||||
@tag_subscription ||= tag_array.select {|x| x =~ /^sub:/}.map {|x| x.sub(/^sub:/, "")}.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def tag_subscription_tags
|
|
||||||
@tag_subscription_tags ||= TagSubscription.find_tags(tag_subscription)
|
|
||||||
end
|
|
||||||
|
|
||||||
def presenter
|
def presenter
|
||||||
@presenter ||= ::PostSetPresenters::Post.new(self)
|
@presenter ||= ::PostSetPresenters::Post.new(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class UserDeletion
|
|||||||
clear_user_settings
|
clear_user_settings
|
||||||
remove_favorites
|
remove_favorites
|
||||||
clear_tag_subscriptions
|
clear_tag_subscriptions
|
||||||
|
clear_saved_searches
|
||||||
rename
|
rename
|
||||||
reset_password
|
reset_password
|
||||||
create_mod_action
|
create_mod_action
|
||||||
@@ -37,6 +38,10 @@ private
|
|||||||
TagSubscription.where(:creator_id => user.id).destroy_all
|
TagSubscription.where(:creator_id => user.id).destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_saved_searches
|
||||||
|
SavedSearch.where(user_id: user.id).destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
def clear_user_settings
|
def clear_user_settings
|
||||||
user.email = nil
|
user.email = nil
|
||||||
user.last_logged_in_at = nil
|
user.last_logged_in_at = nil
|
||||||
|
|||||||
@@ -512,10 +512,6 @@ class Tag < ActiveRecord::Base
|
|||||||
q[:tags][:related] << "fav:#{user_id}"
|
q[:tags][:related] << "fav:#{user_id}"
|
||||||
q[:ordfav] = user_id
|
q[:ordfav] = user_id
|
||||||
|
|
||||||
when "sub"
|
|
||||||
q[:subscriptions] ||= []
|
|
||||||
q[:subscriptions] << $2
|
|
||||||
|
|
||||||
when "search"
|
when "search"
|
||||||
q[:saved_searches] ||= []
|
q[:saved_searches] ||= []
|
||||||
q[:saved_searches] << $2
|
q[:saved_searches] << $2
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ module PostSetPresenters
|
|||||||
pattern_tags
|
pattern_tags
|
||||||
elsif post_set.is_saved_search?
|
elsif post_set.is_saved_search?
|
||||||
SavedSearch.labels_for(CurrentUser.user.id).map {|x| "search:#{x}"}
|
SavedSearch.labels_for(CurrentUser.user.id).map {|x| "search:#{x}"}
|
||||||
elsif post_set.is_tag_subscription?
|
|
||||||
post_set.tag_subscription_tags
|
|
||||||
elsif post_set.is_single_tag?
|
elsif post_set.is_single_tag?
|
||||||
related_tags_for_single(post_set.tag_string)
|
related_tags_for_single(post_set.tag_string)
|
||||||
elsif post_set.unordered_tag_array.size == 1
|
elsif post_set.unordered_tag_array.size == 1
|
||||||
|
|||||||
@@ -63,20 +63,6 @@ class UserPresenter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts_for_subscription(subscription)
|
|
||||||
arel = Post.where("id in (?)", subscription.post_id_array.map(&:to_i)).order("id desc").limit(6)
|
|
||||||
|
|
||||||
if CurrentUser.user.hide_deleted_posts?
|
|
||||||
arel = arel.undeleted
|
|
||||||
end
|
|
||||||
|
|
||||||
arel
|
|
||||||
end
|
|
||||||
|
|
||||||
def tag_links_for_subscription(template, subscription)
|
|
||||||
subscription.tag_query_array.map {|x| template.link_to(x, template.posts_path(:tags => x))}.join(", ").html_safe
|
|
||||||
end
|
|
||||||
|
|
||||||
def upload_limit
|
def upload_limit
|
||||||
if user.can_upload_free?
|
if user.can_upload_free?
|
||||||
return "none"
|
return "none"
|
||||||
@@ -213,14 +199,6 @@ class UserPresenter
|
|||||||
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id}))
|
template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscriptions
|
|
||||||
if CurrentUser.user.id == user.id
|
|
||||||
user.subscriptions
|
|
||||||
else
|
|
||||||
user.subscriptions.select {|x| x.is_public?}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def saved_search_labels
|
def saved_search_labels
|
||||||
if CurrentUser.user.id == user.id
|
if CurrentUser.user.id == user.id
|
||||||
SavedSearch.labels_for(CurrentUser.user.id)
|
SavedSearch.labels_for(CurrentUser.user.id)
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
<ul id="related-list">
|
<ul id="related-list">
|
||||||
<li><%= link_to "Deleted posts", posts_path(:tags => "#{params[:tags]} status:deleted"), :rel => "nofollow" %></li>
|
<li><%= link_to "Deleted posts", posts_path(:tags => "#{params[:tags]} status:deleted"), :rel => "nofollow" %></li>
|
||||||
|
|
||||||
<% if @post_set.is_tag_subscription? %>
|
|
||||||
<li><%= link_to "Manage subscriptions", tag_subscriptions_path %></li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<li><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post", :rel => "nofollow" %></li>
|
<li><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post", :rel => "nofollow" %></li>
|
||||||
|
|
||||||
<li><%= link_to "Mobile version", mobile_posts_path(:tags => params[:tags]) %></li>
|
<li><%= link_to "Mobile version", mobile_posts_path(:tags => params[:tags]) %></li>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", tag_subscriptions_path %></li>
|
<li><%= link_to "Listing", tag_subscriptions_path %></li>
|
||||||
<% if CurrentUser.is_member? %>
|
|
||||||
<li><%= link_to "New", new_tag_subscription_path %></li>
|
|
||||||
<% end %>
|
|
||||||
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_subscriptions") %></li>
|
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_subscriptions") %></li>
|
||||||
|
|
||||||
<% if @tag_subscription && !@tag_subscription.new_record? && @tag_subscription.editable_by?(CurrentUser.user) %>
|
<% if @tag_subscription && !@tag_subscription.new_record? && @tag_subscription.editable_by?(CurrentUser.user) %>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<div id="c-tag-subscriptions">
|
<div id="c-tag-subscriptions">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<h1>Tag Subscriptions</h1>
|
<h1>Tag Subscriptions</h1>
|
||||||
|
|
||||||
|
<p class="info">The tag subscription feature is being deprecated. You can move your current tag subscriptions to saved searches by clicking the "migrate" link below.</p>
|
||||||
|
|
||||||
<table class="striped" width="100%">
|
<table class="striped" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -17,17 +20,13 @@
|
|||||||
<td><%= tag_subscription.pretty_tag_query %></td>
|
<td><%= tag_subscription.pretty_tag_query %></td>
|
||||||
<td><%= tag_subscription.post_id_array.size %></td>
|
<td><%= tag_subscription.post_id_array.size %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to "edit", edit_tag_subscription_path(tag_subscription) %>
|
<%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %>
|
||||||
| <%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %>
|
|
||||||
| <%= link_to "posts", posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}"), :rel => "nofollow" %>
|
|
||||||
| <%= link_to "migrate", migrate_tag_subscription_path(tag_subscription), :method => :post %>
|
| <%= link_to "migrate", migrate_tag_subscription_path(tag_subscription), :method => :post %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p class="info">You can create up to <%= Danbooru.config.max_tag_subscriptions %> subscriptions with up to 20 queries each.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
<div id="a-new">
|
<div id="a-new">
|
||||||
<h1>New Tag Subscription</h1>
|
<h1>New Tag Subscription</h1>
|
||||||
|
|
||||||
<%= error_messages_for "tag_subscription" %>
|
<p class="info">This feature is disabled.</p>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%#= error_messages_for "tag_subscription" %>
|
||||||
|
|
||||||
|
<%#= render "form" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<div id="c-tag-subscriptions">
|
|
||||||
<div id="a-posts">
|
|
||||||
<aside id="sidebar">
|
|
||||||
<%= render "posts/partials/common/search", :path => posts_tag_subscription_path, :tags => @post_set.tag_string, :tags_dom_id => "tags" %>
|
|
||||||
<%= render "posts/partials/index/mode_menu" %>
|
|
||||||
<%= render "posts/partials/index/blacklist" %>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<section id="content">
|
|
||||||
<h1>Tag Subscriptions [<%= link_to "edit", tag_subscriptions_path %>]</h1>
|
|
||||||
|
|
||||||
<%= @post_set.presenter.post_previews_html(self) %>
|
|
||||||
|
|
||||||
<%= numbered_paginator(@posts) %>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<%= render "posts/partials/common/secondary_links" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% content_for(:page_title) do %>
|
|
||||||
Tag Subscriptions - <%= @user.name %> - <%= Danbooru.config.app_name %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
@@ -12,9 +12,6 @@
|
|||||||
<li>|</li>
|
<li>|</li>
|
||||||
<% if @user.id == CurrentUser.user.id %>
|
<% if @user.id == CurrentUser.user.id %>
|
||||||
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
|
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
|
||||||
<% if @user.is_gold? %>
|
|
||||||
<li><%= link_to "Edit subscriptions", tag_subscriptions_path %></li>
|
|
||||||
<% end %>
|
|
||||||
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
||||||
<li><%= link_to "Messages #{CurrentUser.user.dmail_count}", dmails_current_folder_path %></li>
|
<li><%= link_to "Messages #{CurrentUser.user.dmail_count}", dmails_current_folder_path %></li>
|
||||||
|
|
||||||
|
|||||||
@@ -150,13 +150,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Subscriptions</th>
|
<th>Subscriptions</th>
|
||||||
<td>
|
<td>
|
||||||
<% presenter.subscriptions.each do |subscription| %>
|
<em>This feature has been disabled. <%= link_to "Migrate your tag subscriptions to saved searches", tag_subscriptions_path %>.</em>
|
||||||
<p>
|
|
||||||
<strong><%= link_to subscription.pretty_name, posts_path(:tags => "sub:#{user.name}:#{subscription.name}") %></strong>
|
|
||||||
–
|
|
||||||
<%= presenter.tag_links_for_subscription(self, subscription) %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user