Class: Pageflow::Chart::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/chart/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/pageflow/chart/configuration.rb', line 56

def initialize
  @scraper_options = {
    head_script_blacklist: [/piwik/],
    body_script_blacklist: [/piwik/],
    inline_script_blacklist: [/piwik/],
    selector_blacklist: ['body .noscript']
  }
  @paperclip_s3_default_options = {}
  @paperclip_base_path = ':pageflow_s3_root'
  @scraped_sites_root_url = nil
  @supported_hosts = [
    'cf.datawrapper.de',
    'charts.datawrapper.de',
    'datawrapper.dwcdn.de',
    'datawrapper.dwcdn.net'
  ]
  @use_custom_theme = false
  @datawrapper_themes_with_transparent_background_support = ['pageflow']
end

Instance Attribute Details

#datawrapper_themes_with_transparent_background_supportArray<String> (readonly)

List of datawrapper theme names for which an additional css rule shall be injected to make the background transparent. This is only recommended for themes with dark backgrounds. By default, this is only done for the ‘pageflow` theme.

Returns:

  • (Array<String>)

Since:

  • 0.2



54
55
56
# File 'lib/pageflow/chart/configuration.rb', line 54

def datawrapper_themes_with_transparent_background_support
  @datawrapper_themes_with_transparent_background_support
end

#paperclip_base_pathObject

paperclip_base_path is a prefix for the paperclip options path



8
9
10
# File 'lib/pageflow/chart/configuration.rb', line 8

def paperclip_base_path
  @paperclip_base_path
end

#paperclip_s3_default_optionsHash

Default options for paperclip attachments which are supposed to use s3 storage. All options allowed in paperclip has_attached_file calls are allowed. This defaults to the configuration in ‘config/initializers/pageflow.rb` by the same name.

Parameters:

  • opts (Hash)

Returns:

  • (Hash)


29
30
31
# File 'lib/pageflow/chart/configuration.rb', line 29

def paperclip_s3_default_options
  @paperclip_s3_default_options
end

#scraped_sites_root_urlObject

If present scraped_sites_root_url replaces the host/domain-name of the URL paperclip returns for the scraped HTML file.

This can be used to circumvent the same-domain policy by setting it to ie “/datawrapper” and redirecting from there to the S3 host alias that holds the files.



16
17
18
# File 'lib/pageflow/chart/configuration.rb', line 16

def scraped_sites_root_url
  @scraped_sites_root_url
end

#scraper_optionsObject (readonly)

Options to pass to Scraper when it is created in ScrapedSiteJob



5
6
7
# File 'lib/pageflow/chart/configuration.rb', line 5

def scraper_options
  @scraper_options
end

#supported_hostsArray<String> (readonly)

White list of URL prefixes (including protocol) of scraped sites.

Returns:

  • (Array<String>)


34
35
36
# File 'lib/pageflow/chart/configuration.rb', line 34

def supported_hosts
  @supported_hosts
end

#use_custom_themeBoolean

If enabled, set ‘has_custom_theme` to `true` for new scraped sites. This causes styles from `pageflow/chart/custom.scss` to be injected into their iframe on page creation.

This used to be the default, but is disabled in favor of custom Datawrapper themes now.

Returns:

  • (Boolean)


44
45
46
# File 'lib/pageflow/chart/configuration.rb', line 44

def use_custom_theme
  @use_custom_theme
end

Instance Method Details

#paperclip_options(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



77
78
79
80
81
# File 'lib/pageflow/chart/configuration.rb', line 77

def paperclip_options(options = {})
  Pageflow.config.paperclip_s3_default_options
    .deep_merge(default_paperclip_path_options(options))
    .deep_merge(paperclip_s3_default_options)
end