Module: Optimacms::ApplicationHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/optimacms/application_helper.rb
Instance Method Summary collapse
- #block(name) ⇒ Object
- #meta_tags(title = nil, keywords = nil, desc = nil) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #site_page_path(h) ⇒ Object
- #tinymce_editor_insert_block ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
4 5 6 7 8 |
# File 'app/helpers/optimacms/application_helper.rb', line 4 def method_missing(method, *args, &block) main_app.send(method, *args, &block) rescue NoMethodError super end |
Instance Method Details
#block(name) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/optimacms/application_helper.rb', line 28 def block(name) x = Dir.pwd #y = File.expand_path File.dirname(__FILE__) d = File.dirname(@optimacms_tpl) # try1 - in the current folder f = File.join(Dir.pwd, 'app', 'views', d, name+'.html') return render file: f if File.exists? f # names = [] names << [d, name+".html"] names << ["", name+".html"] # parts = name.split /\// parts[-1] = '_'+parts[-1] name2 = parts.join('/') names << [d, name2+".html"] names << ["", name2+".html"] # try 2 names.each do |p| f = File.join(Dir.pwd, 'app', 'views', p[0], p[1]) (return render file: f) if File.exists? f f = File.join(Dir.pwd, 'app', 'views', p[0], p[1]+".haml") (return render file: f) if File.exists? f f = File.join(Dir.pwd, 'app', 'views', p[0], p[1]+".erb") (return render file: f) if File.exists? f end # default render return render f end |
#meta_tags(title = nil, keywords = nil, desc = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/optimacms/application_helper.rb', line 14 def (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 |
#site_page_path(h) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'app/helpers/optimacms/application_helper.rb', line 69 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 |
#tinymce_editor_insert_block ⇒ Object
10 11 12 |
# File 'app/helpers/optimacms/application_helper.rb', line 10 def tinymce_editor_insert_block '<pre>{{block:name:sub}}</pre>' end |