Module Rmobio::Utils
In: utils.rb

Methods

Public Class methods

Retrieve the domain string from a given uri

Public Instance methods

#== backURL(key) This utility handles back url to GLP if page is cached. It expects params[:burl] or a session key and renders the following xml data back to the caller:

<data xmlns="">

 <burl>blah blah url</burl>

</data>

The returned instance data <burl> is determined by the following rules: #* params[:burl] if parameter exists, the url in the session is also updated #* session[:key] if params[:burl] is nil #* empty string if none of the above

To access the backurl from your xfroms, use the following pattern:

  <xf:instance id="homepage" src="storeBackurl?burl=SOMEURL" />

Where the controller should provide a "storeBackurl" method that just call this backURL utility:

  def storeBackurl
    backURL("recipe_burl")
  end

#=== Parameter key => a unique session key to store the burl for the app

if you want to just return partial backurl without headers and no rendering

#== cachControl #=== Adding cache control to response header

#== cacheimg #=== A utility method to add cache control to images #=== This utility is deprecated, use cacheloader instead To add a cache control for an image file in RAILS_ROOT/public/images, edit the configuration file "cachehints.txt with image name and header. Ex:

logo.png: priority=P2;max-age=1296000

To access the image in your xforms, use the following pattern: <icon>img?name=logo.png</icon> Where the controller should provide an img method that just call this cacheimg utility.

Sample cachehints.txt: Skins_176A2-a.png: priority=P2;max-age=1296000 logo.png: priority=P2;max-age=1296000

#== cacheloader #=== A utility method to add cache control to images, styles and files To add a cache control, edit the configuration file ‘cachehints.txt’ with filename and header. Here is a ample configuration:

#logo.png: priority=P2;max-age=1296000

#base.rhtml: priority=P2;max-age=1296000

The utility assumes base directory for images files in RAILS_ROOT/public/images and other files in RAILS_ROOT/apps/views.

To access the image in your xform, use the following pattern: #<icon>recipe/loader?name=logo.png</icon> To access the style in your xform, use the following pattern: #<style xmlns="www.mobio.com/ext" src="recipe/loader?name=layouts/base.rhtml"/>

where the controller ‘recipe’ should provide a method ‘loader’ that calls this utility:

 def loader
   cacheloader
 end

[Validate]