|
@@ -8,6 +8,7 @@ module RSeed
|
|
|
set :root, File.join(File.dirname(__FILE__), '..', '..')
|
|
|
set :haml, :format => :html5
|
|
|
set :server, 'thin'
|
|
|
+ set :xsf_header, 'X-Accel-Redirect'
|
|
|
|
|
|
before do
|
|
|
cache_control :public, :must_revalidate, :max_age => 60
|
|
@@ -32,6 +33,7 @@ module RSeed
|
|
|
# -------
|
|
|
helpers do
|
|
|
include Rack::Utils
|
|
|
+ include Sinatra::Xsendfile
|
|
|
|
|
|
def host
|
|
|
"http://#{request.host}#{request.port == 80 ? '' : ':' + request.port.to_s}"
|
|
@@ -90,12 +92,26 @@ module RSeed
|
|
|
# ---
|
|
|
get %r{/d/([a-zA-Z0-9]*)} do |hash|
|
|
|
if publicLink(hash)
|
|
|
- haml :download, :locals => { :tfiles => @rtorrent.getFilesInfo(hash) }
|
|
|
+ haml :download, :locals => {
|
|
|
+ :tfiles => @rtorrent.getFilesInfo(hash),
|
|
|
+ :tname => @rtorrent.getName(hash),
|
|
|
+ :thash => hash
|
|
|
+ }
|
|
|
else
|
|
|
404
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ post %r{/d/([a-zA-Z0-9]*)} do |hash|
|
|
|
+ if publicLink(hash)
|
|
|
+ @rtorrent.getFilesInfo(hash).each do |file|
|
|
|
+ if file.has_value?(params[:filename])
|
|
|
+ x_send_file(file["path"])
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
# Public link generator
|
|
|
# ---------------------
|
|
|
post '/share' do
|