Class: Optimacms::PageServices::PageData
- Inherits:
-
Object
- Object
- Optimacms::PageServices::PageData
- Includes:
- PageProcessService
- Defined in:
- lib/optimacms/page_services/page_data.rb
Overview
data used for processing page
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#compiled_view_path ⇒ Object
readonly
Returns the value of attribute compiled_view_path.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#page ⇒ Object
page object.
-
#render_extra_options ⇒ Object
Returns the value of attribute render_extra_options.
-
#render_options ⇒ Object
Returns the value of attribute render_options.
-
#template ⇒ Object
Returns the value of attribute template.
-
#url ⇒ Object
, :params.
-
#url_vars ⇒ Object
, :params.
Instance Method Summary collapse
- #compiled_view_filename ⇒ Object
- #controller_class ⇒ Object
- #dir_cache ⇒ Object
- #dirname_views ⇒ Object
- #generate_content ⇒ Object
- #meta ⇒ Object
- #template_path ⇒ Object
- #view_content ⇒ Object
- #view_filename ⇒ Object
Methods included from PageProcessService
#compile_content, #generate_view_name, #save_text_to_compiled_view
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9 10 11 |
# File 'lib/optimacms/page_services/page_data.rb', line 9 def action @action end |
#compiled_view_path ⇒ Object (readonly)
Returns the value of attribute compiled_view_path.
17 18 19 |
# File 'lib/optimacms/page_services/page_data.rb', line 17 def compiled_view_path @compiled_view_path end |
#controller ⇒ Object
Returns the value of attribute controller.
9 10 11 |
# File 'lib/optimacms/page_services/page_data.rb', line 9 def controller @controller end |
#lang ⇒ Object
Returns the value of attribute lang.
8 9 10 |
# File 'lib/optimacms/page_services/page_data.rb', line 8 def lang @lang end |
#layout ⇒ Object
Returns the value of attribute layout.
10 11 12 |
# File 'lib/optimacms/page_services/page_data.rb', line 10 def layout @layout end |
#page ⇒ Object
page object
5 6 7 |
# File 'lib/optimacms/page_services/page_data.rb', line 5 def page @page end |
#render_extra_options ⇒ Object
Returns the value of attribute render_extra_options.
14 15 16 |
# File 'lib/optimacms/page_services/page_data.rb', line 14 def @render_extra_options end |
#render_options ⇒ Object
Returns the value of attribute render_options.
13 14 15 |
# File 'lib/optimacms/page_services/page_data.rb', line 13 def @render_options end |
#template ⇒ Object
Returns the value of attribute template.
11 12 13 |
# File 'lib/optimacms/page_services/page_data.rb', line 11 def template @template end |
#url ⇒ Object
, :params
7 8 9 |
# File 'lib/optimacms/page_services/page_data.rb', line 7 def url @url end |
#url_vars ⇒ Object
, :params
7 8 9 |
# File 'lib/optimacms/page_services/page_data.rb', line 7 def url_vars @url_vars end |
Instance Method Details
#compiled_view_filename ⇒ Object
82 83 84 |
# File 'lib/optimacms/page_services/page_data.rb', line 82 def compiled_view_filename dir_cache+'/'+@compiled_view_basename end |
#controller_class ⇒ Object
21 22 23 |
# File 'lib/optimacms/page_services/page_data.rb', line 21 def controller_class Object.const_get controller.to_s.camelize+'Controller' end |
#dir_cache ⇒ Object
95 96 97 98 |
# File 'lib/optimacms/page_services/page_data.rb', line 95 def dir_cache # TODO: get from settings Rails.root.to_s+'/app/views/'+dirname_views end |
#dirname_views ⇒ Object
91 92 93 |
# File 'lib/optimacms/page_services/page_data.rb', line 91 def dirname_views 'optimacms/cache' end |
#generate_content ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/optimacms/page_services/page_data.rb', line 101 def generate_content @compiled_view_basename = generate_view_name Optimacms::Fileutils::Fileutils::create_dir_if_not_exists compiled_view_filename text = compile_content view_content save_text_to_compiled_view text end |
#meta ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/optimacms/page_services/page_data.rb', line 60 def page_lang = page.is_translated ? lang : '' row = page.translations.where(:lang=>page_lang).first return nil if row.nil? {:title=>row., :keywords=>row., :description=>row.} end |
#template_path ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/optimacms/page_services/page_data.rb', line 51 def template_path if template.is_translated tpl_lang = self.lang else tpl_lang='' end page.template.path(tpl_lang) end |
#view_content ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/optimacms/page_services/page_data.rb', line 69 def view_content return '' if template.basepath.nil? f = template.fullpath return '' if !File.exists? f File.read(f) end |
#view_filename ⇒ Object
77 78 79 80 |
# File 'lib/optimacms/page_services/page_data.rb', line 77 def view_filename #Rails.root.to_s + '/app/views/'+view_path page.template.fullpath end |