add user searches
This commit is contained in:
@@ -28,6 +28,18 @@ module PostsHelper
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def common_searches_html(user)
|
||||||
|
return nil unless Danbooru.config.enable_post_search_counts
|
||||||
|
return nil unless user.is_platinum?
|
||||||
|
return nil unless user.enable_recent_searches?
|
||||||
|
|
||||||
|
key = "uid"
|
||||||
|
value = user.id
|
||||||
|
digest = OpenSSL::Digest.new("sha256")
|
||||||
|
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{key},#{value}")
|
||||||
|
render("users/common_searches", user: user, sig: sig)
|
||||||
|
end
|
||||||
|
|
||||||
def resize_image_links(post, user)
|
def resize_image_links(post, user)
|
||||||
links = []
|
links = []
|
||||||
|
|
||||||
|
|||||||
@@ -35,13 +35,14 @@ class User < ActiveRecord::Base
|
|||||||
disable_categorized_saved_searches
|
disable_categorized_saved_searches
|
||||||
is_super_voter
|
is_super_voter
|
||||||
disable_tagged_filenames
|
disable_tagged_filenames
|
||||||
|
enable_recent_searches
|
||||||
)
|
)
|
||||||
|
|
||||||
include Danbooru::HasBitFlags
|
include Danbooru::HasBitFlags
|
||||||
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
attr_accessor :password, :old_password
|
||||||
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||||
attr_accessible :level, :as => :admin
|
attr_accessible :level, :as => :admin
|
||||||
validates_length_of :name, :within => 2..100, :on => :create
|
validates_length_of :name, :within => 2..100, :on => :create
|
||||||
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
<%= render "posts/partials/index/blacklist" %>
|
<%= render "posts/partials/index/blacklist" %>
|
||||||
|
|
||||||
|
<%= raw common_searches_html(CurrentUser.user) %>
|
||||||
|
|
||||||
<section id="tag-box">
|
<section id="tag-box">
|
||||||
<h1>Tags</h1>
|
<h1>Tags</h1>
|
||||||
<%= @post_set.presenter.tag_list_html(self) %>
|
<%= @post_set.presenter.tag_list_html(self) %>
|
||||||
|
|||||||
1
app/views/static/test.html.erb
Normal file
1
app/views/static/test.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= raw common_searches_html(CurrentUser.user) %>
|
||||||
17
app/views/users/_common_searches.html.erb
Normal file
17
app/views/users/_common_searches.html.erb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<section id="outer-recent-searches" style="display: none;">
|
||||||
|
<h1>Recent Searches</h1>
|
||||||
|
<ul id="recent-searches">
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$.get("<%= Danbooru.config.report_server %>/user_searches", {
|
||||||
|
uid: <%= user.id %>,
|
||||||
|
sig: "<%= sig %>"
|
||||||
|
}, function(data) {
|
||||||
|
$("#recent-searches").html(data);
|
||||||
|
$("#outer-recent-searches").show();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -74,6 +74,8 @@
|
|||||||
|
|
||||||
<%= f.input :disable_tagged_filenames, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
<%= f.input :disable_tagged_filenames, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
||||||
|
|
||||||
|
<%= f.input :enable_recent_searches, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
||||||
|
|
||||||
<div class="input text optional field_with_hint">
|
<div class="input text optional field_with_hint">
|
||||||
<label class="text optional" for="user_favorite_tags">Frequent tags</label>
|
<label class="text optional" for="user_favorite_tags">Frequent tags</label>
|
||||||
<textarea id="user_favorite_tags" class="text optional" rows="5" name="user[favorite_tags]" cols="40"><%= raw @user.favorite_tags %></textarea>
|
<textarea id="user_favorite_tags" class="text optional" rows="5" name="user[favorite_tags]" cols="40"><%= raw @user.favorite_tags %></textarea>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ every 1.month, :at => "2:00 am" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if environment == "production"
|
if environment == "production"
|
||||||
every 1.hour do
|
every 30.minutes do
|
||||||
runner "PostUpdate.push"
|
runner "PostUpdate.push"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user