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