Module: Optimacms::Mycontroller
- Extended by:
- ActiveSupport::Concern
- Included in:
- PagesController
- Defined in:
- lib/optimacms/mycontroller.rb
Instance Method Summary collapse
- #default_render(*args) ⇒ Object
- #get_page_path(page_name, p = {}) ⇒ Object
- #is_optimacms ⇒ Object
- #my_set_meta(meta) ⇒ Object
- #my_set_render ⇒ Object
- #my_set_render_template(tpl_view, tpl_layout) ⇒ Object
- #optimacms_pagedata ⇒ Object
- #optimacms_set_pagedata(_pagedata) ⇒ Object
- #site_page_path(name, p = {}) ⇒ Object
Instance Method Details
#default_render(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/optimacms/mycontroller.rb', line 19 def default_render(*args) if self.controller_name!='pages' && !@optimacms_tpl.nil? && @is_optimacms render @optimacms_tpl, :layout=>@optimacms_layout and return #(render :text => "hello", :layout => @optimacms_layout) and return # http://stackoverflow.com/questions/21129587/ruby-on-rails-how-to-render-file-as-plain-text-without-any-html #render :plain will set the content type to text/plain #render :html will set the content type to text/html #render :body will not set the content type header. # render text: "some text". :plain does not work. end super end |
#get_page_path(page_name, p = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/optimacms/mycontroller.rb', line 58 def get_page_path(page_name, p={}) # get from cache @cache_page_urls ||= {} url = @cache_page_urls.fetch(page_name.to_s, nil) if url.nil? page = Page.find_by_name(page_name) url = page.url if page end return nil if url.nil? # set to cache @cache_page_urls ||= {} @cache_page_urls[page_name.to_s] = url # res = PageServices::PageRouteService.make_url url, p return nil if res.nil? '/'+res end |
#is_optimacms ⇒ Object
15 16 17 |
# File 'lib/optimacms/mycontroller.rb', line 15 def is_optimacms @is_optimacms end |
#my_set_meta(meta) ⇒ Object
48 49 50 51 52 |
# File 'lib/optimacms/mycontroller.rb', line 48 def () = [:title] = [:keywords] = [:description] end |
#my_set_render ⇒ Object
10 11 12 13 |
# File 'lib/optimacms/mycontroller.rb', line 10 def my_set_render @is_optimacms = true end |
#my_set_render_template(tpl_view, tpl_layout) ⇒ Object
43 44 45 46 |
# File 'lib/optimacms/mycontroller.rb', line 43 def my_set_render_template(tpl_view, tpl_layout) @optimacms_tpl = tpl_view @optimacms_layout = tpl_layout end |
#optimacms_pagedata ⇒ Object
34 35 36 |
# File 'lib/optimacms/mycontroller.rb', line 34 def optimacms_pagedata @pagedata end |
#optimacms_set_pagedata(_pagedata) ⇒ Object
38 39 40 41 |
# File 'lib/optimacms/mycontroller.rb', line 38 def optimacms_set_pagedata(_pagedata) @pagedata = _pagedata end |
#site_page_path(name, p = {}) ⇒ Object
54 55 56 |
# File 'lib/optimacms/mycontroller.rb', line 54 def site_page_path(name, p={}) get_page_path(name, p) end |