Class: WidgetsCell

Inherits:
Cell::Rails
  • Object
show all
Defined in:
app/cells/widgets_cell.rb

Instance Method Summary collapse

Instance Method Details

#accordion(args = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'app/cells/widgets_cell.rb', line 32

def accordion(args = {})
  @text = args.fetch(:text, '')
  @items = args.fetch(:items, [])
  @items.each_with_index do |item, _index|
    item[:title] = normalize(item[:title])
    item[:content] = normalize(item[:content])
  end
  render if @items.present?
end

#affilate_commission(_args = {}) ⇒ Object



76
77
78
79
80
81
# File 'app/cells/widgets_cell.rb', line 76

def affilate_commission(_args = {})
  @rates = TranslationCms::Api::Rates::Commission.all!
  @kind = @rates.first.try(:commission_type)

  render
end

#affilate_scheme(_args = {}) ⇒ Object



72
73
74
# File 'app/cells/widgets_cell.rb', line 72

def affilate_scheme(_args = {})
  render
end


28
29
30
# File 'app/cells/widgets_cell.rb', line 28

def cookie_policy(_args = {})
  render
end

#language_drop(_args = {}) ⇒ Object



57
58
59
# File 'app/cells/widgets_cell.rb', line 57

def language_drop(_args = {})
  render
end


42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/cells/widgets_cell.rb', line 42

def sidebar(args = {})
  @structure = args[:structure]
  return if @structure.blank?

  options = {
    css_names: 'sidebar sidebar_right'
  }.merge(args)

  @css_names = options[:css_names]
  @inject = options[:inject]
  @widgets = @structure.widgets.sorted

  render if @widgets.present? || @inject.present?
end

#single_part(args = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'app/cells/widgets_cell.rb', line 61

def single_part(args = {})
  @type = args[:type]
  @type = WidgetType.find_by(id: @type) unless @type.is_a? WidgetType
  args[:widget_type] = @type
  @css_names = args[:css_names]
  @widget = Widget.new(widget_type: @type,
                       title: args[:title],
                       counter: args[:counter])
  render if @widget.present?
end

#tweet(args = {}) ⇒ Object



22
23
24
25
26
# File 'app/cells/widgets_cell.rb', line 22

def tweet(args = {})
  @text = args[:text].gsub(/\[WIDGET:TWEET:START\](.+)\[WIDGET:TWEET:END\]/, '\1')
  @url = args[:url]
  render
end