Module: Redde::Seo::SeosHelper

Defined in:
app/helpers/redde/seo/seos_helper.rb

Instance Method Summary collapse

Instance Method Details

#seo_empty_for(seo) ⇒ Object



37
38
39
# File 'app/helpers/redde/seo/seos_helper.rb', line 37

def seo_empty_for(seo)
  seo.empty? ? '' : ''
end


4
5
6
7
# File 'app/helpers/redde/seo/seos_helper.rb', line 4

def seo_empty_link(name, key = nil)
  return name if params[:empty].to_s == key.to_s
  link_to name, url_for(params.merge(empty: key))
end


23
24
25
# File 'app/helpers/redde/seo/seos_helper.rb', line 23

def seo_link_for_object(seo)
  link_to seo_object_for(seo), [:edit, :admin, seo], alt: seo.url, title: seo.url
end


13
14
15
# File 'app/helpers/redde/seo/seos_helper.rb', line 13

def seo_link_for_url(seo)
  link_to seo_url_for(seo), [:edit, :admin, seo], alt: seo.url, title: seo.url
end

#seo_object_for(seo) ⇒ Object



27
28
29
30
# File 'app/helpers/redde/seo/seos_helper.rb', line 27

def seo_object_for(seo)
  return '' unless seo.seoable
  "#{seo.seoable.class.model_name.human}##{seo.seoable_id}"
end

#seo_title_for(seo) ⇒ Object



32
33
34
35
# File 'app/helpers/redde/seo/seos_helper.rb', line 32

def seo_title_for(seo)
  title = seo.title.present? ? truncate(seo.title, length: 17) : 'НЕ ЗАПОЛНЕНО'
  link_to title, [:edit, :admin, seo], alt: seo.url, title: seo.url
end


9
10
11
# File 'app/helpers/redde/seo/seos_helper.rb', line 9

def seo_type_link(name, key)
  link_to name, url_for(params.merge(seoable_type: key)), class: ['phead-tabs__link', ('_active' if params[:seoable_type] == key)]
end

#seo_url_for(seo) ⇒ Object



17
18
19
20
21
# File 'app/helpers/redde/seo/seos_helper.rb', line 17

def seo_url_for(seo)
  title = CGI.unescape(seo.url || '')
  title = truncate(title, length: 40)
  title.present? ? title : 'НЕ ЗАПОЛНЕНО'
end