scrivito_sdk 1.0.0 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +1 -1
  4. data/app/controllers/scrivito/legacy_redirect_controller.rb +11 -0
  5. data/app/controllers/scrivito/objs_controller.rb +15 -5
  6. data/app/controllers/scrivito/webservice_controller.rb +4 -3
  7. data/app/controllers/scrivito/workspaces_controller.rb +24 -29
  8. data/app/helpers/scrivito_helper.rb +82 -37
  9. data/app/views/scrivito/objs/binary_no_cache.json.jbuilder +1 -0
  10. data/app/views/scrivito/objs/search.json.jbuilder +5 -5
  11. data/app/views/scrivito/webservice/error.json.jbuilder +2 -2
  12. data/config/ca-bundle.crt +1 -1
  13. data/config/precedence_routes.rb +51 -48
  14. data/config/routes.rb +1 -14
  15. data/lib/assets/javascripts/scrivito_ui.js +2447 -266
  16. data/lib/assets/stylesheets/scrivito.css +1 -1
  17. data/lib/assets/stylesheets/scrivito_ui.css +1 -1
  18. data/lib/generators/scrivito/install/install_generator.rb +12 -0
  19. data/lib/generators/scrivito/install/templates/config/initializers/scrivito.rb +3 -0
  20. data/lib/scrivito/attribute_definition.rb +13 -1
  21. data/lib/scrivito/attribute_deserializer.rb +4 -4
  22. data/lib/scrivito/attribute_value_renderer.rb +79 -0
  23. data/lib/scrivito/backend/obj_data_cache.rb +15 -15
  24. data/lib/scrivito/backend/obj_data_from_rest.rb +1 -21
  25. data/lib/scrivito/backend/obj_query.rb +2 -2
  26. data/lib/scrivito/basic_obj.rb +17 -6
  27. data/lib/scrivito/binary.rb +13 -5
  28. data/lib/scrivito/cache/chainable.rb +10 -5
  29. data/lib/scrivito/cache/file_store.rb +4 -0
  30. data/lib/scrivito/cache/ram_store.rb +4 -0
  31. data/lib/scrivito/child_list_tag.rb +16 -14
  32. data/lib/scrivito/client_error.rb +10 -0
  33. data/lib/scrivito/cms_backend.rb +66 -291
  34. data/lib/scrivito/cms_data_cache.rb +7 -9
  35. data/lib/scrivito/cms_dispatch_controller.rb +1 -10
  36. data/lib/scrivito/cms_field_tag.rb +2 -1
  37. data/lib/scrivito/cms_rest_api.rb +2 -0
  38. data/lib/scrivito/cms_routing.rb +26 -22
  39. data/lib/scrivito/configuration.rb +38 -0
  40. data/lib/scrivito/connection_manager.rb +69 -0
  41. data/lib/scrivito/controller_actions.rb +2 -2
  42. data/lib/scrivito/controller_helper.rb +2 -2
  43. data/lib/scrivito/date_attribute.rb +4 -1
  44. data/lib/scrivito/deprecation.rb +5 -4
  45. data/lib/scrivito/editing_context.rb +2 -2
  46. data/lib/scrivito/errors.rb +17 -0
  47. data/lib/scrivito/image_tag.rb +2 -2
  48. data/lib/scrivito/link_parser.rb +10 -5
  49. data/lib/scrivito/meta_data_collection.rb +11 -0
  50. data/lib/scrivito/obj_collection.rb +1 -1
  51. data/lib/scrivito/obj_facet_value.rb +19 -7
  52. data/lib/scrivito/obj_params_parser.rb +43 -14
  53. data/lib/scrivito/obj_search_builder.rb +1 -2
  54. data/lib/scrivito/obj_search_enumerator/batch.rb +22 -0
  55. data/lib/scrivito/obj_search_enumerator/batch_iterator.rb +36 -0
  56. data/lib/scrivito/obj_search_enumerator/query_executor.rb +35 -0
  57. data/lib/scrivito/obj_search_enumerator.rb +218 -93
  58. data/lib/scrivito/obj_update_params_parser.rb +1 -0
  59. data/lib/scrivito/preset_routes.rb +25 -0
  60. data/lib/scrivito/revision.rb +13 -11
  61. data/lib/scrivito/route.rb +62 -0
  62. data/lib/scrivito/routing_extensions.rb +92 -0
  63. data/lib/scrivito/sdk_engine.rb +4 -0
  64. data/lib/scrivito/task.rb +77 -0
  65. data/lib/scrivito/type_computer.rb +3 -3
  66. data/lib/scrivito/ui_config.rb +4 -0
  67. data/lib/scrivito/user.rb +24 -18
  68. data/lib/scrivito/workspace/publish_checker.rb +2 -3
  69. data/lib/scrivito/workspace.rb +38 -6
  70. data/lib/scrivito/workspace_data.rb +0 -14
  71. metadata +14 -10
  72. data/lib/scrivito/content_service.rb +0 -121
  73. data/lib/scrivito/content_state.rb +0 -109
  74. data/lib/scrivito/content_state_caching.rb +0 -47
  75. data/lib/scrivito/content_state_visitor.rb +0 -19
  76. data/lib/scrivito/obj_data_from_service.rb +0 -63
  77. data/lib/scrivito/workspace_data_from_service.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0eb4d80674f7358857ae70658858582add7287a
4
- data.tar.gz: 40285d81b022ae837d5faf654813fe293045a96a
3
+ metadata.gz: 12a55c387b16a4a537845c0ef7d10d00b4c6bd4a
4
+ data.tar.gz: e79c326cc3f757de2d46b05d4287ab0548550aeb
5
5
  SHA512:
6
- metadata.gz: fef1e96a24e7dddf8f3cff047a346e876d4a2327aec887f56aa23cd9c4d198172523242ccf4517ef758403497166b309d112eb4974ae8950c01da4483f6e1cdb
7
- data.tar.gz: d8138405353535ff21989e5a14740e0ecd7b95e4081fcb2a796e157a97603e89fb80512687eb99322a3828fdb420bf2bcf7cc30e823f0fcd46b760f9443aac32
6
+ metadata.gz: 1a9338acbdbd0901b6ed31bc8962c1278f9057c507f2af2791c83291de9480f0d8230fb58acd1c039753a34ab18fd5a2033c39676f67d09ba0205b9c92b7e4e0
7
+ data.tar.gz: cd8ba88553f5bf4a3974a7a1901391dda745100e3749b54801e3507825caa8e52817506fe0c3622f105363311db88841596a53c5df4e2b15a3ee88843750c0ff
data/.yardopts CHANGED
@@ -6,3 +6,4 @@
6
6
  --embed-mixin AttributeContent
7
7
  --embed-mixin Scrivito::AttributeContent::ClassMethods
8
8
  --exclude lib/scrivito/cms_dispatch_controller.rb
9
+ --exclude app/controllers/scrivito/legacy_redirect_controller.rb
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Scrivito SDK
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/scrivito_sdk.png)](http://badge.fury.io/rb/scrivito_sdk)
3
+ [![Gem Version](https://badge.fury.io/rb/scrivito_sdk.svg)](https://badge.fury.io/rb/scrivito_sdk)
4
4
 
5
5
  The Scrivito SDK makes CMS objects maintained by means of the cloud-based Scrivito CMS available
6
6
  to your Rails application. It offers easy-to-use functionality for rendering CMS content, doing
@@ -0,0 +1,11 @@
1
+ module Scrivito
2
+ class LegacyRedirectController < ActionController::Metal
3
+ include ActionController::Redirecting
4
+ include Rails.application.routes.url_helpers
5
+
6
+ def index
7
+ route = Route.find(_routes, :slug_id)
8
+ redirect_to route.generate_path(self, params.slice(:id, :slug).symbolize_keys)
9
+ end
10
+ end
11
+ end
@@ -35,8 +35,12 @@ module Scrivito
35
35
  params_parser = ObjCreateParamsParser.new(request.host, request.port)
36
36
  @obj = Obj.create(params_parser.parse(params[:obj]), scrivito_user: scrivito_user)
37
37
  render :obj
38
- rescue ObjClassNotFound
39
- head :not_found
38
+ rescue ObjClassNotFound => e
39
+ raise ClientError.new(
40
+ "You've tried to create a CMS object based on the \"#{e.message}\" class, which is "\
41
+ "either missing or not suitable for the object.",
42
+ 400
43
+ )
40
44
  end
41
45
 
42
46
  def details
@@ -48,14 +52,12 @@ module Scrivito
48
52
  params_parser = ObjUpdateParamsParser.new(request.host, request.port,
49
53
  current_obj: current_obj, scrivito_user: scrivito_user)
50
54
  current_obj.update(params_parser.parse(params[:obj]))
51
- rescue ObjClassNotFound
52
- head :not_found
53
55
  end
54
56
 
55
57
  def destroy
56
58
  in_selected_workspace do
57
59
  parent = current_obj.parent
58
- @redirect_to = parent ? scrivito_path(parent) : scrivito_root_path
60
+ @redirect_to = parent ? scrivito_path(parent) : "/"
59
61
  current_obj.destroy
60
62
  end
61
63
  end
@@ -94,6 +96,13 @@ module Scrivito
94
96
  in_selected_workspace { @is_outdated = current_obj.outdated? }
95
97
  end
96
98
 
99
+ def binary_no_cache
100
+ in_selected_workspace do
101
+ binary = current_obj[params[:attribute_name]]
102
+ @no_cache_url = binary.no_cache_url
103
+ end
104
+ end
105
+
97
106
  def mark_resolved
98
107
  in_selected_workspace { current_obj.mark_resolved }
99
108
  render_empty_json
@@ -158,6 +167,7 @@ module Scrivito
158
167
  return render action: 'search/facet'
159
168
  end
160
169
 
170
+ @batch = @enumerator.fetch_batch(params[:continuation])
161
171
  render :search
162
172
  end
163
173
  end
@@ -1,9 +1,10 @@
1
1
  module Scrivito
2
2
 
3
3
  class WebserviceController < ActionController::Base
4
- rescue_from ClientError do |exception|
5
- @exception = exception
6
- render 'scrivito/webservice/error', formats: :json, status: exception.http_code
4
+ rescue_from ApplicationError, ClientError, ResourceNotFound do |error|
5
+ @error = error
6
+ @timestamp = Time.zone.now
7
+ render 'scrivito/webservice/error', formats: :json, status: error.http_code
7
8
  end
8
9
 
9
10
  before_filter :merge_correctly_parsed_json_params
@@ -1,9 +1,20 @@
1
1
  module Scrivito
2
2
  class WorkspacesController < WebserviceController
3
- around_action :authorize_workspace_create, only: :create
4
- around_action :authorize_current_workspace_read, only: :show
5
- around_action :authorize_current_workspace_write, only: [:update, :destroy, :rebase]
6
- around_action :authorize_current_workspace_publish, only: [:check, :publish]
3
+ def self.restrict_access_to(action_name, require_permission:)
4
+ around_action only: action_name do |_, block|
5
+ subject = params.has_key?(:id) ? current_workspace : :workspace
6
+ authorize_workspace_access(require_permission, subject, &block)
7
+ end
8
+ end
9
+
10
+ restrict_access_to :create, require_permission: :create
11
+ restrict_access_to :show, require_permission: :read
12
+ restrict_access_to :rename, require_permission: :write
13
+ restrict_access_to :memberships, require_permission: :invite_to
14
+ restrict_access_to :destroy, require_permission: :delete
15
+ restrict_access_to :rebase, require_permission: :write
16
+ restrict_access_to :check, require_permission: :publish
17
+ restrict_access_to :publish, require_permission: :publish
7
18
 
8
19
  def index
9
20
  @workspaces = Workspace.all.select(&method(:can_user_read_workspace?))
@@ -25,8 +36,13 @@ module Scrivito
25
36
  end
26
37
  end
27
38
 
28
- def update
29
- current_workspace.update(workspace_params)
39
+ def rename
40
+ current_workspace.update(workspace_params.slice(:title))
41
+ render_empty_json
42
+ end
43
+
44
+ def memberships
45
+ current_workspace.update(workspace_params.slice(:memberships))
30
46
  render_empty_json
31
47
  end
32
48
 
@@ -65,9 +81,8 @@ module Scrivito
65
81
  end
66
82
 
67
83
  def conditional_publish
68
- task_unaware_request(:put, current_workspace_backend_path('/publish'), {
69
- if_content_state_id_equals: current_workspace.content_state.content_state_id
70
- })
84
+ task_unaware_request(:put, current_workspace_backend_path('/publish'),
85
+ if_content_state_id_equals: current_workspace.content_state_id)
71
86
  end
72
87
 
73
88
  def valid_publish_request?
@@ -78,26 +93,6 @@ module Scrivito
78
93
  Workspace::PublishChecker.new(current_workspace, scrivito_user)
79
94
  end
80
95
 
81
- def authorize_workspace_create(&block)
82
- authorize_workspace_access(:create, :workspace, &block)
83
- end
84
-
85
- def authorize_current_workspace_read(&block)
86
- authorize_current_workspace_access(:read, &block)
87
- end
88
-
89
- def authorize_current_workspace_write(&block)
90
- authorize_current_workspace_access(:write, &block)
91
- end
92
-
93
- def authorize_current_workspace_publish(&block)
94
- authorize_current_workspace_access(:publish, &block)
95
- end
96
-
97
- def authorize_current_workspace_access(verb, &block)
98
- authorize_workspace_access(verb, current_workspace, &block)
99
- end
100
-
101
96
  def current_workspace
102
97
  @current_workspace ||= Workspace.find(params[:id])
103
98
  end
@@ -75,39 +75,64 @@ module ScrivitoHelper
75
75
  )).render(html_options, &block)
76
76
  end
77
77
 
78
+ #
79
+ # Renders a navigation ready for in-place editing.
78
80
  #
79
81
  # @api public
80
82
  #
81
- # @param tag_name [String, Symbol] Name of the html tag (e.g. +:h1+ or +:div+).
82
- # @param obj [Scrivito::BasicObj] A {Scrivito::BasicObj} from which field_name is read.
83
- # @param field_name [String, Symbol] Which field_name of the Obj should be rendered. Currently
84
- # only +toclist+ is supported
85
- # @param options [Hash] Additional options, which are passed to +content_tag+. Use them to add
86
- # HTML attributes to the tag
83
+ # If a navigation is rendered using this helper method, a special menu is attached to it that lets
84
+ # you change the order of the child pages or insert a new child.
87
85
  #
88
- # @yieldparam [Scrivito::ChildListTag::ObjTag] list An instance, where +tag+ should be called once.
89
- # @yieldparam [Scrivito::BasicObj] child Each child of +toclist+
86
+ # For making the child pages sortable, the parent {Scrivito::BasicObj Obj} requires a
87
+ # +referencelist+ attribute named +child_order+. When creating a page model using the page
88
+ # generator, such an attribute is automatically added to the model.
90
89
  #
91
- # @return [String] The rendered html tag
90
+ # @param tag_name [String, Symbol] Name of the outer HTML tag (e.g. +:ul+ or +:div+).
91
+ # @param obj [Scrivito::BasicObj] The parent {Scrivito::BasicObj Obj}, on which +method_name+ will
92
+ # be called in order to fetch the children.
93
+ # @param method_name [String, Symbol] Name of the method to be called on the parent
94
+ # {Scrivito::BasicObj Obj} in order to fetch the children. Currently, only +toclist+ is
95
+ # supported.
96
+ # @param options [Hash] Options to be passed to +content_tag+. Use them to add HTML attributes to
97
+ # the tag.
92
98
  #
93
- # @example
94
- # scrivito_tag_list(:div, @obj, :toclist, class: "very_important") do |list, child|
95
- # list.tag(:div, class: "also_important") do
99
+ # @yieldparam [Scrivito::ChildListTag::ObjTag] list An object on which the
100
+ # {Scrivito::ChildListTag::ObjTag#tag tag} method should be called once per child to enable
101
+ # in-place editing.
102
+ # @yieldparam [Scrivito::BasicObj] child Each child of +toclist+.
103
+ #
104
+ # @return [String] The rendered HTML string.
105
+ #
106
+ # @see Scrivito::ChildListTag::ObjTag#tag
107
+ #
108
+ # @example Renders a navigation for an +@obj+ with two children in its +toclist+, whose titles are +"Toys"+ and +"Electronics"+ respectively:
109
+ # scrivito_tag_list(:ul, @obj, :toclist, class: "my_list") do |list, child|
110
+ # list.tag(:li, class: "my_list_element") do
96
111
  # link_to(scrivito_path(child)) do
97
112
  # scrivito_tag(:span, child, :title)
98
113
  # end
99
114
  # end
100
115
  # end
101
116
  #
102
- # # result for an obj with two children:
103
117
  # #
104
- # # <div class="very_important">
105
- # # <div class="also_important"><a href="/child1"><span>Child 1</span></a></div>
106
- # # <div class="also_important"><a href="/child2"><span>Child 2</span></a></div>
107
- # # </div>
118
+ # # Basically, the rendered HTML will look like this:
119
+ # #
120
+ # # <ul class="my_list">
121
+ # # <li class="my_list_element">
122
+ # # <a href="/toys-902b3e8d6ec861c1">
123
+ # # <span>Toys</span>
124
+ # # </a>
125
+ # # </li>
126
+ # # <li class="my_list_element">
127
+ # # <a href="/electronics-59c6995988ce78f4">
128
+ # # <span>Electronics</span>
129
+ # # </a>
130
+ # # </li>
131
+ # # </ul>
132
+ # #
108
133
  #
109
- def scrivito_tag_list(tag_name, obj, field_name, options = {}, &block)
110
- Scrivito::ChildListTag.new(tag_name, obj, field_name.to_s, self).render(options, &block)
134
+ def scrivito_tag_list(tag_name, obj, method_name, options = {}, &block)
135
+ Scrivito::ChildListTag.new(tag_name, obj, method_name.to_s, self).render(options, &block)
111
136
  end
112
137
 
113
138
  #
@@ -181,30 +206,29 @@ module ScrivitoHelper
181
206
  end
182
207
 
183
208
  #
184
- # Renders an attribute <em>value</em> of a CMS model.
209
+ # Renders an attribute value of a CMS model, taking its type into account.
185
210
  #
186
- # scrivito_value(@obj.title)
187
- # Renders the value, taking its type into account.
188
- # * An HtmlString will be exported by converting its links
189
- # * A Time will be exported in an international form: Year-Month-Day Hour:Minutes
190
- # * A non-HTML String will be quoted
191
- # * other values will be rendered unchanged
211
+ # @api public
192
212
  #
193
- # @note Content rendered using this method
194
- # will not be editable in the Scrivito UI.
195
- # If you want In-Place-Editing, use {ScrivitoHelper#scrivito_tag} instead.
213
+ # Links inside +html+ attributes are rendered using the routing of the application. Values from
214
+ # +string+ attributes are escaped. For other attribute types, a simple default representation is
215
+ # rendered.
196
216
  #
197
- # @api public
217
+ # @example
218
+ # scrivito_value(@obj.title)
219
+ #
220
+ # @note Content rendered using this method will not be editable in the Scrivito UI. If you want
221
+ # in-place editing, use {ScrivitoHelper#scrivito_tag} instead.
198
222
  #
199
223
  def scrivito_value(value)
224
+ renderer = Scrivito::AttributeValueRenderer.new(self)
225
+
200
226
  case value
201
- when Scrivito::HtmlString
202
- Scrivito::CmsRouting.new(request, main_app, scrivito_engine).convert_links(value).html_safe
203
- when String then h(value)
204
- when Time then h(l(value))
205
- when Scrivito::BasicWidget
206
- render(template: value.show_view_path, locals: {widget: value})
207
- else value
227
+ when Scrivito::BasicWidget then render(template: value.show_view_path, locals: {widget: value})
228
+ when Scrivito::HtmlString then renderer.render_as_html(value)
229
+ when String then renderer.render_as_string(value)
230
+ when Time then renderer.render_as_date(value)
231
+ else value
208
232
  end
209
233
  end
210
234
 
@@ -398,4 +422,25 @@ module ScrivitoHelper
398
422
  Please use helper method `scrivito_user` instead.
399
423
  }
400
424
  end
425
+
426
+ # @api public
427
+ #
428
+ # This method wraps Rails' built-in fragment caching to work with content delivered by Scrivito.
429
+ # Fragment caching applies to computed parts of views and helps to improve performance. The
430
+ # Rails guides provide an excellent introduction to caching if you haven't used it yet.
431
+ #
432
+ # The +scrivito_cache+ method extends built-in fragment caching so that cached
433
+ # parts of a view are automatically recomputed when Scrivito content changes. The
434
+ # fragments are only cached for the published content. In editable working copies
435
+ # no caching takes place, and the fragments are computed for every request.
436
+ #
437
+ # @param key [String] a name describing the data to be cached.
438
+ # @param options [Hash] a hash that enables further configuration of the fragment
439
+ # cache. The options are passed to the +cache+ helper of Rails. See the Rails
440
+ # {http://api.rubyonrails.org/classes/ActionView/Helpers/CacheHelper.html#method-i-cache documentation}
441
+ # for details.
442
+ def scrivito_cache(key, options=nil, &block)
443
+ workspace = Scrivito::Workspace.current
444
+ cache_if(workspace.published?, [workspace.cache_key, key], options, &block)
445
+ end
401
446
  end
@@ -0,0 +1 @@
1
+ json.no_cache_url @no_cache_url
@@ -1,6 +1,6 @@
1
- json.total @enumerator.size
2
- json.hits do
3
- json.merge!(@enumerator.load_batch.map { |obj|
4
- @formatter.call(obj, scrivito_user, controller.view_context)
5
- })
1
+ json.total @batch.total
2
+ json.continuation @batch.continuation
3
+ json.hits @batch.objs do |obj|
4
+ json.id obj.id
5
+ json.serialized_obj @formatter.call(obj, scrivito_user, controller.view_context)
6
6
  end
@@ -1,2 +1,2 @@
1
- json.error @exception.message
2
- json.code @exception.backend_code
1
+ json.merge! @error.as_json
2
+ json.timestamp @timestamp.to_s
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: Mon Dec 7 13:17:14 2015
4
+ ## Certificate data from Mozilla as of: Fri Jan 8 14:27:07 2016
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
@@ -3,64 +3,67 @@ Rails.application.routes.draw do
3
3
  end
4
4
 
5
5
  Scrivito::SdkEngine.routes.draw do
6
- resources :objs, controller: 'scrivito/objs', path: '__scrivito/objs',
7
- only: [:show, :create, :update, :destroy], defaults: {format: :json} do
8
- collection do
9
- get :page_class_selection
10
- get :search
11
- end
12
-
13
- member do
14
- get :widget
15
- get :widget_class_selection
16
- get :widget_modification
17
- get :conflicting_workspaces
18
- get :is_outdated
6
+ get 'scrivito', to: 'scrivito/ui#index'
7
+ get 'scrivito/*application_path', to: 'scrivito/ui#index', format: false
19
8
 
20
- post :copy
21
- post :duplicate
9
+ scope '__scrivito', module: 'scrivito' do
10
+ get ':id', to: 'cms_dispatch#index', as: :base_id, constraints: {id: /\h{16}/}
22
11
 
23
- put :revert
24
- put :restore
25
- put :mark_resolved
26
- put :destroy_widget
27
- put :revert_widget
28
- put :restore_widget
29
- put :transfer_modifications
30
- end
31
- end
12
+ resources :objs, controller: 'objs', only: [:show, :create, :update, :destroy],
13
+ defaults: {format: :json} do
14
+ collection do
15
+ get :page_class_selection
16
+ get :search
17
+ end
32
18
 
33
- resources :tasks, controller: 'scrivito/tasks', path: '__scrivito/tasks', only: [:show],
34
- defaults: {format: :json}
19
+ member do
20
+ get :widget
21
+ get :widget_class_selection
22
+ get :widget_modification
23
+ get :conflicting_workspaces
24
+ get :is_outdated
25
+ get :binary_no_cache
35
26
 
36
- get '__scrivito/blobs/upload_permission' => 'scrivito/blobs#upload_permission',
37
- defaults: {format: :json}
38
- put '__scrivito/blobs/activate_upload' => 'scrivito/blobs#activate_upload',
39
- defaults: {format: :json}
27
+ post :copy
28
+ post :duplicate
40
29
 
41
- resources :workspaces,
42
- controller: 'scrivito/workspaces',
43
- path: '__scrivito/workspaces',
44
- only: [:index, :show, :create, :update, :destroy],
45
- defaults: {format: :json} do
46
- member do
47
- put :rebase
48
- put :publish
49
- get :check
30
+ put :revert
31
+ put :restore
32
+ put :mark_resolved
33
+ put :destroy_widget
34
+ put :revert_widget
35
+ put :restore_widget
36
+ put :transfer_modifications
50
37
  end
51
38
  end
52
39
 
53
- get '__scrivito/users/suggest' => 'scrivito/users#suggest', defaults: {format: :json}
54
- get '__scrivito/suggest_completion' => 'scrivito/completion#suggest', defaults: {format: :json}
40
+ resources :tasks, controller: 'tasks', only: [:show], defaults: {format: :json}
55
41
 
56
- get '__scrivito/render_widget/:id/show_widget/:widget_id' => 'scrivito/cms_dispatch#show_widget'
57
- get '__scrivito/render_widget/:id/widget_details/:widget_id' => 'scrivito/cms_dispatch#widget_details'
42
+ get 'blobs/upload_permission' => 'blobs#upload_permission', defaults: {format: :json}
43
+ put 'blobs/activate_upload' => 'blobs#activate_upload', defaults: {format: :json}
58
44
 
59
- get '__scrivito/page_details/:id' => 'scrivito/cms_dispatch#page_details'
60
- get '__scrivito/resource_details/:resource_id', to: 'scrivito/ui#index'
45
+ resources :workspaces,
46
+ controller: 'workspaces',
47
+ only: [:index, :show, :create, :destroy],
48
+ defaults: {format: :json} do
49
+ member do
50
+ put :rename
51
+ put :memberships
52
+ put :rebase
53
+ put :publish
54
+ get :check
55
+ end
56
+ end
61
57
 
62
- get '__scrivito/to_binary' => 'scrivito/binary_redirect#to_binary', as: :binary
58
+ get 'users/suggest' => 'users#suggest', defaults: {format: :json}
59
+ get 'suggest_completion' => 'completion#suggest', defaults: {format: :json}
63
60
 
64
- get 'scrivito', to: 'scrivito/ui#index'
65
- get 'scrivito/*application_path', to: 'scrivito/ui#index', format: false
61
+ get 'render_widget/:id/show_widget/:widget_id' => 'cms_dispatch#show_widget'
62
+ get 'render_widget/:id/widget_details/:widget_id' => 'cms_dispatch#widget_details'
63
+
64
+ get 'page_details/:id' => 'cms_dispatch#page_details'
65
+ get 'resource_details/:resource_id', to: 'ui#index'
66
+
67
+ get 'to_binary' => 'binary_redirect#to_binary', as: :binary
68
+ end
66
69
  end
data/config/routes.rb CHANGED
@@ -1,14 +1 @@
1
- Rails.application.routes.draw do
2
- match '/', via: :all, to: 'scrivito/cms_dispatch#index', as: :scrivito_root
3
-
4
- with_options via: :all, constraints: {id: /[0-9a-f]{16}/} do |proxy|
5
- proxy.match '(/)(*slug-):id', to: 'scrivito/cms_dispatch#index', as: :cms_id
6
- proxy.match ':id(/*slug)', to: 'scrivito/cms_dispatch#legacy', as: :cms_legacy_id
7
- end
8
-
9
- match '/*permalink',
10
- to: 'scrivito/cms_dispatch#index',
11
- as: :scrivito_permalink,
12
- format: false,
13
- via: :all
14
- end
1
+ Scrivito::PresetRoutes.install_into(Rails.application.routes)