Files
danbooru/app/components/source_data_component/source_data_component.html.erb
evazion 4ef8178bd1 sources: remove canonical_url method.
Refactor source strategies to remove the `canonical_url` method.

`canonical_url` returned the URL that should be used as the source of
the post after upload. Now we simply use `Source::URL#page_url` to
determine the source after upload. If the source is an image URL that is
convertible to a page URL, then the image URL is used as the source. If
the source is an image URL that is not convertible to a page URL, then
the page URL is used as the source.

This simplifies source strategies so that all they have to care about is
implementing the `Source::URL#page_url` and `Sources::Strategies#page_url`
methods, and the preferred source will be chosen for posts automatically.
2022-03-23 23:38:06 -05:00

60 lines
1.9 KiB
Plaintext

<div class="source-data p-4 mt-4 mb-4">
<%= link_to "Fetch source data", source_path, class: "source-data-fetch" %>
<%= spinner_icon class: "source-data-loading" %>
<% if @source.present? %>
<table class="source-data-content mt-2">
<tbody>
<% if @source.artists.present? %>
<% @source.artists.each do |artist| %>
<tr>
<th>Artist</th>
<td>
<%= link_to artist.name, artist_path(artist), class: tag_class(artist.tag) %>
<ul class="list-inline">
<% profile_urls(artist).each do |artist_url| %>
<%= external_link_to artist_url.url, external_site_icon(artist_url.site_name), title: artist_url.url %>
<% end %>
</ul>
</td>
</tr>
<% end %>
<% else %>
<% if @source.artist_name.blank? %>
<tr>
<th>Artist</th>
<td><em>None</em></td>
</tr>
<% else %>
<tr>
<th>Artist</th>
<td>
<%= external_link_to @source.profile_url, @source.artist_name %>
(<%= link_to "Create new artist", new_artist_path(artist: { source: @source.page_url || @source.url }) %>)
</td>
</tr>
<% end %>
<% end %>
<tr class="source-data-tags">
<th>Tags</th>
<td>
<% if @source.tags.empty? %>
<em>None</em>
<% else %>
<ul class="list-inline">
<% @source.tags.each do |tag, href| %>
<li>
<%= external_link_to href, tag, class: "source-data-tag" %>
</li>
<% end %>
</ul>
<% end %>
</td>
</tr>
</tbody>
</table>
<% end %>
</div>