Module: Elabs::ContentFiltersHelper

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

Instance Method Summary collapse

Instance Method Details



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

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


63
64
65
66
67
68
# File 'app/helpers/elabs/content_filters_helper.rb', line 63

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
  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(icon, _('Show all'), ['fw'], true)
  end
end


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

def nsfw_only_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(icon, _('Only NSFW'), ['fw'], true)
  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']

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

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

#render_filters?Boolean

Returns:

  • (Boolean)


84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/helpers/elabs/content_filters_helper.rb', line 84

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
  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(icon, _('Only SFW'), ['fw'], true)
  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


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

def with_content_filter_links
  out = []

  out.push all_filter_link
  out.push with_content_only_filter_link

  raw out.join('')
end


56
57
58
59
60
61
# File 'app/helpers/elabs/content_filters_helper.rb', line 56

def with_content_only_filter_link
  icon = !params['with_content_only'] || params['with_content_only'] == 'true' ? 'dot-circle' : 'circle'
  link_to request.params.merge(with_content_only: 'true'), class: 'filter-link' do
    icon_text(icon, _('With content only'), ['fw'], true)
  end
end