stories: show archive link to archive.is

This commit is contained in:
joshua stein 2016-02-10 08:39:42 -06:00
parent c3b62cc166
commit 3afe1538f8
2 changed files with 13 additions and 0 deletions

View file

@ -163,6 +163,11 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
(hidden by <%= pluralize(story.hider_count, "user") %>)
<% end %>
<% end %>
<% if story.url.present? %>
|
<a href="https://archive.is/<%= story.url %>" rel="nofollow"
target="_new">cached</a>
<% end %>
<% if !story.is_gone? %>
<span class="comments_label">
|

View file

@ -41,6 +41,14 @@ class StoryCacher
Rails.logger.error "error fetching #{db_url}: #{e.message}"
end
begin
s = Sponge.new
s.timeout = 45
s.fetch("https://archive.is/#{db_url}")
rescue => e
Rails.logger.error "error caching #{db_url}: #{e.message}"
end
nil
end
end