radiant-downloads-extension 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/downloads_controller.rb +6 -10
- data/app/models/download.rb +2 -17
- data/app/views/admin/downloads/_form.html.haml +1 -9
- data/app/views/admin/downloads/edit.html.haml +2 -0
- data/app/views/admin/downloads/new.html.haml +2 -0
- data/config/locales/en.yml +14 -0
- data/downloads_extension.rb +0 -1
- data/lib/download_ui.rb +1 -1
- data/lib/radiant-downloads-extension.rb +1 -1
- metadata +7 -8
- data/lib/download_group.rb +0 -7
- data/radiant-downloads-extension-0.5.3.gem +0 -0
@@ -4,16 +4,12 @@ class DownloadsController < ReaderActionController
|
|
4
4
|
|
5
5
|
def show
|
6
6
|
@download = Download.find(params[:id])
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
flash[:error] = "Sorry: you don't have permission to download that file."
|
15
|
-
render :template => 'reader/permission_denied'
|
16
|
-
end
|
7
|
+
raise ReaderError::AccessDenied, t("downloads_extension.permission_denied") unless @download.visible_to?(current_reader)
|
8
|
+
response.headers['X-Accel-Redirect'] = @download.document.url
|
9
|
+
response.headers["Content-Type"] = @download.document_content_type
|
10
|
+
response.headers['Content-Disposition'] = "attachment; filename=#{@download.document_file_name}"
|
11
|
+
response.headers['Content-Length'] = @download.document_file_size
|
12
|
+
render :nothing => true
|
17
13
|
end
|
18
14
|
|
19
15
|
end
|
data/app/models/download.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
class Download < ActiveRecord::Base
|
2
2
|
|
3
|
-
|
3
|
+
has_groups
|
4
4
|
belongs_to :created_by, :class_name => 'User'
|
5
5
|
belongs_to :updated_by, :class_name => 'User'
|
6
|
-
has_and_belongs_to_many :groups
|
7
6
|
default_scope :order => 'updated_at DESC, created_at DESC'
|
8
7
|
|
9
8
|
has_attached_file :document,
|
@@ -11,21 +10,7 @@ class Download < ActiveRecord::Base
|
|
11
10
|
:path => ":rails_root/secure_downloads/:id/:basename:no_original_style.:extension"
|
12
11
|
|
13
12
|
validates_attachment_presence :document
|
14
|
-
|
15
|
-
def has_group?(group=nil)
|
16
|
-
return true if groups and group.nil?
|
17
|
-
return false if group.nil?
|
18
|
-
return groups.include?(group)
|
19
|
-
end
|
20
|
-
|
21
|
-
def available_to?(reader=nil)
|
22
|
-
permitted_groups = self.groups
|
23
|
-
return true if permitted_groups.empty?
|
24
|
-
return false if reader.nil?
|
25
|
-
return true if reader.is_admin?
|
26
|
-
return reader.in_any_of_these_groups?(permitted_groups)
|
27
|
-
end
|
28
|
-
|
13
|
+
|
29
14
|
def document_ok?
|
30
15
|
self.document.exists?
|
31
16
|
end
|
@@ -23,15 +23,7 @@
|
|
23
23
|
= link_to @download.document_file_name, download_url(@download)
|
24
24
|
|
25
25
|
- form.edit_access do
|
26
|
-
|
27
|
-
= f.label :groups, "Available to"
|
28
|
-
- Group.find(:all).each do |group|
|
29
|
-
%span.checkbox
|
30
|
-
= check_box_tag "download[group_ids][]", group.id, @download.has_group?(group)
|
31
|
-
= group.name
|
32
|
-
%br
|
33
|
-
%span.formnote
|
34
|
-
If no group is ticked, any logged-in reader can download this file.
|
26
|
+
= render :partial => "admin/groups/edit_access", :locals => {:groupee => @download}
|
35
27
|
|
36
28
|
= javascript_tag "$('download_name').activate()"
|
37
29
|
|
@@ -5,3 +5,5 @@
|
|
5
5
|
- main.edit_form do
|
6
6
|
- form_for :download, :url => admin_download_path(@download), :html => { :method => "put", :multipart => true } do |f|
|
7
7
|
= render :partial => 'form', :locals => { :f => f }
|
8
|
+
- main.edit_popups do
|
9
|
+
= render :partial => 'admin/groups/popup', :locals => {:groupee => @download}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
attributes:
|
4
|
+
download:
|
5
|
+
errors:
|
6
|
+
models:
|
7
|
+
download:
|
8
|
+
attributes:
|
9
|
+
config:
|
10
|
+
download:
|
11
|
+
download: "download"
|
12
|
+
downloads: "Downloads"
|
13
|
+
downloads_extension:
|
14
|
+
permission_denied: "You do not have permission to download the requested file."
|
data/downloads_extension.rb
CHANGED
data/lib/download_ui.rb
CHANGED
@@ -21,7 +21,7 @@ module DownloadUI
|
|
21
21
|
def load_default_download_regions
|
22
22
|
OpenStruct.new.tap do |download|
|
23
23
|
download.edit = Radiant::AdminUI::RegionSet.new do |edit|
|
24
|
-
edit.main.concat %w{edit_header edit_form}
|
24
|
+
edit.main.concat %w{edit_header edit_form edit_popups}
|
25
25
|
edit.form.concat %w{edit_title edit_description edit_document edit_access}
|
26
26
|
edit.form_bottom.concat %w{edit_timestamp edit_buttons}
|
27
27
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module RadiantDownloadsExtension
|
2
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.6.0'
|
3
3
|
SUMMARY = %q{Secure file distribution for radiant readers}
|
4
4
|
DESCRIPTION = %q{Controlled file access using nginx's local redirects. Requires reader extension.}
|
5
5
|
URL = "http://radiant.spanner.org/downloads"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-downloads-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- William Ross
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: paperclip
|
@@ -50,15 +50,14 @@ files:
|
|
50
50
|
- app/views/admin/downloads/edit.html.haml
|
51
51
|
- app/views/admin/downloads/index.html.haml
|
52
52
|
- app/views/admin/downloads/new.html.haml
|
53
|
+
- config/locales/en.yml
|
53
54
|
- config/routes.rb
|
54
55
|
- db/migrate/001_create_downloads.rb
|
55
56
|
- downloads_extension.rb
|
56
|
-
- lib/download_group.rb
|
57
57
|
- lib/download_tags.rb
|
58
58
|
- lib/download_ui.rb
|
59
59
|
- lib/radiant-downloads-extension.rb
|
60
60
|
- lib/tasks/downloads_extension_tasks.rake
|
61
|
-
- radiant-downloads-extension-0.5.3.gem
|
62
61
|
- radiant-downloads-extension.gemspec
|
63
62
|
- Rakefile
|
64
63
|
- README.markdown
|
@@ -77,7 +76,7 @@ files:
|
|
77
76
|
homepage: http://radiant.spanner.org/downloads
|
78
77
|
licenses: []
|
79
78
|
|
80
|
-
post_install_message: "\n Add this to your radiant project with a line in your Gemfile:\n\n gem 'radiant-downloads-extension', '~> 0.
|
79
|
+
post_install_message: "\n Add this to your radiant project with a line in your Gemfile:\n\n gem 'radiant-downloads-extension', '~> 0.6.0'\n\n "
|
81
80
|
rdoc_options: []
|
82
81
|
|
83
82
|
require_paths:
|
data/lib/download_group.rb
DELETED
Binary file
|