add user searches

This commit is contained in:
r888888888
2016-08-23 18:20:21 -07:00
parent 6d20ecb20d
commit c3b78b1752
8 changed files with 38 additions and 3 deletions

View File

@@ -145,7 +145,7 @@ module ApplicationHelper
string += '</div>'
string.html_safe
end
protected
def nav_link_match(controller, url)
url =~ case controller

View File

@@ -28,6 +28,18 @@ module PostsHelper
return nil
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)
links = []

View File

@@ -35,13 +35,14 @@ class User < ActiveRecord::Base
disable_categorized_saved_searches
is_super_voter
disable_tagged_filenames
enable_recent_searches
)
include Danbooru::HasBitFlags
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
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
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"

View File

@@ -7,6 +7,8 @@
<%= render "posts/partials/index/blacklist" %>
<%= raw common_searches_html(CurrentUser.user) %>
<section id="tag-box">
<h1>Tags</h1>
<%= @post_set.presenter.tag_list_html(self) %>

View File

@@ -0,0 +1 @@
<%= raw common_searches_html(CurrentUser.user) %>

View 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>

View File

@@ -74,6 +74,8 @@
<%= 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">
<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>

View File

@@ -24,7 +24,7 @@ every 1.month, :at => "2:00 am" do
end
if environment == "production"
every 1.hour do
every 30.minutes do
runner "PostUpdate.push"
end