deprecate tag subscriptions with warnings
This commit is contained in:
@@ -89,7 +89,7 @@
|
||||
Danbooru.Autocomplete.initialize_tag_autocomplete = function() {
|
||||
var $fields_multiple = $(
|
||||
"#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 = $(
|
||||
"#c-tags #search_name_matches,#c-tag-aliases #query,#c-tag-implications #query," +
|
||||
@@ -184,9 +184,6 @@
|
||||
case "ordfav":
|
||||
Danbooru.Autocomplete.user_source(term, resp, metatag);
|
||||
break;
|
||||
case "sub":
|
||||
Danbooru.Autocomplete.subscription_source(term, resp);
|
||||
break;
|
||||
case "pool":
|
||||
case "-pool":
|
||||
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) {
|
||||
$.ajax({
|
||||
url: "/pools.json",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class TagSubscriptionsController < ApplicationController
|
||||
before_filter :disable_feature, :only => [:create]
|
||||
before_filter :member_only, :only => [:new, :edit, :create, :update, :destroy, :migrate]
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
@@ -70,6 +71,12 @@ class TagSubscriptionsController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
def disable_feature
|
||||
flash[:notice] = "Tag subscriptions are disabled"
|
||||
redirect_to tag_subscriptions_path
|
||||
return false
|
||||
end
|
||||
|
||||
def check_privilege(tag_subscription)
|
||||
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)
|
||||
end
|
||||
|
||||
@@ -8,7 +8,6 @@ class DailyMaintenance
|
||||
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
|
||||
PostVote.prune!
|
||||
CommentVote.prune!
|
||||
#TagSubscription.process_all
|
||||
ApiCacheGenerator.new.generate_tag_cache
|
||||
PostDisapproval.prune!
|
||||
ForumSubscription.process_all!
|
||||
|
||||
@@ -80,27 +80,6 @@ class PostQueryBuilder
|
||||
relation
|
||||
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)
|
||||
if SavedSearch.enabled?
|
||||
saved_searches.each do |saved_search|
|
||||
@@ -228,11 +207,6 @@ class PostQueryBuilder
|
||||
relation = relation.where("posts.pool_string != ''")
|
||||
end
|
||||
|
||||
if q[:subscriptions]
|
||||
relation = add_tag_subscription_relation(q[:subscriptions], relation)
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if q[:saved_searches]
|
||||
relation = add_saved_search_relation(q[:saved_searches], relation)
|
||||
has_constraints!
|
||||
|
||||
@@ -166,22 +166,10 @@ module PostSets
|
||||
[page.to_i, 1].max
|
||||
end
|
||||
|
||||
def is_tag_subscription?
|
||||
tag_subscription.present?
|
||||
end
|
||||
|
||||
def is_saved_search?
|
||||
tag_string =~ /search:/
|
||||
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
|
||||
@presenter ||= ::PostSetPresenters::Post.new(self)
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ class UserDeletion
|
||||
clear_user_settings
|
||||
remove_favorites
|
||||
clear_tag_subscriptions
|
||||
clear_saved_searches
|
||||
rename
|
||||
reset_password
|
||||
create_mod_action
|
||||
@@ -37,6 +38,10 @@ private
|
||||
TagSubscription.where(:creator_id => user.id).destroy_all
|
||||
end
|
||||
|
||||
def clear_saved_searches
|
||||
SavedSearch.where(user_id: user.id).destroy_all
|
||||
end
|
||||
|
||||
def clear_user_settings
|
||||
user.email = nil
|
||||
user.last_logged_in_at = nil
|
||||
|
||||
@@ -512,10 +512,6 @@ class Tag < ActiveRecord::Base
|
||||
q[:tags][:related] << "fav:#{user_id}"
|
||||
q[:ordfav] = user_id
|
||||
|
||||
when "sub"
|
||||
q[:subscriptions] ||= []
|
||||
q[:subscriptions] << $2
|
||||
|
||||
when "search"
|
||||
q[:saved_searches] ||= []
|
||||
q[:saved_searches] << $2
|
||||
|
||||
@@ -13,8 +13,6 @@ module PostSetPresenters
|
||||
pattern_tags
|
||||
elsif post_set.is_saved_search?
|
||||
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?
|
||||
related_tags_for_single(post_set.tag_string)
|
||||
elsif post_set.unordered_tag_array.size == 1
|
||||
|
||||
@@ -63,20 +63,6 @@ class UserPresenter
|
||||
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
|
||||
if user.can_upload_free?
|
||||
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}))
|
||||
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
|
||||
if CurrentUser.user.id == user.id
|
||||
SavedSearch.labels_for(CurrentUser.user.id)
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
<ul id="related-list">
|
||||
<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 "Mobile version", mobile_posts_path(:tags => params[:tags]) %></li>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<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>
|
||||
|
||||
<% if @tag_subscription && !@tag_subscription.new_record? && @tag_subscription.editable_by?(CurrentUser.user) %>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<div id="c-tag-subscriptions">
|
||||
<div id="a-index">
|
||||
<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%">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -17,17 +20,13 @@
|
||||
<td><%= tag_subscription.pretty_tag_query %></td>
|
||||
<td><%= tag_subscription.post_id_array.size %></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 "posts", posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}"), :rel => "nofollow" %>
|
||||
<%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %>
|
||||
| <%= link_to "migrate", migrate_tag_subscription_path(tag_subscription), :method => :post %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p class="info">You can create up to <%= Danbooru.config.max_tag_subscriptions %> subscriptions with up to 20 queries each.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
<div id="a-new">
|
||||
<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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
<% if @user.id == CurrentUser.user.id %>
|
||||
<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 "Messages #{CurrentUser.user.dmail_count}", dmails_current_folder_path %></li>
|
||||
|
||||
|
||||
@@ -150,13 +150,7 @@
|
||||
<tr>
|
||||
<th>Subscriptions</th>
|
||||
<td>
|
||||
<% presenter.subscriptions.each do |subscription| %>
|
||||
<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 %>
|
||||
<em>This feature has been disabled. <%= link_to "Migrate your tag subscriptions to saved searches", tag_subscriptions_path %>.</em>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user