ecm_downloads2 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2686ef3583e0d0e5e86e716d9b196b3e55d1abdf
4
- data.tar.gz: 5c2510f057fea98156706db7de6a6aa007dcdf2b
3
+ metadata.gz: 9e98577d017dc309342a2f23200aae085cbd737e
4
+ data.tar.gz: e1af520faeaffc7b564967af5019df69053aca30
5
5
  SHA512:
6
- metadata.gz: 2bed6fd14d17e4164ee857d1f092adf0f5e5d762833956a4a5b3b536040cbd3e2ac512a14d91d10a0aef04112dd2bf61d9384c867b1f665bc152f4f36b9a4282
7
- data.tar.gz: 1c31c3d99bb6ff4b802bc2a90798173f703d36dedb54eeade77f6ad9f26044b199030faf5fd982bd008c2070eda79b56d4ca4cced518b5c4e0870339308d146a
6
+ metadata.gz: 3276c76926725bfd84f43f8609c44dab7e68b00ad7247fbf0b36e4b309c7d3650e31d4c09ed5a8067bce603815cfe181a173604450cd98d0908482889cdf76ed
7
+ data.tar.gz: 806c4ebc0a10b0a5a29787e9b7e18745027a97e5df9e899dca5a4dfb9dd96f2aeed8bdc20daf160172bf7083cf536c7db898af4ba738cc52e771ad9139e21f84
data/README.rdoc CHANGED
@@ -38,6 +38,15 @@ Add the routes:
38
38
  # config/routes.rb
39
39
  Ecm::Downloads::Routing.routes(self)
40
40
 
41
+ Add the helpers to your application controller:
42
+
43
+ # app/controllers/application_controller.rb
44
+ class ApplicationController < ActionController::Base
45
+ helper Ecm::Downloads::DownloadCategoryHelper
46
+ helper Ecm::Downloads::DownloadHelper
47
+ ...
48
+ end
49
+
41
50
  == Optional: Generate locale files
42
51
 
43
52
  You may want to copy the locales to your app:
@@ -1,8 +1,11 @@
1
1
  module Ecm::Downloads
2
2
  class DownloadCategoryDecorator < Draper::Decorator
3
- # delegate :root?, :parent_id, :persisted?
4
3
  delegate_all
5
4
 
5
+ def display_code
6
+ "<%= render_download_category '#{name}' %>"
7
+ end
8
+
6
9
  def ecm_downloads_downloads_count_label
7
10
  h.content_tag(:span, ecm_downloads_downloads_count, class: 'badge')
8
11
  end
@@ -14,5 +17,13 @@ module Ecm::Downloads
14
17
  def tree_name
15
18
  name
16
19
  end
20
+
21
+ def index_name
22
+ if self.root?
23
+ "[#{self.locale}] #{self.name}"
24
+ else
25
+ "#{'&#160;&#160;&#160;&#160;' * self.level} |--&#160;#{self.name}".html_safe
26
+ end
27
+ end
17
28
  end
18
29
  end
@@ -17,5 +17,9 @@ module Ecm::Downloads
17
17
  def tree_name
18
18
  name
19
19
  end
20
+
21
+ def display_code
22
+ "<%= render_download '#{self.name}' %>"
23
+ end
20
24
  end
21
25
  end
@@ -1,11 +1,18 @@
1
1
  module Ecm::Downloads
2
2
  module DownloadCategoryHelper
3
3
  def render_download_category(download_category_name, options = {})
4
- download_category = DownloadCategory.where(:name => download_category_name).first
4
+ download_category = DownloadCategory.where(:name => download_category_name).first.decorate
5
5
  if download_category.nil?
6
6
  I18n.t('ecm.downloads.download_category.messages.not_found', :name => download_category_name)
7
7
  else
8
- render download_category
8
+ begin
9
+ o = '<notextile>'
10
+ o << render(download_category)
11
+ o << '</notextile>'
12
+ return o.html_safe
13
+ rescue => e
14
+ raise e
15
+ end
9
16
  end
10
17
  end
11
18
  end
@@ -1,11 +1,18 @@
1
1
  module Ecm::Downloads
2
2
  module DownloadHelper
3
3
  def render_download(download_name, options = {})
4
- download = Download.where(:name => download_name).first
4
+ download = Download.where(:name => download_name).first.decorate
5
5
  if download.nil?
6
6
  I18n.t('ecm.downloads.download.messages.not_found', :name => download_name)
7
7
  else
8
- render download
8
+ begin
9
+ o = '<notextile>'
10
+ o << render(download)
11
+ o << '</notextile>'
12
+ return o.html_safe
13
+ rescue => e
14
+ raise e
15
+ end
9
16
  end
10
17
  end
11
18
  end
@@ -70,7 +70,7 @@ class Ecm::Downloads::Download < ActiveRecord::Base
70
70
  validates :name, :presence => true
71
71
  validates_attachment :asset, presence => true
72
72
  do_not_validate_attachment_file_type :asset
73
- # public methods
73
+
74
74
 
75
75
  def human
76
76
  name
@@ -80,8 +80,8 @@ class Ecm::Downloads::Download < ActiveRecord::Base
80
80
  human
81
81
  end
82
82
 
83
- # private methods
84
83
  private
84
+
85
85
  def fix_updated_position
86
86
  Rails.logger.debug "Fixing positions for #{self.to_s} (Moving to last)"
87
87
  add_to_list_bottom
@@ -43,37 +43,11 @@ class Ecm::Downloads::DownloadCategory < ActiveRecord::Base
43
43
  validates :locale, :absence => true,
44
44
  :unless => :root?
45
45
 
46
- # public methods
47
-
48
- # public methods
49
-
50
- def display_code
51
- "<%= render_download_category '#{self.name}' %>"
52
- end
53
-
54
46
  def human
55
47
  name
56
48
  end
57
49
 
58
- def index_name
59
- if self.root?
60
- "[#{self.locale}] #{self.name}"
61
- else
62
- "#{'&#160;&#160;&#160;&#160;' * self.level} |--&#160;#{self.name}".html_safe
63
- end
64
- end
65
-
66
50
  def to_s
67
51
  name
68
52
  end
69
-
70
- # def tree_name
71
- # root_prefix = (self.root?) ? "[#{self.locale}] " : ""
72
-
73
- # if ecm_downloads_downloads_count < 1
74
- # "#{root_prefix}#{to_s}"
75
- # else
76
- # "#{root_prefix}#{to_s} (#{ecm_downloads_downloads_count})"
77
- # end
78
- # end
79
53
  end
@@ -7,14 +7,14 @@
7
7
  </div>
8
8
  <% end %>
9
9
 
10
- <%= render partial: 'table', locals: { download_categories: Ecm::Downloads::DownloadCategoryDecorator.decorate_collection(download_category.descendants) } %>
10
+ <%= render partial: 'ecm/downloads/download_categories/table', locals: { download_categories: Ecm::Downloads::DownloadCategoryDecorator.decorate_collection(download_category.descendants) } %>
11
11
 
12
12
  <div class="download_category-downloads item_list">
13
- <h2><%= Ecm::Downloads::DownloadCategory.human_attribute_name(:ecm_downloads_downloads) %></h2>
13
+
14
14
  <% if download_category.ecm_downloads_downloads.published.count == 0 %>
15
15
  <p><%= t('ecm.downloads.download_category.messages.no_downloads_available') %></p>
16
16
  <% else %>
17
- <%= render partial: 'ecm/downloads/downloads/table', locals: { downloads: download_category.ecm_downloads_downloads.published } %>
17
+ <%= render partial: 'ecm/downloads/downloads/table_in_download_category', locals: { downloads: download_category.ecm_downloads_downloads.published } %>
18
18
  <% end %>
19
19
  </div>
20
20
  </div>
@@ -1,7 +1,7 @@
1
1
  <div class="table-responsive">
2
2
  <table class="<%= Ecm::Downloads::Configuration.download_categories_table_classes %>">
3
3
  <tbody>
4
- <%= render partial: 'download_category_in_table', collection: download_categories, as: :download_category %>
4
+ <%= render partial: 'ecm/downloads/download_categories/download_category_in_table', collection: download_categories, as: :download_category %>
5
5
  </tbody>
6
6
  </table>
7
7
  </div>
@@ -4,6 +4,6 @@
4
4
  <% if @download_category.root? %>
5
5
  <%= link_to(t('ecm.downloads.download_category.actions.back_to_index'), ecm_downloads_download_categories_path, class: 'btn btn-default') if respond_to?(:ecm_downloads_download_categories_path) %>
6
6
  <% else %>
7
- <%= link_to(Ecm::Downloads::DownloadCategory.human_attribute_name(:parent), @download_category.parent, class: 'btn btn-default') %>
7
+ <%= link_to(t('ecm.downloads.views.actions.back'), @download_category.parent, class: 'btn btn-default') %>
8
8
  <% end %>
9
9
  </div>
@@ -1,4 +1,4 @@
1
- <h1><%= download.human %></h1>
1
+ <h3><%= download.human %></h3>
2
2
 
3
3
  <div class="description bottom-margin-1">
4
4
  <%= download.description %>
@@ -0,0 +1,12 @@
1
+ <div class="panel panel-primary">
2
+ <div class="panel-heading">
3
+ <h3 class="panel-title"><%= Ecm::Downloads::DownloadCategory.human_attribute_name(:ecm_downloads_downloads) %></h3>
4
+ </div>
5
+ <div class="table-responsive">
6
+ <table class="<%= Ecm::Downloads::Configuration.downloads_table_classes %>">
7
+ <tbody>
8
+ <%= render partial: 'ecm/downloads/downloads/download_in_table', collection: downloads, as: :download %>
9
+ </tbody>
10
+ </table>
11
+ </div>
12
+ </div>
@@ -13,6 +13,8 @@ de:
13
13
  description: Beschreibung
14
14
  ecm_downloads_download_category: Download Kategorie
15
15
  ecm_downloads_download_category_id: Download Kategorie
16
+ filesize: Dateigröße
17
+ link: Link
16
18
  locale: Sprache
17
19
  name: Name
18
20
  position: Position
@@ -13,6 +13,8 @@ en:
13
13
  description: description
14
14
  ecm_downloads_download_category: download category
15
15
  ecm_downloads_download_category_id: download category
16
+ filesize: filesize
17
+ link: link
16
18
  locale: locale
17
19
  name: name
18
20
  position: position
@@ -10,6 +10,7 @@ de:
10
10
  ecm_downloads_downloads: Downloads
11
11
  ecm_downloads_downloads_count: Downloads
12
12
  lft: Links
13
+ link: Link
13
14
  locale: Sprache
14
15
  name: Name
15
16
  parent: Über Kategorie
@@ -10,6 +10,7 @@ en:
10
10
  ecm_downloads_downloads: downloads
11
11
  ecm_downloads_downloads_count: downloads
12
12
  lft: left
13
+ link: link
13
14
  locale: locale
14
15
  name: name
15
16
  parent: parent
@@ -3,6 +3,8 @@ if defined?(ActiveAdmin)
3
3
  include ActiveAdmin::AwesomeNestedSet::Helper
4
4
 
5
5
  ActiveAdmin.register Ecm::Downloads::DownloadCategory do
6
+ decorate_with Ecm::Downloads::DownloadCategoryDecorator
7
+
6
8
  # menu entry settings
7
9
  menu :parent => I18n.t('ecm.downloads.active_admin.menu')
8
10
 
@@ -41,7 +43,7 @@ if defined?(ActiveAdmin)
41
43
  f.inputs do
42
44
  f.semantic_errors *f.object.errors.keys
43
45
  end
44
-
46
+
45
47
  f.inputs do
46
48
  f.input :parent, :as => :select,
47
49
  :collection => nested_set_options(Ecm::Downloads::DownloadCategory, f.object) { |dc| "#{'-' * dc.depth} #{dc.name}" }
@@ -104,7 +106,7 @@ if defined?(ActiveAdmin)
104
106
 
105
107
  panel Ecm::Downloads::DownloadCategory.human_attribute_name(:link) do
106
108
  div do
107
- ecm_downloads_download_category_path(I18n.locale, ecm_downloads_download_category)
109
+ ecm_downloads_download_category_path(ecm_downloads_download_category)
108
110
  end
109
111
  end
110
112
 
@@ -2,6 +2,8 @@ include ActiveAdmin::ActsAsList::Helper
2
2
  include ActsAsPublished::ActiveAdminHelper
3
3
 
4
4
  ActiveAdmin.register Ecm::Downloads::Download do
5
+ decorate_with Ecm::Downloads::DownloadDecorator
6
+
5
7
  # acts as list
6
8
  sortable_member_actions
7
9
 
@@ -46,4 +48,36 @@ ActiveAdmin.register Ecm::Downloads::Download do
46
48
  column :created_at
47
49
  actions
48
50
  end
51
+
52
+ show :title => :to_s do
53
+ attributes_table do
54
+ row :ecm_downloads_download_category
55
+ row :name
56
+ row :published_at
57
+ row :asset_file_name
58
+ row :filesize
59
+ row :asset_content_type
60
+ row :asset_fingerprint
61
+ row :created_at
62
+ row :updated_at
63
+ end
64
+
65
+ panel Ecm::Downloads::Download.human_attribute_name(:description) do
66
+ div do
67
+ ecm_downloads_download.description
68
+ end
69
+ end
70
+
71
+ panel Ecm::Downloads::Download.human_attribute_name(:display_code) do
72
+ div do
73
+ ecm_downloads_download.display_code
74
+ end
75
+ end
76
+
77
+ panel Ecm::Downloads::Download.human_attribute_name(:link) do
78
+ div do
79
+ ecm_downloads_download_path(ecm_downloads_download)
80
+ end
81
+ end
82
+ end
49
83
  end if defined?(ActiveAdmin)
@@ -1,6 +1,6 @@
1
1
  module Ecm
2
2
  module Downloads
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
6
6
 
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: 1.1.0
4
+ version: 1.1.1
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: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -439,6 +439,7 @@ files:
439
439
  - app/views/ecm/downloads/downloads/_download.html.erb
440
440
  - app/views/ecm/downloads/downloads/_download_in_table.html.erb
441
441
  - app/views/ecm/downloads/downloads/_table.html.erb
442
+ - app/views/ecm/downloads/downloads/_table_in_download_category.html.erb
442
443
  - app/views/ecm/downloads/downloads/index.html.erb
443
444
  - app/views/ecm/downloads/downloads/show.html.erb
444
445
  - config/locales/active_admin.patch.de.yml