Module: Optimacms::ApplicationHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/optimacms/application_helper.rb
Instance Method Summary collapse
- #block(name) ⇒ Object
- #eval_meta_string(s) ⇒ Object
- #fix_quotes(s) ⇒ Object
- #meta_tags(title = nil, keywords = nil, desc = nil) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #tinymce_editor_insert_block ⇒ Object
- #url_for(options = nil) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
8 9 10 11 12 |
# File 'app/helpers/optimacms/application_helper.rb', line 8 def method_missing(method, *args, &block) main_app.send(method, *args, &block) rescue NoMethodError super end |
Instance Method Details
#block(name) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/helpers/optimacms/application_helper.rb', line 66 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 |
#eval_meta_string(s) ⇒ Object
18 19 20 |
# File 'app/helpers/optimacms/application_helper.rb', line 18 def (s) eval('"'+s+'"') end |
#fix_quotes(s) ⇒ Object
22 23 24 |
# File 'app/helpers/optimacms/application_helper.rb', line 22 def fix_quotes(s) s.gsub /"/, '\"' end |
#meta_tags(title = nil, keywords = nil, desc = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/optimacms/application_helper.rb', line 48 def (title=nil, keywords=nil, desc=nil) #s = 'news "11"' #s1 = s.gsub /"/, '\"' #s2 = eval('"'+s1+'"') title ||= (fix_quotes()) keywords ||= () desc ||= () 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 |
#tinymce_editor_insert_block ⇒ Object
14 15 16 |
# File 'app/helpers/optimacms/application_helper.rb', line 14 def tinymce_editor_insert_block '<pre>{{block:name:sub}}</pre>' end |
#url_for(options = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/optimacms/application_helper.rb', line 26 def url_for( = nil) #url_for # page processed by CMS if .present? && .kind_of?(Hash) && [:controller]=='optimacms/pages' && [:action]=='show' # get current page name page_name = [:page_name] || controller.optimacms_pagedata.page.name if page_name.present? u = site_page_path(page_name, ) if u.present? return u end end end # return super() end |