Merge pull request #3957 from evazion/fix-related-tags
Related tags: build html server-side, eliminate cookies
This commit is contained in:
1
app/views/artist_urls/update.js
Normal file
1
app/views/artist_urls/update.js
Normal file
@@ -0,0 +1 @@
|
||||
Danbooru.Upload.fetch_data_manual();
|
||||
@@ -82,20 +82,12 @@
|
||||
<span id="open-edit-dialog" class="ui-icon ui-icon-arrow-1-ne" title="detach" style="display: none;" data-shortcut="shift+e"/>
|
||||
</div>
|
||||
|
||||
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
|
||||
<% TagCategory.related_button_list.each do |category| %>
|
||||
<%= button_tag "#{TagCategory.related_button_mapping[category]}", :id => "related-#{category}-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<% end %>
|
||||
<%= render "related_tags/buttons" %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= submit_tag "Submit", :class => "ui-button ui-widget ui-corner-all" %>
|
||||
</div>
|
||||
|
||||
<div id="related-tags-container">
|
||||
<h1>Related Tags <a href="#" id="toggle-related-tags-link" style="display: none;">«</a></h1>
|
||||
<div id="related-tags" class="related-tags">
|
||||
</div>
|
||||
</div>
|
||||
<%= render "related_tags/container" %>
|
||||
<% end %>
|
||||
|
||||
5
app/views/related_tags/_buttons.html.erb
Normal file
5
app/views/related_tags/_buttons.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<%= button_tag "Related tags", type: :button, class: "related-tags-button ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
|
||||
<% TagCategory.related_button_list.each do |category| %>
|
||||
<%= button_tag TagCategory.related_button_mapping[category], type: :button, "data-category": category, class: "related-tags-button ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<% end %>
|
||||
13
app/views/related_tags/_container.html.erb
Normal file
13
app/views/related_tags/_container.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div id="related-tags-container" class="visible">
|
||||
<h3>
|
||||
Related Tags
|
||||
<a href="#" id="show-related-tags-link">»</a>
|
||||
<a href="#" id="hide-related-tags-link">«</a>
|
||||
</h3>
|
||||
|
||||
<div class="related-tags">
|
||||
<%= render "related_tags/user_tags", related_tags: nil %>
|
||||
<%= render "related_tags/current_tags", related_tags: nil %>
|
||||
<%= render "related_tags/source_tags", source: nil %>
|
||||
</div>
|
||||
</div>
|
||||
10
app/views/related_tags/_current_tags.html.erb
Normal file
10
app/views/related_tags/_current_tags.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="current-related-tags-columns">
|
||||
<% if related_tags.present? %>
|
||||
<%= render "related_tags/tag_column", tags: related_tags.tags, class: "general-related-tags-column", title: related_tags.pretty_name %>
|
||||
<%= render "related_tags/tag_column", tags: related_tags.wiki_page_tags, class: "wiki-related-tags-column", title: link_to("wiki:#{related_tags.pretty_name}", show_or_new_wiki_pages_path(title: related_tags.query)) %>
|
||||
|
||||
<% related_tags.other_wiki_category_tags.each do |wiki| %>
|
||||
<%= render "related_tags/tag_column", tags: wiki.tags, class: "other-wiki-related-tags-column", title: link_to("wiki:#{wiki.pretty_title}", show_or_new_wiki_pages_path(title: wiki.title)) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
34
app/views/related_tags/_source_tags.html.erb
Normal file
34
app/views/related_tags/_source_tags.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="source-related-tags-columns">
|
||||
<% if source.present? %>
|
||||
<%= render "related_tags/tag_column", tags: source.translated_tags.map(&:first), title: "Translated Tags" %>
|
||||
|
||||
<div class="tag-column wide-column artist-related-tags-column">
|
||||
<h6>Artist</h6>
|
||||
|
||||
<% if source.artists.size == 0 %>
|
||||
none
|
||||
<% else %>
|
||||
<% if source.artists.any?(&:is_banned?) %>
|
||||
<%= TagSetPresenter.new(["banned_artist"]).tag_list_html(name_only: true) %>
|
||||
<% end %>
|
||||
|
||||
<% source.artists.each do |artist| %>
|
||||
<%= TagSetPresenter.new([artist.name]).tag_list_html(name_only: true) %>
|
||||
|
||||
<ul>
|
||||
<% artist.sorted_urls.each do |url| %>
|
||||
<li>
|
||||
<% if url.is_active %>
|
||||
<%= external_link_to url.url, truncate: 30 %>
|
||||
<%= link_to tag.i(class: "fas fa-minus-circle"), artist_url_path(id: url.id, artist_url: { is_active: false }), remote: true, method: :put, "data-confirm": "This will mark the URL as inactive. Continue?" %>
|
||||
<% else %>
|
||||
<del><%= truncate(url.url, length: 30) %></del>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
8
app/views/related_tags/_tag_column.html.erb
Normal file
8
app/views/related_tags/_tag_column.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<%# tags, title, class (optional) %>
|
||||
|
||||
<div class="tag-column <%= local_assigns[:class] || "#{title.parameterize}-related-tags-column" %>">
|
||||
<% if tags.present? %>
|
||||
<h6><%= title %></h6>
|
||||
<%= TagSetPresenter.new(tags).tag_list_html(name_only: true) %>
|
||||
<% end %>
|
||||
</div>
|
||||
6
app/views/related_tags/_user_tags.html.erb
Normal file
6
app/views/related_tags/_user_tags.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="user-related-tags-columns">
|
||||
<% if related_tags.present? %>
|
||||
<%= render "related_tags/tag_column", tags: related_tags.recent_tags, title: "Recent" %>
|
||||
<%= render "related_tags/tag_column", tags: related_tags.favorite_tags, title: "Frequent" %>
|
||||
<% end %>
|
||||
</div>
|
||||
7
app/views/related_tags/show.js.erb
Normal file
7
app/views/related_tags/show.js.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<% if params[:user_tags] %>
|
||||
$(".user-related-tags-columns").replaceWith("<%= j render "user_tags", related_tags: @query %>");
|
||||
<% else %>
|
||||
$(".current-related-tags-columns").replaceWith("<%= j render "current_tags", related_tags: @query %>");
|
||||
<% end %>
|
||||
|
||||
Danbooru.RelatedTag.update_selected();
|
||||
@@ -1,8 +1,9 @@
|
||||
$("#source-info").replaceWith("<%= j render "info", source: @source %>");
|
||||
|
||||
Danbooru.RelatedTag.recent_artists = <%= raw @source.artists.to_json(include: :sorted_urls) %>;
|
||||
Danbooru.RelatedTag.translated_tags = <%= raw @source.translated_tags.to_json %>;
|
||||
Danbooru.RelatedTag.build_all();
|
||||
$(document).trigger("danbooru:update-source-data", {
|
||||
source: <%= raw @source.to_json %>,
|
||||
related_tags_html: "<%= j render "related_tags/source_tags", source: @source %>",
|
||||
});
|
||||
|
||||
if ($("#c-uploads #a-new").length) {
|
||||
$("#upload_artist_commentary_title").val(<%= raw @source.dtext_artist_commentary_title.to_json %>);
|
||||
|
||||
@@ -97,22 +97,14 @@
|
||||
<span id="open-edit-dialog" class="ui-icon ui-icon-arrow-1-ne" title="detach" style="display: none;" data-shortcut="shift+e"/>
|
||||
</div>
|
||||
|
||||
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
|
||||
<% TagCategory.related_button_list.each do |category| %>
|
||||
<%= button_tag "#{TagCategory.related_button_mapping[category]}", :id => "related-#{category}-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
|
||||
<% end %>
|
||||
<%= render "related_tags/buttons" %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= submit_tag "Submit", :id => "submit-button", :class => "large ui-button ui-widget ui-corner-all gradient", data: {disable_with: false} %>
|
||||
</div>
|
||||
|
||||
<div id="related-tags-container">
|
||||
<h1>Related Tags <a href="#" id="toggle-related-tags-link" style="display: none;">«</a></h1>
|
||||
<div id="related-tags" class="related-tags">
|
||||
</div>
|
||||
</div>
|
||||
<%= render "related_tags/container" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<h2 style="margin-bottom: 1em;">You <%= CurrentUser.user.upload_limited_reason %></h2>
|
||||
|
||||
Reference in New Issue
Block a user