locomotive_cms 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 243b2783fdaefcb54415d93da1d0918dd81890f7
4
- data.tar.gz: 4652d77c5a747fa2fdf429eef59b7ef2f56b3642
3
+ metadata.gz: b5296380d468cf4e5522e01268698e14df1be493
4
+ data.tar.gz: f55fa2c7671c33d05b6d93c12cd6a33034b69b61
5
5
  SHA512:
6
- metadata.gz: 864e756b9dfab5708b8e89ae55229879518a44fb2f91ed207537e19e4f0a3189948d60ad0f93b66d4f757dfa765866b00df1000bacdcd60cdfc9b1c663939d44
7
- data.tar.gz: 3268fb0c1d076f4084208593ffe762f360c496304ea9d911b5dfc92655ae3cbe794286e502386dfd658e6d1c91b7f229c0b9520b35313b75ba27aa7579cd23ad
6
+ metadata.gz: 3c1bfd20751c88557fe805ba6b3e2292c4c9f03c71e8034f5cb6cd3ad5f2120b830b9fedcdb03eda475b34c97b6fc752d93cefd9f5c4f09286d9a392b33bc295
7
+ data.tar.gz: 7db9d6cb249af95f012abb14833df09945373194d487515c84a879611ed3605707992069a4011ab8bf3a3a13bfb173c3a24c90c3485c735ca5a629ea06e0a585
@@ -23,5 +23,16 @@ class Locomotive.Models.EditableElementsCollection extends Backbone.Collection
23
23
  by_block: (name) ->
24
24
  @filter (editable) -> editable.get('block_name') == name
25
25
 
26
+ find_similar: (editable) ->
27
+ @find (_editable) ->
28
+ editable.get('block') == _editable.get('block') &&
29
+ editable.get('slug') == _editable.get('slug') &&
30
+ editable.get('type') == _editable.get('type')
31
+
32
+ update_content_from: (collection) ->
33
+ collection.each (element) =>
34
+ _element = @find_similar(element)
35
+ _element.set('content', element.get('content')) if _element
36
+
26
37
  toJSONForSave: ->
27
38
  @map (model) => model.toJSONForSave()
@@ -159,5 +159,4 @@ class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
159
159
  @$('li#page_redirect_url_input, li#page_redirect_type_input').hide()
160
160
 
161
161
  enable_other_checkboxes: ->
162
- _.each ['published', 'listed'], (exp) =>
163
- @$('li#page_' + exp + '_input input[type=checkbox]').checkToggle()
162
+ @$('li.toggle input[type=checkbox].simple-toggle').checkToggle()
@@ -11,6 +11,11 @@ class Locomotive.Views.Pages.EditView extends Locomotive.Views.Pages.FormView
11
11
 
12
12
  @clear_errors()
13
13
 
14
+ # store the previous editable elements in case we
15
+ # need to use the content of these elements for
16
+ # the new ones (same block and slug).
17
+ editable_elements = _.clone @model.get('editable_elements')
18
+
14
19
  @model.save {},
15
20
  success: (model, response) =>
16
21
  form.trigger('ajax:complete')
@@ -18,6 +23,7 @@ class Locomotive.Views.Pages.EditView extends Locomotive.Views.Pages.FormView
18
23
  model._normalize()
19
24
 
20
25
  if model.get('template_changed') == true
26
+ model.get('editable_elements').update_content_from(editable_elements)
21
27
  @reset_editable_elements()
22
28
  else
23
29
  @refresh_editable_elements()
@@ -32,7 +32,7 @@ module Locomotive
32
32
  end
33
33
 
34
34
  def current_ability
35
- @current_ability ||= Ability.new(current_locomotive_account, current_site)
35
+ @current_ability ||= Locomotive::Ability.new(current_locomotive_account, current_site)
36
36
  end
37
37
 
38
38
  def require_account
@@ -56,7 +56,7 @@ module Locomotive
56
56
  end
57
57
 
58
58
  def current_ability
59
- @current_ability ||= Ability.new(current_locomotive_account, current_site)
59
+ @current_ability ||= Locomotive::Ability.new(current_locomotive_account, current_site)
60
60
  end
61
61
 
62
62
  def require_account
@@ -19,12 +19,10 @@ module Locomotive
19
19
  end
20
20
 
21
21
  def parent_pages_options
22
- roots = current_site.pages.roots.where(:slug.ne => '404').and(:_id.ne => @page.id)
23
-
24
22
  [].tap do |list|
25
- roots.each do |page|
26
- list = add_children_to_options(page, list)
27
- end
23
+ root = Locomotive::Page.quick_tree(current_site).first
24
+
25
+ add_children_to_options(root, list)
28
26
  end
29
27
  end
30
28
 
@@ -20,6 +20,7 @@ module Locomotive
20
20
  ## indexes ##
21
21
  index position: 1
22
22
  index depth: 1, position: 1
23
+ index site_id: 1, depth: 1, position: 1
23
24
 
24
25
  alias_method_chain :rearrange, :identity_map
25
26
  alias_method_chain :rearrange_children, :identity_map
@@ -83,12 +84,7 @@ module Locomotive
83
84
  end
84
85
  end
85
86
 
86
- current_page.instance_eval do
87
- def children=(list); @children = list; end
88
- def children; @children || []; end
89
- end
90
-
91
- current_page.children = children
87
+ current_page.instance_variable_set(:@children, children || [])
92
88
 
93
89
  current_page
94
90
  end
@@ -19,7 +19,7 @@ module Locomotive
19
19
 
20
20
  ## methods ##
21
21
 
22
- Ability::ROLES.each do |_role|
22
+ Locomotive::Ability::ROLES.each do |_role|
23
23
  define_method("#{_role}?") do
24
24
  self.role == _role
25
25
  end
@@ -48,13 +48,13 @@ module Locomotive
48
48
  end
49
49
 
50
50
  def ability
51
- @ability ||= Ability.new(self.account, self.site)
51
+ @ability ||= Locomotive::Ability.new(self.account, self.site)
52
52
  end
53
53
 
54
54
  protected
55
55
 
56
56
  def define_role
57
- self.role = Ability::ROLES.include?(role.downcase) ? role.downcase : Ability::ROLES.first
57
+ self.role = Locomotive::Ability::ROLES.include?(role.downcase) ? role.downcase : Locomotive::Ability::ROLES.first
58
58
  end
59
59
 
60
60
  # Users should not be able to set the role of another user to be higher than
@@ -67,7 +67,7 @@ module Locomotive
67
67
  if current_membership.present?
68
68
  # The role cannot be set higher than the current one (we use the index in
69
69
  # the roles array to check role presidence)
70
- errors.add(:role, :invalid) if Ability::ROLES.index(role) < Ability::ROLES.index(current_membership.role)
70
+ errors.add(:role, :invalid) if Locomotive::Ability::ROLES.index(role) < Locomotive::Ability::ROLES.index(current_membership.role)
71
71
  end
72
72
  end
73
73
 
@@ -35,9 +35,9 @@
35
35
 
36
36
  = f.input :target_klass_name, as: :select, collection: options_for_target_klass_name, include_blank: false, wrapper_html: { style: "#{'display: none' if !@page.templatized? || @page.templatized_from_parent?}" }
37
37
 
38
- = f.input :published, as: :'Locomotive::Toggle'
38
+ = f.input :published, as: :'Locomotive::Toggle', input_html: { class: 'simple-toggle' }
39
39
 
40
- = f.input :listed, as: :'Locomotive::Toggle'
40
+ = f.input :listed, as: :'Locomotive::Toggle', input_html: { class: 'simple-toggle' }
41
41
 
42
42
  = f.input :redirect, as: :'Locomotive::Toggle', wrapper_html: { style: "#{'display: none' if @page.templatized? || !@page.default_response_type?}" }
43
43
 
@@ -45,6 +45,8 @@
45
45
 
46
46
  = f.input :redirect_type, as: :select, collection: options_for_page_redirect_type, include_blank: false, wrapper_html: { style: "#{'display: none' unless @page.redirect?}" }
47
47
 
48
+ = render_cell 'locomotive/partials', :display, :page_form, g: f
49
+
48
50
  - if can?(:customize, @page)
49
51
 
50
52
  = f.input :cache_strategy, as: :select, collection: options_for_page_cache_strategy, include_blank: false, wrapper_html: { style: "#{'display: none' if @page.redirect?}" }
data/config/routes.rb CHANGED
@@ -8,6 +8,10 @@ Locomotive::Engine.routes.draw do
8
8
  failure_app: 'Locomotive::Devise::FailureApp',
9
9
  controllers: { sessions: 'locomotive/sessions', passwords: 'locomotive/passwords' }
10
10
 
11
+ authenticated :locomotive_account do
12
+ root to: 'pages#index'
13
+ end
14
+
11
15
  devise_scope :locomotive_account do
12
16
  match '/' => 'sessions#new'
13
17
  delete 'signout' => 'sessions#destroy', as: :destroy_locomotive_session
@@ -7,4 +7,7 @@ require 'locomotive/carrierwave/patches'
7
7
  # register missing mime types
8
8
  EXTENSIONS[:eot] = 'application/vnd.ms-fontobject'
9
9
  EXTENSIONS[:woff] = 'application/x-woff'
10
- EXTENSIONS[:otf] = 'application/octet-stream'
10
+ EXTENSIONS[:otf] = 'application/octet-stream'
11
+
12
+ # Allow retina images
13
+ CarrierWave::SanitizedFile.sanitize_regexp = /[^a-zA-Z0-9\.\-\+_\@]/
@@ -42,23 +42,17 @@ module Locomotive
42
42
  protected
43
43
 
44
44
  def retrieve_page_from_handle(site, context)
45
- context.scopes.reverse_each do |scope|
46
- handle = scope[@handle] || @handle
47
-
48
- page = case handle
49
- when Locomotive::Page then handle
50
- when Locomotive::Liquid::Drops::Page then handle.instance_variable_get(:@_source)
51
- when String then fetch_page(site, handle)
52
- when Locomotive::ContentEntry then fetch_page(site, handle, true)
53
- when Locomotive::Liquid::Drops::ContentEntry then fetch_page(site, handle.instance_variable_get(:@_source), true)
54
- else
55
- nil
56
- end
57
-
58
- return page unless page.nil?
45
+ handle = context[@handle] || @handle
46
+
47
+ case handle
48
+ when Locomotive::Page then handle
49
+ when Locomotive::Liquid::Drops::Page then handle.instance_variable_get(:@_source)
50
+ when String then fetch_page(site, handle)
51
+ when Locomotive::ContentEntry then fetch_page(site, handle, true)
52
+ when Locomotive::Liquid::Drops::ContentEntry then fetch_page(site, handle.instance_variable_get(:@_source), true)
53
+ else
54
+ nil
59
55
  end
60
-
61
- nil
62
56
  end
63
57
 
64
58
  def fetch_page(site, handle, templatized = false)
@@ -96,7 +96,7 @@ module Locomotive
96
96
 
97
97
  # Get the Locomotive page matching the request and scoped by the current Locomotive site
98
98
  #
99
- # @param [ String ] path An optional path overriding the default default behaviour to get a page
99
+ # @param [ String ] path An optional path overriding the default behaviour to get a page
100
100
  #
101
101
  # @return [ Object ] The Locomotive::Page
102
102
  #
@@ -1,3 +1,3 @@
1
1
  module Locomotive #:nodoc
2
- VERSION = '2.3.0'
2
+ VERSION = '2.3.1'
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "highline/import"
2
2
 
3
3
  namespace :development do
4
+ desc "Setup sites and account for development"
4
5
  task bootstrap: :environment do
5
6
  if Locomotive::Site.count > 0 || Locomotive::Account.count > 0
6
7
  puts "This will wipe out all sites and accounts"
Binary file
@@ -55,6 +55,12 @@ describe Locomotive::ThemeAsset do
55
55
  asset.local_path.should == 'images/a_la_poubelle/5k.png'
56
56
  end
57
57
 
58
+ it 'should keep the original name for a retina image' do
59
+ asset.source = FixturedAsset.open('5k@2x.png')
60
+ asset.save
61
+ asset.local_path.should == 'images/5k@2x.png'
62
+ end
63
+
58
64
  end
59
65
 
60
66
  describe '#validation' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotive_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-25 00:00:00.000000000 Z
11
+ date: 2013-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -1269,6 +1269,7 @@ files:
1269
1269
  - spec/cells/locomotive/main_menu_cell_spec.rb
1270
1270
  - spec/cells/locomotive/settings_menu_cell_spec.rb
1271
1271
  - spec/fixtures/assets/5k.png
1272
+ - spec/fixtures/assets/5k@2x.png
1272
1273
  - spec/fixtures/assets/5k_2.png
1273
1274
  - spec/fixtures/assets/application.js
1274
1275
  - spec/fixtures/assets/main.css
@@ -1483,6 +1484,7 @@ test_files:
1483
1484
  - spec/cells/locomotive/main_menu_cell_spec.rb
1484
1485
  - spec/cells/locomotive/settings_menu_cell_spec.rb
1485
1486
  - spec/fixtures/assets/5k.png
1487
+ - spec/fixtures/assets/5k@2x.png
1486
1488
  - spec/fixtures/assets/5k_2.png
1487
1489
  - spec/fixtures/assets/application.js
1488
1490
  - spec/fixtures/assets/main.css