Add "Download" link which will include post's tags in filename

This commit is contained in:
Toks
2015-06-10 23:38:25 -04:00
parent fd74f860ee
commit 0120fe8acb
2 changed files with 5 additions and 0 deletions

View File

@@ -95,6 +95,10 @@ class Post < ActiveRecord::Base
"#{Rails.root}/public/data/preview/#{file_path_prefix}#{md5}.jpg"
end
def file_name
"#{file_path_prefix}#{md5}.#{file_ext}"
end
def file_url
"/data/#{file_path_prefix}#{md5}.#{file_ext}"
end

View File

@@ -3,6 +3,7 @@
<li><%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites", :title => "Shortcut is F" %></li>
<li><%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %></li>
<li><%= link_to "Edit", "#", :id => "side-edit-link" %></li>
<li><%= link_to_if post.visible?, "Download", post.file_url, :download => post.presenter.humanized_essential_tag_string + " - " + post.file_name %></li>
<li id="random-post-list"><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post" %></li>
<li id="add-to-pool-list"><%= link_to "Add to pool", "#", :id => "pool" %></li>
<% if post.is_note_locked? %>