Sha256: 5bbf128d4fc0254d07c5307ac415cb5d641cf9a234427cd05cb81277cdd94afe

Contents?: true

Size: 1.88 KB

Versions: 21

Compression:

Stored size: 1.88 KB

Contents

# Rails view helpers needed accross Umlaut controllers are collected
# here. Generally UmlautController will call "helper Umlaut::Helper" to
# expose these to all umlaut controllers. 

module Umlaut::Helper
  include Umlaut::UrlGeneration
  include Umlaut::FooterHelper
  include Umlaut::HtmlHeadHelper
  
  
  
  # pass in an OpenURL::ContextObject, outputs a link.
  def resolver_link(context_object, params={})
    
    # Content of the link. 
    if ( umlaut_config.link_img_url && params[:text].blank? )
      link_content = image_tag(umlaut_config.link_img_url, :border=>0, :alt=>umlaut_config.app_name)
    elsif ! params[:text].blank?
      link_content = params[:text]
    else
      link_content = umlaut_config.app_name
    end

    # url of the link. 
    if ( params[:params])
      link_to_arg = params[:params]
    else
      link_params = {:controller=>'/resolve', :action => "index"}
      link_params.merge!( params[:extra_params] ) if params[:extra_params]
      link_to_arg = url_for_with_co( link_params, context_object )      
    end
    
    link_to(link_content, link_to_arg , :target=>params[:target])
  end

  # formats dates sent in an OpenURL into a more human-friendly
  # format. Input Dates look like '20000304'. Can be just year, or just
  # year/month, or all. Not sure what this format
  # is officially called. Not sure if they can have dashes sometimes? 
  def date_format(date_string)      
    date_string =~ /(\d\d\d\d)\-?(\d\d)?\-?(\d\d)?/

    begin
      year, month, day_of_month = $1, $2, $3
  
      if ( month )                
        date = Date.civil(year.to_i, month.to_i)
        formatted_month = date.strftime('%b')
      end
      
      output = year
      output += ' ' + formatted_month if formatted_month
      output += ' ' + day_of_month if day_of_month && day_of_month.to_i != 0
  
      return output
    rescue
      return date_string
    end
  end

  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
umlaut-3.0.5 app/helpers/umlaut/helper.rb
umlaut-3.0.4 app/helpers/umlaut/helper.rb
umlaut-3.0.3 app/helpers/umlaut/helper.rb
umlaut-3.0.2 app/helpers/umlaut/helper.rb
umlaut-3.0.1 app/helpers/umlaut/helper.rb
umlaut-3.0.0 app/helpers/umlaut/helper.rb
umlaut-3.0.0rc1 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta10 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta9 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta8 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta7 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta6 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta5 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta4 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta3 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta2 app/helpers/umlaut/helper.rb
umlaut-3.0.0beta1 app/helpers/umlaut/helper.rb
umlaut-3.0.0alpha15 app/helpers/umlaut/helper.rb
umlaut-3.0.0alpha14 app/helpers/umlaut/helper.rb
umlaut-3.0.0alpha13 app/helpers/umlaut/helper.rb