Sha256: 9ff84e5b23028ad4ace4a3ecc092a078eb9c98299a44a57cc6b73b9a5531458b

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

module PagesCms
  module ApplicationHelper

    def account
      account = Account.first
      if account
        account
      else
        false
      end
    end

    def current_account
      if Account.exists?(session[:current_account])
        Account.find(session[:current_account])
      else
        false
      end
    end

    # added by PagesCMS. Use this helper to link to user created pages.
    def slugged_path(page)
      if page.class == String
        "/#{page}"
      else
        mount = page.account.mount_location
        if page.parent.nil?
          "#{'/' unless mount == '/'}#{mount unless mount == '/'}/#{page.slug}"
        else
          "#{'/' unless mount == '/'}#{mount unless mount == '/'}/#{page.parent.slug}/#{page.slug}"
        end
      end
    end

    # redirects to the blog with a search
    def blog_path(current_site, search = '')
      blog = current_site.pages.find_by(slug: 'blog')
      unless blog.nil?
        "#{slugged_path(blog)}?search=#{search}"
      end
    end

    def insert_html_breaks(string)
      string.gsub(/\n/, '<br />')
    end

    def meta_tags

    end

    def meta_description

    end

    def current_site
      if params[:account]
        Account.where(id: params[:account]).first
      elsif session[:current_account]
        Account.where(id: session[:current_account]).first
      else
        false
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pages_cms-2.2.3 app/helpers/pages_cms/application_helper.rb
pages_cms-2.2.2 app/helpers/pages_cms/application_helper.rb
pages_cms-2.2.1 app/helpers/pages_cms/application_helper.rb
pages_cms-2.1.1 app/helpers/pages_cms/application_helper.rb
pages_cms-2.1.0 app/helpers/pages_cms/application_helper.rb
pages_cms-2.0.1 app/helpers/pages_cms/application_helper.rb
pages_cms-2.0.0 app/helpers/pages_cms/application_helper.rb