2010-05-14 15:12:31 -07:00
|
|
|
module ApplicationHelper
|
2010-11-08 17:40:03 -08:00
|
|
|
def add_body_class(class_name)
|
|
|
|
@body_class ||= ''
|
|
|
|
@body_class << " #{class_name}"
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-10-18 15:10:50 -07:00
|
|
|
def auth_server_icon_url
|
2010-11-13 07:37:57 -08:00
|
|
|
"http://#{Openneo::Auth.config.auth_server}/favicon.png"
|
2010-10-18 15:10:50 -07:00
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-11-05 15:45:05 -07:00
|
|
|
def body_class
|
2010-11-08 17:40:03 -08:00
|
|
|
"#{params[:controller]} #{params[:controller]}-#{params[:action]}".tap do |output|
|
|
|
|
output << @body_class if @body_class
|
|
|
|
end
|
2010-11-05 15:45:05 -07:00
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2011-07-09 08:45:30 -07:00
|
|
|
def campaign_progress(&block)
|
2011-07-01 12:38:13 -07:00
|
|
|
include_campaign_progress_requirements
|
|
|
|
|
2011-07-09 08:45:30 -07:00
|
|
|
if block_given?
|
|
|
|
content = capture(&block)
|
|
|
|
else
|
|
|
|
content = link_to('We need your help to keep growing and stay online!', donate_path) +
|
|
|
|
link_to('Donate now!', donate_path, :class => 'button')
|
|
|
|
end
|
|
|
|
|
2011-07-01 12:38:13 -07:00
|
|
|
html = content_tag(:div, nil, :class => 'campaign-progress') +
|
|
|
|
content_tag(:div, content, :class => 'campaign-progress-label')
|
|
|
|
content_tag(:div, html, :class => 'campaign-progress-wrapper')
|
|
|
|
end
|
|
|
|
|
2010-05-15 10:47:46 -07:00
|
|
|
def flashes
|
2010-11-05 15:45:05 -07:00
|
|
|
raw(flash.inject('') do |html, pair|
|
2010-05-15 10:47:46 -07:00
|
|
|
key, value = pair
|
2011-07-15 14:21:18 -07:00
|
|
|
html + content_tag('p', value, :class => "flash #{key}")
|
2010-11-05 15:45:05 -07:00
|
|
|
end)
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2011-07-01 12:38:13 -07:00
|
|
|
def include_campaign_progress_requirements
|
|
|
|
unless @included_campaign_progress_requirements
|
|
|
|
content_for(:javascripts,
|
|
|
|
include_javascript_libraries(:jquery) +
|
|
|
|
javascript_include_tag('pledgie')
|
|
|
|
)
|
|
|
|
|
|
|
|
content_for(:meta,
|
|
|
|
tag(:meta, :name => 'pledgie-campaign-id', :content => PLEDGIE_CAMPAIGN_ID)
|
|
|
|
)
|
|
|
|
|
|
|
|
@included_campaign_progress_requirements = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-11-30 13:52:38 -08:00
|
|
|
def hide_home_link
|
|
|
|
@hide_home_link = true
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-11-30 13:52:38 -08:00
|
|
|
def home_link?
|
|
|
|
!@hide_home_link
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-12-06 15:50:13 -08:00
|
|
|
JAVASCRIPT_LIBRARIES = {
|
|
|
|
:addthis => 'http://s7.addthis.com/js/250/addthis_widget.js#username=openneo',
|
|
|
|
:bitly => 'http://bit.ly/javascript-api.js?version=latest&login=openneo&apiKey=R_4d0438829b7a99860de1d3edf55d8dc8',
|
|
|
|
:html5 => 'http://html5shim.googlecode.com/svn/trunk/html5.js',
|
|
|
|
:jquery => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js',
|
|
|
|
:jquery_tmpl => 'http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js',
|
|
|
|
:swfobject => 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js'
|
|
|
|
}
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-12-06 15:50:13 -08:00
|
|
|
def include_javascript_libraries(*library_names)
|
|
|
|
raw(library_names.inject('') do |html, name|
|
|
|
|
html + javascript_include_tag(JAVASCRIPT_LIBRARIES[name])
|
|
|
|
end)
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-10-18 15:17:08 -07:00
|
|
|
def login_path_with_return_to
|
2010-11-10 13:59:54 -08:00
|
|
|
login_path :return_to => request.fullpath
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-11-10 13:59:54 -08:00
|
|
|
def logout_path_with_return_to
|
|
|
|
logout_path :return_to => request.fullpath
|
2010-10-18 15:17:08 -07:00
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-11-05 17:09:03 -07:00
|
|
|
def origin_tag(value)
|
|
|
|
hidden_field_tag 'origin', value, :id => nil
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
|
|
|
def show_title_header?
|
|
|
|
params[:controller] != 'items'
|
|
|
|
end
|
|
|
|
|
2010-11-11 10:43:22 -08:00
|
|
|
def signed_in_meta_tag
|
|
|
|
%(<meta name="user-signed-in" content="#{user_signed_in?}">).html_safe
|
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|
2010-11-06 08:52:58 -07:00
|
|
|
def title(value)
|
|
|
|
content_for :title, value
|
|
|
|
end
|
2011-07-12 17:03:04 -07:00
|
|
|
|
|
|
|
def user_is?(user)
|
|
|
|
user_signed_in? && user == current_user
|
|
|
|
end
|
2010-05-14 15:12:31 -07:00
|
|
|
end
|
2011-05-13 05:20:29 -07:00
|
|
|
|