Module: MuckRakerServicesHelper
- Defined in:
- app/helpers/muck_raker_services_helper.rb
Instance Method Summary collapse
-
#service_categories(service_categories, title = nil, css = '') ⇒ Object
Render a view with all services in categories.
-
#service_delete(identity_feed, button_type = :button, button_text = t("muck.general.delete")) ⇒ Object
Renders a delete button for an identity_feed.
- #service_external_link(identity_feed, link_css = nil, wrapper = nil) ⇒ Object
-
#service_icon(name, size = 24) ⇒ Object
Renders an icon for the given service Name is the name of the image file associated with the service Size can be one of 16, 24, 48 or 60.
- #service_icon_background(service) ⇒ Object
- #service_image(name, size = 24) ⇒ Object
-
#service_lightbox(parent, service, link_css = 'lightbox', wrapper = 'li') ⇒ Object
Renders a link for a new user service with class ‘lightbox’ or optional css set on the link.
-
#service_lightbox_edit(parent, identity_feed, link_css = 'lightbox', wrapper = nil) ⇒ Object
Renders a link for editing a user feed with class ‘lightbox’ or optional css set on the link.
-
#service_link(path, service, link_css, wrapper, link_text = nil, target = nil, id = nil) ⇒ Object
Renders a service link optionally wrapping it in the specified element.
-
#service_prompt(service) ⇒ Object
By default renders Service username e.g.
-
#service_title(service) ⇒ Object
Renders name and icon for the service.
-
#services_for_user(identity_feeds, title = nil, css = '') ⇒ Object
Render a view with the user’s registered services.
-
#services_for_user_edit(identity_feeds, title = nil, css = '') ⇒ Object
Render an edit view with the user’s registered services.
-
#services_summary(parent) ⇒ Object
Render a summary of all services for the given parent.
- #url_by_identity_feed(owner, identity_feed, service) ⇒ Object
Instance Method Details
#service_categories(service_categories, title = nil, css = '') ⇒ Object
Render a view with all services in categories. service_categories: Results from a query to service_categories. For performance try something like this:
ServiceCategory.sorted.find(:all, :include => [:identity_services])
title: Optional title. Default is ‘Available Services’ - from I18n.t(‘muck.raker.available_services’) css: Optional css to be added to the div that surrounds the categories
14 15 16 |
# File 'app/helpers/muck_raker_services_helper.rb', line 14 def service_categories(service_categories, title = nil, css = '') render :partial => 'identity_feeds/service_categories', :locals => { :service_categories => service_categories, :css => css, :title => title } end |
#service_delete(identity_feed, button_type = :button, button_text = t("muck.general.delete")) ⇒ Object
Renders a delete button for an identity_feed
87 88 89 90 91 92 93 |
# File 'app/helpers/muck_raker_services_helper.rb', line 87 def service_delete(identity_feed, = :button, = t("muck.general.delete")) render :partial => 'shared/delete', :locals => { :delete_object => identity_feed, :button_type => , :button_text => , :form_class => 'identity-feed-delete', :delete_path => identity_feed_path(identity_feed, :format => 'js') } end |
#service_external_link(identity_feed, link_css = nil, wrapper = nil) ⇒ Object
80 81 82 83 84 |
# File 'app/helpers/muck_raker_services_helper.rb', line 80 def service_external_link(identity_feed, link_css = nil, wrapper = nil) path = identity_feed.feed.display_uri || identity_feed.feed.uri link_text = identity_feed.feed.title unless identity_feed.feed.title.blank? service_link(path, identity_feed.feed.service, link_css, wrapper, link_text, 'blank') end |
#service_icon(name, size = 24) ⇒ Object
Renders an icon for the given service Name is the name of the image file associated with the service Size can be one of 16, 24, 48 or 60.
39 40 41 |
# File 'app/helpers/muck_raker_services_helper.rb', line 39 def service_icon(name, size = 24) %Q{<img src="/images/service_icons/#{size}/#{name}" />} end |
#service_icon_background(service) ⇒ Object
105 106 107 |
# File 'app/helpers/muck_raker_services_helper.rb', line 105 def service_icon_background(service) %Q{style="background: transparent url('#{service_image(service.icon, 24)}') no-repeat scroll left top;"} end |
#service_image(name, size = 24) ⇒ Object
43 44 45 |
# File 'app/helpers/muck_raker_services_helper.rb', line 43 def service_image(name, size = 24) %Q{/images/service_icons/#{size}/#{name}} end |
#service_lightbox(parent, service, link_css = 'lightbox', wrapper = 'li') ⇒ Object
Renders a link for a new user service with class ‘lightbox’ or optional css set on the link.
68 69 70 71 |
# File 'app/helpers/muck_raker_services_helper.rb', line 68 def service_lightbox(parent, service, link_css = 'lightbox', wrapper = 'li') path = new_polymorphic_url([parent, :identity_feed], :service_id => service.to_param) service_link(path, service, link_css, wrapper, nil, nil, "#{service.name.parameterize}-link") end |
#service_lightbox_edit(parent, identity_feed, link_css = 'lightbox', wrapper = nil) ⇒ Object
Renders a link for editing a user feed with class ‘lightbox’ or optional css set on the link.
74 75 76 77 78 |
# File 'app/helpers/muck_raker_services_helper.rb', line 74 def service_lightbox_edit(parent, identity_feed, link_css = 'lightbox', wrapper = nil) path = edit_polymorphic_url([parent, identity_feed]) link_text = identity_feed.feed.title unless identity_feed.feed.title.blank? service_link(path, identity_feed.feed.service, link_css, wrapper, link_text) end |
#service_link(path, service, link_css, wrapper, link_text = nil, target = nil, id = nil) ⇒ Object
Renders a service link optionally wrapping it in the specified element
96 97 98 99 100 101 102 103 |
# File 'app/helpers/muck_raker_services_helper.rb', line 96 def service_link(path, service, link_css, wrapper, link_text = nil, target = nil, id = nil) link = %Q{<a #{'id=' + id if id} href="#{path}" #{service_icon_background(service)} #{'target=' + target if target} class="service-link #{link_css}">#{link_text || service.name}</a>} if wrapper content_tag wrapper, link, :class => 'identity-service' else link end end |
#service_prompt(service) ⇒ Object
By default renders Service username e.g. Flickr username If the service has a ‘prompt’ set it will look for a value in the localization files. For example, setting service.prompt to ‘blog_url’ will cause this method to look for a translation at muck.raker.blog_url and will pass the name of the service using ‘service’ so your translation might look like: muck.raker.blog_url: “Blog Url” or muck.raker.facebook_prompt: “{service} Feeds”
59 60 61 62 63 64 65 |
# File 'app/helpers/muck_raker_services_helper.rb', line 59 def service_prompt(service) if @service.prompt.blank? I18n.t('muck.raker.service_username', :service => @service.name) else I18n.t("muck.raker.#{@service.prompt}", :service => @service.name) end end |
#service_title(service) ⇒ Object
Renders name and icon for the service
48 49 50 |
# File 'app/helpers/muck_raker_services_helper.rb', line 48 def service_title(service) %Q{<div class="identity-service-title" #{service_icon_background(service)}>#{service_prompt(service)}</div>} end |
#services_for_user(identity_feeds, title = nil, css = '') ⇒ Object
Render a view with the user’s registered services. identity_feeds: Results from a query to service_categories. For performance try something like this:
@user.identity_feeds.find(:all, :include => [{:feed => :service}])
title: Optional title. Default is ‘My Services’ - from I18n.t(‘muck.raker.my_services’) css: Optional css to be added to the div that surrounds the categories
23 24 25 |
# File 'app/helpers/muck_raker_services_helper.rb', line 23 def services_for_user(identity_feeds, title = nil, css = '') render :partial => 'identity_feeds/services_for_user', :locals => { :identity_feeds => identity_feeds, :css => css, :title => title, :edit => false } end |
#services_for_user_edit(identity_feeds, title = nil, css = '') ⇒ Object
Render an edit view with the user’s registered services. identity_feeds: Results from a query to service_categories. For performance try something like this:
@user.identity_feeds.find(:all, :include => [{:feed => :service}])
title: Optional title. Default is ‘My Services’ - from I18n.t(‘muck.raker.my_services’) css: Optional css to be added to the div that surrounds the categories
32 33 34 |
# File 'app/helpers/muck_raker_services_helper.rb', line 32 def services_for_user_edit(identity_feeds, title = nil, css = '') render :partial => 'identity_feeds/services_for_user', :locals => { :identity_feeds => identity_feeds, :css => css, :title => title, :edit => true } end |
#services_summary(parent) ⇒ Object
Render a summary of all services for the given parent. The parent should ‘acts_as_muck_feed_owner’
4 5 6 7 |
# File 'app/helpers/muck_raker_services_helper.rb', line 4 def services_summary(parent) identity_feeds = parent.identity_feeds.find(:all, :include => [{:feed => :service}]) render :partial => 'services/summary', :locals => { :identity_feeds => identity_feeds } end |
#url_by_identity_feed(owner, identity_feed, service) ⇒ Object
109 110 111 112 113 114 115 |
# File 'app/helpers/muck_raker_services_helper.rb', line 109 def url_by_identity_feed(owner, identity_feed, service) if identity_feed polymorphic_url([owner, @identity_feed], :service_id => service.to_param) else polymorphic_url([owner, :identity_feeds], :service_id => service.to_param) end end |