lib/wcc/contentful/configuration.rb in wcc-contentful-1.4.0 vs lib/wcc/contentful/configuration.rb in wcc-contentful-1.5.0.rc1
- old
+ new
@@ -12,10 +12,11 @@
environment
instrumentation_adapter
logger
management_token
preview_token
+ rich_text_renderer
schema_file
space
store
sync_retry_limit
sync_retry_wait
@@ -75,10 +76,16 @@
# Each subsequent retry uses an exponential backoff, so the second retry will be
# after (2 * sync_retry_wait), the third after (4 * sync_retry_wait), etc.
# Default: 2.seconds
attr_accessor :sync_retry_wait
+ # Sets the rich text renderer implementation. This must be a class that accepts a WCC::Contentful::RichText::Document
+ # in the constructor, and responds to `:call` with a string containing the HTML.
+ # In a Rails context, the implementation defaults to WCC::Contentful::ActionViewRichTextRenderer.
+ # In a non-Rails context, you must provide your own implementation.
+ attr_accessor :rich_text_renderer
+
# Returns true if the currently configured environment is pointing at `master`.
def master?
!environment.present?
end
@@ -202,9 +209,15 @@
preview_api_url: 'https://preview.contentful.com/',
management_api_url: 'https://api.contentful.com'
}
@management_token = ENV.fetch('CONTENTFUL_MANAGEMENT_TOKEN', nil)
@preview_token = ENV.fetch('CONTENTFUL_PREVIEW_TOKEN', nil)
+
+ if defined?(ActionView)
+ require 'wcc/contentful/action_view_rich_text_renderer'
+ @rich_text_renderer = WCC::Contentful::ActionViewRichTextRenderer
+ end
+
@space = ENV.fetch('CONTENTFUL_SPACE_ID', nil)
@default_locale = 'en-US'
@locale_fallbacks = {}
@middleware = []
@update_schema_file = :if_possible