fixes #813
This commit is contained in:
@@ -105,13 +105,9 @@
|
||||
var $dest = $("#related-tags");
|
||||
$dest.empty();
|
||||
|
||||
if (Danbooru.Cookie.get("recent_tags")) {
|
||||
$dest.append(Danbooru.RelatedTag.build_html("recent", Danbooru.RelatedTag.recent_tags()));
|
||||
}
|
||||
if (Danbooru.RelatedTag.favorite_tags().length) {
|
||||
$dest.append(Danbooru.RelatedTag.build_html("frequent", Danbooru.RelatedTag.favorite_tags()));
|
||||
}
|
||||
$dest.append(Danbooru.RelatedTag.build_html(query, related_tags));
|
||||
$dest.append(this.build_html("recent", this.other_tags(Danbooru.Cookie.get("recent_tags"))));
|
||||
$dest.append(this.build_html("frequent", this.other_tags(Danbooru.meta("favorite-tags"))));
|
||||
$dest.append(this.build_html(query, related_tags));
|
||||
if (wiki_page_tags.length) {
|
||||
$dest.append(Danbooru.RelatedTag.build_html("wiki:" + query, wiki_page_tags));
|
||||
}
|
||||
@@ -138,22 +134,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.RelatedTag.favorite_tags = function() {
|
||||
var string = Danbooru.meta("favorite-tags");
|
||||
if (string) {
|
||||
return $.map(string.match(/\S+/g), function(x, i) {
|
||||
return [[x, 0]];
|
||||
});
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.RelatedTag.recent_tags = function() {
|
||||
var string = Danbooru.Cookie.get("recent_tags");
|
||||
Danbooru.RelatedTag.other_tags = function(string) {
|
||||
if (string && string.length) {
|
||||
return $.map(string.match(/\S+/g), function(x, i) {
|
||||
return [[x, 0]];
|
||||
return $.map(string.match(/\S+ \d+/g), function(x, i) {
|
||||
var submatch = x.match(/(\S+) (\d+)/);
|
||||
return [[submatch[1], submatch[2]]];
|
||||
});
|
||||
} else {
|
||||
return [];
|
||||
|
||||
@@ -93,7 +93,7 @@ private
|
||||
if @post
|
||||
tags = Tag.scan_tags(@post.tag_string)
|
||||
tags = TagAlias.to_aliased(tags) + Tag.scan_tags(cookies[:recent_tags])
|
||||
cookies[:recent_tags] = tags.uniq.slice(0, 40).join(" ")
|
||||
cookies[:recent_tags] = Tag.categories_for(tags.uniq.slice(0, 30)).to_a.flatten.join(" ")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ protected
|
||||
if @upload
|
||||
tags = Tag.scan_tags(@upload.tag_string)
|
||||
tags = TagAlias.to_aliased(tags) + Tag.scan_tags(cookies[:recent_tags])
|
||||
cookies[:recent_tags] = tags.uniq.slice(0, 40).join(" ")
|
||||
cookies[:recent_tags] = Tag.categories_for(tags.uniq.slice(0, 30).join(" ")).to_a.flatten.join(" ")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,6 +51,7 @@ class UsersController < ApplicationController
|
||||
check_privilege(@user)
|
||||
sanitize_params!
|
||||
@user.update_attributes(params[:user], :as => CurrentUser.role)
|
||||
cookies.delete(:favorite_tags)
|
||||
respond_with(@user)
|
||||
end
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ class SessionLoader
|
||||
|
||||
update_last_logged_in_at
|
||||
set_time_zone
|
||||
store_favorite_tags_in_cookies
|
||||
set_statement_timeout
|
||||
end
|
||||
|
||||
@@ -81,6 +82,12 @@ private
|
||||
cookies[:password_hash] && cookies.signed[:user_name] && User.authenticate_cookie_hash(cookies.signed[:user_name], cookies[:password_hash])
|
||||
end
|
||||
|
||||
def store_favorite_tags_in_cookies
|
||||
if cookies[:favorite_tags].blank? && CurrentUser.user.favorite_tags.present?
|
||||
cookies[:favorite_tags] = Tag.categories_for(CurrentUser.user.favorite_tags.scan(/\S+/)).to_a.flatten.join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
def update_last_logged_in_at
|
||||
return if CurrentUser.is_anonymous?
|
||||
return if CurrentUser.last_logged_in_at && CurrentUser.last_logged_in_at > 1.week.ago
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<meta name="post-is-flagged" content="<%= @post.is_flagged? %>">
|
||||
<meta name="config-large-width" content="<%= Danbooru.config.large_image_width %>">
|
||||
<meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
|
||||
<meta name="favorite-tags" content="<%= CurrentUser.user.favorite_tags %>">
|
||||
<meta name="favorite-tags" content="<%= cookies[:favorite_tags] %>">
|
||||
<meta property="og:title" content="<%= h @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
|
||||
<meta property="og:description" content="<%= h @post.presenter.humanized_tag_string %>">
|
||||
<meta property="og:image" content="<%= @post.preview_file_url %>">
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<% end %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="favorite-tags" content="<%= CurrentUser.user.favorite_tags %>">
|
||||
<meta name="favorite-tags" content="<%= cookies[:favorite_tags] %>">
|
||||
<% end %>
|
||||
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
|
||||
Reference in New Issue
Block a user