spina 0.8.3 → 0.9.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.
- checksums.yaml +4 -4
- data/README.md +63 -52
- data/app/assets/javascripts/spina/admin/application.js +0 -1
- data/app/controllers/spina/admin/accounts_controller.rb +11 -16
- data/app/controllers/spina/admin/admin_controller.rb +12 -23
- data/app/controllers/spina/admin/attachments_controller.rb +1 -1
- data/app/controllers/spina/admin/pages_controller.rb +14 -7
- data/app/controllers/spina/admin/photos_controller.rb +4 -2
- data/app/controllers/spina/admin/sessions_controller.rb +3 -3
- data/app/controllers/spina/admin/users_controller.rb +3 -3
- data/app/controllers/spina/application_controller.rb +7 -3
- data/app/controllers/spina/pages_controller.rb +13 -2
- data/app/controllers/spina/sitemaps_controller.rb +1 -0
- data/app/helpers/spina/admin/pages_helper.rb +12 -2
- data/app/helpers/spina/application_helper.rb +0 -9
- data/app/models/concerns/spina/part.rb +31 -0
- data/app/models/{spina → concerns/spina}/partable.rb +0 -0
- data/app/models/spina/ability.rb +0 -1
- data/app/models/spina/account.rb +6 -6
- data/app/models/spina/attachment.rb +1 -1
- data/app/models/spina/layout_part.rb +4 -27
- data/app/models/spina/line.rb +2 -0
- data/app/models/spina/page.rb +24 -5
- data/app/models/spina/page_part.rb +6 -30
- data/app/models/spina/structure_part.rb +7 -19
- data/app/models/spina/text.rb +2 -0
- data/app/views/layouts/spina/admin/application.html.haml +12 -14
- data/app/views/layouts/spina/admin/media_library.html.haml +4 -4
- data/app/views/layouts/spina/admin/settings.html.haml +7 -8
- data/app/views/layouts/spina/admin/website.html.haml +9 -16
- data/app/views/spina/admin/accounts/style.html.haml +10 -10
- data/app/views/spina/admin/attachments/_attachment.html.haml +1 -2
- data/app/views/spina/admin/{pages/_attachment_fields.html.haml → attachments/_fields.html.haml} +0 -0
- data/app/views/spina/admin/attachments/index.html.haml +2 -7
- data/app/views/spina/admin/layout_partables/colors/_form.html.haml +4 -0
- data/app/views/spina/admin/layout_partables/lines/_form.html.haml +2 -0
- data/app/views/spina/admin/page_partables/attachment_collections/_form.html.haml +15 -0
- data/app/views/spina/admin/page_partables/attachments/_form.html.haml +14 -0
- data/app/views/spina/admin/page_partables/colors/_form.html.haml +7 -0
- data/app/views/spina/admin/page_partables/lines/_form.html.haml +5 -0
- data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +17 -0
- data/app/views/spina/admin/page_partables/photos/_form.html.haml +18 -0
- data/app/views/spina/admin/page_partables/structures/_form.html.haml +22 -0
- data/app/views/spina/admin/page_partables/texts/_form.html.haml +5 -0
- data/app/views/spina/admin/pages/_form.html.haml +11 -8
- data/app/views/spina/admin/pages/_form_advanced.html.haml +3 -3
- data/app/views/spina/admin/pages/_form_page_content.html.haml +8 -3
- data/app/views/spina/admin/pages/_form_page_seo.html.haml +1 -1
- data/app/views/spina/admin/pages/edit.html.haml +13 -1
- data/app/views/spina/admin/photos/_photo.html.haml +1 -3
- data/app/views/spina/admin/photos/create.js.erb +1 -2
- data/app/views/spina/admin/photos/create_and_select.js.erb +7 -0
- data/app/views/spina/admin/photos/index.html.haml +7 -6
- data/app/views/spina/admin/shared/_primary_navigation.html.haml +19 -0
- data/app/views/spina/admin/shared/_rich_text_field.html.haml +2 -2
- data/app/views/spina/admin/structure_items/_fields.html.haml +16 -0
- data/app/views/spina/admin/structure_partables/lines/_form.html.haml +2 -0
- data/app/views/spina/admin/structure_partables/photos/_form.html.haml +11 -0
- data/app/views/spina/admin/structure_partables/texts/_form.html.haml +2 -0
- data/app/views/spina/sitemaps/show.xml.builder +12 -8
- data/{lib/spina/carrierwave.rb → config/initializers/spina.rb} +0 -0
- data/config/locales/de.yml +0 -26
- data/config/locales/en.yml +4 -26
- data/config/locales/es.yml +0 -26
- data/config/locales/fr.yml +4 -27
- data/config/locales/it.yml +0 -26
- data/config/locales/nl.yml +2 -28
- data/config/locales/pt-BR.yml +0 -26
- data/config/locales/ru.yml +0 -26
- data/config/locales/tr.yml +2 -28
- data/config/locales/zh-CN.yml +0 -3
- data/config/routes.rb +3 -19
- data/db/migrate/{20150507135428_create_spina_tables.rb → 1_create_spina_tables.rb} +0 -11
- data/db/migrate/2_create_spina_translation_tables.rb +13 -0
- data/lib/generators/spina/install_generator.rb +23 -9
- data/lib/generators/spina/templates/app/assets/stylesheets/demo/application.css.sass +3 -0
- data/lib/generators/spina/templates/app/views/demo/shared/_languages.html.haml +2 -0
- data/lib/generators/spina/templates/app/views/layouts/demo/application.html.haml +1 -0
- data/lib/generators/spina/templates/config/initializers/carrierwave.rb +17 -0
- data/lib/generators/spina/templates/config/initializers/spina.rb +2 -22
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +29 -45
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +82 -92
- data/lib/spina.rb +24 -30
- data/lib/spina/engine.rb +2 -22
- data/lib/spina/plugin.rb +21 -3
- data/lib/spina/railtie.rb +9 -0
- data/lib/spina/theme.rb +34 -6
- data/lib/spina/version.rb +1 -1
- metadata +51 -124
- data/app/assets/javascripts/spina/admin/aviary.js.coffee +0 -25
- data/app/controllers/spina/admin/inquiries_controller.rb +0 -63
- data/app/controllers/spina/inquiries_controller.rb +0 -30
- data/app/mailers/spina/inquiry_mailer.rb +0 -19
- data/app/models/spina/inquiry.rb +0 -41
- data/app/views/layouts/spina/admin/messages.html.haml +0 -24
- data/app/views/spina/admin/accounts/aviary.html.haml +0 -26
- data/app/views/spina/admin/inquiries/inbox.html.haml +0 -30
- data/app/views/spina/admin/inquiries/index.html.haml +0 -36
- data/app/views/spina/admin/inquiries/show.html.haml +0 -23
- data/app/views/spina/admin/inquiries/spam.html.haml +0 -36
- data/app/views/spina/admin/layout_partables/_color_form.html.haml +0 -4
- data/app/views/spina/admin/layout_partables/_line_form.html.haml +0 -2
- data/app/views/spina/admin/page_partables/_attachment_collection_form.html.haml +0 -20
- data/app/views/spina/admin/page_partables/_attachment_form.html.haml +0 -19
- data/app/views/spina/admin/page_partables/_color_form.html.haml +0 -12
- data/app/views/spina/admin/page_partables/_line_form.html.haml +0 -10
- data/app/views/spina/admin/page_partables/_photo_collection_form.html.haml +0 -22
- data/app/views/spina/admin/page_partables/_photo_form.html.haml +0 -23
- data/app/views/spina/admin/page_partables/_structure_form.html.haml +0 -28
- data/app/views/spina/admin/page_partables/_text_form.html.haml +0 -10
- data/app/views/spina/admin/pages/_structure_item_fields.html.haml +0 -15
- data/app/views/spina/admin/shared/_navigation.html.haml +0 -21
- data/app/views/spina/admin/structure_partables/_line_form.html.haml +0 -2
- data/app/views/spina/admin/structure_partables/_photo_form.html.haml +0 -11
- data/app/views/spina/admin/structure_partables/_text_form.html.haml +0 -2
- data/app/views/spina/inquiries/create.html.haml +0 -2
- data/app/views/spina/inquiries/index.html.haml +0 -19
- data/app/views/spina/inquiry_mailer/inquiry.html.haml +0 -15
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/default/application.css.sass +0 -0
- data/test/dummy/app/assets/stylesheets/demo/application.css.sass +0 -66
- data/test/dummy/app/assets/stylesheets/fonts.css.sass +0 -3
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/default/pages/homepage.html.haml +0 -2
- data/test/dummy/app/views/default/pages/show.html.haml +0 -3
- data/test/dummy/app/views/default/shared/_navigation.html.haml +0 -5
- data/test/dummy/app/views/demo/pages/demo.html.haml +0 -30
- data/test/dummy/app/views/demo/pages/homepage.html.haml +0 -2
- data/test/dummy/app/views/demo/pages/show.html.haml +0 -3
- data/test/dummy/app/views/demo/shared/_navigation.html.haml +0 -5
- data/test/dummy/app/views/layouts/default/application.html.haml +0 -11
- data/test/dummy/app/views/layouts/demo/application.html.haml +0 -11
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -52
- data/test/dummy/config/application.yml +0 -2
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -24
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -70
- data/test/dummy/config/environments/test.rb +0 -38
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/spina.rb +0 -33
- data/test/dummy/config/initializers/themes/default.rb +0 -47
- data/test/dummy/config/initializers/themes/demo.rb +0 -103
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/locales/nl.yml +0 -214
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/config/secrets.yml +0 -7
- data/test/dummy/db/migrate/20160114085213_create_spina_tables.spina.rb +0 -167
- data/test/dummy/db/schema.rb +0 -183
- data/test/dummy/db/seeds.rb +0 -1
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/dummy/tmp/restart.txt +0 -0
- data/test/fixtures/spina/accounts.yml +0 -3
- data/test/fixtures/spina/pages.yml +0 -10
- data/test/fixtures/spina/users.yml +0 -5
- data/test/functional/spina/admin/admin_controller.rb +0 -36
- data/test/functional/spina/admin/sessions_controller_test.rb +0 -32
- data/test/functional/spina/pages_controller_test.rb +0 -16
- data/test/integration/navigation_test.rb +0 -8
- data/test/integration/spina/admin/login_test.rb +0 -31
- data/test/integration/spina/admin/logout_test.rb +0 -17
- data/test/integration/spina/admin/pages_test.rb +0 -34
- data/test/integration/spina/pages_test.rb +0 -19
- data/test/models/spina/line_test.rb +0 -9
- data/test/models/spina/text_test.rb +0 -9
- data/test/test_helper.rb +0 -23
- data/test/unit/helpers/spina/accounts_helper_test.rb +0 -6
- data/test/unit/helpers/spina/inquiries_helper_test.rb +0 -6
- data/test/unit/helpers/spina/page_parts_helper_test.rb +0 -6
- data/test/unit/helpers/spina/pages_helper_test.rb +0 -6
- data/test/unit/helpers/spina/photos_helper_test.rb +0 -6
- data/test/unit/helpers/spina/sessions_helper_test.rb +0 -6
- data/test/unit/helpers/spina/users_helper_test.rb +0 -6
- data/test/unit/spina/account_test.rb +0 -9
- data/test/unit/spina/file_collection_file_test.rb +0 -9
- data/test/unit/spina/gallery_test.rb +0 -9
- data/test/unit/spina/inquiry_test.rb +0 -9
- data/test/unit/spina/page_include_test.rb +0 -9
- data/test/unit/spina/page_part_test.rb +0 -9
- data/test/unit/spina/page_test.rb +0 -9
- data/test/unit/spina/photo_collection_file_test.rb +0 -9
- data/test/unit/spina/photo_collection_test.rb +0 -9
- data/test/unit/spina/photo_test.rb +0 -9
- data/test/unit/spina/user_test.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 457fad6084480ec4091b8dba28d0f799dbd097dd
|
4
|
+
data.tar.gz: a3fb127947659c26b7583459ff2766891a51e6f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc1056660d8c8cbd510508e426187be991ca7c0d50228eb1376ab17f1ed4a1320731f4c146554206ec9f3e11c2f9ae679e0d2695efdc50276e756bd5aca1345
|
7
|
+
data.tar.gz: 2559f8f9966ffde4febf060be5b2e455592f886bef922febc738a20abe59d70dd37992fa1c98fe6ae35dacad33907abf9b10b009990d83cfa827a3ee92bb40db
|
data/README.md
CHANGED
@@ -26,6 +26,19 @@ The installer will help you setup your first user.
|
|
26
26
|
|
27
27
|
Then start `rails s` and access your admin panel at `/admin`.
|
28
28
|
|
29
|
+
## Upgrading from 0.8 to 0.9
|
30
|
+
|
31
|
+
Theme configuration changed to:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# config/initializers/themes/default.rb
|
35
|
+
Spina::Theme.register do |theme|
|
36
|
+
# Theme config
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Check out [config/initializers/themes/default.rb](https://github.com/denkGroot/Spina/blob/master/lib/generators/spina/templates/config/initializers/themes/default.rb) for an example.
|
41
|
+
|
29
42
|
## Upgrading from 0.7 to 0.8
|
30
43
|
|
31
44
|
Spina-specific configuration moved from `Spina::Engine.config` to just `Spina.config`.
|
@@ -67,42 +80,36 @@ Spina uses an initializer to create the basic building blocks of your page. Ther
|
|
67
80
|
When you install Spina, you will see the following in `config/initializers/themes/default.rb`
|
68
81
|
|
69
82
|
```ruby
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
|
102
|
-
self.custom_pages = [
|
103
|
-
{ name: 'homepage', title: 'Homepage', deletable: false, view_template: 'homepage' }
|
104
|
-
]
|
105
|
-
end
|
83
|
+
::Spina::Theme.register do |theme|
|
84
|
+
|
85
|
+
theme.name = 'default'
|
86
|
+
theme.title = 'Default Theme'
|
87
|
+
|
88
|
+
theme.page_parts = [{
|
89
|
+
name: 'content',
|
90
|
+
title: 'Content',
|
91
|
+
partable_type: 'Spina::Text'
|
92
|
+
}]
|
93
|
+
|
94
|
+
theme.view_templates = [{
|
95
|
+
name: 'homepage',
|
96
|
+
title: 'Homepage',
|
97
|
+
page_parts: ['content']
|
98
|
+
}, {
|
99
|
+
name: 'show',
|
100
|
+
title: 'Default',
|
101
|
+
description: 'A simple page',
|
102
|
+
usage: 'Use for your content',
|
103
|
+
page_parts: ['content']
|
104
|
+
}]
|
105
|
+
|
106
|
+
theme.custom_pages = [{
|
107
|
+
name: 'homepage',
|
108
|
+
title: 'Homepage',
|
109
|
+
deletable: false,
|
110
|
+
view_template: 'homepage'
|
111
|
+
}]
|
112
|
+
|
106
113
|
end
|
107
114
|
```
|
108
115
|
|
@@ -113,10 +120,15 @@ Spina represents each building block of your page, called a 'page part,' as a ha
|
|
113
120
|
Let's say I wanted to add another text box below this called `portfolio`. First I would add another hash to the `self.page_parts` array like so:
|
114
121
|
|
115
122
|
```ruby
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
123
|
+
theme.page_parts = [{
|
124
|
+
name: 'content',
|
125
|
+
title: 'Content',
|
126
|
+
partable_type: 'Spina::Text'
|
127
|
+
}, {
|
128
|
+
name: 'portfolio', # added this hash
|
129
|
+
title: 'Portfolio',
|
130
|
+
partable_type: 'Spina::Text'
|
131
|
+
}]
|
120
132
|
```
|
121
133
|
|
122
134
|
#### Add it to the view template
|
@@ -124,18 +136,17 @@ self.page_parts = [
|
|
124
136
|
Now, we need to update the `self.view_templates` hash next. These view templates provide customization for the different views you might want. For example, you may have a 'blog' view or an 'about' view which add different page parts. For this example we will add the portfolio part into the 'Default' view template.
|
125
137
|
|
126
138
|
```ruby
|
127
|
-
|
128
|
-
'homepage'
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
'show'
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
}
|
139
|
+
theme.view_templates = [{
|
140
|
+
name: 'homepage',
|
141
|
+
title: 'Homepage',
|
142
|
+
page_parts: ['content']
|
143
|
+
}, {
|
144
|
+
name: 'show',
|
145
|
+
title: 'Default',
|
146
|
+
description: 'A simple page',
|
147
|
+
usage: 'Use for your content',
|
148
|
+
page_parts: ['content', 'portfolio'] # added 'portfolio'
|
149
|
+
}]
|
139
150
|
```
|
140
151
|
|
141
152
|
#### Add it to the view
|
@@ -26,30 +26,25 @@ module Spina
|
|
26
26
|
add_breadcrumb I18n.t('spina.preferences.social_media'), spina.social_admin_account_path
|
27
27
|
end
|
28
28
|
|
29
|
-
def aviary
|
30
|
-
add_breadcrumb I18n.t('spina.preferences.aviary'), spina.aviary_admin_account_path
|
31
|
-
end
|
32
|
-
|
33
29
|
def style
|
34
30
|
add_breadcrumb I18n.t('spina.preferences.style'), spina.style_admin_account_path
|
35
|
-
@themes = ::Spina.
|
36
|
-
@layout_parts = current_theme.
|
31
|
+
@themes = ::Spina::Theme.all
|
32
|
+
@layout_parts = current_theme.layout_parts.map { |layout_part| current_account.layout_part(layout_part) }
|
37
33
|
end
|
38
34
|
|
39
35
|
private
|
40
36
|
|
41
37
|
def account_params
|
42
|
-
params.require(:account).permit(:address, :city, :email, :logo, :name, :phone,
|
43
|
-
:postal_code, :preferences, :google_analytics,
|
44
|
-
:google_site_verification, :facebook, :twitter, :google_plus,
|
45
|
-
:
|
46
|
-
:
|
47
|
-
|
48
|
-
|
49
|
-
:
|
50
|
-
layout_partable_attributes:
|
38
|
+
params.require(:account).permit(:address, :city, :email, :logo, :name, :phone,
|
39
|
+
:postal_code, :preferences, :google_analytics,
|
40
|
+
:google_site_verification, :facebook, :twitter, :google_plus,
|
41
|
+
:kvk_identifier, :theme, :vat_identifier, :robots_allowed,
|
42
|
+
layout_parts_attributes:
|
43
|
+
[:id, :layout_partable_type, :layout_partable_id,
|
44
|
+
:name, :title, :position, :content, :page_id,
|
45
|
+
layout_partable_attributes:
|
51
46
|
[:content, :photo_tokens, :attachment_tokens, :id]])
|
52
47
|
end
|
53
48
|
end
|
54
|
-
end
|
49
|
+
end
|
55
50
|
end
|
@@ -1,36 +1,25 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
|
-
class AdminController < ApplicationController
|
4
|
-
|
5
|
-
|
6
|
-
before_filter :new_messages
|
3
|
+
class AdminController < ::Spina::ApplicationController
|
4
|
+
before_action :set_admin_locale
|
5
|
+
before_action :authorize_user
|
7
6
|
|
8
7
|
layout 'spina/admin/application'
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
def authorize_user
|
13
|
-
redirect_to spina.admin_login_url, flash: {information: I18n.t('spina.notifications.login')} unless current_user
|
9
|
+
def current_admin_path
|
10
|
+
request.fullpath[%r{/#{ Spina.config.backend_path }(.*)}, 1]
|
14
11
|
end
|
12
|
+
helper_method :current_admin_path
|
15
13
|
|
16
|
-
|
17
|
-
@new_messages = Inquiry.new_messages.sorted
|
18
|
-
end
|
14
|
+
private
|
19
15
|
|
20
|
-
def
|
21
|
-
|
22
|
-
end
|
23
|
-
helper_method :current_account
|
24
|
-
|
25
|
-
def current_user
|
26
|
-
@current_user ||= User.where(id: session[:user_id]).first if session[:user_id]
|
16
|
+
def set_admin_locale
|
17
|
+
I18n.locale = I18n.default_locale
|
27
18
|
end
|
28
|
-
helper_method :current_user
|
29
19
|
|
30
|
-
def
|
31
|
-
|
20
|
+
def authorize_user
|
21
|
+
redirect_to spina.admin_login_url, flash: {information: I18n.t('spina.notifications.login')} unless current_user
|
32
22
|
end
|
33
|
-
|
34
23
|
end
|
35
24
|
end
|
36
|
-
end
|
25
|
+
end
|
@@ -2,8 +2,9 @@ module Spina
|
|
2
2
|
module Admin
|
3
3
|
class PagesController < AdminController
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
before_action :set_breadcrumb
|
6
|
+
before_action :set_tabs, only: [:new, :create, :edit, :update]
|
7
|
+
before_action :set_locale
|
7
8
|
|
8
9
|
authorize_resource class: Page
|
9
10
|
|
@@ -19,13 +20,12 @@ module Spina
|
|
19
20
|
@page.view_template = params[:view_template]
|
20
21
|
end
|
21
22
|
add_breadcrumb I18n.t('spina.pages.new')
|
22
|
-
@page_parts = current_theme.
|
23
|
+
@page_parts = current_theme.page_parts.map { |page_part| @page.page_part(page_part) }
|
23
24
|
end
|
24
25
|
|
25
26
|
def create
|
26
27
|
@page = Page.new(page_params)
|
27
28
|
add_breadcrumb I18n.t('spina.pages.new')
|
28
|
-
# @page.set_materialized_path
|
29
29
|
if @page.save
|
30
30
|
redirect_to spina.edit_admin_page_url(@page)
|
31
31
|
else
|
@@ -37,15 +37,18 @@ module Spina
|
|
37
37
|
def edit
|
38
38
|
@page = Page.find(params[:id])
|
39
39
|
add_breadcrumb @page.title
|
40
|
-
@page_parts = current_theme.
|
40
|
+
@page_parts = current_theme.page_parts.map { |page_part| @page.page_part(page_part) }
|
41
41
|
end
|
42
42
|
|
43
43
|
def update
|
44
|
+
I18n.locale = params[:locale] || I18n.default_locale
|
44
45
|
@page = Page.find(params[:id])
|
45
46
|
add_breadcrumb @page.title
|
46
47
|
respond_to do |format|
|
47
48
|
if @page.update_attributes(page_params)
|
48
|
-
|
49
|
+
@page.touch
|
50
|
+
I18n.locale = I18n.default_locale
|
51
|
+
format.html { redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale}) }
|
49
52
|
format.js
|
50
53
|
else
|
51
54
|
format.html do
|
@@ -72,6 +75,10 @@ module Spina
|
|
72
75
|
|
73
76
|
private
|
74
77
|
|
78
|
+
def set_locale
|
79
|
+
@locale = params[:locale] || I18n.default_locale
|
80
|
+
end
|
81
|
+
|
75
82
|
def set_breadcrumb
|
76
83
|
add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
|
77
84
|
end
|
@@ -94,7 +101,7 @@ module Spina
|
|
94
101
|
end
|
95
102
|
|
96
103
|
def page_params
|
97
|
-
params.require(:page).permit
|
104
|
+
params.require(:page).permit!.merge(locale: params[:locale] || I18n.default_locale)
|
98
105
|
end
|
99
106
|
|
100
107
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class PhotosController < AdminController
|
4
|
-
|
4
|
+
before_action :set_breadcrumbs
|
5
5
|
|
6
6
|
authorize_resource class: Photo
|
7
7
|
|
@@ -16,7 +16,9 @@ module Spina
|
|
16
16
|
def create
|
17
17
|
@photo = Photo.create!(photo_params)
|
18
18
|
respond_to do |format|
|
19
|
-
format.js
|
19
|
+
format.js do
|
20
|
+
render params[:media_library] ? :create : :create_and_select
|
21
|
+
end
|
20
22
|
format.json do
|
21
23
|
render json: { file_url: @photo.file_url }
|
22
24
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class SessionsController < AdminController
|
4
|
-
|
4
|
+
|
5
5
|
layout "spina/login"
|
6
6
|
|
7
|
-
|
7
|
+
skip_before_action :authorize_user
|
8
8
|
|
9
9
|
def new
|
10
10
|
end
|
@@ -25,6 +25,6 @@ module Spina
|
|
25
25
|
session[:user_id] = nil
|
26
26
|
redirect_to "/"
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class UsersController < AdminController
|
4
|
-
|
5
|
-
|
4
|
+
before_action :set_breadcrumbs
|
5
|
+
|
6
6
|
authorize_resource class: User
|
7
7
|
|
8
8
|
layout "spina/admin/settings"
|
@@ -58,7 +58,7 @@ module Spina
|
|
58
58
|
def user_params
|
59
59
|
params.require(:user).permit(:admin, :email, :name, :password_digest, :password, :password_confirmation, :last_logged_in)
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spina
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
|
3
4
|
protect_from_forgery with: :exception
|
4
|
-
helper_method :current_theme, :current_user, :current_account
|
5
5
|
|
6
6
|
include ApplicationHelper
|
7
7
|
|
@@ -12,15 +12,19 @@ module Spina
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def current_theme
|
15
|
-
@current_theme = ::Spina.
|
15
|
+
@current_theme = ::Spina::Theme.find_by_name(current_account.theme)
|
16
16
|
end
|
17
|
+
helper_method :current_theme
|
17
18
|
|
18
19
|
def current_user
|
19
|
-
@current_user ||= User.where(id: session[:user_id]).first if session[:user_id]
|
20
|
+
@current_user ||= Spina::User.where(id: session[:user_id]).first if session[:user_id]
|
20
21
|
end
|
22
|
+
helper_method :current_user
|
21
23
|
|
22
24
|
def current_account
|
23
25
|
@current_account ||= Account.first
|
24
26
|
end
|
27
|
+
helper_method :current_account
|
28
|
+
|
25
29
|
end
|
26
30
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module Spina
|
2
2
|
class PagesController < Spina::ApplicationController
|
3
|
+
rescue_from ActiveRecord::RecordNotFound, with: :render_404
|
4
|
+
|
5
|
+
before_action :set_locale
|
3
6
|
before_action :rewrite_page, only: [:show]
|
4
7
|
before_action :current_user_can_view_page?, except: [:robots]
|
5
8
|
|
@@ -19,6 +22,10 @@ module Spina
|
|
19
22
|
|
20
23
|
private
|
21
24
|
|
25
|
+
def set_locale
|
26
|
+
I18n.locale = params[:locale] || I18n.default_locale
|
27
|
+
end
|
28
|
+
|
22
29
|
def rewrite_page
|
23
30
|
unless page.present?
|
24
31
|
@rule = RewriteRule.find_by(old_path: "/" + params[:id])
|
@@ -27,7 +34,7 @@ module Spina
|
|
27
34
|
end
|
28
35
|
|
29
36
|
def page
|
30
|
-
@page ||= (action_name == 'homepage') ? Page.find_by!(name: 'homepage') : Page.find_by!(materialized_path:
|
37
|
+
@page ||= (action_name == 'homepage') ? Page.find_by!(name: 'homepage') : Page.with_translations(I18n.locale).find_by!(materialized_path: request.path) || Page.with_translations(I18n.default_locale).find_by!(materialized_path: request.path)
|
31
38
|
end
|
32
39
|
helper_method :page
|
33
40
|
|
@@ -44,7 +51,11 @@ module Spina
|
|
44
51
|
end
|
45
52
|
|
46
53
|
def render_with_template(page)
|
47
|
-
render layout: "#{current_theme.
|
54
|
+
render layout: "#{current_theme.name.parameterize.underscore}/application", template: "#{current_theme.name.parameterize.underscore}/pages/#{page.view_template || 'show'}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_404
|
58
|
+
render file: "#{Rails.root}/public/404.html", status: 404
|
48
59
|
end
|
49
60
|
|
50
61
|
end
|