Moved tag logic for Javascript to config file
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
Danbooru.Autocomplete.initialize_all = function() {
|
||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||
Danbooru.Autocomplete.enable_local_storage = this.test_local_storage();
|
||||
this.update_static_metatags();
|
||||
this.initialize_tag_autocomplete();
|
||||
this.initialize_mention_autocomplete();
|
||||
this.prune_local_storage();
|
||||
@@ -94,7 +95,7 @@
|
||||
var $fields_multiple = $('[data-autocomplete="tag-query"], [data-autocomplete="tag-edit"]');
|
||||
var $fields_single = $('[data-autocomplete="tag"]');
|
||||
|
||||
var prefixes = "-|~|general:|gen:|artist:|art:|copyright:|copy:|co:|character:|char:|ch:";
|
||||
var prefixes = "-|~|" + $.map(JSON.parse(Danbooru.meta("tag-category-names")), function (category) { return category + ':'}).join('|');
|
||||
var metatags = "order|-status|status|-rating|rating|-locked|locked|child|filetype|-filetype|" +
|
||||
"-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-fav|fav|ordfav|" +
|
||||
"-pool|pool|ordpool|favgroup|-search|search";
|
||||
@@ -326,10 +327,6 @@
|
||||
"portrait", "landscape",
|
||||
"filesize", "filesize_asc",
|
||||
"tagcount", "tagcount_asc",
|
||||
"gentags", "gentags_asc",
|
||||
"arttags", "arttags_asc",
|
||||
"chartags", "chartags_asc",
|
||||
"copytags", "copytags_asc",
|
||||
"rank",
|
||||
"random"
|
||||
],
|
||||
@@ -350,6 +347,11 @@
|
||||
],
|
||||
}
|
||||
|
||||
//This must be done as a separate function as Danbooru.meta does not exist at program initialization
|
||||
Danbooru.Autocomplete.update_static_metatags = function () {
|
||||
Array.prototype.push.apply(Danbooru.Autocomplete.static_metatags.order,$.map(JSON.parse(Danbooru.meta("short-tag-category-names")), function(shorttag) { return [shorttag + "tags", shorttag + "tags_asc"]}));
|
||||
}
|
||||
|
||||
Danbooru.Autocomplete.static_metatag_source = function(term, resp, metatag) {
|
||||
var sub_metatags = this.static_metatags[metatag];
|
||||
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
|
||||
Danbooru.RelatedTag.initialize_buttons = function() {
|
||||
this.common_bind("#related-tags-button", "");
|
||||
this.common_bind("#related-general-button", "general");
|
||||
this.common_bind("#related-artists-button", "artist");
|
||||
this.common_bind("#related-characters-button", "character");
|
||||
this.common_bind("#related-copyrights-button", "copyright");
|
||||
$.each(JSON.parse(Danbooru.meta("related-tag-button-list")), function(i,category) {
|
||||
Danbooru.RelatedTag.common_bind("#related-" + category + "-button", category);
|
||||
});
|
||||
$("#find-artist-button").click(Danbooru.RelatedTag.find_artist);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<% unless cookies[:dm] %>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<% end %>
|
||||
<meta name="tag-category-names" content="<%= Danbooru.config.tag_category_mapping.keys %>">
|
||||
<meta name="short-tag-category-names" content="<%= Danbooru.config.short_tag_name_mapping.keys %>">
|
||||
<meta name="current-user-name" content="<%= CurrentUser.name %>">
|
||||
<meta name="current-user-id" content="<%= CurrentUser.id %>">
|
||||
<meta name="current-user-can-approve-posts" content="<%= CurrentUser.can_approve_posts? %>">
|
||||
|
||||
@@ -77,10 +77,10 @@
|
||||
</div>
|
||||
|
||||
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "General", :id => "related-general-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "Artists", :id => "related-artists-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "Characters", :id => "related-characters-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "Copyrights", :id => "related-copyrights-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
|
||||
<% Danbooru.config.related_tag_button_list.each do |category| %>
|
||||
<%= button_tag "#{Danbooru.config.full_tag_config_info[category]["relatedtag"]}", :id => "related-#{category}-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
|
||||
@@ -153,6 +153,7 @@
|
||||
<% end %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="related-tag-button-list" content="<%= Danbooru.config.related_tag_button_list %>">
|
||||
<meta name="description" content="<%= @post.presenter.humanized_tag_string %>">
|
||||
<meta name="tags" content="<%= @post.tag_string %>">
|
||||
<meta name="favorites" content="<%= @post.fav_string %>">
|
||||
|
||||
@@ -109,10 +109,10 @@
|
||||
</div>
|
||||
|
||||
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "General", :id => "related-general-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "Artists", :id => "related-artists-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "Characters", :id => "related-characters-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<%= button_tag "Copyrights", :id => "related-copyrights-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
|
||||
<% Danbooru.config.related_tag_button_list.each do |category| %>
|
||||
<%= button_tag "#{Danbooru.config.full_tag_config_info[category]["relatedtag"]}", :id => "related-#{category}-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
@@ -141,4 +141,8 @@
|
||||
Upload - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="related-tag-button-list" content="<%= Danbooru.config.related_tag_button_list %>">
|
||||
<% end %>
|
||||
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
|
||||
@@ -224,7 +224,8 @@ module Danbooru
|
||||
"short" => "gen",
|
||||
"extra" => [],
|
||||
"header" => "<h1>Tags</h1>",
|
||||
"humanized" => nil
|
||||
"humanized" => nil,
|
||||
"relatedtag" => "General"
|
||||
},
|
||||
"character" => {
|
||||
"category" => 4,
|
||||
@@ -236,7 +237,8 @@ module Danbooru
|
||||
"exclusion" => [],
|
||||
"regexmap" => /^(.+?)(?:_\(.+\))?$/,
|
||||
"formatstr" => "%s"
|
||||
}
|
||||
},
|
||||
"relatedtag" => "Characters"
|
||||
},
|
||||
"copyright" => {
|
||||
"category" => 3,
|
||||
@@ -248,7 +250,8 @@ module Danbooru
|
||||
"exclusion" => [],
|
||||
"regexmap" => //,
|
||||
"formatstr" => "(%s)"
|
||||
}
|
||||
},
|
||||
"relatedtag" => "Copyrights"
|
||||
},
|
||||
"artist" => {
|
||||
"category" => 1,
|
||||
@@ -260,7 +263,8 @@ module Danbooru
|
||||
"exclusion" => %w(banned_artist),
|
||||
"regexmap" => //,
|
||||
"formatstr" => "drawn by %s"
|
||||
}
|
||||
},
|
||||
"relatedtag" => "Artists"
|
||||
}
|
||||
}
|
||||
end
|
||||
@@ -308,6 +312,11 @@ module Danbooru
|
||||
@categorized_tag_list ||= ["copyright","character","artist","general"]
|
||||
end
|
||||
|
||||
#Sets the order of the related tag buttons (javascripts/related_tag.js)
|
||||
def related_tag_button_list
|
||||
@related_tag_button_list ||= ["general","artist","character","copyright"]
|
||||
end
|
||||
|
||||
#END TAG
|
||||
|
||||
# If enabled, users must verify their email addresses.
|
||||
|
||||
Reference in New Issue
Block a user