spina 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spina might be problematic. Click here for more details.

Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +5 -14
  4. data/app/assets/config/spina/manifest.js +5 -0
  5. data/app/assets/config/spina_manifest.js +5 -0
  6. data/app/assets/images/spina/arrow-left.svg +1 -0
  7. data/app/assets/images/spina/arrow-right.svg +1 -0
  8. data/app/assets/images/spina/datepicker.svg +1 -0
  9. data/app/assets/images/spina/divider.svg +1 -0
  10. data/app/assets/images/spina/media_folder_placeholder.svg +1 -0
  11. data/app/assets/images/spina/spina.svg +1 -0
  12. data/app/assets/javascripts/spina/admin/application.js +1 -2
  13. data/app/assets/javascripts/spina/admin/controllers/gallery_select_controller.js +52 -0
  14. data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +2 -2
  15. data/app/assets/javascripts/spina/admin/controllers/page_collapse_controller.js +35 -0
  16. data/app/assets/javascripts/spina/admin/media_gallery.coffee +1 -1
  17. data/app/assets/javascripts/spina/admin/trix.coffee.erb +79 -5
  18. data/app/assets/javascripts/spina/admin/uploads.coffee +1 -1
  19. data/app/assets/stylesheets/spina.sass +8 -4
  20. data/app/assets/stylesheets/spina/_buttons.sass +1 -0
  21. data/app/assets/stylesheets/spina/_forms.sass +1 -1
  22. data/app/assets/stylesheets/spina/_gallery.sass +45 -12
  23. data/app/assets/stylesheets/spina/_sortable_lists.sass +7 -0
  24. data/app/assets/stylesheets/spina/_trix_custom.sass +227 -0
  25. data/app/assets/stylesheets/spina/admin/{application.sass → application.css.sass} +0 -0
  26. data/app/controllers/concerns/spina/frontend.rb +5 -5
  27. data/app/controllers/spina/admin/accounts_controller.rb +2 -1
  28. data/app/controllers/spina/admin/images_controller.rb +1 -1
  29. data/app/controllers/spina/admin/media_picker_controller.rb +14 -2
  30. data/app/controllers/spina/admin/navigations_controller.rb +9 -7
  31. data/app/controllers/spina/admin/pages_controller.rb +16 -11
  32. data/app/controllers/spina/admin/password_resets_controller.rb +2 -2
  33. data/app/controllers/spina/admin/resources_controller.rb +9 -7
  34. data/app/controllers/spina/admin/settings_controller.rb +1 -1
  35. data/app/controllers/spina/admin/users_controller.rb +8 -7
  36. data/app/controllers/spina/pages_controller.rb +1 -3
  37. data/app/helpers/spina/admin/pages_helper.rb +2 -2
  38. data/app/helpers/spina/images_helper.rb +1 -1
  39. data/app/models/spina/account.rb +14 -6
  40. data/app/models/spina/attachment.rb +3 -3
  41. data/app/models/spina/image.rb +10 -1
  42. data/app/models/spina/image_collection.rb +3 -3
  43. data/app/models/spina/line.rb +1 -1
  44. data/app/models/spina/navigation_item.rb +2 -1
  45. data/app/models/spina/page.rb +11 -6
  46. data/app/models/spina/resource.rb +11 -0
  47. data/app/models/spina/text.rb +1 -1
  48. data/app/presenters/spina/menu_presenter.rb +74 -0
  49. data/app/views/layouts/spina/admin/admin.html.haml +1 -1
  50. data/app/views/spina/admin/accounts/social.html.haml +18 -0
  51. data/app/views/spina/admin/images/_form.html.haml +1 -1
  52. data/app/views/spina/admin/images/_image.html.haml +3 -5
  53. data/app/views/spina/admin/media_folders/_media_folder.html.haml +2 -2
  54. data/app/views/spina/admin/media_folders/show.html.haml +1 -1
  55. data/app/views/spina/admin/media_picker/_modal.html.haml +51 -14
  56. data/app/views/spina/admin/media_picker/select.js.erb +4 -2
  57. data/app/views/spina/admin/pages/_form.html.haml +1 -1
  58. data/app/views/spina/admin/pages/children.html.haml +4 -0
  59. data/app/views/spina/admin/partables/lines/_form.html.haml +1 -1
  60. data/app/views/spina/admin/partables/texts/_form.html.haml +4 -1
  61. data/app/views/spina/admin/password_resets/edit.html.haml +1 -1
  62. data/app/views/spina/admin/password_resets/new.html.haml +1 -1
  63. data/app/views/spina/admin/resources/edit.html.haml +1 -1
  64. data/app/views/spina/admin/resources/show.html.haml +13 -3
  65. data/app/views/spina/admin/sessions/new.html.haml +1 -1
  66. data/app/views/spina/admin/shared/_primary_navigation.html.haml +1 -1
  67. data/app/views/spina/admin/shared/_rich_text_field.html.haml +1 -32
  68. data/app/views/spina/shared/_admin_bar.html.haml +1 -1
  69. data/app/views/spina/shared/_social.html.haml +2 -2
  70. data/config/locales/de.yml +3 -0
  71. data/config/locales/en.yml +4 -0
  72. data/config/locales/es.yml +3 -0
  73. data/config/locales/fr.yml +3 -0
  74. data/config/locales/it.yml +3 -0
  75. data/config/locales/nl.yml +4 -0
  76. data/config/locales/pt-BR.yml +20 -1
  77. data/config/locales/ru.yml +3 -0
  78. data/config/locales/tr.yml +3 -0
  79. data/config/locales/zh-CN.yml +3 -0
  80. data/config/routes.rb +1 -0
  81. data/lib/generators/spina/install_generator.rb +10 -10
  82. data/lib/generators/spina/templates/app/views/default/shared/_navigation.html.haml +2 -3
  83. data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +4 -3
  84. data/lib/generators/spina/templates/app/views/demo/shared/_navigation.html.haml +2 -3
  85. data/lib/generators/spina/templates/app/views/layouts/default/application.html.haml +0 -1
  86. data/lib/generators/spina/templates/app/views/layouts/demo/application.html.haml +0 -1
  87. data/lib/generators/spina/templates/config/initializers/mobility.rb +0 -1
  88. data/lib/spina.rb +1 -0
  89. data/lib/spina/engine.rb +1 -1
  90. data/lib/spina/railtie.rb +9 -0
  91. data/lib/spina/theme.rb +2 -1
  92. data/lib/spina/version.rb +1 -1
  93. data/lib/tasks/spina_tasks.rake +8 -2
  94. data/vendor/assets/javascripts/spina/trix.js +9 -9
  95. data/vendor/assets/stylesheets/spina/_normalize.scss +1 -1
  96. data/vendor/assets/stylesheets/spina/_trix.css +369 -0
  97. metadata +39 -21
  98. data/app/assets/images/spina/arrow-left.png +0 -0
  99. data/app/assets/images/spina/arrow-right.png +0 -0
  100. data/app/assets/images/spina/datepicker.png +0 -0
  101. data/app/assets/images/spina/divider.png +0 -0
  102. data/app/assets/images/spina/media_folder_placeholder.png +0 -0
  103. data/app/assets/images/spina/spina-large.png +0 -0
  104. data/app/assets/javascripts/spina/admin/galleryselect.coffee +0 -20
  105. data/app/assets/stylesheets/spina/_trix.sass +0 -102
  106. data/config/initializers/assets.rb +0 -6
  107. data/config/initializers/time_formats.rb +0 -1
@@ -129,6 +129,13 @@
129
129
  opacity: 1
130
130
  transform: translateX(10px)
131
131
 
132
+ .collapse-link
133
+ color: $primary-color
134
+ display: inline-block
135
+ margin-left: -10px
136
+ padding: 6px 10px
137
+ transform: translateX(-26px)
138
+
132
139
  .dd-dragel
133
140
  pointer-events: none
134
141
  position: absolute
@@ -0,0 +1,227 @@
1
+ trix-toolbar
2
+ .trix-button-group
3
+ border: 0
4
+
5
+ &:not(:first-child)
6
+ margin-left: 10px
7
+
8
+ .trix-button
9
+ @extend .button
10
+ border-bottom: 0
11
+ border-radius: 0
12
+ margin: 0
13
+
14
+ &:disabled
15
+ color: rgba(0, 0, 0, .6)
16
+
17
+ &:not(:first-child)
18
+ border-left: 0
19
+
20
+ &:first-child
21
+ border-top-left-radius: 3px
22
+ border-bottom-left-radius: 3px
23
+
24
+ &:last-child
25
+ border-top-right-radius: 3px
26
+ border-bottom-right-radius: 3px
27
+
28
+ &.trix-active
29
+ background: $primary-color
30
+ color: #fff
31
+
32
+ .trix-button--text
33
+ padding-left: 12px
34
+ padding-right: 12px
35
+
36
+ .trix-button--icon
37
+ padding: 18px 16px
38
+
39
+ &::before
40
+ background: none
41
+ font-family: 'Font Awesome 5 Free'
42
+ display: inline-block
43
+ font-weight: 900
44
+ line-height: 36px
45
+ opacity: 1
46
+ text-indent: 0
47
+
48
+ &.trix-button--icon-bold
49
+ &::before
50
+ content: "\f032"
51
+
52
+ &.trix-button--icon-italic
53
+ &::before
54
+ content: "\f033"
55
+
56
+ &.trix-button--icon-strike
57
+ &::before
58
+ content: "\f0cc"
59
+
60
+ &.trix-button--icon-link
61
+ &::before
62
+ content: "\f0c1"
63
+
64
+ &.trix-button--icon-image
65
+ &::before
66
+ content: "\f03e"
67
+
68
+ &.trix-button--icon-quote
69
+ &::before
70
+ content: "\f10e"
71
+
72
+ &.trix-button--icon-code
73
+ &::before
74
+ content: "\f121"
75
+
76
+ &.trix-button--icon-bullet-list
77
+ &::before
78
+ content: "\f0ca"
79
+
80
+ &.trix-button--icon-number-list
81
+ &::before
82
+ content: "\f0cb"
83
+
84
+ &.trix-button--icon-decrease-nesting-level
85
+ &::before
86
+ content: "\f03b"
87
+
88
+ &.trix-button--icon-increase-nesting-level
89
+ &::before
90
+ content: "\f03c"
91
+
92
+ &.trix-button--icon-undo
93
+ &::before
94
+ content: "\f2ea"
95
+
96
+ &.trix-button--icon-redo
97
+ &::before
98
+ content: "\f2f9"
99
+
100
+ .trix-dialog
101
+ border-top-color: $primary-color
102
+ border-radius: 3px
103
+
104
+ trix-editor
105
+ line-height: 18px
106
+ min-height: 100px
107
+
108
+ h1, h2, h3, h4, h5, h6
109
+ padding-left: 24px
110
+ position: relative
111
+
112
+ &:after
113
+ color: #ccc
114
+ content: "H1"
115
+ font-size: 12px
116
+ font-weight: bold
117
+ left: 0px
118
+ line-height: inherit
119
+ position: absolute
120
+ top: 0px
121
+
122
+ h1, h2, h3, h4, h5, h6
123
+ font-size: 24px
124
+ font-weight: 600
125
+ line-height: 38px
126
+
127
+ h2
128
+ font-size: 22px
129
+ line-height: 34px
130
+
131
+ h3
132
+ font-size: 20px
133
+ line-height: 30px
134
+
135
+ h4
136
+ font-size: 18px
137
+ line-height: 26px
138
+
139
+ h5
140
+ font-size: 16px
141
+ line-height: 22px
142
+
143
+ h6
144
+ font-size: 14px
145
+ line-height: 18px
146
+
147
+ h2:after
148
+ content: "H2"
149
+
150
+ h3:after
151
+ content: "H3"
152
+
153
+ h4:after
154
+ content: "H4"
155
+
156
+ h5:after
157
+ content: "H5"
158
+
159
+ h6:after
160
+ content: "H6"
161
+
162
+ a
163
+ text-decoration: underline
164
+
165
+ p
166
+ margin: 0
167
+
168
+ ul
169
+ list-style: disc
170
+ padding-left: 20px
171
+
172
+ figure.attachment
173
+ .attachment__metadata
174
+ display: none
175
+
176
+ textarea
177
+ min-height: 0
178
+ border-radius: 0
179
+ box-shadow: none
180
+ font-size: 16px
181
+
182
+ .trix-attachment-spina-image
183
+ cursor: default
184
+ display: block
185
+ margin-bottom: 40px
186
+ position: relative
187
+
188
+ &[data-label=""]
189
+ margin-bottom: 0px
190
+
191
+ &:before
192
+ display: none
193
+
194
+ img
195
+ border-radius: 4px
196
+ display: block
197
+ max-height: 150px
198
+ max-width: 200px
199
+
200
+ &:before
201
+ background: #eee
202
+ border-radius: 40px
203
+ bottom: -36px
204
+ color: #666
205
+ content: attr(data-label)
206
+ display: block
207
+ font-size: 13px
208
+ font-style: italic
209
+ line-height: 16px
210
+ left: 0px
211
+ padding: 6px 12px
212
+ position: absolute
213
+ text-align: left
214
+ white-space: nowrap
215
+ width: auto
216
+
217
+ figure[data-trix-mutable]
218
+ .trix-attachment-spina-image:before
219
+ background: $primary-color
220
+ color: white
221
+
222
+ &.attachment img
223
+ box-shadow: 0 0 15px rgba(0, 0, 0, .15)
224
+
225
+ .trix-button--remove
226
+ border: none
227
+ box-shadow: 0 0 5px rgba(0, 0, 0, .15)
@@ -13,7 +13,7 @@ module Spina
13
13
  if should_skip_to_first_child?
14
14
  redirect_to first_live_child.try(:materialized_path) and return
15
15
  elsif page.link_url.present?
16
- redirect_to Current.page.link_url and return
16
+ redirect_to Spina::Current.page.link_url and return
17
17
  end
18
18
 
19
19
  render_with_template(page)
@@ -26,7 +26,7 @@ module Spina
26
26
  end
27
27
 
28
28
  def set_current_page
29
- Current.page = page
29
+ Spina::Current.page = page
30
30
  end
31
31
 
32
32
  def page_by_locale(locale)
@@ -49,11 +49,11 @@ module Spina
49
49
  end
50
50
 
51
51
  def should_skip_to_first_child?
52
- Current.page.skip_to_first_child && first_live_child
52
+ Spina::Current.page.skip_to_first_child && first_live_child
53
53
  end
54
54
 
55
55
  def first_live_child
56
- Current.page.children.sorted.live.first
56
+ Spina::Current.page.children.sorted.live.first
57
57
  end
58
58
 
59
59
  def redirect_or_render_404
@@ -69,7 +69,7 @@ module Spina
69
69
  end
70
70
 
71
71
  def render_with_template(page)
72
- render layout: "#{current_theme.name.parameterize.underscore}/#{page.layout_template || 'application'}", template: "#{current_theme.name.parameterize.underscore}/pages/#{Current.page.view_template || 'show'}"
72
+ render layout: "#{current_theme.name.parameterize.underscore}/#{page.layout_template || 'application'}", template: "#{current_theme.name.parameterize.underscore}/pages/#{Spina::Current.page.view_template || 'show'}"
73
73
  end
74
74
 
75
75
  end
@@ -7,7 +7,7 @@ module Spina
7
7
  end
8
8
 
9
9
  def update
10
- current_account.update_attributes(account_params)
10
+ current_account.update(account_params)
11
11
  redirect_back fallback_location: spina.edit_admin_account_path
12
12
  end
13
13
 
@@ -31,6 +31,7 @@ module Spina
31
31
  params.require(:account).permit(:address, :city, :email, :name, :phone,
32
32
  :postal_code, :preferences, :google_analytics,
33
33
  :google_site_verification, :facebook, :twitter, :google_plus,
34
+ :instagram, :youtube, :linkedin,
34
35
  :kvk_identifier, :theme, :vat_identifier, :robots_allowed,
35
36
  layout_parts_attributes:
36
37
  [:id, :layout_partable_type, :layout_partable_id,
@@ -18,7 +18,7 @@ module Spina
18
18
  def create
19
19
  @images = params[:image][:files].map do |file|
20
20
  # Create the image and attach the file
21
- image = Image.create
21
+ image = Image.create(media_folder_id: params[:media_library])
22
22
  image.file.attach(file)
23
23
 
24
24
  # Was it not an image after all? DESTROY IT
@@ -1,9 +1,14 @@
1
1
  module Spina
2
2
  module Admin
3
3
  class MediaPickerController < AdminController
4
+ before_action :set_media_folders
4
5
 
5
6
  def show
6
- @images = Image.page(params[:page])
7
+ if @media_folder.present?
8
+ @images = @media_folder.images.page(params[:page])
9
+ else
10
+ @images = Image.where(media_folder_id: nil).page(params[:page])
11
+ end
7
12
 
8
13
  if params[:selected_ids].present?
9
14
  ids = params[:selected_ids].map(&:to_i).join(', ')
@@ -17,12 +22,19 @@ module Spina
17
22
 
18
23
  def select
19
24
  if params[:multiple]
20
- @images = Image.where(id: params[:image_ids])
25
+ @images = Image.where(id: params[:image_ids].split("-"))
21
26
  else
22
27
  @image = Image.find(params[:image_id])
23
28
  end
24
29
  end
25
30
 
31
+ private
32
+
33
+ def set_media_folders
34
+ @media_folders = MediaFolder.order(:name)
35
+ @media_folder = MediaFolder.find(params[:media_folder_id]) if params[:media_folder_id].present?
36
+ end
37
+
26
38
  end
27
39
  end
28
40
  end
@@ -4,22 +4,20 @@ module Spina
4
4
  layout 'spina/admin/pages'
5
5
 
6
6
  before_action :set_breadcrumb, except: [:show]
7
+ before_action :set_navigation, only: [:show, :edit, :update]
7
8
 
8
- def show
9
- @navigation = Navigation.find(params[:id])
9
+ def show
10
10
  add_breadcrumb t('spina.website.pages')
11
11
  end
12
12
 
13
- def edit
14
- @navigation = Navigation.find(params[:id])
13
+ def edit
15
14
  add_breadcrumb @navigation.label, spina.admin_navigation_path(@navigation)
16
15
  add_breadcrumb t('spina.edit')
17
16
  render layout: 'spina/admin/admin'
18
17
  end
19
18
 
20
- def update
21
- @navigation = Navigation.find(params[:id])
22
- if @navigation.update_attributes(navigation_params)
19
+ def update
20
+ if @navigation.update(navigation_params)
23
21
  redirect_to spina.admin_navigation_path(@navigation)
24
22
  else
25
23
  render :edit
@@ -56,6 +54,10 @@ module Spina
56
54
  def navigation_params
57
55
  params.require(:navigation).permit(:auto_add_pages, page_ids: [])
58
56
  end
57
+
58
+ def set_navigation
59
+ @navigation = Navigation.find(params[:id])
60
+ end
59
61
  end
60
62
  end
61
63
  end
@@ -3,6 +3,7 @@ module Spina
3
3
  class PagesController < AdminController
4
4
  before_action :set_tabs, only: [:new, :create, :edit, :update]
5
5
  before_action :set_locale
6
+ before_action :set_page, only: [:edit, :update, :destroy, :children]
6
7
 
7
8
  def index
8
9
  add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
@@ -12,7 +13,7 @@ module Spina
12
13
 
13
14
  def new
14
15
  @resource = Resource.find_by(id: params[:resource_id])
15
- @page = Page.new(resource: @resource, parent: @resource&.parent_page)
16
+ @page = Page.new(resource: @resource, parent: Page.find_by(id: params[:parent_id]) || @resource&.parent_page)
16
17
  add_index_breadcrumb
17
18
  if current_theme.new_page_templates.any? { |template| template[0] == params[:view_template] }
18
19
  @page.view_template = params[:view_template]
@@ -34,27 +35,24 @@ module Spina
34
35
  end
35
36
  end
36
37
 
37
- def edit
38
- @page = Page.find(params[:id])
38
+ def edit
39
39
  add_index_breadcrumb
40
40
  add_breadcrumb @page.title
41
41
  @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
42
42
  render layout: 'spina/admin/admin'
43
43
  end
44
44
 
45
- def update
46
- I18n.locale = params[:locale] || I18n.default_locale
47
- @page = Page.find(params[:id])
45
+ def update
48
46
  respond_to do |format|
49
- if @page.update_attributes(page_params)
50
- add_breadcrumb @page.title
47
+ Mobility.locale = @locale
48
+ if @page.update(page_params)
51
49
  @page.touch
52
- I18n.locale = I18n.default_locale
53
50
  format.html { redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale}), flash: {success: t('spina.pages.saved')} }
54
51
  format.js
55
52
  else
56
53
  format.html do
57
54
  @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
55
+ Mobility.locale = I18n.default_locale
58
56
  render :edit, layout: 'spina/admin/admin'
59
57
  end
60
58
  end
@@ -69,8 +67,12 @@ module Spina
69
67
  head :ok
70
68
  end
71
69
 
72
- def destroy
73
- @page = Page.find(params[:id])
70
+ def children
71
+ @children = @page.children.active.sorted
72
+ render layout: false
73
+ end
74
+
75
+ def destroy
74
76
  @page.destroy
75
77
  redirect_to spina.admin_pages_url
76
78
  end
@@ -110,6 +112,9 @@ module Spina
110
112
  params.require(:page).permit!
111
113
  end
112
114
 
115
+ def set_page
116
+ @page = Page.find(params[:id])
117
+ end
113
118
  end
114
119
  end
115
120
  end