Module: BcmsMobile::MobileAware
- Defined in:
- lib/bcms_mobile/mobile_aware.rb
Instance Method Summary collapse
- #banner(m) ⇒ Object
-
#cms_cache_directory ⇒ Object
Returns the directory where BrowserCMS should write out it’s Page cache files for the full version of the site.
-
#determine_page_template ⇒ Object
Looks for a mobile template if the request is mobile, falling back to the html template if it can’t be found.
-
#mobile_cache_directory ⇒ Object
Returns the directory where BrowserCMS should write out it’s Page cache files for the mobile version of the site.
- #w(m) ⇒ Object
Instance Method Details
#banner(m) ⇒ Object
22 23 24 25 |
# File 'lib/bcms_mobile/mobile_aware.rb', line 22 def (m) w "*" * 20 w m end |
#cms_cache_directory ⇒ Object
Returns the directory where BrowserCMS should write out it’s Page cache files for the full version of the site. This should be exactly the same as where a typical CMS project stores it’s files. (Optionally) It can be configured in environment files via:
config.browsercms_cache_directory = File.join(Rails.root, 'some', 'dir')
39 40 41 42 |
# File 'lib/bcms_mobile/mobile_aware.rb', line 39 def cms_cache_directory configured_dir = Rails.application.config.browsercms_cache_directory configured_dir ? configured_dir : default_browsercms_cache_directory end |
#determine_page_template ⇒ Object
Looks for a mobile template if the request is mobile, falling back to the html template if it can’t be found.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bcms_mobile/mobile_aware.rb', line 45 def determine_page_template layout = @page.layout layout_name = @page.template_file_name if respond_as_mobile? w "Does html layout exist?:#{template_exists?(layout_name, "layouts/templates")}" mobile_exists = template_exists?(layout_name, "layouts/mobile") w "Does mobile layout exist?:#{mobile_exists}" layout = "mobile/#{layout_name}" if mobile_exists end w "layout = #{layout}" layout end |
#mobile_cache_directory ⇒ Object
Returns the directory where BrowserCMS should write out it’s Page cache files for the mobile version of the site. (Optionally) It can be configured in environment files via:
config.bcms_mobile_cache_directory = File.join(Rails.root, 'some', 'mobile_dir')
30 31 32 33 |
# File 'lib/bcms_mobile/mobile_aware.rb', line 30 def mobile_cache_directory configured_dir = Rails.application.config.bcms_mobile_cache_directory configured_dir ? configured_dir : default_mobile_cache_directory end |
#w(m) ⇒ Object
18 19 20 |
# File 'lib/bcms_mobile/mobile_aware.rb', line 18 def w(m) logger.warn m end |