Module: PagesHelper
- Defined in:
- app/helpers/pages_helper.rb
Instance Method Summary collapse
- #active_page_class(page) ⇒ Object
- #asset_for(id) ⇒ Object
- #current_page ⇒ Object
- #current_page_class(page) ⇒ Object
- #current_page_path(lang = nil) ⇒ Object
- #homepage ⇒ Object
- #navigation_for(options) {|pages| ... } ⇒ Object
- #page_for_level(num) ⇒ Object
- #read_more_link(id) ⇒ Object
- #render_markdown(text) ⇒ Object
- #search_page_form ⇒ Object
Instance Method Details
#active_page_class(page) ⇒ Object
52 53 54 55 56 |
# File 'app/helpers/pages_helper.rb', line 52 def active_page_class page input = controller.current_url if controller.respond_to? :current_url input ||= params[:url].presence || '' input.include?(page.url.to_s) ? :active : nil end |
#asset_for(id) ⇒ Object
18 19 20 |
# File 'app/helpers/pages_helper.rb', line 18 def asset_for id Kuhsaft::Asset.find(id) end |
#current_page ⇒ Object
2 3 4 5 6 |
# File 'app/helpers/pages_helper.rb', line 2 def current_page # page = @page # yield @page if block_given? # rescue end |
#current_page_class(page) ⇒ Object
58 59 60 |
# File 'app/helpers/pages_helper.rb', line 58 def current_page_class page :current if active_page_class(page) == :active end |
#current_page_path(lang = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/pages_helper.rb', line 8 def current_page_path(lang=nil) # if @page.present? # '/' + Kuhsaft::Page.find(@page.id).localized_pages.where('locale = ?', lang).first.url # else # root_path # end # rescue # root_path end |
#homepage ⇒ Object
38 39 40 |
# File 'app/helpers/pages_helper.rb', line 38 def homepage Kuhsaft::Page.roots.first end |
#navigation_for(options) {|pages| ... } ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/pages_helper.rb', line 26 def if .is_a?(Hash) && slug = .delete(:slug) pages = Kuhsaft::LocalizedPage.(slug).first.page.children.current_locale.published rescue [] elsif (.is_a?(Fixnum) && id = ) || id = .delete(:id) pages = Kuhsaft::Page.published.where('parent_id = ?', id) elsif .nil? pages = Kuhsaft::Page.published.roots end yield pages if block_given? && pages.length > 0 pages end |
#page_for_level(num) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/pages_helper.rb', line 42 def page_for_level num input = controller.current_url if controller.respond_to? :current_url input ||= params[:url].presence || '' url = input.split('/').take(num + 1).join('/') unless input.blank? page = Kuhsaft::Page.find_by_url(url) yield page if block_given? page rescue end |
#read_more_link(id) ⇒ Object
62 63 64 65 66 67 |
# File 'app/helpers/pages_helper.rb', line 62 def read_more_link(id) link_to(id, :'data-toggle' => 'collapse', :'data-target' => id, :class => 'collapsed button button-read-more') do @content = content_tag(:p, t('kuhsaft.text_bricks.text_brick.read_more'), :class => 'read-more-text') @content << content_tag(:p, t('kuhsaft.text_bricks.text_brick.read_less'), :class => 'read-less-text') end end |
#render_markdown(text) ⇒ Object
22 23 24 |
# File 'app/helpers/pages_helper.rb', line 22 def render_markdown text RDiscount.new(text).to_html if text.present? end |
#search_page_form ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'app/helpers/pages_helper.rb', line 69 def search_page_form form_tag kuhsaft.pages_path, :method => :get, :class => 'form-inline' do if block_given? yield else render 'kuhsaft/search/form' end end end |