Sha256: e8cfe078736c4111f916fa35730f79826efac5aec217319d7f21be14c2d7069f

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

module Optimacms
  module ApplicationHelper

    #include ActionView::Helpers::ApplicationHelper
    #include SimpleFilter::FormsHelper


    def method_missing(method, *args, &block)
      main_app.send(method, *args, &block)
    rescue NoMethodError
      super
    end

    def tinymce_editor_insert_block
      '<pre>{{block:name:sub}}</pre>'
    end

    def meta_tags(title=nil, keywords=nil, desc=nil)
      title ||= @optimacms_meta_title
      keywords ||= @optimacms_meta_keywords
      desc ||= @optimacms_meta_description

      return %(<title>#{title}</title>
<meta name="keywords" content="#{keywords}"/>
<meta name="description" content="#{desc}"/>
      ).html_safe
      #content_tag(:title, title)+
      #content_tag(:meta, nil, content: keywords, name: 'keywords')+
      #content_tag(:meta, nil, content: desc, name: 'description')
    end

    def block(name)
      x = Dir.pwd
      #y = File.expand_path File.dirname(__FILE__)
      d = File.dirname(@optimacms_tpl)

      # extensions
      extensions = ['', '.html.haml', '.html.erb', '.html']


      # try. HTML file in the current folder
      f = File.join(Dir.pwd, 'app', 'views', d, name+'.html')
      return render file: f if File.exists? f

      #
      names = []

      #
      parts = name.split /\//

      parts[-1] = '_'+parts[-1]
      name2 = parts.join('/')

      #
      names << [d, name]
      names << ["", name]

      names << [d, name2]
      names << ["", name2]


      # try 2
      names.each do |p|
        extensions.each do |ext|
          f = File.join(Dir.pwd, 'app', 'views', p[0], p[1]+ext)
          (return render file: f)      if File.exists? f
        end
      end

      # default render
      return render name
    end
    
    
    def site_page_path(h)
      if h.is_a? String
        cms.cms_page_path(h+'.html')
      elsif h.is_a? Hash
        cms.cms_page_path(h[:page]+'.html')
      end

    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
optimacms-0.1.36 app/helpers/optimacms/application_helper.rb
optimacms-0.1.34 app/helpers/optimacms/application_helper.rb