forked from e621ng/e621ng
additional saved search fixes
This commit is contained in:
parent
1207faa600
commit
8a93fdf18f
2
Procfile
2
Procfile
@ -1,2 +1,2 @@
|
|||||||
unicorn: bundle exec unicorn -c config/unicorn/unicorn.rb
|
unicorn: bundle exec rails server
|
||||||
jobs: bundle exec script/delayed_job run
|
jobs: bundle exec script/delayed_job run
|
||||||
|
@ -548,7 +548,7 @@
|
|||||||
method: "get",
|
method: "get",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
resp($.map(data, function(saved_search) {
|
resp($.map(data, function(saved_search) {
|
||||||
var category = saved_search.category === null ? "Uncategorized" : saved_search.category;
|
var category = saved_search.category === null ? "uncategorized" : saved_search.category;
|
||||||
return {
|
return {
|
||||||
label: category,
|
label: category,
|
||||||
value: category
|
value: category
|
||||||
|
7
app/assets/stylesheets/specific/saved_searches.css.scss
Normal file
7
app/assets/stylesheets/specific/saved_searches.css.scss
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#c-saved-searches {
|
||||||
|
#a-index {
|
||||||
|
table {
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
class SavedSearch < ActiveRecord::Base
|
class SavedSearch < ActiveRecord::Base
|
||||||
UNCATEGORIZED_NAME = "Uncategorized"
|
UNCATEGORIZED_NAME = "uncategorized"
|
||||||
|
|
||||||
module ListbooruMethods
|
module ListbooruMethods
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
@ -57,9 +57,15 @@ class SavedSearch < ActiveRecord::Base
|
|||||||
body = Cache.get("ss-pids-#{user_id}-#{hash_name}", 60) do
|
body = Cache.get("ss-pids-#{user_id}-#{hash_name}", 60) do
|
||||||
params = {
|
params = {
|
||||||
"key" => Danbooru.config.listbooru_auth_key,
|
"key" => Danbooru.config.listbooru_auth_key,
|
||||||
"user_id" => user_id,
|
"user_id" => user_id
|
||||||
"name" => name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if name == UNCATEGORIZED_NAME
|
||||||
|
params["name"] = nil
|
||||||
|
elsif name.present?
|
||||||
|
params["name"] = name
|
||||||
|
end
|
||||||
|
|
||||||
uri = URI.parse("#{Danbooru.config.listbooru_server}/users")
|
uri = URI.parse("#{Danbooru.config.listbooru_server}/users")
|
||||||
uri.query = URI.encode_www_form(params)
|
uri.query = URI.encode_www_form(params)
|
||||||
|
|
||||||
@ -133,7 +139,13 @@ class SavedSearch < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.categories_for(user)
|
def self.categories_for(user)
|
||||||
user.saved_searches.pluck("distinct category")
|
user.saved_searches.pluck("distinct category").map do |x|
|
||||||
|
if x.blank?
|
||||||
|
SavedSearch::UNCATEGORIZED_NAME
|
||||||
|
else
|
||||||
|
x
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize
|
def normalize
|
||||||
|
@ -11,6 +11,8 @@ module PostSetPresenters
|
|||||||
def related_tags
|
def related_tags
|
||||||
if post_set.is_pattern_search?
|
if post_set.is_pattern_search?
|
||||||
pattern_tags
|
pattern_tags
|
||||||
|
elsif post_set.is_saved_search?
|
||||||
|
SavedSearch.categories_for(CurrentUser.user).map {|x| "search:#{x}"}
|
||||||
elsif post_set.is_tag_subscription?
|
elsif post_set.is_tag_subscription?
|
||||||
post_set.tag_subscription_tags
|
post_set.tag_subscription_tags
|
||||||
elsif post_set.is_single_tag?
|
elsif post_set.is_single_tag?
|
||||||
@ -59,6 +61,10 @@ module PostSetPresenters
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_list_html(template, options = {})
|
def tag_list_html(template, options = {})
|
||||||
|
if post_set.is_saved_search?
|
||||||
|
options[:name_only] = true
|
||||||
|
end
|
||||||
|
|
||||||
tag_set_presenter.tag_list_html(template, options)
|
tag_set_presenter.tag_list_html(template, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<%= link_to_if SavedSearch.posts_search_available?, category.tr("_", " "), posts_path(:tags => "search:#{category}") %>
|
<%= link_to_if SavedSearch.posts_search_available?, category.tr("_", " "), posts_path(:tags => "search:#{category}") %>
|
||||||
(<%= link_to "rename", new_saved_search_category_change_path(:old => category) %>)
|
(<%= link_to "rename", new_saved_search_category_change_path(:old => category) %>)
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to_if SavedSearch.posts_search_available?, SavedSearch::UNCATEGORIZED_NAME, posts_path(:tags => "search:all") %>
|
<%= link_to_if SavedSearch.posts_search_available?, SavedSearch::UNCATEGORIZED_NAME, posts_path(:tags => "search:#{SavedSearch::UNCATEGORIZED_NAME}") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</h2>
|
</h2>
|
||||||
<table class="striped" width="100%">
|
<table class="striped" width="100%">
|
||||||
|
Loading…
Reference in New Issue
Block a user