Class: Lcms::Engine::ContentPresenter
Constant Summary
collapse
- CONFIG_PATH =
Rails.root.join('config', 'pdf.yml')
- DEFAULT_CONFIG =
:default
- MATERIALS_CONFIG_PATH =
Rails.root.join('config', 'materials_rules.yml')
- PDF_EXT =
'.pdf'
- THUMB_EXT =
'.jpg'
Class Method Summary
collapse
Instance Method Summary
collapse
#t
Constructor Details
Returns a new instance of ContentPresenter.
45
46
47
48
49
50
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 45
def initialize(obj, opts = {})
super(obj)
opts.each_pair do |key, value|
instance_variable_set("@#{key}", value)
end
end
|
Class Method Details
.base_config ⇒ Object
12
13
14
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 12
def self.base_config
@base_config ||= YAML.load_file(CONFIG_PATH).deep_symbolize_keys
end
|
.materials_config ⇒ Object
16
17
18
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 16
def self.materials_config
@materials_config ||= YAML.load_file(MATERIALS_CONFIG_PATH).deep_symbolize_keys
end
|
Instance Method Details
#base_filename ⇒ Object
20
21
22
23
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 20
def base_filename
name = short_breadcrumb(join_with: '_', with_short_lesson: true)
"#{name}_v#{version.presence || 1}"
end
|
#config ⇒ Object
25
26
27
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 25
def config
@config ||= self.class.base_config[DEFAULT_CONFIG].deep_merge(self.class.base_config[content_type.to_sym] || {})
end
|
#content_type ⇒ Object
29
30
31
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 29
def content_type
@content_type.presence || 'none'
end
|
33
34
35
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 33
def
padding_styles(align_type: 'margin')
end
|
#gdoc_folder ⇒ Object
37
38
39
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 37
def gdoc_folder
"#{id}_v#{version}"
end
|
#materials_config_for(type) ⇒ Object
52
53
54
55
56
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 52
def materials_config_for(type)
self.class.materials_config[type.to_sym].flat_map do |k, v|
v.map { |x| { k => x } }
end
end
|
#orientation ⇒ Object
58
59
60
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 58
def orientation
config[:orientation]
end
|
#padding_styles(align_type: 'padding') ⇒ Object
62
63
64
|
# File 'app/presenters/lcms/engine/content_presenter.rb', line 62
def padding_styles(align_type: 'padding')
config[:padding].map { |k, v| "#{align_type}-#{k}:#{v};" }.join
end
|