ecm_downloads2 1.2.2 → 2.0.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.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.rdoc +18 -10
- data/Rakefile +2 -11
- data/{lib/ecm/downloads/active_admin → app/admin}/ecm_downloads_download_categories.rb +17 -17
- data/{lib/ecm/downloads/active_admin → app/admin}/ecm_downloads_downloads.rb +11 -11
- data/app/decorators/ecm/downloads/download_category_decorator.rb +3 -3
- data/app/decorators/ecm/downloads/download_decorator.rb +2 -2
- data/app/helpers/ecm/downloads/download_category_helper.rb +4 -4
- data/app/helpers/ecm/downloads/download_helper.rb +4 -4
- data/app/models/ecm/downloads/download.rb +6 -7
- data/app/models/ecm/downloads/download_category.rb +14 -14
- data/config/initializers/assets.rb +1 -0
- data/db/migrate/001_create_ecm_downloads_download_categories.rb +4 -4
- data/db/migrate/002_create_ecm_downloads_downloads.rb +1 -1
- data/lib/ecm/downloads/configuration.rb +1 -1
- data/lib/ecm/downloads/engine.rb +8 -16
- data/lib/ecm/downloads/routing.rb +11 -13
- data/lib/ecm/downloads/version.rb +1 -2
- data/lib/ecm_downloads2.rb +0 -3
- data/lib/generators/ecm/downloads/install/install_generator.rb +9 -4
- data/lib/generators/ecm/downloads/install/templates/{ecm_downloads.rb → initializer.rb} +0 -0
- data/lib/generators/ecm/downloads/install/templates/routes.source +5 -0
- data/lib/generators/ecm/downloads/locales/locales_generator.rb +7 -9
- data/lib/tasks/ecm_downloads_tasks.rake +11 -12
- metadata +62 -39
- data/config/routes.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a31f99f96df76db2c5024d0c579a02a8eb24506
|
4
|
+
data.tar.gz: ca1952b40679aef1f7ce41d5fc5b615b397fc8df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac6fba402abc117c7b65f2a0e3e70a10b5b2adfb997a292d1ac8287661c805265a6cf00c09497d801383991e3d94f477301f6d30fd7698c82c10c146be5f182a
|
7
|
+
data.tar.gz: 342731c3cf13a763b98f18b755abdd65c25924d3be0cdc1d433ccbe7d8f025afc3b6cda3936e5cc2d91c1e95b263a4770c5b5a1623573e07f9148739ce51758c
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -2,13 +2,22 @@
|
|
2
2
|
|
3
3
|
This version supports rails 4.x and twitter bootstrap 3. For legacy support use ecm_downloads
|
4
4
|
|
5
|
-
=
|
5
|
+
= Migrating from 1.x.x to 2.0.0
|
6
6
|
|
7
|
-
|
7
|
+
Add active_admin-awesome_nested_set and active_admin-acts_as_list to your gemfile, if you are using activeadmin:
|
8
8
|
|
9
|
-
|
9
|
+
# Gemfile
|
10
|
+
gem 'active_admin-awesome_nested_set'
|
11
|
+
gem 'active_admin-acts_as_list'
|
12
|
+
|
13
|
+
= Prerequisites
|
14
|
+
|
15
|
+
if you are using activeadmin as backend, ecm_cms2 comes with admin files to provide a backend. In that case, you'll need active_admin-awesome_nested_set and active_admin-acts_as_list. Add it to your gemfile:
|
16
|
+
|
17
|
+
# Gemfile
|
18
|
+
gem 'active_admin-awesome_nested_set'
|
19
|
+
gem 'active_admin-acts_as_list'
|
10
20
|
|
11
|
-
TODO
|
12
21
|
|
13
22
|
= Installation
|
14
23
|
|
@@ -53,13 +62,12 @@ You may want to copy the locales to your app:
|
|
53
62
|
|
54
63
|
> rails generate ecm:downloads:locales
|
55
64
|
|
56
|
-
=
|
57
|
-
|
58
|
-
TODO>
|
59
|
-
|
60
|
-
= Todo
|
65
|
+
= Running specs
|
61
66
|
|
62
|
-
|
67
|
+
gem install bundler
|
68
|
+
bundle
|
69
|
+
cd spec/dummy && rake db:migrate RAILS_ENV=test && cd ../..
|
70
|
+
guard
|
63
71
|
|
64
72
|
= License
|
65
73
|
|
data/Rakefile
CHANGED
@@ -14,21 +14,12 @@ end
|
|
14
14
|
|
15
15
|
RDoc::Task.new(:rdoc) do |rdoc|
|
16
16
|
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = '
|
17
|
+
rdoc.title = 'ECM Downloads 2'
|
18
18
|
rdoc.options << '--line-numbers'
|
19
19
|
rdoc.rdoc_files.include('README.rdoc')
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
23
|
Bundler::GemHelper.install_tasks
|
26
24
|
|
27
|
-
require 'rails/dummy/tasks'
|
28
|
-
|
29
|
-
# Travis CI
|
30
|
-
task :default => [:spec]
|
31
|
-
desc 'run Rspec specs'
|
32
|
-
task :spec do
|
33
|
-
sh 'cd ./spec/dummy && rspec && cd ../../'
|
34
|
-
end
|
25
|
+
require 'rails/dummy/tasks'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
if
|
1
|
+
if Gem::Specification.find_all_by_name('activeadmin').any?
|
2
2
|
include ActiveAdmin::ActsAsList::Helper
|
3
3
|
include ActiveAdmin::AwesomeNestedSet::Helper
|
4
4
|
|
@@ -6,7 +6,7 @@ if defined?(ActiveAdmin)
|
|
6
6
|
decorate_with Ecm::Downloads::DownloadCategoryDecorator
|
7
7
|
|
8
8
|
# menu entry settings
|
9
|
-
menu :
|
9
|
+
menu parent: I18n.t('ecm.downloads.active_admin.menu')
|
10
10
|
|
11
11
|
permit_params :description,
|
12
12
|
:ecm_downloads_downloads_count,
|
@@ -33,8 +33,8 @@ if defined?(ActiveAdmin)
|
|
33
33
|
scope :all
|
34
34
|
scope :roots
|
35
35
|
I18n.available_locales.each do |locale|
|
36
|
-
|
37
|
-
klass.where(:
|
36
|
+
send(:scope, locale.to_s) do |klass|
|
37
|
+
klass.where(locale: locale)
|
38
38
|
# klass.where(klass.arel_table[:locale].eq(locale).or(klass.arel_table[:locale].eq(nil)))
|
39
39
|
end
|
40
40
|
end
|
@@ -45,10 +45,10 @@ if defined?(ActiveAdmin)
|
|
45
45
|
end
|
46
46
|
|
47
47
|
f.inputs do
|
48
|
-
f.input :parent, :
|
49
|
-
:
|
50
|
-
f.input :locale, :
|
51
|
-
:
|
48
|
+
f.input :parent, as: :select,
|
49
|
+
collection: nested_set_options(Ecm::Downloads::DownloadCategory, f.object) { |dc| "#{'-' * dc.depth} #{dc.name}" }
|
50
|
+
f.input :locale, as: :select,
|
51
|
+
collection: I18n.available_locales.map(&:to_s)
|
52
52
|
f.input :name
|
53
53
|
f.input :description
|
54
54
|
end
|
@@ -56,11 +56,11 @@ if defined?(ActiveAdmin)
|
|
56
56
|
f.inputs do
|
57
57
|
f.has_many :ecm_downloads_downloads do |d|
|
58
58
|
if d.object.persisted?
|
59
|
-
d.input :_destroy, :
|
59
|
+
d.input :_destroy, as: :boolean, label: I18n.t('active_admin.delete')
|
60
60
|
end
|
61
|
-
d.input :asset, :
|
61
|
+
d.input :asset, as: :file
|
62
62
|
d.input :name
|
63
|
-
d.input :published, :
|
63
|
+
d.input :published, as: :boolean
|
64
64
|
d.input :description
|
65
65
|
end
|
66
66
|
end
|
@@ -73,16 +73,16 @@ if defined?(ActiveAdmin)
|
|
73
73
|
sortable_tree_columns
|
74
74
|
column :locale
|
75
75
|
column :name do |dc|
|
76
|
-
span(:
|
76
|
+
span(style: "margin-left: #{25 * dc.level}px") { dc.name }
|
77
77
|
end
|
78
78
|
column(:description) do |dc|
|
79
|
-
truncate(dc.description, :
|
79
|
+
truncate(dc.description, length: 100, separator: ' ')
|
80
80
|
end
|
81
81
|
column :ecm_downloads_downloads_count
|
82
82
|
actions
|
83
83
|
end
|
84
84
|
|
85
|
-
show :
|
85
|
+
show title: :to_s do
|
86
86
|
attributes_table do
|
87
87
|
row :parent
|
88
88
|
row :locale
|
@@ -111,7 +111,7 @@ if defined?(ActiveAdmin)
|
|
111
111
|
end
|
112
112
|
|
113
113
|
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:children) do
|
114
|
-
table_for ecm_downloads_download_category.children, :
|
114
|
+
table_for ecm_downloads_download_category.children, i18n: Ecm::Downloads::DownloadCategory do
|
115
115
|
sortable_tree_columns
|
116
116
|
column(:index_name) do |ecm_downloads_download_category|
|
117
117
|
link_to ecm_downloads_download_category, [:admin, ecm_downloads_download_category]
|
@@ -122,14 +122,14 @@ if defined?(ActiveAdmin)
|
|
122
122
|
end
|
123
123
|
|
124
124
|
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:ecm_downloads_downloads) do
|
125
|
-
table_for ecm_downloads_download_category.ecm_downloads_downloads, :
|
125
|
+
table_for ecm_downloads_download_category.ecm_downloads_downloads, i18n: Ecm::Downloads::Download do
|
126
126
|
sortable_columns
|
127
127
|
column(:name) do |ecm_downloads_download|
|
128
128
|
link_to ecm_downloads_download, [:admin, ecm_downloads_download]
|
129
129
|
end
|
130
130
|
acts_as_published_columns
|
131
131
|
column :asset_file_name
|
132
|
-
column :asset_file_size, :
|
132
|
+
column :asset_file_size, sortable: :asset_file_size do |download|
|
133
133
|
number_to_human_size(download.asset_file_size)
|
134
134
|
end
|
135
135
|
column :created_at
|
@@ -1,5 +1,5 @@
|
|
1
|
-
include ActiveAdmin::ActsAsList::Helper
|
2
|
-
include ActsAsPublished::ActiveAdminHelper
|
1
|
+
include ActiveAdmin::ActsAsList::Helper if Gem::Specification.find_all_by_name('activeadmin').any?
|
2
|
+
include ActsAsPublished::ActiveAdminHelper if Gem::Specification.find_all_by_name('activeadmin').any?
|
3
3
|
|
4
4
|
ActiveAdmin.register Ecm::Downloads::Download do
|
5
5
|
decorate_with Ecm::Downloads::DownloadDecorator
|
@@ -11,7 +11,7 @@ ActiveAdmin.register Ecm::Downloads::Download do
|
|
11
11
|
acts_as_published_actions
|
12
12
|
|
13
13
|
# config
|
14
|
-
menu :
|
14
|
+
menu parent: I18n.t('ecm.downloads.active_admin.menu')
|
15
15
|
|
16
16
|
permit_params :asset,
|
17
17
|
:description,
|
@@ -23,13 +23,13 @@ ActiveAdmin.register Ecm::Downloads::Download do
|
|
23
23
|
scope :published
|
24
24
|
scope :unpublished
|
25
25
|
|
26
|
-
form :
|
26
|
+
form html: { enctype: 'multipart/form-data' } do |f|
|
27
27
|
f.inputs do
|
28
|
-
f.input :ecm_downloads_download_category, :
|
29
|
-
:
|
30
|
-
f.input :asset, :
|
28
|
+
f.input :ecm_downloads_download_category, as: :select,
|
29
|
+
collection: nested_set_options(Ecm::Downloads::DownloadCategory) { |dc| "#{'-' * dc.level} #{dc.name}" }
|
30
|
+
f.input :asset, as: :file
|
31
31
|
f.input :name
|
32
|
-
f.input :published, :
|
32
|
+
f.input :published, as: :boolean
|
33
33
|
f.input :description
|
34
34
|
end
|
35
35
|
|
@@ -42,14 +42,14 @@ ActiveAdmin.register Ecm::Downloads::Download do
|
|
42
42
|
column :name
|
43
43
|
acts_as_published_columns
|
44
44
|
column :asset_file_name
|
45
|
-
column :asset_file_size, :
|
45
|
+
column :asset_file_size, sortable: :asset_file_size do |download|
|
46
46
|
number_to_human_size(download.asset_file_size)
|
47
47
|
end
|
48
48
|
column :created_at
|
49
49
|
actions
|
50
50
|
end
|
51
51
|
|
52
|
-
show :
|
52
|
+
show title: :to_s do
|
53
53
|
attributes_table do
|
54
54
|
row :ecm_downloads_download_category
|
55
55
|
row :name
|
@@ -80,4 +80,4 @@ ActiveAdmin.register Ecm::Downloads::Download do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
-
end if
|
83
|
+
end if Gem::Specification.find_all_by_name('activeadmin').any?
|
@@ -20,10 +20,10 @@ module Ecm::Downloads
|
|
20
20
|
|
21
21
|
def index_name
|
22
22
|
if self.root?
|
23
|
-
"[#{
|
23
|
+
"[#{locale}] #{name}"
|
24
24
|
else
|
25
|
-
"#{'    ' *
|
25
|
+
"#{'    ' * level} |-- #{name}".html_safe
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Ecm::Downloads
|
2
2
|
module DownloadCategoryHelper
|
3
|
-
def render_download_category(download_category_name,
|
4
|
-
download_category = DownloadCategory.where(:
|
3
|
+
def render_download_category(download_category_name, _options = {})
|
4
|
+
download_category = DownloadCategory.where(name: download_category_name).first.decorate
|
5
5
|
if download_category.nil?
|
6
|
-
I18n.t('ecm.downloads.download_category.messages.not_found', :
|
6
|
+
I18n.t('ecm.downloads.download_category.messages.not_found', name: download_category_name)
|
7
7
|
else
|
8
8
|
begin
|
9
9
|
o = Ecm::Downloads::Configuration.prevent_textile_rendering_in_html ? '<notextile>' : ''
|
@@ -16,4 +16,4 @@ module Ecm::Downloads
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Ecm::Downloads
|
2
2
|
module DownloadHelper
|
3
|
-
def render_download(download_name,
|
4
|
-
download = Download.where(:
|
3
|
+
def render_download(download_name, _options = {})
|
4
|
+
download = Download.where(name: download_name).first.decorate
|
5
5
|
if download.nil?
|
6
|
-
I18n.t('ecm.downloads.download.messages.not_found', :
|
6
|
+
I18n.t('ecm.downloads.download.messages.not_found', name: download_name)
|
7
7
|
else
|
8
8
|
begin
|
9
9
|
o = Ecm::Downloads::Configuration.prevent_textile_rendering_in_html ? '<notextile>' : ''
|
@@ -16,4 +16,4 @@ module Ecm::Downloads
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -3,7 +3,7 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
3
3
|
self.table_name = 'ecm_downloads_downloads'
|
4
4
|
|
5
5
|
# acts as list
|
6
|
-
acts_as_list :
|
6
|
+
acts_as_list scope: :ecm_downloads_download_category
|
7
7
|
|
8
8
|
# acts as published
|
9
9
|
include ActsAsPublished::ActiveRecord
|
@@ -21,22 +21,21 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
21
21
|
:name if respond_to? :attr_accessible
|
22
22
|
|
23
23
|
# callbacks
|
24
|
-
before_update :fix_updated_position, :
|
24
|
+
before_update :fix_updated_position, if: proc { |d| !position.blank? && d.ecm_downloads_download_category_id_changed? }
|
25
25
|
|
26
26
|
# friendly id
|
27
27
|
extend FriendlyId
|
28
|
-
friendly_id :name, :
|
28
|
+
friendly_id :name, use: [:slugged, :finders]
|
29
29
|
|
30
30
|
# paperclip
|
31
31
|
has_attached_file :asset, Ecm::Downloads::Configuration.paperclip_options
|
32
32
|
|
33
33
|
# validations
|
34
|
-
validates :ecm_downloads_download_category, :
|
35
|
-
validates :name, :
|
34
|
+
validates :ecm_downloads_download_category, presence: true
|
35
|
+
validates :name, presence: true
|
36
36
|
validates_attachment :asset, presence => true
|
37
37
|
do_not_validate_attachment_file_type :asset
|
38
38
|
|
39
|
-
|
40
39
|
def human
|
41
40
|
name
|
42
41
|
end
|
@@ -48,7 +47,7 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
48
47
|
private
|
49
48
|
|
50
49
|
def fix_updated_position
|
51
|
-
Rails.logger.debug "Fixing positions for #{self
|
50
|
+
Rails.logger.debug "Fixing positions for #{self} (Moving to last)"
|
52
51
|
add_to_list_bottom
|
53
52
|
end
|
54
53
|
end
|
@@ -4,13 +4,13 @@ class Ecm::Downloads::DownloadCategory < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
# associations
|
6
6
|
has_many :ecm_downloads_downloads, -> { order(:position) },
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
7
|
+
class_name: Ecm::Downloads::Download,
|
8
|
+
dependent: :destroy,
|
9
|
+
foreign_key: :ecm_downloads_download_category_id,
|
10
10
|
inverse_of: :ecm_downloads_download_category
|
11
11
|
|
12
12
|
accepts_nested_attributes_for :ecm_downloads_downloads,
|
13
|
-
:
|
13
|
+
allow_destroy: true
|
14
14
|
|
15
15
|
# attributes
|
16
16
|
attr_accessible :description,
|
@@ -24,24 +24,24 @@ class Ecm::Downloads::DownloadCategory < ActiveRecord::Base
|
|
24
24
|
|
25
25
|
# awesome nested set
|
26
26
|
acts_as_nested_set
|
27
|
-
default_scope
|
27
|
+
default_scope { order('lft ASC') }
|
28
28
|
|
29
29
|
# friendly id
|
30
30
|
extend FriendlyId
|
31
|
-
friendly_id :name, :
|
31
|
+
friendly_id :name, use: [:slugged, :finders]
|
32
32
|
|
33
33
|
# validations
|
34
|
-
validates :name, :
|
35
|
-
:
|
34
|
+
validates :name, presence: true,
|
35
|
+
uniqueness: { scope: [:parent_id] }
|
36
36
|
|
37
|
-
validates :locale, :
|
38
|
-
:
|
37
|
+
validates :locale, presence: true,
|
38
|
+
if: :root?
|
39
39
|
|
40
|
-
validates :locale, :
|
41
|
-
:
|
40
|
+
validates :locale, inclusion: I18n.available_locales.map(&:to_s),
|
41
|
+
if: proc { |cc| cc.locale.present? }
|
42
42
|
|
43
|
-
validates :locale, :
|
44
|
-
:
|
43
|
+
validates :locale, absence: true,
|
44
|
+
unless: :root?
|
45
45
|
|
46
46
|
def ecm_downloads_downloads_count
|
47
47
|
ecm_downloads_downloads.count
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w( ecm_downloads.css )
|
@@ -5,16 +5,16 @@ class CreateEcmDownloadsDownloadCategories < ActiveRecord::Migration
|
|
5
5
|
t.text :description
|
6
6
|
t.string :locale
|
7
7
|
t.integer :position
|
8
|
-
|
8
|
+
|
9
9
|
# references
|
10
|
-
t.integer :ecm_downloads_downloads_count, :
|
11
|
-
|
10
|
+
t.integer :ecm_downloads_downloads_count, default: 0, null: false
|
11
|
+
|
12
12
|
# awesome nested set
|
13
13
|
t.integer :parent_id
|
14
14
|
t.integer :lft
|
15
15
|
t.integer :rgt
|
16
16
|
t.integer :depth
|
17
|
-
|
17
|
+
|
18
18
|
# frienldy id
|
19
19
|
t.string :slug
|
20
20
|
|
@@ -26,6 +26,6 @@ class CreateEcmDownloadsDownloads < ActiveRecord::Migration
|
|
26
26
|
end
|
27
27
|
add_index :ecm_downloads_downloads,
|
28
28
|
:ecm_downloads_download_category_id,
|
29
|
-
:
|
29
|
+
name: 'index_ecm_downloads_downloads_on_download_category_id'
|
30
30
|
end
|
31
31
|
end
|
data/lib/ecm/downloads/engine.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
module Ecm
|
2
2
|
module Downloads
|
3
|
-
class Engine < Rails::Engine
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
initializer :ecm_downloads_engine do
|
5
|
+
::ActiveAdmin.setup do |config|
|
6
|
+
config.load_paths += Dir[root.join(*%(app admin))]
|
7
|
+
config.register_stylesheet 'ecm_downloads.css'
|
8
|
+
# config.register_javascript 'ecm_downloads.js'
|
8
9
|
end
|
9
|
-
end if
|
10
|
-
|
11
|
-
# helpers
|
12
|
-
config.to_prepare do
|
13
|
-
ApplicationController.helper(Ecm::Downloads::DownloadCategoryHelper)
|
14
|
-
ApplicationController.helper(Ecm::Downloads::DownloadHelper)
|
15
|
-
end
|
16
|
-
|
17
|
-
# locales
|
18
|
-
paths["config/locales"] << File.dirname(__FILE__) + '/../../../config/locales'
|
10
|
+
end if Gem::Specification.find_all_by_name('activeadmin').any?
|
19
11
|
end
|
20
12
|
end
|
21
|
-
end
|
13
|
+
end
|
@@ -9,18 +9,16 @@ module Ecm
|
|
9
9
|
# This will only create the show action for download categories, but omit the index action.
|
10
10
|
def self.routes(router, options = {})
|
11
11
|
options.reverse_merge!(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}
|
12
|
+
download_category_actions: [:index, :show],
|
13
|
+
download_actions: [:index, :show],
|
14
|
+
add_download_member_action: false
|
16
15
|
)
|
17
16
|
|
18
|
-
router.resources :ecm_downloads_download_categories, :
|
19
|
-
router.resources :ecm_downloads_downloads, :
|
20
|
-
router.get :download, :
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
17
|
+
router.resources :ecm_downloads_download_categories, only: options[:download_category_actions], controller: 'ecm/downloads/download_categories'
|
18
|
+
router.resources :ecm_downloads_downloads, only: options[:download_actions], controller: 'ecm/downloads/downloads' do
|
19
|
+
router.get :download, on: :member, if: options[:add_download_member_action]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/ecm_downloads2.rb
CHANGED
@@ -2,15 +2,20 @@ module Ecm
|
|
2
2
|
module Downloads
|
3
3
|
module Generators
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
|
-
desc
|
5
|
+
desc 'Generates the intializer'
|
6
6
|
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
|
-
def
|
10
|
-
copy_file
|
9
|
+
def generate_initializer
|
10
|
+
copy_file 'initializer.rb', 'config/initializers/ecm_downloads.rb'
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_routes
|
14
|
+
inject_into_file 'config/routes.rb', before: "\nend" do
|
15
|
+
File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
16
|
-
|
File without changes
|
@@ -2,23 +2,21 @@ module Ecm
|
|
2
2
|
module Downloads
|
3
3
|
module Generators
|
4
4
|
class LocalesGenerator < Rails::Generators::Base
|
5
|
-
desc
|
5
|
+
desc 'Copies the locale files to your application'
|
6
6
|
|
7
7
|
source_root File.expand_path('../../../../../../config/locales', __FILE__)
|
8
8
|
|
9
9
|
def generate_locales
|
10
|
-
copy_file
|
11
|
-
copy_file
|
10
|
+
copy_file 'ecm.downloads.en.yml', 'config/locales/ecm.downloads.en.yml'
|
11
|
+
copy_file 'ecm.downloads.de.yml', 'config/locales/ecm.downloads.de.yml'
|
12
12
|
|
13
|
-
copy_file
|
14
|
-
copy_file
|
13
|
+
copy_file 'ecm.downloads.download_category.en.yml', 'config/locales/ecm.downloads.download_category.en.yml'
|
14
|
+
copy_file 'ecm.downloads.download_category.de.yml', 'config/locales/ecm.downloads.download_category.de.yml'
|
15
15
|
|
16
|
-
|
17
|
-
copy_file
|
18
|
-
copy_file "ecm.downloads.download.de.yml", "config/locales/ecm.downloads.download.de.yml"
|
16
|
+
copy_file 'ecm.downloads.download.en.yml', 'config/locales/ecm.downloads.download.en.yml'
|
17
|
+
copy_file 'ecm.downloads.download.de.yml', 'config/locales/ecm.downloads.download.de.yml'
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
24
|
-
|
@@ -1,22 +1,21 @@
|
|
1
1
|
namespace :ecm_downloads do
|
2
2
|
namespace :db do
|
3
|
-
desc
|
4
|
-
task :populate!, [] => [:environment] do |
|
5
|
-
|
6
|
-
Rake::Task[
|
7
|
-
Rake::Task["ecm_downloads:db:populate"].execute
|
3
|
+
desc 'Purges and creates example data'
|
4
|
+
task :populate!, [] => [:environment] do |_t, _args|
|
5
|
+
Rake::Task['ecm_downloads:db:clear!'].execute
|
6
|
+
Rake::Task['ecm_downloads:db:populate'].execute
|
8
7
|
end
|
9
8
|
|
10
|
-
desc
|
11
|
-
task :clear!, [] => [:environment] do |
|
9
|
+
desc 'Clears all data!'
|
10
|
+
task :clear!, [] => [:environment] do |_t, _args|
|
12
11
|
Ecm::Downloads::DownloadCategory.delete_all
|
13
12
|
Ecm::Downloads::Download.delete_all
|
14
13
|
end
|
15
14
|
|
16
|
-
desc
|
17
|
-
task :populate, [] => [:environment] do |
|
18
|
-
require
|
19
|
-
require
|
15
|
+
desc 'Creates example_data'
|
16
|
+
task :populate, [] => [:environment] do |_t, _args|
|
17
|
+
require 'ffaker'
|
18
|
+
require 'forgery'
|
20
19
|
|
21
20
|
# Create example download category roots
|
22
21
|
10.times do
|
@@ -42,7 +41,7 @@ namespace :ecm_downloads do
|
|
42
41
|
Ecm::Downloads::Download.create! do |d|
|
43
42
|
d.ecm_downloads_download_category = download_categories.choice
|
44
43
|
d.name = Faker::Product.product_name
|
45
|
-
d.asset = File.open(Ecm::Downloads::Engine.root +
|
44
|
+
d.asset = File.open(Ecm::Downloads::Engine.root + 'spec/fixtures/download/example.txt')
|
46
45
|
d.published = [true, false].choice
|
47
46
|
d.description = Faker::Lorem.paragraph(rand(10))
|
48
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecm_downloads2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,11 +24,8 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '4.0'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: acts_as_list
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - ">="
|
@@ -45,7 +39,7 @@ dependencies:
|
|
45
39
|
- !ruby/object:Gem::Version
|
46
40
|
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: acts_as_published
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - ">="
|
@@ -59,7 +53,7 @@ dependencies:
|
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: '0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
56
|
+
name: awesome_nested_set
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - ">="
|
@@ -73,7 +67,7 @@ dependencies:
|
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: '0'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
70
|
+
name: awesome_nested_set-tools
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
73
|
- - ">="
|
@@ -87,7 +81,7 @@ dependencies:
|
|
87
81
|
- !ruby/object:Gem::Version
|
88
82
|
version: '0'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
84
|
+
name: friendly_id
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
87
|
- - ">="
|
@@ -101,7 +95,7 @@ dependencies:
|
|
101
95
|
- !ruby/object:Gem::Version
|
102
96
|
version: '0'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
98
|
+
name: paperclip
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
101
|
- - ">="
|
@@ -115,7 +109,7 @@ dependencies:
|
|
115
109
|
- !ruby/object:Gem::Version
|
116
110
|
version: '0'
|
117
111
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
112
|
+
name: draper
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
120
114
|
requirements:
|
121
115
|
- - ">="
|
@@ -129,13 +123,13 @@ dependencies:
|
|
129
123
|
- !ruby/object:Gem::Version
|
130
124
|
version: '0'
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
126
|
+
name: sqlite3
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
129
|
- - ">="
|
136
130
|
- !ruby/object:Gem::Version
|
137
131
|
version: '0'
|
138
|
-
type: :
|
132
|
+
type: :development
|
139
133
|
prerelease: false
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
@@ -143,13 +137,13 @@ dependencies:
|
|
143
137
|
- !ruby/object:Gem::Version
|
144
138
|
version: '0'
|
145
139
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
140
|
+
name: rails-dummy
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
148
142
|
requirements:
|
149
143
|
- - ">="
|
150
144
|
- !ruby/object:Gem::Version
|
151
145
|
version: '0'
|
152
|
-
type: :
|
146
|
+
type: :development
|
153
147
|
prerelease: false
|
154
148
|
version_requirements: !ruby/object:Gem::Requirement
|
155
149
|
requirements:
|
@@ -157,7 +151,7 @@ dependencies:
|
|
157
151
|
- !ruby/object:Gem::Version
|
158
152
|
version: '0'
|
159
153
|
- !ruby/object:Gem::Dependency
|
160
|
-
name:
|
154
|
+
name: thin
|
161
155
|
requirement: !ruby/object:Gem::Requirement
|
162
156
|
requirements:
|
163
157
|
- - ">="
|
@@ -171,7 +165,7 @@ dependencies:
|
|
171
165
|
- !ruby/object:Gem::Version
|
172
166
|
version: '0'
|
173
167
|
- !ruby/object:Gem::Dependency
|
174
|
-
name:
|
168
|
+
name: devise
|
175
169
|
requirement: !ruby/object:Gem::Requirement
|
176
170
|
requirements:
|
177
171
|
- - ">="
|
@@ -185,7 +179,7 @@ dependencies:
|
|
185
179
|
- !ruby/object:Gem::Version
|
186
180
|
version: '0'
|
187
181
|
- !ruby/object:Gem::Dependency
|
188
|
-
name:
|
182
|
+
name: therubyracer
|
189
183
|
requirement: !ruby/object:Gem::Requirement
|
190
184
|
requirements:
|
191
185
|
- - ">="
|
@@ -199,7 +193,7 @@ dependencies:
|
|
199
193
|
- !ruby/object:Gem::Version
|
200
194
|
version: '0'
|
201
195
|
- !ruby/object:Gem::Dependency
|
202
|
-
name:
|
196
|
+
name: less-rails
|
203
197
|
requirement: !ruby/object:Gem::Requirement
|
204
198
|
requirements:
|
205
199
|
- - ">="
|
@@ -213,21 +207,21 @@ dependencies:
|
|
213
207
|
- !ruby/object:Gem::Version
|
214
208
|
version: '0'
|
215
209
|
- !ruby/object:Gem::Dependency
|
216
|
-
name:
|
210
|
+
name: twitter-bootstrap-rails
|
217
211
|
requirement: !ruby/object:Gem::Requirement
|
218
212
|
requirements:
|
219
|
-
- - "
|
213
|
+
- - ">="
|
220
214
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
215
|
+
version: '0'
|
222
216
|
type: :development
|
223
217
|
prerelease: false
|
224
218
|
version_requirements: !ruby/object:Gem::Requirement
|
225
219
|
requirements:
|
226
|
-
- - "
|
220
|
+
- - ">="
|
227
221
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
222
|
+
version: '0'
|
229
223
|
- !ruby/object:Gem::Dependency
|
230
|
-
name:
|
224
|
+
name: jquery-rails
|
231
225
|
requirement: !ruby/object:Gem::Requirement
|
232
226
|
requirements:
|
233
227
|
- - ">="
|
@@ -241,7 +235,7 @@ dependencies:
|
|
241
235
|
- !ruby/object:Gem::Version
|
242
236
|
version: '0'
|
243
237
|
- !ruby/object:Gem::Dependency
|
244
|
-
name:
|
238
|
+
name: rubocop
|
245
239
|
requirement: !ruby/object:Gem::Requirement
|
246
240
|
requirements:
|
247
241
|
- - ">="
|
@@ -255,7 +249,35 @@ dependencies:
|
|
255
249
|
- !ruby/object:Gem::Version
|
256
250
|
version: '0'
|
257
251
|
- !ruby/object:Gem::Dependency
|
258
|
-
name:
|
252
|
+
name: activeadmin
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: 1.0.0.pre2
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: 1.0.0.pre2
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: active_admin-acts_as_list
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: active_admin-awesome_nested_set
|
259
281
|
requirement: !ruby/object:Gem::Requirement
|
260
282
|
requirements:
|
261
283
|
- - ">="
|
@@ -342,16 +364,16 @@ dependencies:
|
|
342
364
|
name: shoulda-matchers
|
343
365
|
requirement: !ruby/object:Gem::Requirement
|
344
366
|
requirements:
|
345
|
-
- - "
|
367
|
+
- - ">="
|
346
368
|
- !ruby/object:Gem::Version
|
347
|
-
version:
|
369
|
+
version: '0'
|
348
370
|
type: :development
|
349
371
|
prerelease: false
|
350
372
|
version_requirements: !ruby/object:Gem::Requirement
|
351
373
|
requirements:
|
352
|
-
- - "
|
374
|
+
- - ">="
|
353
375
|
- !ruby/object:Gem::Version
|
354
|
-
version:
|
376
|
+
version: '0'
|
355
377
|
- !ruby/object:Gem::Dependency
|
356
378
|
name: factory_girl_rails
|
357
379
|
requirement: !ruby/object:Gem::Requirement
|
@@ -418,6 +440,8 @@ files:
|
|
418
440
|
- MIT-LICENSE
|
419
441
|
- README.rdoc
|
420
442
|
- Rakefile
|
443
|
+
- app/admin/ecm_downloads_download_categories.rb
|
444
|
+
- app/admin/ecm_downloads_downloads.rb
|
421
445
|
- app/assets/images/ecm_downloads/download_categories/last_node.png
|
422
446
|
- app/assets/images/ecm_downloads/download_categories/node.png
|
423
447
|
- app/assets/images/ecm_downloads/download_categories/vertical_line.png
|
@@ -442,6 +466,7 @@ files:
|
|
442
466
|
- app/views/ecm/downloads/downloads/_table_in_download_category.html.erb
|
443
467
|
- app/views/ecm/downloads/downloads/index.html.erb
|
444
468
|
- app/views/ecm/downloads/downloads/show.html.erb
|
469
|
+
- config/initializers/assets.rb
|
445
470
|
- config/locales/active_admin.patch.de.yml
|
446
471
|
- config/locales/ecm.downloads.de.yml
|
447
472
|
- config/locales/ecm.downloads.download.de.yml
|
@@ -449,18 +474,16 @@ files:
|
|
449
474
|
- config/locales/ecm.downloads.download_category.de.yml
|
450
475
|
- config/locales/ecm.downloads.download_category.en.yml
|
451
476
|
- config/locales/ecm.downloads.en.yml
|
452
|
-
- config/routes.rb
|
453
477
|
- db/migrate/001_create_ecm_downloads_download_categories.rb
|
454
478
|
- db/migrate/002_create_ecm_downloads_downloads.rb
|
455
|
-
- lib/ecm/downloads/active_admin/ecm_downloads_download_categories.rb
|
456
|
-
- lib/ecm/downloads/active_admin/ecm_downloads_downloads.rb
|
457
479
|
- lib/ecm/downloads/configuration.rb
|
458
480
|
- lib/ecm/downloads/engine.rb
|
459
481
|
- lib/ecm/downloads/routing.rb
|
460
482
|
- lib/ecm/downloads/version.rb
|
461
483
|
- lib/ecm_downloads2.rb
|
462
484
|
- lib/generators/ecm/downloads/install/install_generator.rb
|
463
|
-
- lib/generators/ecm/downloads/install/templates/
|
485
|
+
- lib/generators/ecm/downloads/install/templates/initializer.rb
|
486
|
+
- lib/generators/ecm/downloads/install/templates/routes.source
|
464
487
|
- lib/generators/ecm/downloads/locales/locales_generator.rb
|
465
488
|
- lib/tasks/ecm_downloads_tasks.rake
|
466
489
|
homepage: https://github.com/robotex82/ecm_downloads
|
data/config/routes.rb
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
## Rails.application.routes.draw do
|
2
|
-
#Ecm::Downloads::Engine.routes.draw do
|
3
|
-
# resources :ecm_downloads_download_categories, :only => [ :index, :show ], :controller => 'ecm/downloads/download_categories'
|
4
|
-
# resources :ecm_downloads_downloads, :only => [ :index, :show ], :controller => 'ecm/downloads/downloads'
|
5
|
-
#end
|