Module: Elabs::ContentFiltersHelper

Defined in:
app/helpers/elabs/content_filters_helper.rb

Instance Method Summary collapse

Instance Method Details



54
55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/elabs/content_filters_helper.rb', line 54

def admin_order_by_link(title, field)
  current_direction = params['order_by'] == field && params['direction'] ? params['direction'] : 'desc'
  direction         = current_direction == 'asc' ? :desc : :asc
  options           = { order_by: field, direction: direction }

  icon = direction == :asc ? 'sort-up' : 'sort-down'

  link_to options, class: 'filter-link' do
    icon_text icon, title, ['fw'], true
  end
end


47
48
49
50
51
52
# File 'app/helpers/elabs/content_filters_helper.rb', line 47

def all_filter_link
  icon = params['with_content_only'] && params['with_content_only'] == 'false' ? 'dot-circle' : 'circle'
  link_to request.params.merge(with_content_only: 'false'), class: 'filter-link' do
    icon_text(icon, _('Show all'), ['fw'], true)
  end
end


40
41
42
43
44
45
# File 'app/helpers/elabs/content_filters_helper.rb', line 40

def all_sfw_status_link
  link_icon = params['sfw_status'] && %w[sfw_only nsfw_only].include?(params['sfw_status']) ? 'circle' : 'dot-circle'
  link_to request.params.merge(sfw_status: 'all'), class: 'filter-link' do
    icon_text link_icon, ('span', _('Show all'), class: 'link'), %w[fw icon]
  end
end


33
34
35
36
37
38
# File 'app/helpers/elabs/content_filters_helper.rb', line 33

def nsfw_only_link
  link_icon = params['sfw_status'] && params['sfw_status'] == 'nsfw_only' ? 'dot-circle' : 'circle'
  link_to request.params.merge(sfw_status: 'nsfw_only'), class: 'filter-link' do
    icon_text link_icon, ('span', _('Only NSFW'), class: 'link'), %w[fw icon]
  end
end


3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/elabs/content_filters_helper.rb', line 3

def order_link(title, field)
  param_name            = "order_by_#{field}"
  direction             = params[param_name] && params[param_name] == 'asc' ? :desc : :asc
  options               = { param_name => direction }
  options['sfw_status'] = params['sfw_status'] if params['sfw_status']

  link_icon = determine_sort_icon param_name, direction

  link_to options, class: 'filter-link' do
    icon_text link_icon, ('span', title, class: 'link'), %w[fw icon], true
  end
end

#render_filters?Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/helpers/elabs/content_filters_helper.rb', line 68

def render_filters?
  %w[acts
     languages
     licenses
     tags
     users
     albums
     articles
     notes
     projects
     uploads].include?(controller_name) && action_name == 'index'
end


26
27
28
29
30
31
# File 'app/helpers/elabs/content_filters_helper.rb', line 26

def sfw_only_link
  link_icon = params['sfw_status'] && params['sfw_status'] == 'sfw_only' ? 'dot-circle' : 'circle'
  link_to request.params.merge(sfw_status: 'sfw_only'), class: 'filter-link' do
    icon_text link_icon, ('span', _('Only SFW'), class: 'link'), %w[fw icon]
  end
end


16
17
18
19
20
21
22
23
24
# File 'app/helpers/elabs/content_filters_helper.rb', line 16

def sfw_status_links
  out = []

  out.push all_sfw_status_link
  out.push sfw_only_link
  out.push nsfw_only_link

  raw out.join('')
end