Module: Scrivito
- Defined in:
- lib/scrivito_sdk.rb,
app/cms/scrivito/diff.rb,
app/cms/scrivito/link.rb,
app/cms/scrivito/task.rb,
app/cms/scrivito/user.rb,
app/cms/scrivito/cache.rb,
app/cms/scrivito/route.rb,
app/cms/scrivito/binary.rb,
app/cms/scrivito/cms_env.rb,
app/cms/scrivito/warning.rb,
app/cms/scrivito/gem_info.rb,
app/cms/scrivito/obj_data.rb,
app/cms/scrivito/revision.rb,
app/cms/scrivito/basic_obj.rb,
app/cms/scrivito/image_tag.rb,
app/cms/scrivito/ui_config.rb,
app/cms/scrivito/workspace.rb,
app/cms/scrivito/comparison.rb,
app/cms/scrivito/membership.rb,
app/cms/scrivito/migrations.rb,
app/cms/scrivito/sdk_engine.rb,
app/cms/scrivito/widget_tag.rb,
app/cms/scrivito/cms_backend.rb,
app/cms/scrivito/cms_routing.rb,
app/cms/scrivito/deprecation.rb,
app/cms/scrivito/html_string.rb,
app/cms/scrivito/layout_tags.rb,
app/cms/scrivito/link_parser.rb,
app/cms/scrivito/page_config.rb,
app/cms/scrivito/parent_path.rb,
app/cms/scrivito/associations.rb,
app/cms/scrivito/basic_widget.rb,
app/cms/scrivito/client_error.rb,
app/cms/scrivito/cms_rest_api.rb,
app/cms/scrivito/modification.rb,
app/cms/scrivito/tag_renderer.rb,
app/cms/scrivito/test_request.rb,
app/cms/scrivito/access_denied.rb,
app/cms/scrivito/backend/index.rb,
app/cms/scrivito/backend_error.rb,
app/cms/scrivito/cms_field_tag.rb,
app/cms/scrivito/configuration.rb,
app/cms/scrivito/future_binary.rb,
app/cms/scrivito/model_library.rb,
app/cms/scrivito/network_error.rb,
app/cms/scrivito/obj_ui_config.rb,
app/cms/scrivito/preset_routes.rb,
app/cms/scrivito/type_computer.rb,
app/cms/scrivito/binary_rewrite.rb,
app/cms/scrivito/binary_routing.rb,
app/cms/scrivito/child_list_tag.rb,
app/cms/scrivito/cms_data_cache.rb,
app/cms/scrivito/internal_error.rb,
app/cms/scrivito/log_subscriber.rb,
app/cms/scrivito/model_identity.rb,
app/cms/scrivito/obj_collection.rb,
app/cms/scrivito/scrivito_error.rb,
app/cms/scrivito/string_tagging.rb,
app/cms/scrivito/workspace_data.rb,
app/cms/scrivito/base_widget_tag.rb,
app/cms/scrivito/cache/chainable.rb,
app/cms/scrivito/cache/ram_store.rb,
app/cms/scrivito/date_conversion.rb,
app/cms/scrivito/editing_context.rb,
app/cms/scrivito/obj_facet_value.rb,
app/cms/scrivito/publish_ability.rb,
app/cms/scrivito/restriction_set.rb,
app/cms/scrivito/uploaded_binary.rb,
app/cms/scrivito/user_definition.rb,
app/cms/scrivito/backend/obj_load.rb,
app/cms/scrivito/cache/file_store.rb,
app/cms/scrivito/cache_middleware.rb,
app/cms/scrivito/class_collection.rb,
app/cms/scrivito/float_conversion.rb,
app/cms/scrivito/generator_helper.rb,
app/cms/scrivito/request_homepage.rb,
app/cms/scrivito/application_error.rb,
app/cms/scrivito/attribute_content.rb,
app/cms/scrivito/backend/obj_query.rb,
app/cms/scrivito/controller_helper.rb,
app/cms/scrivito/widget_collection.rb,
app/cms/scrivito/backend/base_index.rb,
app/cms/scrivito/backend/path_index.rb,
app/cms/scrivito/connection_manager.rb,
app/cms/scrivito/content_conversion.rb,
app/cms/scrivito/controller_actions.rb,
app/cms/scrivito/controller_runtime.rb,
app/cms/scrivito/dialog_size_helper.rb,
app/cms/scrivito/errored_widget_tag.rb,
app/cms/scrivito/integer_conversion.rb,
app/cms/scrivito/obj_data_from_hash.rb,
app/cms/scrivito/obj_search_builder.rb,
app/cms/scrivito/resource_not_found.rb,
app/cms/scrivito/routing_extensions.rb,
app/cms/scrivito/communication_error.rb,
app/cms/scrivito/migrations/migrator.rb,
app/cms/scrivito/obj_class_not_found.rb,
app/cms/scrivito/rate_limit_exceeded.rb,
app/cms/scrivito/attribute_definition.rb,
app/cms/scrivito/attribute_serializer.rb,
app/cms/scrivito/meta_data_collection.rb,
app/cms/scrivito/migrations/migration.rb,
app/cms/scrivito/transformation_error.rb,
app/cms/scrivito/binary_param_verifier.rb,
app/cms/scrivito/membership_collection.rb,
app/cms/scrivito/obj_search_enumerator.rb,
app/controllers/scrivito/ui_controller.rb,
app/cms/scrivito/attribute_deserializer.rb,
app/cms/scrivito/backend/obj_data_cache.rb,
app/cms/scrivito/migrations/cms_backend.rb,
app/cms/scrivito/backend/permalink_index.rb,
app/cms/scrivito/cache_garbage_collector.rb,
app/cms/scrivito/cms_rest_api/rate_limit.rb,
app/controllers/scrivito/objs_controller.rb,
app/cms/scrivito/attribute_value_renderer.rb,
app/cms/scrivito/obj_create_params_parser.rb,
app/controllers/scrivito/users_controller.rb,
app/cms/scrivito/backend/parent_path_index.rb,
app/cms/scrivito/migrations/workspace_lock.rb,
app/cms/scrivito/workspace/publish_checker.rb,
app/cms/scrivito/backend/content_state_node.rb,
app/cms/scrivito/backend/obj_data_from_rest.rb,
app/cms/scrivito/cms_rest_api/request_timer.rb,
app/cms/scrivito/editing_context_middleware.rb,
app/cms/scrivito/migrations/migration_store.rb,
lib/generators/scrivito/page/page_generator.rb,
app/cms/scrivito/client_attribute_serializer.rb,
app/cms/scrivito/obj_search_enumerator/batch.rb,
app/cms/scrivito/transformation_source_error.rb,
app/controllers/scrivito/sessions_controller.rb,
app/controllers/scrivito/obj_class_controller.rb,
app/cms/scrivito/cms_rest_api/widget_extractor.rb,
app/cms/scrivito/ui_obj_classes_json_formatter.rb,
app/controllers/scrivito/ui_configs_controller.rb,
app/controllers/scrivito/webservice_controller.rb,
app/controllers/scrivito/workspaces_controller.rb,
app/cms/scrivito/workspace_selection_middleware.rb,
app/controllers/scrivito/default_cms_controller.rb,
lib/generators/scrivito/widget/widget_generator.rb,
app/cms/scrivito/attribute_definition_collection.rb,
app/cms/scrivito/transformation_definition_error.rb,
app/controllers/scrivito/resolve_paths_controller.rb,
lib/generators/scrivito/install/install_generator.rb,
app/cms/scrivito/obj_search_enumerator/facet_query.rb,
app/controllers/scrivito/binary_redirect_controller.rb,
app/cms/scrivito/obj_search_enumerator/batch_iterator.rb,
app/cms/scrivito/obj_search_enumerator/query_executor.rb,
app/controllers/scrivito/publish_abilities_controller.rb,
lib/generators/scrivito/migration/migration_generator.rb,
app/cms/scrivito/disable_browser_cache_for_ui_middleware.rb
Defined Under Namespace
Modules: Associations, AttributeContent, BinaryRewrite, ControllerHelper, RoutingExtensions, TestRequest Classes: AttributeDefinition, AttributeDefinitionCollection, BasicObj, BasicWidget, Binary, CacheGarbageCollector, ClassCollection, Configuration, FutureBinary, Link, Membership, MembershipCollection, ModelLibrary, ObjClassNotFound, ObjCollection, ObjFacetValue, ObjSearchEnumerator, ResourceNotFound, ScrivitoError, TransformationDefinitionError, TransformationError, TransformationSourceError, User, UserDefinition, WidgetCollection, Workspace
Class Method Summary collapse
-
.configure {|Configuration| ... } ⇒ Object
Configures the Scrivito SDK.
-
.models ⇒ Object
Configures which classes Scrivito regards as CMS models.
Class Method Details
.configure {|Configuration| ... } ⇒ Object
Configures the Scrivito SDK. The tenant
and api_key
configuration keys must be provided.
15 16 17 |
# File 'lib/scrivito_sdk.rb', line 15 def self.configure yield Configuration end |
.models ⇒ Object
Configures which classes Scrivito regards as CMS models.
In order to provide access to CMS class details, Scrivito needs to know which CMS model classes are available. These models can be defined in the Rails application itself or in 3rd-party gems.
Scrivito assumes that all the classes descending from BasicObj, whose class names end with “Page” are pages (e.g. MyPage
, HomePage
, BlogPostPage
etc.) and all the classes descending from BasicWidget, whose class names end with “Widget” are widgets (e.g. TextWidget
, ImageWidget
etc.). It also assumes that all the classes descending from BasicObj, regardless of the class names, are CMS object models (e.g. all pages, but also Obj
, Image
, Download
etc.).
The loaded pages can be inspected with Scrivito.models.pages, which will return a ClassCollection containing the available pages and the loaded widgets can be inspected with Scrivito.models.widgets, which will return a ClassCollection containing the available widgets. All available CMS object models can be inspected with Scrivito.models.objs. The Scrivito.models.pages will also include the Page
model, if it is defined in page.rb
, and Scrivito.models.objs will include the Obj
model.
Scrivito recursively scans for CMS models in all directories from Scrivito.models.paths, which is an array of strings. By default, Scrivito includes the app/models
directory of the Rails application when searching for models. It will, for example, find the following page, widget and obj models:
app/models/my_page.rb
app/models/.rb
app/models/my_obj.rb
app/models/my_namespace/my_other_page.rb
app/models/my_namespace/.rb
app/models/my_namespace/my_other_obj.rb
app/models/my_namespace/my_other_namespace/my_other_special_page.rb
app/models/my_namespace/my_other_namespace/.rb
app/models/my_namespace/my_other_namespace/my_other_special_obj.rb
Also, Scrivito.models.paths includes all app/models
directories of any available Rails engine, provided that these directories are included in the autoload paths of Rails (which is the default). For example, it will find the following page, widget and obj models in an engine:
/../some_engine/app/models/my_page.rb
/../some_engine/app/models/my_widget.rb
/../some_engine/app/models/my_obj.rb
/../some_engine/app/models/my_namespace/my_other_page.rb
/../some_engine/app/models/my_namespace/my_other_widget.rb
/../some_engine/app/models/my_namespace/my_other_obj.rb
/../some_engine/app/models/my_namespace/my_other_namespace/my_other_special_page.rb
/../some_engine/app/models/my_namespace/my_other_namespace/my_other_special_widget.rb
/../some_engine/app/models/my_namespace/my_other_namespace/my_other_special_obj.rb
You can add custom directories to scan for models and register single page and widget models using Scrivito.models.define (see examples below).
The scan results are cached. If Rails.application.config.cache_classes
is false
, the cache is cleared on every request. Otherwise, the cache is kept between the requests. You can clear the cache using Scrivito.models.clear_cache.
136 137 138 |
# File 'lib/scrivito_sdk.rb', line 136 def self.models @models ||= ModelLibrary.new end |