Class: TagSidebar

Inherits:
Sidebar
  • Object
show all
Defined in:
app/models/tag_sidebar.rb

Instance Method Summary collapse

Methods inherited from Sidebar

#admin_state, apply_staging_on_active!, #content_partial, description, #description, #display_name, display_name, #fieldmap, #fields, #html_id, ordered_sidebars, #parse_request, path_name, #publish, purge, setting, short_name, #short_name, #to_locals_hash

Instance Method Details

#font_multiplierObject



25
26
27
# File 'app/models/tag_sidebar.rb', line 25

def font_multiplier
  80
end

#sizesObject



14
15
16
17
18
19
20
21
22
23
# File 'app/models/tag_sidebar.rb', line 14

def sizes
  return @sizes if @sizes

  total = tags.reduce(0) { |sum, tag| sum + tag.content_counter }
  average = total.to_f / @tags.size
  @sizes = tags.reduce({}) do |h, tag|
    size = tag.content_counter.to_f / average
    h.merge tag => size.clamp(2.0 / 3.0, 2) * 100
  end
end

#tagsObject



9
10
11
12
# File 'app/models/tag_sidebar.rb', line 9

def tags
  @tags ||= Tag.find_all_with_content_counters
    .take(maximum_tags.to_i).sort_by(&:name)
end