diff --git a/app/assets/javascripts/autocomplete.js b/app/assets/javascripts/autocomplete.js index c40572e27..e2807850f 100644 --- a/app/assets/javascripts/autocomplete.js +++ b/app/assets/javascripts/autocomplete.js @@ -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]; diff --git a/app/assets/javascripts/related_tag.js b/app/assets/javascripts/related_tag.js index def95d0af..bc06c953d 100644 --- a/app/assets/javascripts/related_tag.js +++ b/app/assets/javascripts/related_tag.js @@ -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); } diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index ca1e07620..499eb270a 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -8,6 +8,8 @@ <% unless cookies[:dm] %> <% end %> + + diff --git a/app/views/posts/partials/show/_edit.html.erb b/app/views/posts/partials/show/_edit.html.erb index 4d8df1044..17c223d75 100644 --- a/app/views/posts/partials/show/_edit.html.erb +++ b/app/views/posts/partials/show/_edit.html.erb @@ -77,10 +77,10 @@ <%= 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 %>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 4b96f8efa..2c5c3d0bb 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -153,6 +153,7 @@ <% end %> <% content_for(:html_header) do %> + diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index 4413c9b4b..a40a5b82a 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -109,10 +109,10 @@
<%= 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 %>
@@ -141,4 +141,8 @@ Upload - <%= Danbooru.config.app_name %> <% end %> +<% content_for(:html_header) do %> + +<% end %> + <%= render "posts/partials/common/secondary_links" %> diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 51105c339..6e01f2223 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -224,7 +224,8 @@ module Danbooru "short" => "gen", "extra" => [], "header" => "

Tags

", - "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.