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.
-
#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
- #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.
14 15 16 |
# File 'lib/optimacms/page_services/page_data.rb', line 14 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 |
#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
68 69 70 |
# File 'lib/optimacms/page_services/page_data.rb', line 68 def compiled_view_filename dir_cache+'/'+@compiled_view_basename end |
#controller_class ⇒ Object
18 19 20 |
# File 'lib/optimacms/page_services/page_data.rb', line 18 def controller_class Object.const_get controller.to_s.camelize+'Controller' end |
#dir_cache ⇒ Object
81 82 83 84 |
# File 'lib/optimacms/page_services/page_data.rb', line 81 def dir_cache # TODO: get from settings Rails.root.to_s+'/app/views/'+dirname_views end |
#dirname_views ⇒ Object
77 78 79 |
# File 'lib/optimacms/page_services/page_data.rb', line 77 def dirname_views 'optimacms/cache' end |
#generate_content ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/optimacms/page_services/page_data.rb', line 87 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
46 47 48 49 50 51 52 53 |
# File 'lib/optimacms/page_services/page_data.rb', line 46 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 |
#view_content ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/optimacms/page_services/page_data.rb', line 55 def view_content return '' if template.basepath.nil? f = template.fullpath return '' if !File.exists? f File.read(f) end |
#view_filename ⇒ Object
63 64 65 66 |
# File 'lib/optimacms/page_services/page_data.rb', line 63 def view_filename #Rails.root.to_s + '/app/views/'+view_path page.template.fullpath end |