lib/scrivito/configuration.rb in scrivito_sdk-0.16.0 vs lib/scrivito/configuration.rb in scrivito_sdk-0.17.0
- old
+ new
@@ -30,10 +30,12 @@
class << self
# Determine if current visitor is permitted to edit content.
attr_accessor :editing_auth_callback
+ attr_accessor :find_user_proc
+
# Configure a callback to be invoked when the Scrivito SDK determines,
# if current visitor is permitted to edit content.
# Default is <code>false</code>.
#
# Example Usage:
@@ -48,10 +50,38 @@
else
raise ArgumentError, 'editing_auth should have only one attribute!'
end
end
+ # Configures how to find users for the in-place GUI.
+ # @api public
+ # @param [Proc] find_user_proc proc for finding a user by the user id
+ # @yieldparam [String] user_id id of the user
+ # @yieldreturn [Scrivito::User] if the user with the given user id was found
+ # @yieldreturn [NilClass] if the user with the given user id was not found
+ # @raise [Scrivito::ScrivitoError] if the proc returns neither a {Scrivito::User}, nor +nil+
+ # @note This configuration key is optional. If it is not configured the in-place GUI would
+ # behave normally, but would not be able to find any users.
+ # @example Return a "dummy" {Scrivito::User}
+ # Scrivito.configure do |config|
+ # config.find_user do |user_id|
+ # Scrivito::User.new(user_id)
+ # end
+ # end
+ # @example Find the user with a custom user model and convert it to a {Scrivito::User}
+ # Scrivito.configure do |config|
+ # config.find_user do |user_id|
+ # my_user = MyUserModel.find(user_id)
+ # if my_user
+ # my_user.to_scrivito_user
+ # end
+ # end
+ # end
+ def find_user(&find_user_proc)
+ self.find_user_proc = find_user_proc
+ end
+
# TODO: Legacy compatiblity. Remove when DisplayHelper gets removed.
def editor_interface_enabled?
false
end
@@ -148,11 +178,11 @@
self.ca_file = DEFAULT_CA_FILE
self.editing_auth { |env| false }
self.endpoint = 'api.scrivito.com'
end
- attr_accessor :choose_homepage_callback
+ attr_accessor :choose_homepage_callback, :activate_users_and_permissions
# Configure a callback to be invoked when the Scrivito SDK delivers the homepage.
# The given callback will receive the rack env
# and must return an {BasicObj Obj} to be used as the homepage.
# If no callback is configured, {BasicObj.homepage Obj.homepage} will be used as the default.
@@ -173,10 +203,10 @@
' config.action_dispatch.x_sendfile_header = "X-Sendfile"'
end
def obj_formats
@obj_formats ||= {
- '_changes_list' => proc do |obj|
+ '_default' => proc do |obj|
{
id: obj.id,
obj_class_name: obj.obj_class_name,
description_for_editor: obj.description_for_editor,
modification: obj.modification,