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