locomotive_cms 2.0.0.rc7 → 2.0.0.rc8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/Gemfile +6 -4
  2. data/README.textile +4 -3
  3. data/app/assets/images/locomotive/icons/flags/{no.png → nb.png} +0 -0
  4. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/lib/locomotive_media-plugin.js +1 -1
  5. data/app/assets/javascripts/locomotive/utils/core_ext.js +2 -0
  6. data/app/assets/javascripts/locomotive/views/application_view.js.coffee +7 -0
  7. data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +4 -1
  8. data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +4 -2
  9. data/app/assets/javascripts/locomotive/views/content_entries/_popup_form_view.js.coffee +8 -3
  10. data/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +0 -2
  11. data/app/assets/javascripts/locomotive/views/content_types/custom_field_entry_view.js.coffee +9 -2
  12. data/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee +10 -11
  13. data/app/assets/javascripts/locomotive/views/inline_editor/application_view.js.coffee +9 -0
  14. data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +3 -3
  15. data/app/assets/javascripts/locomotive/views/shared/asset_picker_view.js.coffee +11 -18
  16. data/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee +0 -4
  17. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +2 -1
  18. data/app/assets/javascripts/locomotive/views/snippets/_form_view.js.coffee +3 -1
  19. data/app/assets/javascripts/locomotive/views/theme_assets/_form_view.js.coffee +4 -4
  20. data/app/assets/javascripts/locomotive/views/theme_assets/image_picker_view.js.coffee +10 -2
  21. data/app/assets/javascripts/tinymce/plugins/locomotive_media/editor_plugin.js +4 -1
  22. data/app/assets/stylesheets/locomotive/backoffice/codemirror_changes.css.scss +1 -0
  23. data/app/assets/stylesheets/locomotive/backoffice/datepicker.css.scss +1 -1
  24. data/app/assets/stylesheets/locomotive/backoffice/dialog_changes.css.scss +9 -3
  25. data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +3 -1
  26. data/app/cells/locomotive/global_actions_cell.rb +1 -1
  27. data/app/controllers/locomotive/api/base_controller.rb +7 -4
  28. data/app/controllers/locomotive/api/content_assets_controller.rb +13 -0
  29. data/app/controllers/locomotive/api/content_types_controller.rb +14 -1
  30. data/app/controllers/locomotive/api/current_site_controller.rb +3 -1
  31. data/app/controllers/locomotive/api/memberships_controller.rb +49 -0
  32. data/app/controllers/locomotive/api/pages_controller.rb +14 -1
  33. data/app/controllers/locomotive/api/sites_controller.rb +44 -0
  34. data/app/controllers/locomotive/api/snippets_controller.rb +14 -1
  35. data/app/controllers/locomotive/api/theme_assets_controller.rb +13 -0
  36. data/app/controllers/locomotive/public/content_entries_controller.rb +7 -3
  37. data/app/helpers/locomotive/content_types_helper.rb +4 -0
  38. data/app/helpers/locomotive/custom_fields_helper.rb +1 -1
  39. data/app/models/locomotive/ability.rb +2 -0
  40. data/app/models/locomotive/content_entry.rb +4 -2
  41. data/app/models/locomotive/content_type.rb +7 -0
  42. data/app/models/locomotive/extensions/content_type/default_values.rb +1 -1
  43. data/app/models/locomotive/extensions/page/redirect.rb +1 -1
  44. data/app/models/locomotive/extensions/page/tree.rb +14 -1
  45. data/app/models/locomotive/site.rb +5 -1
  46. data/app/models/locomotive/theme_asset.rb +1 -1
  47. data/app/presenters/locomotive/membership_presenter.rb +7 -2
  48. data/app/presenters/locomotive/site_presenter.rb +5 -0
  49. data/app/views/locomotive/content_assets/_picker.html.haml +3 -3
  50. data/app/views/locomotive/content_entries/_form.html.haml +1 -1
  51. data/app/views/locomotive/content_types/_form.html.haml +2 -2
  52. data/app/views/locomotive/current_site/_form.html.haml +1 -1
  53. data/app/views/locomotive/custom_fields/types/_many_to_many.html.haml +5 -5
  54. data/app/views/locomotive/my_account/edit.html.haml +1 -1
  55. data/app/views/locomotive/pages/_form.html.haml +1 -1
  56. data/app/views/locomotive/public/pages/show_toolbar.html.haml +2 -2
  57. data/app/views/locomotive/public/sitemaps/show.xml.builder +2 -2
  58. data/app/views/locomotive/shared/_form_actions.html.haml +1 -1
  59. data/app/views/locomotive/shared/_head.html.haml +2 -2
  60. data/app/views/locomotive/snippets/_form.html.haml +1 -1
  61. data/app/views/locomotive/theme_assets/_form.html.haml +1 -1
  62. data/app/views/locomotive/theme_assets/index.html.haml +5 -5
  63. data/config/locales/admin_ui.de.yml +37 -31
  64. data/config/locales/admin_ui.en.yml +1 -1
  65. data/config/locales/admin_ui.es.yml +2 -1
  66. data/config/locales/admin_ui.fr.yml +1 -1
  67. data/config/locales/admin_ui.it.yml +2 -1
  68. data/config/locales/{admin_ui.no.yml → admin_ui.nb.yml} +72 -55
  69. data/config/locales/admin_ui.nl.yml +2 -1
  70. data/config/locales/admin_ui.pt-BR.yml +2 -1
  71. data/config/locales/admin_ui.ru.yml +1 -1
  72. data/config/locales/{carrierwave.no.yml → carrierwave.nb.yml} +1 -1
  73. data/config/locales/default.de.yml +13 -3
  74. data/config/locales/default.en.yml +5 -0
  75. data/config/locales/default.fr.yml +4 -0
  76. data/config/locales/{default.no.yml → default.nb.yml} +43 -1
  77. data/config/locales/{devise.no.yml → devise.nb.yml} +9 -9
  78. data/config/locales/{flash.no.yml → flash.nb.yml} +1 -1
  79. data/config/locales/{formtastic.no.yml → formtastic.nb.yml} +21 -17
  80. data/config/routes.rb +4 -0
  81. data/lib/generators/locomotive/install/templates/locomotive.rb +9 -2
  82. data/lib/locomotive.rb +1 -0
  83. data/lib/locomotive/configuration.rb +4 -3
  84. data/lib/locomotive/custom_fields.rb +2 -0
  85. data/lib/locomotive/liquid/drops/page.rb +1 -1
  86. data/lib/locomotive/liquid/tags/csrf.rb +40 -0
  87. data/lib/locomotive/liquid/tags/extends.rb +3 -9
  88. data/lib/locomotive/liquid/tags/nav.rb +8 -8
  89. data/lib/locomotive/mongoid/patches.rb +54 -9
  90. data/lib/locomotive/rails.rb +1 -0
  91. data/lib/locomotive/rails/action_view.rb +9 -0
  92. data/lib/locomotive/render.rb +4 -4
  93. data/lib/locomotive/version.rb +1 -1
  94. data/vendor/assets/javascripts/locomotive/backbone.modelbinding.js +13 -4
  95. metadata +259 -95
@@ -43,13 +43,16 @@
43
43
  'collection': new Locomotive.Models.ContentAssetsCollection()
44
44
  });
45
45
 
46
+ view.render();
47
+
46
48
  // Register commands
47
49
  ed.addCommand('locomotiveMedia', function() {
48
50
  view.options.on_select = function(asset) {
49
51
  insertImage(ed, asset);
50
52
  view.close();
51
53
  }
52
- view.render();
54
+
55
+ view.fetch_assets();
53
56
  });
54
57
 
55
58
  // Register buttons
@@ -7,6 +7,7 @@
7
7
 
8
8
  font-size: 13px;
9
9
  font-weight: normal;
10
+ line-height: 15px;
10
11
 
11
12
  @include background-image(linear-gradient(top, #f0f0f0, #f9f9f9 4px, #f9f9f9 4px, #ffffff 12px, #ffffff));
12
13
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  width: auto;
10
10
 
11
- z-index: 999 !important;
11
+ z-index: 1001 !important;
12
12
 
13
13
  background: #f1f1f1;
14
14
 
@@ -60,7 +60,7 @@
60
60
 
61
61
  .ui-dialog-content {
62
62
  position: relative;
63
- z-index: 999;
63
+ z-index: 1200;
64
64
 
65
65
  text-align: left;
66
66
 
@@ -84,6 +84,12 @@
84
84
  width: 530px;
85
85
  }
86
86
  } // li.string
87
+
88
+ li.date {
89
+ input[type=text] {
90
+ width: 90px;
91
+ }
92
+ } // li.string
87
93
  }
88
94
  }
89
95
  } // .form.formtastic
@@ -118,14 +124,14 @@
118
124
  top: 8px;
119
125
  right: 10px;
120
126
 
121
- z-index: 1003;
127
+ z-index: 1203;
122
128
 
123
129
  a, input[type=submit] {
124
130
  @include light-button;
125
131
  }
126
132
 
127
133
  input[type=file] {
128
- z-index: 1003;
134
+ z-index: 1203;
129
135
  }
130
136
 
131
137
  } // .button-wrapper
@@ -421,8 +421,10 @@ form.formtastic {
421
421
  }
422
422
 
423
423
  &.no-label {
424
+ padding-top: 12px;
425
+
424
426
  > textarea, .CodeMirror, .CodeMirror-scroll {
425
- margin-top: 12px;
427
+ margin-top: 0px;
426
428
  width: 868px;
427
429
  }
428
430
  }
@@ -24,7 +24,7 @@ module Locomotive
24
24
  add :switch, :url => '#', :id => 'sites-picker-link'
25
25
  end
26
26
 
27
- add :help, :url => '#', :class => 'tutorial', :id => 'help'
27
+ add :help, :url => 'http://doc.locomotivecms.com/templates/basics', :class => 'tutorial', :id => 'help'
28
28
  add :logout, :url => destroy_locomotive_session_url, :confirm => t('locomotive.messages.confirm'), :method => :delete
29
29
  end
30
30
 
@@ -7,15 +7,13 @@ module Locomotive
7
7
 
8
8
  skip_before_filter :verify_authenticity_token
9
9
 
10
- skip_load_and_authorize_resource
11
-
12
10
  before_filter :require_account
13
11
 
14
12
  before_filter :require_site
15
13
 
16
14
  before_filter :set_locale
17
15
 
18
- # before_filter :validate_site_membership
16
+ before_filter :set_current_thread_variables
19
17
 
20
18
  self.responder = Locomotive::ActionController::Responder # custom responder
21
19
 
@@ -23,6 +21,11 @@ module Locomotive
23
21
 
24
22
  protected
25
23
 
24
+ def set_current_thread_variables
25
+ Thread.current[:account] = current_locomotive_account
26
+ Thread.current[:site] = current_site
27
+ end
28
+
26
29
  def current_ability
27
30
  @current_ability ||= Ability.new(current_locomotive_account, current_site)
28
31
  end
@@ -40,4 +43,4 @@ module Locomotive
40
43
 
41
44
  end
42
45
  end
43
- end
46
+ end
@@ -2,11 +2,18 @@ module Locomotive
2
2
  module Api
3
3
  class ContentAssetsController < BaseController
4
4
 
5
+ load_and_authorize_resource :class => Locomotive::ContentAsset
6
+
5
7
  def index
6
8
  @content_assets = current_site.content_assets
7
9
  respond_with(@content_assets)
8
10
  end
9
11
 
12
+ def show
13
+ @content_asset = current_site.content_assets.find(params[:id])
14
+ respond_with(@content_asset)
15
+ end
16
+
10
17
  def create
11
18
  @content_asset = current_site.content_assets.create(params[:content_asset])
12
19
  respond_with @content_asset, :location => main_app.locomotive_api_content_assets_url
@@ -18,6 +25,12 @@ module Locomotive
18
25
  respond_with @content_asset, :location => main_app.locomotive_api_content_assets_url
19
26
  end
20
27
 
28
+ def destroy
29
+ @content_asset = current_site.content_assets.find(params[:id])
30
+ @content_asset.destroy
31
+ respond_with @content_asset
32
+ end
33
+
21
34
  end
22
35
  end
23
36
  end
@@ -2,11 +2,18 @@ module Locomotive
2
2
  module Api
3
3
  class ContentTypesController < BaseController
4
4
 
5
+ load_and_authorize_resource :class => Locomotive::ContentType
6
+
5
7
  def index
6
- @content_types = current_site.content_types
8
+ @content_types = current_site.content_types.order_by([[:name, :asc]])
7
9
  respond_with(@content_types)
8
10
  end
9
11
 
12
+ def show
13
+ @content_type = current_site.content_types.find(params[:id])
14
+ respond_with @content_type
15
+ end
16
+
10
17
  def create
11
18
  @content_type = current_site.content_types.create(params[:content_type])
12
19
  respond_with @content_type, :location => main_app.locomotive_api_content_types_url
@@ -18,6 +25,12 @@ module Locomotive
18
25
  respond_with @content_type, :location => main_app.locomotive_api_content_types_url
19
26
  end
20
27
 
28
+ def destroy
29
+ @content_type = current_site.content_types.find(params[:id])
30
+ @content_type.destroy
31
+ respond_with @content_type
32
+ end
33
+
21
34
  end
22
35
  end
23
36
  end
@@ -3,7 +3,9 @@ module Locomotive
3
3
  class CurrentSiteController < BaseController
4
4
 
5
5
  def show
6
- respond_with(current_site)
6
+ @site = current_site
7
+ authorize! :show, @site
8
+ respond_with(@site)
7
9
  end
8
10
 
9
11
  end
@@ -0,0 +1,49 @@
1
+ module Locomotive
2
+ module Api
3
+ class MembershipsController < BaseController
4
+
5
+ # It's an embedded document, so we'll just load manually
6
+ before_filter :load_membership, :only => [ :show, :update, :destroy ]
7
+ before_filter :load_memberships, :only => [ :index ]
8
+
9
+ authorize_resource :class => Locomotive::Membership
10
+
11
+ def index
12
+ respond_with(@memberships)
13
+ end
14
+
15
+ def show
16
+ respond_with(@membership)
17
+ end
18
+
19
+ def create
20
+ build_params = params[:membership].merge({ :role => 'author' }) # force author by default
21
+ @membership = current_site.memberships.create(build_params)
22
+ respond_with(@membership)
23
+ end
24
+
25
+ def update
26
+ @membership.update_attributes(params[:membership])
27
+ respond_with(@membership)
28
+ end
29
+
30
+ def destroy
31
+ @membership.destroy
32
+ respond_with(@membership)
33
+ end
34
+
35
+ protected
36
+
37
+ def load_membership
38
+ @membership ||= load_memberships.find(params[:id])
39
+ end
40
+
41
+ def load_memberships
42
+ @memberships ||= current_site.memberships
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
49
+
@@ -2,11 +2,18 @@ module Locomotive
2
2
  module Api
3
3
  class PagesController < BaseController
4
4
 
5
+ load_and_authorize_resource :class => Locomotive::Page
6
+
5
7
  def index
6
- @pages = current_site.pages.all
8
+ @pages = current_site.pages.order_by([[:depth, :asc], [:position, :asc]])
7
9
  respond_with(@pages)
8
10
  end
9
11
 
12
+ def show
13
+ @page = current_site.pages.find(params[:id])
14
+ respond_with(@page)
15
+ end
16
+
10
17
  def create
11
18
  @page = current_site.pages.create(params[:page])
12
19
  respond_with @page, :location => main_app.locomotive_api_pages_url
@@ -18,6 +25,12 @@ module Locomotive
18
25
  respond_with @page, :location => main_app.locomotive_api_pages_url
19
26
  end
20
27
 
28
+ def destroy
29
+ @page = current_site.pages.find(params[:id])
30
+ @page.destroy
31
+ respond_with @page
32
+ end
33
+
21
34
  end
22
35
 
23
36
  end
@@ -0,0 +1,44 @@
1
+ module Locomotive
2
+ module Api
3
+ class SitesController < BaseController
4
+
5
+ load_and_authorize_resource :class => Locomotive::Site
6
+
7
+ # FIXME: the auto-loaded site won't pass authorization for show, update, or destroy
8
+ skip_load_and_authorize_resource :only => [ :show, :update, :destroy ]
9
+
10
+ def index
11
+ @sites = Locomotive::Site.all
12
+ respond_with(@sites)
13
+ end
14
+
15
+ def show
16
+ @site = Locomotive::Site.find(params[:id])
17
+ authorize! :show, @site
18
+ respond_with(@site)
19
+ end
20
+
21
+ def create
22
+ @site = Locomotive::Site.create(params[:site])
23
+ respond_with(@site)
24
+ end
25
+
26
+ def update
27
+ @site = Locomotive::Site.find(params[:id])
28
+ authorize! :update, @site
29
+ @site.update_attributes(params[:site])
30
+ respond_with @site
31
+ end
32
+
33
+ def destroy
34
+ @site = Locomotive::Site.find(params[:id])
35
+ authorize! :destroy, @site
36
+ @site.destroy
37
+ respond_with @site
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+
@@ -2,11 +2,18 @@ module Locomotive
2
2
  module Api
3
3
  class SnippetsController < BaseController
4
4
 
5
+ load_and_authorize_resource :class => Locomotive::Snippet
6
+
5
7
  def index
6
- @snippets = current_site.snippets.all
8
+ @snippets = current_site.snippets.order_by([[:name, :asc]])
7
9
  respond_with(@snippets)
8
10
  end
9
11
 
12
+ def show
13
+ @snippet = current_site.snippets.find(params[:id])
14
+ respond_with @snippet
15
+ end
16
+
10
17
  def create
11
18
  @snippet = current_site.snippets.create(params[:snippet])
12
19
  respond_with @snippet, :location => main_app.locomotive_api_snippets_url
@@ -18,6 +25,12 @@ module Locomotive
18
25
  respond_with @snippet, :location => main_app.locomotive_api_snippets_url
19
26
  end
20
27
 
28
+ def destroy
29
+ @snippet = current_site.snippets.find(params[:id])
30
+ @snippet.destroy
31
+ respond_with @snippet
32
+ end
33
+
21
34
  end
22
35
  end
23
36
  end
@@ -2,11 +2,18 @@ module Locomotive
2
2
  module Api
3
3
  class ThemeAssetsController < BaseController
4
4
 
5
+ load_and_authorize_resource :class => Locomotive::ThemeAsset
6
+
5
7
  def index
6
8
  @theme_assets = current_site.theme_assets.all
7
9
  respond_with(@theme_assets)
8
10
  end
9
11
 
12
+ def show
13
+ @theme_asset = current_site.theme_assets.find(params[:id])
14
+ respond_with @theme_asset
15
+ end
16
+
10
17
  def create
11
18
  @theme_asset = current_site.theme_assets.create(params[:theme_asset])
12
19
  respond_with @theme_asset, :location => main_app.locomotive_api_theme_assets_url
@@ -18,6 +25,12 @@ module Locomotive
18
25
  respond_with @theme_asset, :location => main_app.locomotive_api_theme_assets_url
19
26
  end
20
27
 
28
+ def destroy
29
+ @theme_asset = current_site.theme_assets.find(params[:id])
30
+ @theme_asset.destroy
31
+ respond_with @theme_asset
32
+ end
33
+
21
34
  end
22
35
  end
23
36
  end
@@ -6,8 +6,6 @@ module Locomotive
6
6
 
7
7
  before_filter :sanitize_entry_params, :only => :create
8
8
 
9
- skip_before_filter :verify_authenticity_token
10
-
11
9
  skip_load_and_authorize_resource
12
10
 
13
11
  self.responder = Locomotive::ActionController::PublicResponder # custom responder
@@ -17,7 +15,6 @@ module Locomotive
17
15
  def create
18
16
  @entry = @content_type.entries.create(params[:entry] || params[:content])
19
17
  flash[@content_type.slug.singularize] = @entry.to_presenter(:include_errors => true).as_json
20
- Rails.logger.debug @entry.to_presenter(:include_errors => true).as_json
21
18
  respond_with @entry, :location => self.callback_url
22
19
  end
23
20
 
@@ -48,6 +45,13 @@ module Locomotive
48
45
  end
49
46
  end
50
47
 
48
+ def handle_unverified_request
49
+ if Locomotive.config.csrf_protection
50
+ reset_session
51
+ redirect_to '/', :status => 302
52
+ end
53
+ end
54
+
51
55
  end
52
56
  end
53
57
  end
@@ -27,6 +27,10 @@ module Locomotive
27
27
  end
28
28
 
29
29
  visible << content_type
30
+
31
+ end.each do |content_type|
32
+ # make sure to have a fresh copy of the content types because for now we don't have the full content types (ie: content_types.only(...))
33
+ ::Mongoid::IdentityMap.remove(content_type)
30
34
  end
31
35
 
32
36
  if visible.size > 0