diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 300eaf6b8..ebf8da34e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -67,7 +67,7 @@ module ApplicationHelper def time_ago_in_words_tagged(time, compact: false) if time.past? text = time_ago_in_words(time) + " ago" - text = text.gsub(/almost|about|over/, "") if compact + text = text.gsub(/almost|about|over/, "").strip if compact raw time_tag(text, time) else raw time_tag("in " + distance_of_time_in_words(Time.now, time), time) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 4efe7b8ba..e864c8ab0 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -21,6 +21,7 @@ class PostPresenter < Presenter end locals = {} + locals[:post] = post locals[:article_attrs] = { "id" => "post_#{post.id}", @@ -74,7 +75,7 @@ class PostPresenter < Presenter end if options[:similarity] - locals[:similarity] = options[:similarity].round + locals[:similarity] = options[:similarity].round(1) else locals[:similarity] = nil end diff --git a/app/views/posts/partials/index/_preview.html.erb b/app/views/posts/partials/index/_preview.html.erb index 0dfd621d5..dce16f23a 100644 --- a/app/views/posts/partials/index/_preview.html.erb +++ b/app/views/posts/partials/index/_preview.html.erb @@ -13,12 +13,23 @@ <% end -%> <% if similarity -%>

- Similarity: <%= similarity %> + <% if post.source =~ %r!\Ahttps?://!i %> + <%= external_link_to post.normalized_source, post.source_domain %> + (<%= time_ago_in_words_tagged(post.created_at, compact: true) %>) + <% else %> + <%= time_ago_in_words_tagged(post.created_at, compact: true) %> + <% end %>

- <% end -%> + <% end %> <% if size -%>

- <%= number_to_human_size(size) %> (<%= width %>x<%= height %>) + <%= link_to number_to_human_size(size), post.file_url %> + (<%= width %>x<%= height %>) +

+ <% end -%> + <% if similarity -%> +

+ <%= link_to "#{similarity}%", iqdb_queries_path(post_id: post.id) %> similarity

<% end -%> <% end -%>