module Platform::ActionViewExtension::InstanceMethods
Public Instance Methods
platform_app_icon_tag(app, options = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 129 def platform_app_icon_tag(app, options = {}) options[:style] ||= "" options[:style] << "width:16px;height:16px;" image_tag(app.icon_url, :style => options[:style]) end
platform_app_logo_tag(app, options = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 135 def platform_app_logo_tag(app, options = {}) options[:style] ||= "" options[:style] << "width:75px;height:75px;" image_tag(app.logo_url, :style => options[:style]) end
platform_app_rank_tag(app, rank = nil, opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 73 def platform_app_rank_tag(app, rank = nil, opts = {}) return "" unless app rank ||= app.rank || 0 rank = rank * 100 / 5 html = "<span dir='ltr'>" 1.upto(5) do |i| if rank > i * 20 - 10 and rank < i * 20 html << image_tag("platform/rating_star05.png") elsif rank < i * 20 - 10 html << image_tag("platform/rating_star0.png") else html << image_tag("platform/rating_star1.png") end end html << "</span>" html.html_safe end
platform_display_time(time, format)
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 183 def platform_display_time(time, format) time.tr(format).gsub('/ ', '/').sub(/^[0:]*/,"") end
platform_documentation_api_decorators_tag(api)
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 61 def platform_documentation_api_decorators_tag(api) return unless api[:status] return image_tag("platform/exclamation.png", :style=>"vertical-align:top;height:10px;", :title => trl("The API structure has changed")) if ['changed'].include?(api[:status]) return image_tag("platform/cancel.png", :style=>"vertical-align:top;height:10px;", :title => trl("The API has been removed")) if ['removed', 'deprecated'].include?(api[:status]) return image_tag("platform/add.png", :style=>"vertical-align:top;height:10px;", :title => trl("This API has been added")) if api[:status] == 'added' return image_tag("platform/accept.png", :style=>"vertical-align:top;height:10px;", :title => trl("This API has been updated")) if api[:status] == 'updated' end
platform_documentation_field_decorators_tag(field)
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 53 def platform_documentation_field_decorators_tag(field) return unless field[:status] return image_tag("platform/cancel.png", :style=>"vertical-align:top;height:10px;", :title => trl("This field has been deprecated and will no longer be supported in the future versions")) if ['deprecated', 'removed'].include?(field[:status]) return image_tag("platform/exclamation.png", :style=>"vertical-align:top;height:10px;", :title => trl("This field will be changed in the future versions")) if field[:status] == 'changed' return image_tag("platform/add.png", :style=>"vertical-align:top;height:10px;", :title => trl("This field has been added")) if field[:status] == 'added' return image_tag("platform/accept.png", :style=>"vertical-align:top;height:10px;", :title => trl("This field has been changed")) if field[:status] == 'updated' end
platform_documentation_tag(url_options = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 49 def platform_documentation_tag(url_options = {}) link_to(image_tag("platform/bullet_go.png", :style=>"vertical-align:middle;"), url_options.merge({:controller => "/platform/developer/help", :action => "api"})) end
platform_help_icon_tag(path = "index", opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 171 def platform_help_icon_tag(path = "index", opts = {}) link_to(image_tag("platform/help.png", :style => "border:0px; vertical-align:middle;", :title => trl("Help")), opts.merge({:controller => "/platform/developer/help", :action => path}), :target => "_new") end
platform_login_url_tag(label)
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 159 def platform_login_url_tag(label) link_to(label, platform_stringify_url(Platform::Config.login_url, :display => params[:display], :client_id => params[:client_id])) end
platform_logout_url_tag(label)
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 163 def platform_logout_url_tag(label) link_to(label, platform_stringify_url(Platform::Config.logout_url, :display => params[:display], :client_id => params[:client_id])) end
platform_paginator_tag(collection, options = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 167 def platform_paginator_tag(collection, options = {}) render :partial => "/platform/common/paginator", :locals => {:collection => collection, :options => options} end
platform_rating_tag(rating, opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 93 def platform_rating_tag(rating, opts = {}) return "" unless rating value = rating.value || 0 style = [] style << "width:#{opts[:width]}" if opts[:width] html = "<span dir='ltr'>" 1.upto(5) do |i| if i <= value html << image_tag("platform/rating_star1.png", :style => style.join(";")) else html << image_tag("platform/rating_star0.png", :style => style.join(";")) end end html << "</span>" html.html_safe end
platform_scripts_tag(opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 69 def platform_scripts_tag(opts = {}) render(:partial => '/platform/common/scripts', :locals => {:opts => opts}) end
platform_spinner_tag(id = "spinner", label = nil, cls='spinner')
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 112 def platform_spinner_tag(id = "spinner", label = nil, cls='spinner') html = "<div id='#{id}' class='#{cls}' style='display:none'>" html << image_tag("platform/spinner.gif", :style => "vertical-align:middle;") html << " #{trl(label)}" if label html << "</div>" end
platform_stringify_url(path, params)
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 175 def platform_stringify_url(path, params) "#{path}#{path.index('?') ? '&' : '?'}#{params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join("&")}" end
platform_toggler_tag(content_id, label = "", open = true, opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 33 def platform_toggler_tag(content_id, label = "", open = true, opts = {}) style = opts[:style] || 'text-align:center; vertical-align:middle' html = "<span id='#{content_id}_open' " html << "style='display:none'" unless open html << ">" html << link_to_function("#{image_tag("platform/arrow_down.gif", :style=>style)} #{label}".html_safe, "Tr8n.Effects.hide('#{content_id}_open'); Tr8n.Effects.show('#{content_id}_closed'); Tr8n.Effects.blindUp('#{content_id}');", :style=> "text-decoration:none") html << "</span>" html << "<span id='#{content_id}_closed' " html << "style='display:none'" if open html << ">" html << link_to_function("#{image_tag("platform/arrow_right.gif", :style=>style)} #{label}".html_safe, "Tr8n.Effects.show('#{content_id}_open'); Tr8n.Effects.hide('#{content_id}_closed'); Tr8n.Effects.blindDown('#{content_id}');", :style=> "text-decoration:none") html << "</span>" html.html_safe end
platform_user_login_tag(opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 28 def platform_user_login_tag(opts = {}) opts[:class] ||= 'tr8n_right_horiz_list' render(:partial => '/platform/common/user_login', :locals => {:opts => opts}) end
platform_user_mugshot_tag(user, options = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 141 def platform_user_mugshot_tag(user, options = {}) if user and !Platform::Config.user_mugshot(user).blank? img_url = Platform::Config.user_mugshot(user) else img_url = Platform::Config.silhouette_image(user) end img_tag = "<img src='#{img_url}' style='width:48px'>" if user and options[:linked] link_to(img_tag, Platform::Config.user_link(user)) else img_tag end img_tag.html_safe end
platform_user_tag(user, options = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 119 def platform_user_tag(user, options = {}) return "Deleted Translator" unless user if options[:linked] link_to(Platform::Config.user_name(user), Platform::Config.user_link(user)) else Platform::Config.user_name(user) end end
platform_when_string_tag(time, opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 187 def platform_when_string_tag(time, opts = {}) elapsed_seconds = Time.now - time return platform_when_string_tr("Today") if time.today_in_time_zone? if opts[:days_only] return platform_when_string_tr('In the future, Marty!') if elapsed_seconds < 0 return platform_when_string_tr('A moment ago') if elapsed_seconds < 2.minutes return platform_when_string_tr("{minutes||minute} ago", :minutes => (elapsed_seconds / 1.minute).to_i) if elapsed_seconds < 1.hour return platform_when_string_tr("{hours||hour} ago", :hours => 1) if elapsed_seconds < 1.75.hours return platform_when_string_tr("{hours||hour} ago", :hours => 2) if elapsed_seconds < 2.hours return platform_when_string_tr("{hours||hour} ago", :hours => (elapsed_seconds / 1.hour).to_i) if elapsed_seconds < 1.day return platform_when_string_tr("Yesterday") if elapsed_seconds < 48.hours return platform_when_string_tr("{days||day} ago", :days => elapsed_seconds.to_i / 1.day) if elapsed_seconds < 14.days return platform_when_string_tr("{weeks||week} ago", :weeks => (elapsed_seconds / 1.day / 7).to_i) if elapsed_seconds < 4.weeks return platform_display_time(time, :monthname_abbr) if Date.today.year == time.year return platform_display_time(time, :monthname_abbr_year) end
platform_when_string_tr(key, opts = {})
click to toggle source
# File lib/platform/extensions/action_view_extension.rb, line 179 def platform_when_string_tr(key, opts = {}) tr(key, 'Time reference', opts) end