This commit is contained in:
albert
2013-03-08 15:31:11 -05:00
parent 35a51c0351
commit c3ac9832f9
2 changed files with 18 additions and 4 deletions

View File

@@ -88,6 +88,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("favorite", Danbooru.RelatedTag.favorite_tags()));
}
@@ -108,6 +111,17 @@
}
}
Danbooru.RelatedTag.recent_tags = function() {
var string = Danbooru.Cookie.get("recent_tags");
if (string && string.length) {
return $.map(string.match(/\S+/g), function(x, i) {
return [[x, 0]];
});
} else {
return [];
}
}
Danbooru.RelatedTag.build_html = function(query, related_tags) {
if (query === null || query === "") {
return "";

View File

@@ -66,10 +66,10 @@ private
end
def save_recent_tags
if tag_query
tags = Tag.scan_tags(tag_query)
tags = TagAlias.to_aliased(tags) + Tag.scan_tags(session[:recent_tags])
session[:recent_tags] = tags.uniq.slice(0, 40).join(" ")
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(" ")
end
end
end