scrivito_sdk 0.66.0 → 0.70.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/scrivito/blobs_controller.rb +5 -0
  3. data/app/controllers/scrivito/objs_controller.rb +2 -1
  4. data/app/controllers/scrivito/ui_controller.rb +33 -3
  5. data/app/helpers/scrivito_helper.rb +14 -20
  6. data/app/views/scrivito/objs/update.json.jbuilder +1 -1
  7. data/app/views/scrivito/ui/index.html.erb +1 -1
  8. data/app/views/scrivito/webservice/_workspace.json.jbuilder +2 -1
  9. data/config/ca-bundle.crt +1 -1
  10. data/config/precedence_routes.rb +3 -2
  11. data/lib/assets/javascripts/scrivito.js +46 -0
  12. data/lib/assets/javascripts/scrivito_ui.js +931 -501
  13. data/lib/assets/stylesheets/scrivito.css +1 -0
  14. data/lib/assets/stylesheets/scrivito_ui.css +1 -1
  15. data/lib/generators/scrivito/install/templates/app/views/page/index.html.erb +3 -3
  16. data/lib/generators/scrivito/page/page_generator.rb +3 -0
  17. data/lib/generators/scrivito/page/templates/model.erb +3 -0
  18. data/lib/generators/scrivito/widget/templates/model.erb +3 -0
  19. data/lib/generators/scrivito/widget/widget_generator.rb +3 -0
  20. data/lib/scrivito/attribute_content.rb +93 -60
  21. data/lib/scrivito/attribute_definition.rb +3 -3
  22. data/lib/scrivito/attribute_serializer.rb +2 -2
  23. data/lib/scrivito/backend/obj_data_cache.rb +22 -9
  24. data/lib/scrivito/basic_obj.rb +238 -130
  25. data/lib/scrivito/basic_widget.rb +32 -20
  26. data/lib/scrivito/binary.rb +74 -45
  27. data/lib/scrivito/binary_routing.rb +52 -0
  28. data/lib/scrivito/cache_middleware.rb +0 -5
  29. data/lib/scrivito/client_attribute_serializer.rb +134 -0
  30. data/lib/scrivito/cms_backend.rb +51 -33
  31. data/lib/scrivito/cms_data_cache.rb +1 -0
  32. data/lib/scrivito/cms_dispatch_controller.rb +1 -1
  33. data/lib/scrivito/cms_env.rb +1 -11
  34. data/lib/scrivito/cms_field_tag.rb +10 -7
  35. data/lib/scrivito/cms_rest_api/rate_limit.rb +5 -5
  36. data/lib/scrivito/cms_rest_api/request_timer.rb +27 -0
  37. data/lib/scrivito/cms_rest_api/widget_extractor.rb +8 -6
  38. data/lib/scrivito/cms_rest_api.rb +107 -54
  39. data/lib/scrivito/cms_routing.rb +13 -25
  40. data/lib/scrivito/configuration.rb +5 -2
  41. data/lib/scrivito/controller_actions.rb +68 -7
  42. data/lib/scrivito/controller_runtime.rb +8 -0
  43. data/lib/scrivito/date_attribute.rb +8 -0
  44. data/lib/scrivito/errors.rb +6 -3
  45. data/lib/scrivito/generator_helper.rb +13 -0
  46. data/lib/scrivito/image_tag.rb +24 -30
  47. data/lib/scrivito/layout_tags.rb +12 -6
  48. data/lib/scrivito/link.rb +46 -30
  49. data/lib/scrivito/log_subscriber.rb +15 -0
  50. data/lib/scrivito/membership.rb +3 -3
  51. data/lib/scrivito/membership_collection.rb +10 -10
  52. data/lib/scrivito/meta_data_collection.rb +22 -0
  53. data/lib/scrivito/model_library.rb +7 -1
  54. data/lib/scrivito/obj_collection.rb +18 -16
  55. data/lib/scrivito/obj_params_parser.rb +1 -1
  56. data/lib/scrivito/obj_search_enumerator.rb +35 -35
  57. data/lib/scrivito/page_config.rb +55 -0
  58. data/lib/scrivito/request_homepage.rb +23 -0
  59. data/lib/scrivito/routing_helper.rb +8 -8
  60. data/lib/scrivito/sdk_engine.rb +2 -3
  61. data/lib/scrivito/ui_config.rb +85 -0
  62. data/lib/scrivito/user.rb +30 -23
  63. data/lib/scrivito/user_definition.rb +48 -47
  64. data/lib/scrivito/widget_tag.rb +11 -0
  65. data/lib/scrivito/workspace.rb +93 -35
  66. data/lib/scrivito/workspace_selection_middleware.rb +8 -1
  67. data/lib/scrivito_sdk.rb +24 -24
  68. metadata +24 -33
  69. data/lib/assets/javascripts/scrivito_sdk.js +0 -57
  70. data/lib/assets/stylesheets/scrivito_sdk.css +0 -1
  71. data/lib/scrivito/client_config.rb +0 -113
  72. data/lib/scrivito/editing_context_helper.rb +0 -19
  73. data/lib/scrivito/named_link.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cdabe0c3d8f058d37b6ab909fce7231a616635f
4
- data.tar.gz: 251a1e0d3579e39d5fd8b752b2d0dba72e5a0570
3
+ metadata.gz: db9dbbb4e8e68455e0fe9b3bc987ac8034f36751
4
+ data.tar.gz: 05117844c6a7c272dd31645ee5cad9b374b5c661
5
5
  SHA512:
6
- metadata.gz: 5d90aaf3ad8fd408516d947f4fff7accbb1ee574c417c50ee588ffd39f7a11426e1d6609498cef4407c324e73f1507732f3297eb3b4ccc7f111ab18c1d6b207b
7
- data.tar.gz: 5d0c6ae6c502d9534a5908c7d728156864bf78cf852eb9de18cfc8194ac241204f19f0519474f32722fc884ce464dec1d102f8c4198fa040d0c3338f43415b87
6
+ metadata.gz: d6ba62c8a1296eedd929af7246b95df7bdbb8b770e81eebef8f049378d35b8a9efcdb6899f1b8d92f3ee2e5bc6c85feb5998c286d532500eb9b8f9e9ecbbd204
7
+ data.tar.gz: c5cd61adaa67b40927297df9283b38b919629bc0914be07244bc2f9ebb6bc86d2feac2d78ea8925c801cd12fe9783b240468af440d464557c82d0645cc2e15ad
@@ -4,6 +4,11 @@ class BlobsController < WebserviceController
4
4
  def upload_permission
5
5
  @permission = CmsRestApi.task_unaware_request(:get, 'blobs/upload_permission')
6
6
  end
7
+
8
+ def activate_upload
9
+ CmsRestApi.activate_upload(params.slice(:upload, :obj_id, :filename, :content_type))
10
+ render_empty_json
11
+ end
7
12
  end
8
13
 
9
14
  end
@@ -54,7 +54,8 @@ module Scrivito
54
54
 
55
55
  def destroy
56
56
  in_selected_workspace do
57
- @redirect_to = scrivito_path(current_obj.parent || Obj.homepage)
57
+ parent = current_obj.parent
58
+ @redirect_to = parent ? scrivito_path(parent) : scrivito_root_path
58
59
  current_obj.destroy
59
60
  end
60
61
  end
@@ -2,13 +2,43 @@ module Scrivito
2
2
 
3
3
  class UiController < ActionController::Base
4
4
  def index
5
+ @application_src = application_src
6
+ if editing_context.editor
7
+ @ui_config = UiConfig.new(
8
+ editing_context: editing_context,
9
+ resource: resource,
10
+ return_to: params[:return_to],
11
+ app_extension_tags: app_extension_tags,
12
+ ).to_json
13
+ else
14
+ redirect_to @application_src
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def application_src
21
+ return "/" if resource_details?
22
+
5
23
  given_query = request.env['QUERY_STRING']
6
24
  query = "?#{given_query}" if given_query.present?
7
- @application_src = "/#{params['application_path']}#{query}"
8
- redirect_to @application_src unless editing_context.editor
25
+ "/#{params['application_path']}#{query}"
9
26
  end
10
27
 
11
- private
28
+ def resource_details?
29
+ params[:resource_id].present?
30
+ end
31
+
32
+ def resource
33
+ if resource_details?
34
+ editing_context.selected_workspace.objs.find_including_deleted(params[:resource_id])
35
+ end
36
+ end
37
+
38
+ def app_extension_tags
39
+ view_context.javascript_include_tag('scrivito_app_extensions') +
40
+ view_context.stylesheet_link_tag('scrivito_app_extensions')
41
+ end
12
42
 
13
43
  def editing_context
14
44
  EditingContextMiddleware.from_request(request)
@@ -122,6 +122,9 @@ module ScrivitoHelper
122
122
  # @option editing_options [String] :placeholder ('/assets/scrivito/image_placeholder.png') URL
123
123
  # or path to image to be displayed if target is missing
124
124
  #
125
+ # @option editing_options [Hash] :transform if set, the displayed image will be transformed using
126
+ # the definition in the given hash, see {Scrivito::Binary#transform}.
127
+ #
125
128
  # @example
126
129
  # scrivito_image_tag(@obj, :my_linklist)
127
130
  # scrivito_image_tag(@obj, :my_linklist, alt: 'Interesting picture', class: 'my_image')
@@ -140,6 +143,9 @@ module ScrivitoHelper
140
143
  # @example Render an image tag for a binary Obj
141
144
  # scrivito_image_tag(@image)
142
145
  #
146
+ # @example Render an image tag with an on-the-fly calculated thumbnail
147
+ # scrivito_image_tag @obj, :my_binary, {}, transform: {width: 50, height: 50}
148
+ #
143
149
  # @return [String] HTML image tag
144
150
  #
145
151
  # @raise [ScrivitoError] if +field_name+ is not set and Obj is not binary
@@ -356,7 +362,7 @@ module ScrivitoHelper
356
362
  # @api public
357
363
  #
358
364
  def scrivito_body_tags
359
- Scrivito::LayoutTags.new(self).client_config(@obj, @scrivito_resource)
365
+ Scrivito::LayoutTags.new(self).page_config(@obj)
360
366
  end
361
367
 
362
368
  {
@@ -379,16 +385,11 @@ module ScrivitoHelper
379
385
  end
380
386
  end
381
387
 
382
- #
383
- # Returns the current user.
384
- #
385
388
  # @api public
386
- # @return [Scrivito::User] if the {Scrivito::Configuration.editing_auth} callback returns an
387
- # instance of {Scrivito::User}.
388
- # @return +nil+ otherwise.
389
- #
389
+ # @return [Scrivito::User, nil]
390
+ # See {Scrivito::ControllerActions#scrivito_user} for details.
390
391
  def scrivito_user
391
- Scrivito::EditingContextHelper.new(request).scrivito_user
392
+ Scrivito::EditingContextMiddleware.from_request(request).editor
392
393
  end
393
394
 
394
395
  def inplace_editing_allowed?
@@ -398,15 +399,8 @@ module ScrivitoHelper
398
399
  }
399
400
  end
400
401
 
401
- #
402
- # Returns whether the GUI is in the +editable+ view.
403
- #
404
- # @api public
405
- # @return +true+ if the current visitor is an authenticated editor, the selected workspace is
406
- # editable and the display mode is +editing+.
407
- # @return +false+ otherwise.
408
- #
409
- def scrivito_in_editable_view?
410
- Scrivito::EditingContextHelper.new(request).in_editable_view?
411
- end
402
+ # @!method scrivito_in_editable_view?
403
+ # @return [Boolean]
404
+ # See {Scrivito::ControllerActions#scrivito_in_editable_view?} for details.
405
+ # @api public
412
406
  end
@@ -1 +1 @@
1
- json.merge! current_obj.as_client_json
1
+ json.merge! Scrivito::ClientAttributeSerializer.serialize_obj(current_obj)
@@ -9,6 +9,6 @@
9
9
  </head>
10
10
  <body id="scrivito_ui">
11
11
  <iframe name="scrivito_application" src="<%= @application_src %>"></iframe>
12
- <%= scrivito_body_tags %>
12
+ <%= content_tag(:div, '', 'data-scrivito-private-ui-config' => @ui_config) %>
13
13
  </body>
14
14
  </html>
@@ -1,8 +1,9 @@
1
1
  json.extract! workspace, :id, :title
2
+ json.is_accessible can_user_read_workspace?(workspace)
2
3
 
3
4
  json.memberships workspace.memberships do |membership|
4
5
  json.extract! membership, :user_id, :role
5
6
  json.description membership.user.description
6
7
  end
7
8
 
8
- json.is_accessible can_user_read_workspace?(workspace)
9
+ json.outdated workspace.outdated?
data/config/ca-bundle.crt CHANGED
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Bundle of CA Root Certificates
3
3
  ##
4
- ## Certificate data from Mozilla as of: Wed Jul 22 11:23:10 2015
4
+ ## Certificate data from Mozilla as of: Wed Sep 2 13:20:26 2015
5
5
  ##
6
6
  ## This is a bundle of X.509 certificates of public Certificate Authorities
7
7
  ## (CA). These were automatically extracted from Mozilla's root certificates
@@ -34,6 +34,8 @@ Scrivito::SdkEngine.routes.draw do
34
34
 
35
35
  get '__scrivito/blobs/upload_permission' => 'scrivito/blobs#upload_permission',
36
36
  defaults: {format: :json}
37
+ put '__scrivito/blobs/activate_upload' => 'scrivito/blobs#activate_upload',
38
+ defaults: {format: :json}
37
39
 
38
40
  resources :workspaces,
39
41
  controller: 'scrivito/workspaces',
@@ -53,8 +55,7 @@ Scrivito::SdkEngine.routes.draw do
53
55
  get '__scrivito/render_widget/:id/widget_details/:widget_id' => 'scrivito/cms_dispatch#widget_details'
54
56
 
55
57
  get '__scrivito/page_details/:id' => 'scrivito/cms_dispatch#page_details'
56
-
57
- get '__scrivito/resource_details/:resource_id' => 'scrivito/cms_dispatch#resource_details'
58
+ get '__scrivito/resource_details/:resource_id', to: 'scrivito/ui#index'
58
59
 
59
60
  get '__scrivito/to_binary' => 'scrivito/binary_redirect#to_binary', as: :binary
60
61
 
@@ -0,0 +1,46 @@
1
+ (function() {
2
+ if (window.parent !== window) {
3
+ var scrivito_ui = window.parent.scrivito;
4
+ if (scrivito_ui) {
5
+ // In an iframe and parent window contains the UI: in UI mode.
6
+ var cms_document = scrivito_ui.cms_element.from_dom_element(document);
7
+ cms_document.install_public_api();
8
+ cms_document.add_app_extensions();
9
+
10
+ // wait for app to be fully loaded
11
+ document.addEventListener("DOMContentLoaded", function() {
12
+ // wait for UI to be fully loaded
13
+ scrivito_ui.on("load", function() {
14
+ cms_document.assert_user_logged_in();
15
+ cms_document.connect();
16
+ });
17
+ });
18
+ }
19
+ } else {
20
+ document.addEventListener("DOMContentLoaded", function() {
21
+ // Not in UI mode, but editing is allowed: redirect to the UI mode.
22
+ if (document.querySelector('[data-scrivito-private-page-config]')) {
23
+ console.log('Scrivito config found: redirecting to the UI...');
24
+ window.location = '/scrivito' +
25
+ window.location.pathname +
26
+ window.location.search +
27
+ window.location.hash;
28
+ }
29
+ });
30
+ }
31
+
32
+ // If the SDK is completely missing, the custom callbacks should nevertheless run.
33
+ if (!window.scrivito) {
34
+ window.scrivito = {
35
+ on: function(event_name, callback) {
36
+ if (event_name === 'content') {
37
+ document.addEventListener("DOMContentLoaded", function() {
38
+ callback(window.document);
39
+ });
40
+ }
41
+ },
42
+
43
+ in_editable_view: function() { return false; }
44
+ };
45
+ }
46
+ }());