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.

Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +63 -52
  3. data/app/assets/javascripts/spina/admin/application.js +0 -1
  4. data/app/controllers/spina/admin/accounts_controller.rb +11 -16
  5. data/app/controllers/spina/admin/admin_controller.rb +12 -23
  6. data/app/controllers/spina/admin/attachments_controller.rb +1 -1
  7. data/app/controllers/spina/admin/pages_controller.rb +14 -7
  8. data/app/controllers/spina/admin/photos_controller.rb +4 -2
  9. data/app/controllers/spina/admin/sessions_controller.rb +3 -3
  10. data/app/controllers/spina/admin/users_controller.rb +3 -3
  11. data/app/controllers/spina/application_controller.rb +7 -3
  12. data/app/controllers/spina/pages_controller.rb +13 -2
  13. data/app/controllers/spina/sitemaps_controller.rb +1 -0
  14. data/app/helpers/spina/admin/pages_helper.rb +12 -2
  15. data/app/helpers/spina/application_helper.rb +0 -9
  16. data/app/models/concerns/spina/part.rb +31 -0
  17. data/app/models/{spina → concerns/spina}/partable.rb +0 -0
  18. data/app/models/spina/ability.rb +0 -1
  19. data/app/models/spina/account.rb +6 -6
  20. data/app/models/spina/attachment.rb +1 -1
  21. data/app/models/spina/layout_part.rb +4 -27
  22. data/app/models/spina/line.rb +2 -0
  23. data/app/models/spina/page.rb +24 -5
  24. data/app/models/spina/page_part.rb +6 -30
  25. data/app/models/spina/structure_part.rb +7 -19
  26. data/app/models/spina/text.rb +2 -0
  27. data/app/views/layouts/spina/admin/application.html.haml +12 -14
  28. data/app/views/layouts/spina/admin/media_library.html.haml +4 -4
  29. data/app/views/layouts/spina/admin/settings.html.haml +7 -8
  30. data/app/views/layouts/spina/admin/website.html.haml +9 -16
  31. data/app/views/spina/admin/accounts/style.html.haml +10 -10
  32. data/app/views/spina/admin/attachments/_attachment.html.haml +1 -2
  33. data/app/views/spina/admin/{pages/_attachment_fields.html.haml → attachments/_fields.html.haml} +0 -0
  34. data/app/views/spina/admin/attachments/index.html.haml +2 -7
  35. data/app/views/spina/admin/layout_partables/colors/_form.html.haml +4 -0
  36. data/app/views/spina/admin/layout_partables/lines/_form.html.haml +2 -0
  37. data/app/views/spina/admin/page_partables/attachment_collections/_form.html.haml +15 -0
  38. data/app/views/spina/admin/page_partables/attachments/_form.html.haml +14 -0
  39. data/app/views/spina/admin/page_partables/colors/_form.html.haml +7 -0
  40. data/app/views/spina/admin/page_partables/lines/_form.html.haml +5 -0
  41. data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +17 -0
  42. data/app/views/spina/admin/page_partables/photos/_form.html.haml +18 -0
  43. data/app/views/spina/admin/page_partables/structures/_form.html.haml +22 -0
  44. data/app/views/spina/admin/page_partables/texts/_form.html.haml +5 -0
  45. data/app/views/spina/admin/pages/_form.html.haml +11 -8
  46. data/app/views/spina/admin/pages/_form_advanced.html.haml +3 -3
  47. data/app/views/spina/admin/pages/_form_page_content.html.haml +8 -3
  48. data/app/views/spina/admin/pages/_form_page_seo.html.haml +1 -1
  49. data/app/views/spina/admin/pages/edit.html.haml +13 -1
  50. data/app/views/spina/admin/photos/_photo.html.haml +1 -3
  51. data/app/views/spina/admin/photos/create.js.erb +1 -2
  52. data/app/views/spina/admin/photos/create_and_select.js.erb +7 -0
  53. data/app/views/spina/admin/photos/index.html.haml +7 -6
  54. data/app/views/spina/admin/shared/_primary_navigation.html.haml +19 -0
  55. data/app/views/spina/admin/shared/_rich_text_field.html.haml +2 -2
  56. data/app/views/spina/admin/structure_items/_fields.html.haml +16 -0
  57. data/app/views/spina/admin/structure_partables/lines/_form.html.haml +2 -0
  58. data/app/views/spina/admin/structure_partables/photos/_form.html.haml +11 -0
  59. data/app/views/spina/admin/structure_partables/texts/_form.html.haml +2 -0
  60. data/app/views/spina/sitemaps/show.xml.builder +12 -8
  61. data/{lib/spina/carrierwave.rb → config/initializers/spina.rb} +0 -0
  62. data/config/locales/de.yml +0 -26
  63. data/config/locales/en.yml +4 -26
  64. data/config/locales/es.yml +0 -26
  65. data/config/locales/fr.yml +4 -27
  66. data/config/locales/it.yml +0 -26
  67. data/config/locales/nl.yml +2 -28
  68. data/config/locales/pt-BR.yml +0 -26
  69. data/config/locales/ru.yml +0 -26
  70. data/config/locales/tr.yml +2 -28
  71. data/config/locales/zh-CN.yml +0 -3
  72. data/config/routes.rb +3 -19
  73. data/db/migrate/{20150507135428_create_spina_tables.rb → 1_create_spina_tables.rb} +0 -11
  74. data/db/migrate/2_create_spina_translation_tables.rb +13 -0
  75. data/lib/generators/spina/install_generator.rb +23 -9
  76. data/lib/generators/spina/templates/app/assets/stylesheets/demo/application.css.sass +3 -0
  77. data/lib/generators/spina/templates/app/views/demo/shared/_languages.html.haml +2 -0
  78. data/lib/generators/spina/templates/app/views/layouts/demo/application.html.haml +1 -0
  79. data/lib/generators/spina/templates/config/initializers/carrierwave.rb +17 -0
  80. data/lib/generators/spina/templates/config/initializers/spina.rb +2 -22
  81. data/lib/generators/spina/templates/config/initializers/themes/default.rb +29 -45
  82. data/lib/generators/spina/templates/config/initializers/themes/demo.rb +82 -92
  83. data/lib/spina.rb +24 -30
  84. data/lib/spina/engine.rb +2 -22
  85. data/lib/spina/plugin.rb +21 -3
  86. data/lib/spina/railtie.rb +9 -0
  87. data/lib/spina/theme.rb +34 -6
  88. data/lib/spina/version.rb +1 -1
  89. metadata +51 -124
  90. data/app/assets/javascripts/spina/admin/aviary.js.coffee +0 -25
  91. data/app/controllers/spina/admin/inquiries_controller.rb +0 -63
  92. data/app/controllers/spina/inquiries_controller.rb +0 -30
  93. data/app/mailers/spina/inquiry_mailer.rb +0 -19
  94. data/app/models/spina/inquiry.rb +0 -41
  95. data/app/views/layouts/spina/admin/messages.html.haml +0 -24
  96. data/app/views/spina/admin/accounts/aviary.html.haml +0 -26
  97. data/app/views/spina/admin/inquiries/inbox.html.haml +0 -30
  98. data/app/views/spina/admin/inquiries/index.html.haml +0 -36
  99. data/app/views/spina/admin/inquiries/show.html.haml +0 -23
  100. data/app/views/spina/admin/inquiries/spam.html.haml +0 -36
  101. data/app/views/spina/admin/layout_partables/_color_form.html.haml +0 -4
  102. data/app/views/spina/admin/layout_partables/_line_form.html.haml +0 -2
  103. data/app/views/spina/admin/page_partables/_attachment_collection_form.html.haml +0 -20
  104. data/app/views/spina/admin/page_partables/_attachment_form.html.haml +0 -19
  105. data/app/views/spina/admin/page_partables/_color_form.html.haml +0 -12
  106. data/app/views/spina/admin/page_partables/_line_form.html.haml +0 -10
  107. data/app/views/spina/admin/page_partables/_photo_collection_form.html.haml +0 -22
  108. data/app/views/spina/admin/page_partables/_photo_form.html.haml +0 -23
  109. data/app/views/spina/admin/page_partables/_structure_form.html.haml +0 -28
  110. data/app/views/spina/admin/page_partables/_text_form.html.haml +0 -10
  111. data/app/views/spina/admin/pages/_structure_item_fields.html.haml +0 -15
  112. data/app/views/spina/admin/shared/_navigation.html.haml +0 -21
  113. data/app/views/spina/admin/structure_partables/_line_form.html.haml +0 -2
  114. data/app/views/spina/admin/structure_partables/_photo_form.html.haml +0 -11
  115. data/app/views/spina/admin/structure_partables/_text_form.html.haml +0 -2
  116. data/app/views/spina/inquiries/create.html.haml +0 -2
  117. data/app/views/spina/inquiries/index.html.haml +0 -19
  118. data/app/views/spina/inquiry_mailer/inquiry.html.haml +0 -15
  119. data/test/dummy/README.rdoc +0 -261
  120. data/test/dummy/Rakefile +0 -7
  121. data/test/dummy/app/assets/javascripts/application.js +0 -15
  122. data/test/dummy/app/assets/stylesheets/default/application.css.sass +0 -0
  123. data/test/dummy/app/assets/stylesheets/demo/application.css.sass +0 -66
  124. data/test/dummy/app/assets/stylesheets/fonts.css.sass +0 -3
  125. data/test/dummy/app/controllers/application_controller.rb +0 -3
  126. data/test/dummy/app/helpers/application_helper.rb +0 -2
  127. data/test/dummy/app/views/default/pages/homepage.html.haml +0 -2
  128. data/test/dummy/app/views/default/pages/show.html.haml +0 -3
  129. data/test/dummy/app/views/default/shared/_navigation.html.haml +0 -5
  130. data/test/dummy/app/views/demo/pages/demo.html.haml +0 -30
  131. data/test/dummy/app/views/demo/pages/homepage.html.haml +0 -2
  132. data/test/dummy/app/views/demo/pages/show.html.haml +0 -3
  133. data/test/dummy/app/views/demo/shared/_navigation.html.haml +0 -5
  134. data/test/dummy/app/views/layouts/default/application.html.haml +0 -11
  135. data/test/dummy/app/views/layouts/demo/application.html.haml +0 -11
  136. data/test/dummy/config.ru +0 -4
  137. data/test/dummy/config/application.rb +0 -52
  138. data/test/dummy/config/application.yml +0 -2
  139. data/test/dummy/config/boot.rb +0 -10
  140. data/test/dummy/config/database.yml +0 -24
  141. data/test/dummy/config/environment.rb +0 -5
  142. data/test/dummy/config/environments/development.rb +0 -41
  143. data/test/dummy/config/environments/production.rb +0 -70
  144. data/test/dummy/config/environments/test.rb +0 -38
  145. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  146. data/test/dummy/config/initializers/inflections.rb +0 -15
  147. data/test/dummy/config/initializers/mime_types.rb +0 -5
  148. data/test/dummy/config/initializers/session_store.rb +0 -8
  149. data/test/dummy/config/initializers/spina.rb +0 -33
  150. data/test/dummy/config/initializers/themes/default.rb +0 -47
  151. data/test/dummy/config/initializers/themes/demo.rb +0 -103
  152. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  153. data/test/dummy/config/locales/en.yml +0 -5
  154. data/test/dummy/config/locales/nl.yml +0 -214
  155. data/test/dummy/config/routes.rb +0 -4
  156. data/test/dummy/config/secrets.yml +0 -7
  157. data/test/dummy/db/migrate/20160114085213_create_spina_tables.spina.rb +0 -167
  158. data/test/dummy/db/schema.rb +0 -183
  159. data/test/dummy/db/seeds.rb +0 -1
  160. data/test/dummy/public/404.html +0 -26
  161. data/test/dummy/public/422.html +0 -26
  162. data/test/dummy/public/500.html +0 -25
  163. data/test/dummy/public/favicon.ico +0 -0
  164. data/test/dummy/script/rails +0 -6
  165. data/test/dummy/tmp/restart.txt +0 -0
  166. data/test/fixtures/spina/accounts.yml +0 -3
  167. data/test/fixtures/spina/pages.yml +0 -10
  168. data/test/fixtures/spina/users.yml +0 -5
  169. data/test/functional/spina/admin/admin_controller.rb +0 -36
  170. data/test/functional/spina/admin/sessions_controller_test.rb +0 -32
  171. data/test/functional/spina/pages_controller_test.rb +0 -16
  172. data/test/integration/navigation_test.rb +0 -8
  173. data/test/integration/spina/admin/login_test.rb +0 -31
  174. data/test/integration/spina/admin/logout_test.rb +0 -17
  175. data/test/integration/spina/admin/pages_test.rb +0 -34
  176. data/test/integration/spina/pages_test.rb +0 -19
  177. data/test/models/spina/line_test.rb +0 -9
  178. data/test/models/spina/text_test.rb +0 -9
  179. data/test/test_helper.rb +0 -23
  180. data/test/unit/helpers/spina/accounts_helper_test.rb +0 -6
  181. data/test/unit/helpers/spina/inquiries_helper_test.rb +0 -6
  182. data/test/unit/helpers/spina/page_parts_helper_test.rb +0 -6
  183. data/test/unit/helpers/spina/pages_helper_test.rb +0 -6
  184. data/test/unit/helpers/spina/photos_helper_test.rb +0 -6
  185. data/test/unit/helpers/spina/sessions_helper_test.rb +0 -6
  186. data/test/unit/helpers/spina/users_helper_test.rb +0 -6
  187. data/test/unit/spina/account_test.rb +0 -9
  188. data/test/unit/spina/file_collection_file_test.rb +0 -9
  189. data/test/unit/spina/gallery_test.rb +0 -9
  190. data/test/unit/spina/inquiry_test.rb +0 -9
  191. data/test/unit/spina/page_include_test.rb +0 -9
  192. data/test/unit/spina/page_part_test.rb +0 -9
  193. data/test/unit/spina/page_test.rb +0 -9
  194. data/test/unit/spina/photo_collection_file_test.rb +0 -9
  195. data/test/unit/spina/photo_collection_test.rb +0 -9
  196. data/test/unit/spina/photo_test.rb +0 -9
  197. data/test/unit/spina/user_test.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8050dae6944a2f6eab52fd1cacefc622d0cbd867
4
- data.tar.gz: d192030943c6f20cee65e9a668034a9f75dc25a2
3
+ metadata.gz: 457fad6084480ec4091b8dba28d0f799dbd097dd
4
+ data.tar.gz: a3fb127947659c26b7583459ff2766891a51e6f5
5
5
  SHA512:
6
- metadata.gz: 67d7777dd5978acc9f3d6cfb65273e16725a353e31e5f66c75abc5e3fc76e048e63a08cf8c3fcc50d77d0aa47870ba8dbb53c7eb79dfa837c5a0892366930992
7
- data.tar.gz: b50e5baecdf2803b9c9524c1ea83865ce2119e034b085e67e010474797a6440de737961d196562da9ad15618c200ecd0cab72717de29b0270786acdce020baf0
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
- module Spina
71
- module DefaultTheme
72
- include ::ActiveSupport::Configurable
73
-
74
- config_accessor :title, :page_parts, :view_templates, :layout_parts, :custom_pages, :plugins, :structures
75
-
76
- self.title = "Default theme"
77
-
78
- self.page_parts = [{
79
- name: 'content',
80
- title: 'Content',
81
- page_partable_type: "Spina::Text"
82
- }]
83
-
84
- self.structures = []
85
- self.layout_parts = []
86
- self.custom_pages = []
87
- self.plugins = []
88
-
89
- self.view_templates = {
90
- 'homepage' => {
91
- title: 'Homepage',
92
- page_parts: ['content']
93
- },
94
- 'show' => {
95
- title: 'Default',
96
- description: 'A simple page',
97
- usage: 'Use for your content',
98
- page_parts: ['content']
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
- self.page_parts = [
117
- { name: 'content', title: 'Content', page_partable_type: "Spina::Text" },
118
- { name: 'portfolio', title: 'Portfolio', page_partable_type: "Spina::Text" } # added this second hash
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
- self.view_templates = {
128
- 'homepage' => {
129
- title: 'Homepage',
130
- page_parts: ['content']
131
- },
132
- 'show' => {
133
- title: 'Default',
134
- description: 'A simple page',
135
- usage: 'Use for your content',
136
- page_parts: ['content', 'portfolio'] # added 'portfolio' here.
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
@@ -2,7 +2,6 @@
2
2
  //= require jquery_ujs
3
3
  //= require turbolinks
4
4
  //= require spina
5
- //= require ./aviary
6
5
  //= require ./account
7
6
  //= require ./confirm_delete
8
7
  //= require ./pages
@@ -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.themes
36
- @layout_parts = current_theme.config.layout_parts.map { |layout_part| current_account.layout_part(layout_part) }
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
- :aviary_api_key, :aviary_language, :ngrok_address,
46
- :kvk_identifier, :theme, :vat_identifier, :robots_allowed,
47
- layout_parts_attributes:
48
- [:id, :layout_partable_type, :layout_partable_id,
49
- :name, :title, :position, :content, :page_id,
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
- before_filter :authorize_user
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
- private
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
- def new_messages
17
- @new_messages = Inquiry.new_messages.sorted
18
- end
14
+ private
19
15
 
20
- def current_account
21
- @current_account ||= Account.first
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 current_ability
31
- @current_ability ||= Ability.new(current_user)
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
@@ -1,7 +1,7 @@
1
1
  module Spina
2
2
  module Admin
3
3
  class AttachmentsController < AdminController
4
- before_filter :set_breadcrumbs
4
+ before_action :set_breadcrumbs
5
5
 
6
6
  authorize_resource class: Attachment
7
7
 
@@ -2,8 +2,9 @@ module Spina
2
2
  module Admin
3
3
  class PagesController < AdminController
4
4
 
5
- before_filter :set_breadcrumb
6
- before_filter :set_tabs, only: [:new, :create, :edit, :update]
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.config.page_parts.map { |page_part| @page.page_part(page_part) }
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.config.page_parts.map { |page_part| @page.page_part(page_part) }
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
- format.html { redirect_to spina.edit_admin_page_url(@page) }
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
- before_filter :set_breadcrumbs
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
- skip_before_filter :authorize_user
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
- before_filter :set_breadcrumbs
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.themes.detect{|theme| theme.name == current_account.theme }
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: "/" + params[:id])
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.to_s.parameterize.underscore}/application", template: "#{current_theme.to_s.parameterize.underscore}/pages/#{page.view_template || 'show'}"
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