spina 0.12.0 → 1.0.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 (210) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +65 -7
  3. data/app/assets/fonts/spina/ics_spina.eot +0 -0
  4. data/app/assets/fonts/spina/ics_spina.svg +65 -61
  5. data/app/assets/fonts/spina/ics_spina.ttf +0 -0
  6. data/app/assets/fonts/spina/ics_spina.woff +0 -0
  7. data/app/assets/fonts/spina/ics_spina.woff2 +0 -0
  8. data/app/assets/icons/spina/export.svg +10 -0
  9. data/app/assets/icons/spina/preview/ics_spina-preview.html +17 -1
  10. data/app/assets/images/spina/media_folder_placeholder.png +0 -0
  11. data/app/assets/images/spina/{admin/spina.png → spina-large.png} +0 -0
  12. data/app/assets/javascripts/spina/admin/application.js +50 -0
  13. data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +40 -0
  14. data/app/assets/javascripts/spina/admin/media_gallery.coffee +65 -0
  15. data/app/assets/javascripts/spina/admin/modal.coffee +0 -1
  16. data/app/assets/javascripts/spina/admin/pages.coffee.erb +2 -2
  17. data/app/assets/javascripts/spina/admin/{application.coffee.erb → scaffold.coffee} +20 -61
  18. data/app/assets/javascripts/spina/admin/trix.coffee.erb +5 -8
  19. data/app/assets/javascripts/spina/admin/uploads.coffee +2 -2
  20. data/app/assets/stylesheets/spina.sass +3 -3
  21. data/app/assets/stylesheets/spina/_buttons.sass +0 -1
  22. data/app/assets/stylesheets/spina/{_configuration.sass → _configuration.sass.erb} +5 -1
  23. data/app/assets/stylesheets/spina/_forms.sass +79 -20
  24. data/app/assets/stylesheets/spina/_gallery.sass +91 -3
  25. data/app/assets/stylesheets/spina/_ics_spina.scss +1 -0
  26. data/app/assets/stylesheets/spina/_tables.sass +4 -0
  27. data/app/assets/stylesheets/spina/_trix.sass +7 -4
  28. data/app/assets/stylesheets/spina_front_end.sass +19 -0
  29. data/app/controllers/concerns/spina/frontend.rb +29 -12
  30. data/app/controllers/spina/admin/admin_controller.rb +1 -1
  31. data/app/controllers/spina/admin/attachments_controller.rb +10 -5
  32. data/app/controllers/spina/admin/images_controller.rb +51 -0
  33. data/app/controllers/spina/admin/media_folders_controller.rb +37 -0
  34. data/app/controllers/spina/admin/media_picker_controller.rb +28 -0
  35. data/app/controllers/spina/admin/pages_controller.rb +16 -6
  36. data/app/controllers/spina/admin/resources_controller.rb +33 -0
  37. data/app/controllers/spina/admin/settings_controller.rb +56 -0
  38. data/app/controllers/spina/pages_controller.rb +0 -6
  39. data/app/helpers/spina/admin/pages_helper.rb +2 -2
  40. data/app/helpers/spina/admin_nav_helper.rb +7 -0
  41. data/app/helpers/spina/files_helper.rb +9 -0
  42. data/app/helpers/spina/images_helper.rb +17 -0
  43. data/app/helpers/spina/pages_helper.rb +17 -0
  44. data/app/models/concerns/spina/image_collectable.rb +23 -0
  45. data/app/models/concerns/spina/part.rb +7 -4
  46. data/app/models/spina/account.rb +10 -14
  47. data/app/models/spina/attachment.rb +8 -10
  48. data/app/models/spina/attachment_collection.rb +6 -1
  49. data/app/models/spina/current.rb +5 -0
  50. data/app/models/spina/image.rb +26 -0
  51. data/app/models/spina/{photo_collection.rb → image_collection.rb} +6 -6
  52. data/app/models/spina/image_collections_image.rb +6 -0
  53. data/app/models/spina/line.rb +1 -0
  54. data/app/models/spina/media_folder.rb +7 -0
  55. data/app/models/spina/navigation.rb +4 -0
  56. data/app/models/spina/navigation_item.rb +1 -1
  57. data/app/models/spina/page.rb +18 -13
  58. data/app/models/spina/page_part.rb +1 -0
  59. data/app/models/spina/resource.rb +16 -0
  60. data/app/models/spina/setting.rb +7 -0
  61. data/app/models/spina/structure.rb +2 -0
  62. data/app/models/spina/structure_item.rb +2 -0
  63. data/app/models/spina/structure_part.rb +2 -1
  64. data/app/models/spina/text.rb +1 -0
  65. data/app/views/dummy/show.html.haml +1 -0
  66. data/app/views/layouts/spina/admin/media_library.html.haml +6 -3
  67. data/app/views/layouts/spina/admin/pages.html.haml +4 -1
  68. data/app/views/layouts/spina/admin/resources.html.haml +10 -0
  69. data/app/views/spina/admin/accounts/style.html.haml +3 -2
  70. data/app/views/spina/admin/attachments/_attachment.html.haml +3 -3
  71. data/app/views/spina/admin/attachments/_select.html.haml +7 -15
  72. data/app/views/spina/admin/attachments/_select_collection.html.haml +7 -14
  73. data/app/views/spina/admin/attachments/create.js.erb +1 -3
  74. data/app/views/spina/admin/attachments/index.html.haml +4 -3
  75. data/app/views/spina/admin/attachments/insert.js.erb +5 -0
  76. data/app/views/spina/admin/image_collections/_image_collection.html.haml +5 -0
  77. data/app/views/spina/admin/images/_form.html.haml +5 -0
  78. data/app/views/spina/admin/images/_image.html.haml +10 -0
  79. data/app/views/spina/admin/images/create.js.erb +8 -0
  80. data/app/views/spina/admin/images/index.html.haml +22 -0
  81. data/app/views/spina/admin/images/index.js.erb +7 -0
  82. data/app/views/spina/admin/media_folders/_form.html.haml +14 -0
  83. data/app/views/spina/admin/media_folders/_media_folder.html.haml +8 -0
  84. data/app/views/spina/admin/media_folders/new.js.erb +1 -0
  85. data/app/views/spina/admin/media_folders/show.html.haml +17 -0
  86. data/app/views/spina/admin/media_picker/_modal.html.haml +26 -0
  87. data/app/views/spina/admin/media_picker/infinite_scroll.js.erb +5 -0
  88. data/app/views/spina/admin/media_picker/select.js.erb +28 -0
  89. data/app/views/spina/admin/media_picker/show.js.erb +1 -0
  90. data/app/views/spina/admin/navigations/_page.html.haml +2 -2
  91. data/app/views/spina/admin/navigations/edit.html.haml +1 -1
  92. data/app/views/spina/admin/pages/_form.html.haml +21 -15
  93. data/app/views/spina/admin/pages/_form_advanced.html.haml +53 -43
  94. data/app/views/spina/admin/pages/_form_page_content.html.haml +1 -1
  95. data/app/views/spina/admin/pages/_form_page_seo.html.haml +1 -1
  96. data/app/views/spina/admin/pages/_page_nested_list.html.haml +3 -3
  97. data/app/views/spina/admin/pages/index.html.haml +1 -1
  98. data/app/views/spina/admin/{page_partables → partables}/attachment_collections/_form.html.haml +1 -1
  99. data/app/views/spina/admin/{page_partables → partables}/attachments/_form.html.haml +4 -4
  100. data/app/views/spina/admin/partables/image_collections/_form.html.haml +16 -0
  101. data/app/views/spina/admin/partables/images/_form.html.haml +14 -0
  102. data/app/views/spina/admin/{page_partables → partables}/lines/_form.html.haml +1 -1
  103. data/app/views/spina/admin/{structure_partables → partables}/options/_form.html.haml +1 -1
  104. data/app/views/spina/admin/partables/photo_collections/_form.html.haml +4 -0
  105. data/app/views/spina/admin/partables/photos/_form.html.haml +4 -0
  106. data/app/views/spina/admin/{page_partables → partables}/structures/_form.html.haml +3 -3
  107. data/app/views/spina/admin/{page_partables → partables}/texts/_form.html.haml +1 -1
  108. data/app/views/spina/admin/password_resets/edit.html.haml +1 -1
  109. data/app/views/spina/admin/password_resets/new.html.haml +1 -1
  110. data/app/views/spina/admin/resources/edit.html.haml +49 -0
  111. data/app/views/spina/admin/resources/show.html.haml +14 -0
  112. data/app/views/spina/admin/sessions/new.html.haml +1 -1
  113. data/app/views/spina/admin/settings/_string_field.html.haml +4 -0
  114. data/app/views/spina/admin/settings/_wysiwyg_field.html.haml +4 -0
  115. data/app/views/spina/admin/settings/edit.html.haml +13 -0
  116. data/app/views/spina/admin/shared/_primary_navigation.html.haml +13 -5
  117. data/app/views/spina/admin/shared/_rich_text_field.html.haml +10 -10
  118. data/app/views/spina/admin/structure_items/_fields.html.haml +1 -1
  119. data/app/views/spina/admin/structure_partables/attachment_collections/_form.html.haml +14 -0
  120. data/app/views/spina/admin/structure_partables/attachments/_form.html.haml +13 -0
  121. data/app/views/spina/shared/_analytics.html.erb +8 -8
  122. data/app/views/spina/shared/_navigation.html.haml +3 -3
  123. data/app/views/spina/shared/_spina_link.html.haml +2 -0
  124. data/app/views/spina/sitemaps/show.xml.builder +2 -2
  125. data/config/initializers/assets.rb +6 -1
  126. data/config/locales/TH.yml +243 -0
  127. data/config/locales/bg.yml +250 -0
  128. data/config/locales/de.yml +67 -22
  129. data/config/locales/en.yml +29 -2
  130. data/config/locales/es.yml +58 -1
  131. data/config/locales/fr.yml +80 -32
  132. data/config/locales/id.yml +228 -0
  133. data/config/locales/nl.yml +32 -0
  134. data/config/locales/pl.yml +225 -0
  135. data/config/locales/pt-BR.yml +34 -3
  136. data/config/locales/ro.yml +225 -0
  137. data/config/locales/ru.yml +10 -0
  138. data/config/locales/sv.yml +223 -0
  139. data/config/routes.rb +13 -13
  140. data/db/migrate/10_create_spina_image_collections.rb +16 -0
  141. data/db/migrate/11_create_spina_resources.rb +15 -0
  142. data/db/migrate/1_create_spina_tables.rb +0 -19
  143. data/db/migrate/2_create_spina_translation_tables.rb +36 -6
  144. data/db/migrate/7_create_spina_settings.rb +11 -0
  145. data/db/migrate/8_create_spina_media_folders.rb +8 -0
  146. data/db/migrate/9_create_spina_images.rb +10 -0
  147. data/lib/generators/spina/install_generator.rb +2 -2
  148. data/lib/generators/spina/templates/app/views/default/pages/homepage.html.haml +3 -2
  149. data/lib/generators/spina/templates/app/views/default/pages/show.html.haml +2 -2
  150. data/lib/generators/spina/templates/app/views/default/shared/_navigation.html.haml +3 -5
  151. data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +20 -23
  152. data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +2 -2
  153. data/lib/generators/spina/templates/app/views/demo/pages/show.html.haml +2 -2
  154. data/lib/generators/spina/templates/app/views/demo/shared/_navigation.html.haml +3 -5
  155. data/lib/generators/spina/templates/config/initializers/mobility.rb +6 -0
  156. data/lib/generators/spina/templates/config/initializers/spina.rb +3 -0
  157. data/lib/generators/spina/templates/config/initializers/themes/demo.rb +7 -7
  158. data/lib/spina.rb +0 -1
  159. data/lib/spina/engine.rb +6 -7
  160. data/lib/spina/plugin.rb +48 -3
  161. data/lib/spina/version.rb +1 -1
  162. data/vendor/assets/javascripts/spina/stimulus.umd.js +5 -0
  163. data/vendor/assets/javascripts/spina/trix.js +10 -9
  164. metadata +106 -103
  165. data/app/assets/images/spina/danger-zone-ribbon.png +0 -0
  166. data/app/assets/images/spina/spina_small.png +0 -0
  167. data/app/assets/javascripts/spina/admin/infinite_scroll.coffee +0 -25
  168. data/app/controllers/spina/admin/photos_controller.rb +0 -100
  169. data/app/models/concerns/spina/photo_collectable.rb +0 -24
  170. data/app/models/spina/photo.rb +0 -29
  171. data/app/models/spina/photo_collections_photo.rb +0 -6
  172. data/app/presenters/spina/pages/menu_presenter.rb +0 -63
  173. data/app/uploaders/spina/default_store_uploader.rb +0 -15
  174. data/app/uploaders/spina/file_uploader.rb +0 -6
  175. data/app/uploaders/spina/logo_uploader.rb +0 -13
  176. data/app/uploaders/spina/photo_uploader.rb +0 -23
  177. data/app/views/spina/admin/attachments/_fields.html.haml +0 -8
  178. data/app/views/spina/admin/attachments/insert.js.coffee +0 -5
  179. data/app/views/spina/admin/page_partables/options/_form.html.haml +0 -6
  180. data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +0 -17
  181. data/app/views/spina/admin/page_partables/photos/_form.html.haml +0 -14
  182. data/app/views/spina/admin/photos/_photo.html.haml +0 -8
  183. data/app/views/spina/admin/photos/_photo_collection.html.haml +0 -5
  184. data/app/views/spina/admin/photos/_photo_collection_select.html.haml +0 -23
  185. data/app/views/spina/admin/photos/_photo_link.html.haml +0 -11
  186. data/app/views/spina/admin/photos/_photo_multi_picker.html.haml +0 -3
  187. data/app/views/spina/admin/photos/_photo_select.html.haml +0 -16
  188. data/app/views/spina/admin/photos/_photo_single_picker.html.haml +0 -3
  189. data/app/views/spina/admin/photos/_photo_uploaded.html.haml +0 -4
  190. data/app/views/spina/admin/photos/_trix_select.html.haml +0 -11
  191. data/app/views/spina/admin/photos/create.js.erb +0 -4
  192. data/app/views/spina/admin/photos/index.html.haml +0 -13
  193. data/app/views/spina/admin/photos/index.js.erb +0 -5
  194. data/app/views/spina/admin/photos/insert_photo.js.erb +0 -10
  195. data/app/views/spina/admin/photos/insert_photo_collection.js.erb +0 -25
  196. data/app/views/spina/admin/photos/link.js.erb +0 -2
  197. data/app/views/spina/admin/photos/multi_picker_infinite_scroll.js.erb +0 -6
  198. data/app/views/spina/admin/photos/photo_collection_select.js.erb +0 -3
  199. data/app/views/spina/admin/photos/photo_select.js.erb +0 -3
  200. data/app/views/spina/admin/photos/single_picker_infinite_scroll.js.erb +0 -6
  201. data/app/views/spina/admin/photos/trix_infinite_scroll.js.erb +0 -4
  202. data/app/views/spina/admin/photos/trix_insert.js.erb +0 -2
  203. data/app/views/spina/admin/photos/trix_select.js.erb +0 -3
  204. data/app/views/spina/admin/structure_partables/lines/_form.html.haml +0 -5
  205. data/app/views/spina/admin/structure_partables/photo_collections/_form.html.haml +0 -17
  206. data/app/views/spina/admin/structure_partables/photos/_form.html.haml +0 -11
  207. data/app/views/spina/admin/structure_partables/texts/_form.html.haml +0 -5
  208. data/config/initializers/spina.rb +0 -0
  209. data/lib/generators/spina/templates/config/initializers/carrierwave.rb +0 -17
  210. data/lib/spina/railtie.rb +0 -9
@@ -1,10 +1,8 @@
1
1
  module Spina
2
2
  class Account < ApplicationRecord
3
3
  include Partable
4
-
5
- serialize :preferences
6
4
 
7
- mount_uploader :logo, LogoUploader
5
+ serialize :preferences
8
6
 
9
7
  has_many :layout_parts, dependent: :destroy
10
8
  accepts_nested_attributes_for :layout_parts, allow_destroy: true
@@ -24,16 +22,14 @@ module Spina
24
22
 
25
23
  def self.serialized_attr_accessor(*args)
26
24
  args.each do |method_name|
27
- eval "
28
- def #{method_name}
29
- self.preferences.try(:[], :#{method_name})
30
- end
31
-
32
- def #{method_name}=(value)
33
- self.preferences ||= {}
34
- self.preferences[:#{method_name}] = value
35
- end
36
- "
25
+ define_method method_name do
26
+ self.preferences.try(:[], method_name.to_sym)
27
+ end
28
+
29
+ define_method "#{method_name}=" do |value|
30
+ self.preferences ||= {}
31
+ self.preferences[method_name.to_sym] = value
32
+ end
37
33
  end
38
34
  end
39
35
 
@@ -44,7 +40,7 @@ module Spina
44
40
  def bootstrap_website
45
41
  theme_config = ::Spina::Theme.find_by_name(theme)
46
42
  if theme_config
47
- bootstrap_pages(theme_config)
43
+ bootstrap_pages(theme_config)
48
44
  bootstrap_navigations(theme_config)
49
45
  end
50
46
  end
@@ -1,18 +1,21 @@
1
1
  module Spina
2
2
  class Attachment < ApplicationRecord
3
+ has_one_attached :file
3
4
 
4
5
  has_one :page_part, as: :page_partable
6
+ has_many :structure_parts, as: :structure_partable
5
7
  has_and_belongs_to_many :attachment_collections, join_table: 'spina_attachment_collections_attachments'
6
8
 
7
9
  attr_accessor :_destroy
8
10
 
9
- scope :sorted, -> { order('created_at DESC') }
10
- scope :file_attached, -> { where('file IS NOT NULL') }
11
-
12
- mount_uploader :file, FileUploader
11
+ scope :sorted, -> { order('file ASC') }
13
12
 
14
13
  def name
15
- file.file.try(:filename)
14
+ file.filename.to_s
15
+ end
16
+
17
+ def content
18
+ file if file.attached?
16
19
  end
17
20
 
18
21
  alias_method :old_update_attributes, :update_attributes
@@ -24,10 +27,5 @@ module Spina
24
27
  end
25
28
  end
26
29
 
27
- def self.order_by_ids(ids)
28
- sql = sanitize_sql_for_assignment({id: ids})
29
- order("CASE WHEN #{sql} THEN 0 ELSE 1 END")
30
- end
31
-
32
30
  end
33
31
  end
@@ -2,11 +2,16 @@ module Spina
2
2
  class AttachmentCollection < ApplicationRecord
3
3
 
4
4
  has_one :page_part, as: :page_partable
5
+ has_many :structure_parts, as: :structure_partable
5
6
  has_and_belongs_to_many :attachments, join_table: 'spina_attachment_collections_attachments'
6
7
 
7
- attr_reader :attachment_tokens
8
+ attr_reader :attachment_tokens
8
9
  accepts_nested_attributes_for :attachments, allow_destroy: true
9
10
 
11
+ def content
12
+ self
13
+ end
14
+
10
15
  def attachment_tokens=(ids)
11
16
  self.attachment_ids = ids.split(",")
12
17
  end
@@ -0,0 +1,5 @@
1
+ module Spina
2
+ class Current < ActiveSupport::CurrentAttributes
3
+ attribute :page
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ module Spina
2
+ class Image < ApplicationRecord
3
+ belongs_to :media_folder, optional: true
4
+
5
+ has_one_attached :file
6
+
7
+ has_many :page_parts, as: :page_partable
8
+ has_many :structure_parts, as: :structure_partable
9
+
10
+ scope :sorted, -> { order('created_at DESC') }
11
+ scope :sorted_by_image_collection, -> { order('position') }
12
+
13
+ def name
14
+ file.try(:filename).to_s
15
+ end
16
+
17
+ def variant(options)
18
+ file.attached? ? file.variant(options) : ""
19
+ end
20
+
21
+ def content
22
+ self
23
+ end
24
+
25
+ end
26
+ end
@@ -1,13 +1,13 @@
1
1
  module Spina
2
- class PhotoCollection < ApplicationRecord
3
- include PhotoCollectable
2
+ class ImageCollection < ApplicationRecord
3
+ include ImageCollectable
4
4
 
5
5
  has_one :page_part, as: :page_partable
6
- has_many :photo_collections_photos, autosave: true
7
- has_many :photos, through: :photo_collections_photos
6
+ has_many :image_collections_images, autosave: true
7
+ has_many :images, through: :image_collections_images
8
8
  has_many :structure_parts, as: :structure_partable
9
9
 
10
- accepts_nested_attributes_for :photos, allow_destroy: true
10
+ accepts_nested_attributes_for :images, allow_destroy: true
11
11
 
12
12
  def content
13
13
  self
@@ -15,7 +15,7 @@ module Spina
15
15
 
16
16
  alias_method :old_update_attributes, :update_attributes
17
17
  def update_attributes(attributes)
18
- self.photos.clear if attributes.reject{|key,value| key == "id" }.blank?
18
+ self.images.clear if attributes.reject{|key,value| key == "id" }.blank?
19
19
  old_update_attributes(attributes)
20
20
  end
21
21
 
@@ -0,0 +1,6 @@
1
+ module Spina
2
+ class ImageCollectionsImage < ApplicationRecord
3
+ belongs_to :image
4
+ belongs_to :image_collection
5
+ end
6
+ end
@@ -1,5 +1,6 @@
1
1
  module Spina
2
2
  class Line < ApplicationRecord
3
+ extend Mobility
3
4
  translates :content
4
5
 
5
6
  has_many :page_parts, as: :page_partable
@@ -0,0 +1,7 @@
1
+ module Spina
2
+ class MediaFolder < ApplicationRecord
3
+ has_many :images, dependent: :nullify
4
+
5
+ validates :name, presence: true, uniqueness: true
6
+ end
7
+ end
@@ -7,5 +7,9 @@ module Spina
7
7
 
8
8
  validates :name, :label, presence: true
9
9
  validates :name, uniqueness: true
10
+
11
+ def cache_key
12
+ super + "_" + Mobility.locale.to_s
13
+ end
10
14
  end
11
15
  end
@@ -1,6 +1,6 @@
1
1
  module Spina
2
2
  class NavigationItem < ApplicationRecord
3
- belongs_to :navigation
3
+ belongs_to :navigation, touch: true
4
4
  belongs_to :page
5
5
 
6
6
  has_ancestry orphan_strategy: :adopt
@@ -1,5 +1,6 @@
1
1
  module Spina
2
2
  class Page < ApplicationRecord
3
+ extend Mobility
3
4
  include Partable
4
5
 
5
6
  # Stores the old path when generating a new materialized_path
@@ -17,6 +18,11 @@ module Spina
17
18
  has_many :navigation_items, dependent: :destroy
18
19
  has_many :navigations, through: :navigation_items
19
20
 
21
+ # Pages can belong to a resource
22
+ belongs_to :resource, optional: true
23
+
24
+ scope :regular_pages, -> { where(resource: nil) }
25
+ scope :resource_pages, -> { where.not(resource: nil) }
20
26
  scope :active, -> { where(active: true) }
21
27
  scope :sorted, -> { order(:position) }
22
28
  scope :live, -> { active.where(draft: false) }
@@ -24,6 +30,8 @@ module Spina
24
30
 
25
31
  # Save children to update all materialized_paths
26
32
  after_save :save_children
33
+ after_save :touch_navigations
34
+ after_save -> { page_parts.each(&:save) }
27
35
 
28
36
  # Create a 301 redirect if materialized_path changed
29
37
  after_save :rewrite_rule
@@ -32,7 +40,8 @@ module Spina
32
40
  validates :title, presence: true
33
41
  validates :materialized_path, uniqueness: true
34
42
 
35
- translates :title, :menu_title, :seo_title, :description, :materialized_path
43
+ translates :title, :description, :materialized_path
44
+ translates :menu_title, :seo_title, default: -> { title }
36
45
 
37
46
  def to_s
38
47
  name
@@ -47,15 +56,7 @@ module Spina
47
56
  end
48
57
 
49
58
  def save_children
50
- self.children.each { |child| child.save }
51
- end
52
-
53
- def menu_title
54
- read_attribute(:menu_title).blank? ? title : read_attribute(:menu_title)
55
- end
56
-
57
- def seo_title
58
- read_attribute(:seo_title).blank? ? title : read_attribute(:seo_title)
59
+ self.children.each(&:save)
59
60
  end
60
61
 
61
62
  def live?
@@ -73,12 +74,12 @@ module Spina
73
74
  def set_materialized_path
74
75
  self.old_path = materialized_path
75
76
  self.materialized_path = localized_materialized_path
76
- self.materialized_path += "-#{self.class.where(materialized_path: materialized_path).count}" if self.class.where(materialized_path: materialized_path).where.not(id: id).count > 0
77
+ self.materialized_path += "-#{self.class.i18n.where(materialized_path: materialized_path).count}" if self.class.i18n.where(materialized_path: materialized_path).where.not(id: id).count > 0
77
78
  materialized_path
78
79
  end
79
80
 
80
81
  def cache_key
81
- super + "_" + Globalize.locale.to_s
82
+ super + "_" + Mobility.locale.to_s
82
83
  end
83
84
 
84
85
  def view_template_config(theme)
@@ -92,8 +93,12 @@ module Spina
92
93
 
93
94
  private
94
95
 
96
+ def touch_navigations
97
+ navigations.update_all(updated_at: Time.zone.now)
98
+ end
99
+
95
100
  def rewrite_rule
96
- RewriteRule.create(old_path: old_path, new_path: materialized_path) if old_path != materialized_path
101
+ RewriteRule.where(old_path: old_path).first_or_create.update_attributes(new_path: materialized_path) if old_path != materialized_path
97
102
  end
98
103
 
99
104
  def localized_materialized_path
@@ -11,6 +11,7 @@ module Spina
11
11
  validates :name, uniqueness: {scope: :page_id}
12
12
 
13
13
  alias_attribute :partable, :page_partable
14
+ alias_attribute :partable_id, :page_partable_id
14
15
  alias_attribute :partable_type, :page_partable_type
15
16
  alias_method :page_partable_attributes=, :partable_attributes=
16
17
 
@@ -0,0 +1,16 @@
1
+ module Spina
2
+ class Resource < ApplicationRecord
3
+ has_many :pages, dependent: :restrict_with_exception
4
+
5
+ belongs_to :parent_page, class_name: "Spina::Page", optional: true
6
+
7
+ def pages
8
+ case order_by
9
+ when "title"
10
+ super.joins(:translations).where(spina_page_translations: {locale: I18n.locale}).order("spina_page_translations.title")
11
+ else
12
+ super.order(created_at: :desc)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module Spina
2
+ class Setting < ApplicationRecord
3
+
4
+ validates :plugin, presence: true
5
+
6
+ end
7
+ end
@@ -3,6 +3,8 @@ module Spina
3
3
  has_one :page_part, as: :page_partable
4
4
  has_many :structure_items
5
5
 
6
+ after_save -> { structure_items.each(&:save) }
7
+
6
8
  accepts_nested_attributes_for :structure_items, allow_destroy: true
7
9
 
8
10
  def content
@@ -8,6 +8,8 @@ module Spina
8
8
 
9
9
  scope :sorted_by_structure, -> { order(:position) }
10
10
 
11
+ after_save -> { structure_parts.each(&:save) }
12
+
11
13
  validates_presence_of :position
12
14
  accepts_nested_attributes_for :structure_parts, allow_destroy: true
13
15
 
@@ -1,7 +1,7 @@
1
1
  module Spina
2
2
  class StructurePart < ApplicationRecord
3
3
  include Part
4
- include PhotoCollectable
4
+ include ImageCollectable
5
5
  include Optionable
6
6
 
7
7
  belongs_to :structure_item, optional: true
@@ -13,6 +13,7 @@ module Spina
13
13
  validates :name, uniqueness: {scope: :structure_item_id}
14
14
 
15
15
  alias_attribute :partable, :structure_partable
16
+ alias_attribute :partable_id, :structure_partable_id
16
17
  alias_attribute :partable_type, :structure_partable_type
17
18
  alias_method :structure_partable_attributes=, :partable_attributes=
18
19
  end
@@ -1,5 +1,6 @@
1
1
  module Spina
2
2
  class Text < ApplicationRecord
3
+ extend Mobility
3
4
  translates :content
4
5
 
5
6
  has_many :page_parts, as: :page_partable
@@ -0,0 +1 @@
1
+ hoi
@@ -1,13 +1,16 @@
1
1
  - content_for :application do
2
2
  %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
3
6
  = render partial: 'spina/admin/shared/breadcrumbs'
4
7
 
5
8
  %nav#secondary.tabs
6
9
  %ul
7
- %li{class: ('active' if controller_name == 'photos')}
8
- = link_to t('spina.media_library.photos'), spina.admin_photos_path
10
+ %li{class: ('active' if controller_name.in? %w(images media_folders))}
11
+ = link_to t('spina.media_library.images'), admin_images_path
9
12
  %li{class: ('active' if controller_name == 'attachments')}
10
- = link_to t('spina.media_library.attachments'), spina.admin_attachments_path
13
+ = link_to t('spina.media_library.attachments'), admin_attachments_path
11
14
 
12
15
  = yield
13
16
 
@@ -15,7 +15,10 @@
15
15
 
16
16
  = yield(:header_actions) if content_for?(:header_actions)
17
17
 
18
- .breadcrumbs= render_breadcrumbs separator: '<div class="divider"></div>'
18
+ .breadcrumbs
19
+ = render_breadcrumbs separator: '<div class="divider"></div>'
20
+ = link_to '/', class: 'button button-small button-hollow', target: :blank do
21
+ %i.icon.icon-export{style: "margin: 0"}
19
22
 
20
23
  %nav#secondary.tabs
21
24
  %ul
@@ -0,0 +1,10 @@
1
+ - content_for :application do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ = yield
9
+
10
+ = render template: "layouts/spina/admin/admin"
@@ -6,7 +6,7 @@
6
6
  %button.button.button-primary{type: 'submit', data: {icon: 'o'}}
7
7
  = icon('check')
8
8
  = t('spina.preferences.style_save')
9
-
9
+
10
10
  .well
11
11
  .horizontal-form
12
12
  .horizontal-form-group
@@ -16,11 +16,12 @@
16
16
  .select-dropdown.account-theme{data: {layout_parts: current_theme.layout_parts.map{|layout_part| layout_part[:name]}}}
17
17
  - options = options_for_select(::Spina::Theme.all.map { |theme| [theme.name, theme.name, {'data-layout-parts' => theme.layout_parts.map{|layout_part| layout_part[:name] }}] }, current_account.theme)
18
18
  = f.select :theme, options
19
+
19
20
  .horizontal-form-group
20
21
  .horizontal-form-label
21
22
  = Spina::Account.human_attribute_name(:logo)
22
23
  .horizontal-form-content
23
- = image_tag current_account.logo
24
+ = image_tag current_account.logo.url if current_account.logo.present?
24
25
  = f.file_field :logo
25
26
 
26
27
  = f.fields_for :layout_parts do |ff|
@@ -1,7 +1,7 @@
1
1
  %tr
2
- %td= link_to attachment.name, attachment.file.try(:url), target: :blank
3
- %td.nowrap= number_to_human_size(attachment.file.size)
2
+ %td= link_to attachment.name, file_url(attachment.file), target: :blank
3
+ %td.nowrap= number_to_human_size(attachment.file.byte_size)
4
4
  %td.nowrap
5
5
  %small= l attachment.created_at, format: '%d %B %Y %H:%M'
6
- %td.nowrap
6
+ %td.nowrap.text-right
7
7
  = link_to t('spina.delete'), admin_attachment_path(attachment), method: :delete, class: 'button button-link button-danger button-small', data: {confirm: t('spina.delete_confirmation', subject: attachment.name)}