Class: Optimacms::PageServices::PageData

Inherits:
Object
  • Object
show all
Includes:
PageProcessService
Defined in:
lib/optimacms/page_services/page_data.rb

Overview

data used for processing page

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PageProcessService

#compile_content, #generate_view_name, #save_text_to_compiled_view

Instance Attribute Details

#actionObject

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_pathObject (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

#controllerObject

Returns the value of attribute controller.



9
10
11
# File 'lib/optimacms/page_services/page_data.rb', line 9

def controller
  @controller
end

#langObject

Returns the value of attribute lang.



8
9
10
# File 'lib/optimacms/page_services/page_data.rb', line 8

def lang
  @lang
end

#layoutObject

Returns the value of attribute layout.



10
11
12
# File 'lib/optimacms/page_services/page_data.rb', line 10

def layout
  @layout
end

#pageObject

page object



5
6
7
# File 'lib/optimacms/page_services/page_data.rb', line 5

def page
  @page
end

#render_extra_optionsObject

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
  @render_extra_options
end

#render_optionsObject

Returns the value of attribute render_options.



13
14
15
# File 'lib/optimacms/page_services/page_data.rb', line 13

def render_options
  @render_options
end

#templateObject

Returns the value of attribute template.



11
12
13
# File 'lib/optimacms/page_services/page_data.rb', line 11

def template
  @template
end

#urlObject

, :params



7
8
9
# File 'lib/optimacms/page_services/page_data.rb', line 7

def url
  @url
end

#url_varsObject

, :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_filenameObject



82
83
84
# File 'lib/optimacms/page_services/page_data.rb', line 82

def compiled_view_filename
  dir_cache+'/'+@compiled_view_basename
end

#controller_classObject



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_cacheObject



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_viewsObject



91
92
93
# File 'lib/optimacms/page_services/page_data.rb', line 91

def dirname_views
  'optimacms/cache'
end

#generate_contentObject



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

#metaObject



60
61
62
63
64
65
66
67
# File 'lib/optimacms/page_services/page_data.rb', line 60

def meta
  page_lang = page.is_translated ? lang : ''
  row = page.translations.where(:lang=>page_lang).first

  return nil if row.nil?

  {:title=>row.meta_title, :keywords=>row.meta_keywords, :description=>row.meta_description}
end

#template_pathObject



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_contentObject



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_filenameObject



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