udongo 5.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/backend/application.js +1 -1
  3. data/app/controllers/backend/assets_controller.rb +52 -0
  4. data/app/models/asset.rb +37 -0
  5. data/app/models/asset_image.rb +172 -0
  6. data/app/models/concerns/imageable.rb +13 -0
  7. data/app/models/image.rb +11 -0
  8. data/app/uploaders/asset_uploader.rb +36 -0
  9. data/app/views/backend/assets/_filter.html.erb +17 -0
  10. data/app/views/backend/assets/_form.html.erb +28 -0
  11. data/app/views/backend/assets/edit.html.erb +5 -0
  12. data/app/views/backend/assets/index.html.erb +48 -0
  13. data/app/views/backend/assets/new.html.erb +4 -0
  14. data/app/views/backend/snippets/edit.html.erb +1 -1
  15. data/app/views/backend/users/index.html.erb +2 -2
  16. data/app/views/layouts/backend/_top_navigation.html.erb +1 -0
  17. data/changelog.md +9 -0
  18. data/config/locales/en.yml +2 -1
  19. data/config/locales/en_backend.yml +6 -0
  20. data/config/locales/en_general.yml +1 -0
  21. data/config/locales/fr.yml +1 -1
  22. data/config/locales/nl.yml +2 -1
  23. data/config/locales/nl_backend.yml +5 -0
  24. data/config/locales/nl_general.yml +1 -0
  25. data/config/routes.rb +2 -0
  26. data/db/migrate/20170225144523_create_assets.rb +14 -0
  27. data/db/migrate/20170228183831_create_images.rb +18 -0
  28. data/lib/udongo/configs/assets.rb +10 -0
  29. data/lib/udongo/version.rb +1 -1
  30. data/readme.md +11 -0
  31. data/spec/factories/addresses.rb +6 -0
  32. data/spec/factories/admins.rb +10 -0
  33. data/spec/factories/assets.rb +5 -0
  34. data/spec/factories/comments.rb +9 -0
  35. data/spec/factories/content_columns.rb +10 -0
  36. data/spec/factories/content_images.rb +9 -0
  37. data/spec/factories/content_rows.rb +5 -0
  38. data/spec/factories/content_texts.rb +4 -0
  39. data/spec/factories/email_templates.rb +8 -0
  40. data/spec/factories/emails.rb +11 -0
  41. data/spec/factories/images.rb +5 -0
  42. data/spec/factories/logs.rb +4 -0
  43. data/spec/factories/meta.rb +7 -0
  44. data/spec/factories/navigation_items.rb +5 -0
  45. data/spec/factories/navigations.rb +6 -0
  46. data/spec/factories/notes.rb +6 -0
  47. data/spec/factories/pages.rb +5 -0
  48. data/spec/factories/queued_tasks.rb +5 -0
  49. data/spec/factories/redirects.rb +7 -0
  50. data/spec/factories/search_indices.rb +6 -0
  51. data/spec/factories/search_modules.rb +5 -0
  52. data/spec/factories/search_synonyms.rb +7 -0
  53. data/spec/factories/settings.rb +7 -0
  54. data/spec/factories/snippets.rb +6 -0
  55. data/spec/factories/stores.rb +6 -0
  56. data/spec/factories/tagged_items.rb +5 -0
  57. data/spec/factories/tags.rb +7 -0
  58. data/spec/factories/users.rb +9 -0
  59. data/spec/support/concerns/cacheable.rb +10 -0
  60. data/spec/support/concerns/commentable.rb +10 -0
  61. data/spec/support/concerns/content_type.rb +20 -0
  62. data/spec/support/concerns/deletable.rb +33 -0
  63. data/spec/support/concerns/draggable.rb +29 -0
  64. data/spec/support/concerns/emailable.rb +7 -0
  65. data/spec/support/concerns/flexible_content.rb +22 -0
  66. data/spec/support/concerns/imageable.rb +15 -0
  67. data/spec/support/concerns/locale.rb +21 -0
  68. data/spec/support/concerns/loggable.rb +19 -0
  69. data/spec/support/concerns/notable.rb +10 -0
  70. data/spec/support/concerns/parentable.rb +73 -0
  71. data/spec/support/concerns/person.rb +15 -0
  72. data/spec/support/concerns/publishable.rb +41 -0
  73. data/spec/support/concerns/searchable.rb +130 -0
  74. data/spec/support/concerns/seo.rb +54 -0
  75. data/spec/support/concerns/sortable.rb +67 -0
  76. data/spec/support/concerns/spammable.rb +53 -0
  77. data/spec/support/concerns/storable.rb +18 -0
  78. data/spec/support/concerns/taggable.rb +51 -0
  79. data/spec/support/concerns/translatable.rb +71 -0
  80. data/spec/support/concerns/visible.rb +64 -0
  81. metadata +66 -2
@@ -0,0 +1,4 @@
1
+ <% breadcrumb.add t('b.add') %>
2
+ <%= render 'backend/breadcrumbs' %>
3
+
4
+ <%= render 'form' %>
@@ -3,4 +3,4 @@
3
3
  <%= render 'backend/breadcrumbs' %>
4
4
 
5
5
  <%= render 'backend/snippets/tabs', active: :general %>
6
- <%= render 'backend/snippets/form', identifier: false %>
6
+ <%= render 'backend/snippets/form' %>
@@ -23,8 +23,8 @@
23
23
  <td><%= mail_to u.email %></td>
24
24
  <td><%= t u.active?.to_s %></td>
25
25
  <td class="text-xs-right">
26
- <%= link_to icon(:pencil_square_o), edit_backend_user_path(u) %>
27
- <%= link_to icon(:trash), backend_user_path(u), method: :delete, data: {confirm: t('b.msg.confirm') }%>
26
+ <%= link_to_edit [:backend, u] %>
27
+ <%= link_to_delete [:backend, u] %>
28
28
  </td>
29
29
  </tr>
30
30
  <% end %>
@@ -4,6 +4,7 @@
4
4
  <div class="dropdown-menu">
5
5
  <%= link_to t('b.pages'), backend_pages_path, class: 'dropdown-item' %>
6
6
  <%= link_to t('b.snippets'), backend_snippets_path, class: 'dropdown-item' %>
7
+ <%= link_to t('b.files'), backend_assets_path, class: 'dropdown-item' %>
7
8
  </div>
8
9
  </li>
9
10
 
data/changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ 5.2.0 - 2017-03-02
2
+ --
3
+ * Add an assets module to manage all kinds of files.
4
+ * Backend now loads jQuery 3 by default.
5
+ * You can now mark a model as 'Imageable', which makes it possible to link one
6
+ or more images (assets) to it. These assets can be reused for other modules
7
+ as well.
8
+
9
+
1
10
  5.1.0 - 2017-02-15
2
11
  --
3
12
  * The users module now orders by last/first name.
@@ -106,6 +106,7 @@ en:
106
106
  equal_to: must be equal to %{count}
107
107
  even: must be even
108
108
  exclusion: is reserved
109
+ extension_white_list_error: 'You are not allowed to upload %{extension} files, allowed types: %{allowed_types}'
109
110
  greater_than: must be greater than %{count}
110
111
  greater_than_or_equal_to: must be greater than or equal to %{count}
111
112
  inclusion: is not included in the list
@@ -198,7 +199,7 @@ en:
198
199
  time:
199
200
  am: am
200
201
  formats:
201
- default: ! '%B %d, %Y at %Hh%M'
202
+ default: ! '%B %-d, %Y at %Hh%M'
202
203
  timeless: ! '%d %B %Y'
203
204
  short: ! '%d %b at %Hh%M'
204
205
  time_attr: ! '%G-W%V-%uT%R%:z'
@@ -1,6 +1,7 @@
1
1
  en:
2
2
  b:
3
3
  actions: Actions
4
+ active: Active
4
5
  add: Add
5
6
  admin: Admin
6
7
  admins: Admins
@@ -14,6 +15,7 @@ en:
14
15
  description: Description
15
16
  destination: Destination
16
17
  down: Down
18
+ download: Download
17
19
  edit: Edit
18
20
  email: E-mail
19
21
  emails: E-mails
@@ -21,6 +23,8 @@ en:
21
23
  email_templates: E-mail templates
22
24
  enabled?: Enabled?
23
25
  extra: Extra
26
+ file: File
27
+ files: Files
24
28
  filter: Filter
25
29
  first_name: First name
26
30
  flexible_content: Flexible content
@@ -28,6 +32,7 @@ en:
28
32
  general: General
29
33
  house_number: House number
30
34
  html_content: HTML content
35
+ last_changed_at: Last changed at
31
36
  last_name: Last name
32
37
  locale: Locale
33
38
  login: Login
@@ -54,6 +59,7 @@ en:
54
59
  sender: Sender
55
60
  sent_at: Sent at
56
61
  settings: Settings
62
+ size: Size
57
63
  snippet: Snippet
58
64
  snippets: Snippets
59
65
  source: Source
@@ -14,3 +14,4 @@ en:
14
14
  search: Search
15
15
  subject: Subject
16
16
  telephone: Telephone
17
+ type: Type
@@ -206,7 +206,7 @@ fr:
206
206
  time:
207
207
  am: 'am'
208
208
  formats:
209
- default: "%A %d %B %Y à %Hh%M"
209
+ default: "%A %-d %B %Y à %Hh%M"
210
210
  timeless: '%d %B %Y'
211
211
  short: "%d %b à %Hh%M"
212
212
  time_attr: ! '%G-W%V-%uT%R%:z'
@@ -112,6 +112,7 @@ nl:
112
112
  equal_to: moet gelijk zijn aan %{count}
113
113
  even: moet even zijn
114
114
  exclusion: is niet beschikbaar
115
+ extension_white_list_error: 'Bestanden met de extensie %{extension} zijn niet toegestaan. Wel toegestaan zijn: %{allowed_types}'
115
116
  greater_than: moet groter zijn dan %{count}
116
117
  greater_than_or_equal_to: moet groter dan of gelijk zijn aan %{count}
117
118
  inclusion: is niet in de lijst opgenomen
@@ -204,7 +205,7 @@ nl:
204
205
  time:
205
206
  am: ! '''s ochtends'
206
207
  formats:
207
- default: ! '%d %B %Y om %Hu%M'
208
+ default: ! '%-d %B %Y om %Hu%M'
208
209
  timeless: ! '%d %B %Y'
209
210
  short: ! '%d %b om %Hu%M'
210
211
  time_attr: ! '%FT%R%:z'
@@ -15,6 +15,7 @@ nl:
15
15
  description: Beschrijving
16
16
  destination: Bestemming
17
17
  down: Omlaag
18
+ download: Download
18
19
  edit: Bewerk
19
20
  email: E-mail
20
21
  emails: E-mails
@@ -22,6 +23,8 @@ nl:
22
23
  email_templates: E-mail templates
23
24
  enabled?: Ingeschakeld?
24
25
  extra: Extra
26
+ file: Bestand
27
+ files: Bestanden
25
28
  filter: Filter
26
29
  first_name: Voornaam
27
30
  flexible_content: Flexibele inhoud
@@ -29,6 +32,7 @@ nl:
29
32
  general: Algemeen
30
33
  house_number: Huisnummer
31
34
  html_content: HTML inhoud
35
+ last_changed_at: Laatst gewijzigd op
32
36
  last_name: Achternaam
33
37
  locale: Taal
34
38
  login: Inloggen
@@ -55,6 +59,7 @@ nl:
55
59
  sender: Afzender
56
60
  sent_at: Verzonden op
57
61
  settings: Instellingen
62
+ size: Grootte
58
63
  snippet: Snippet
59
64
  snippets: Snippets
60
65
  source: Bron
@@ -14,3 +14,4 @@ nl:
14
14
  search: Zoeken
15
15
  subject: Onderwerp
16
16
  telephone: Telefoon
17
+ type: Type
data/config/routes.rb CHANGED
@@ -76,6 +76,8 @@ Rails.application.routes.draw do
76
76
  end
77
77
  end
78
78
  end
79
+
80
+ resources :assets
79
81
  end
80
82
 
81
83
  get 'go/:slug' => 'redirects#go'
@@ -0,0 +1,14 @@
1
+ class CreateAssets < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :assets do |t|
4
+ t.string :filename
5
+ t.string :content_type
6
+ t.integer :filesize
7
+ t.text :description
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :assets, :content_type
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ class CreateImages < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :images do |t|
4
+ t.integer :imageable_id
5
+ t.string :imageable_type
6
+ t.references :asset
7
+ t.integer :position
8
+ t.boolean :visible
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :images, :imageable_id
14
+ add_index :images, :imageable_type
15
+ add_index :images, :position
16
+ add_index :images, :visible
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module Udongo
2
+ module Configs
3
+ class Assets
4
+ include Virtus.model
5
+
6
+ attribute :image_white_list, Array, default: %w(gif jpeg jpg png)
7
+ attribute :file_white_list, Array, default: %w(doc docx pdf txt xls xlsx)
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Udongo
2
- VERSION = '5.1.0'
2
+ VERSION = '5.2.0'
3
3
  end
data/readme.md CHANGED
@@ -61,6 +61,17 @@ Udongo.config.flexible_content.types = %w(text image)
61
61
  Udongo.config.flexible_content.allowed_breakpoints = %w(xs sm md lg xl)
62
62
  ```
63
63
 
64
+ ## Assets
65
+ ### image_white_list
66
+ ```ruby
67
+ Udongo.config.image_white_list = %w(gif jpeg jpg png)
68
+ ```
69
+
70
+ ### file_white_list
71
+ ```ruby
72
+ Udongo.config.file_white_list = %w(doc docx pdf txt xls xlsx)
73
+ ```
74
+
64
75
  # Concerns
65
76
  ## Storable concern
66
77
  ### Possible field types
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :address do
3
+ addressable_id 1
4
+ addressable_type 'Example'
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :admin do
3
+ locale 'nl'
4
+ first_name 'foo'
5
+ last_name 'bar'
6
+ sequence(:email) { |n| "foo-#{n}@bar.baz" }
7
+ password 'sekret'
8
+ password_confirmation 'sekret'
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :asset do
3
+ filename { fixture_file_upload 'spec/fixtures/files/example.jpg', 'application/jpeg' }
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :comment do
3
+ commentable_id 1
4
+ commentable_type 'Example'
5
+ author 'Foo Bar'
6
+ sequence(:email) { |n| "foo-#{n}@bar.baz" }
7
+ message 'Foo bar baz'
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :content_column do
3
+ association :row, factory: :content_row
4
+ width_xs { rand(1..12) }
5
+ width_sm { rand(1..12) }
6
+ width_md { rand(1..12) }
7
+ width_lg { rand(1..12) }
8
+ width_xl { rand(1..12) }
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :content_image do
3
+ file { fixture_file_upload 'spec/fixtures/files/example.jpg', 'application/jpeg' }
4
+
5
+ after(:create) do |file, proxy|
6
+ proxy.file.close
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :content_row do
3
+ locale 'nl'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ FactoryGirl.define do
2
+ factory :content_text do
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :email_template do
3
+ sequence(:identifier) { |n| "foo-#{n}" }
4
+ description 'foo'
5
+ from_name 'foo'
6
+ from_email 'foo@bar.baz'
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ FactoryGirl.define do
2
+ factory :email do
3
+ from_name 'Foo Bar'
4
+ from_email 'foo@bar.baz'
5
+ to_name 'Bar Foo'
6
+ to_email 'bar@foo.baz'
7
+ subject 'foo'
8
+ plain_content 'foo'
9
+ html_content 'foo'
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :image do
3
+ asset
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ FactoryGirl.define do
2
+ factory :log do
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :meta do
3
+ locale 'nl'
4
+ sequence(:slug) { |n| "foo-#{n}" }
5
+ end
6
+ end
7
+
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :navigation_item do
3
+ navigation
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :navigation do
3
+ sequence(:identifier) { |n| "foo-#{n}" }
4
+ description 'foo'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :note do
3
+ content 'test'
4
+ end
5
+ end
6
+
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :page do
3
+ description 'Foo'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :queued_task do
3
+ klass 'SomeClass'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :redirect do
3
+ source_uri '/nl/foo'
4
+ destination_uri '/nl/bar'
5
+ status_code 303
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :search_index do
3
+ locale 'nl'
4
+ name 'foo'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :search_module do
3
+ name 'Page'
4
+ end
5
+ end