2007-03-30 04:36:52 +00:00
|
|
|
module FeedlistHelper
|
2012-07-18 11:42:26 +02:00
|
|
|
def linkoptions(format, options)
|
2020-10-27 21:39:19 +02:00
|
|
|
merge_hashes({ :format => format }, options, user_token_hash)
|
2012-07-18 11:42:26 +02:00
|
|
|
end
|
2014-08-14 21:05:05 -05:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
def rss_formatted_link(options = {})
|
|
|
|
image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon")
|
2014-08-14 21:05:05 -05:00
|
|
|
link_to(image_tag, linkoptions('rss', options), :title => "RSS feed")
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def text_formatted_link(options = {})
|
2020-10-10 02:27:42 +03:00
|
|
|
link_to(content_tag(:span, 'TXT', { :class => 'feed', :title => "Plain text feed" }), linkoptions('txt', options))
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|
2014-08-14 21:05:05 -05:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
def ical_formatted_link(options = {})
|
2020-10-10 13:58:13 +03:00
|
|
|
link_to(content_tag(:span, 'iCal', { :class => "feed", :title => "iCal feed" }), linkoptions('ics', options))
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|
2010-11-27 17:12:09 +01:00
|
|
|
|
|
|
|
def feed_links(feeds, link_options, title)
|
|
|
|
space = " "
|
|
|
|
html = ""
|
2020-10-10 02:27:42 +03:00
|
|
|
html << rss_formatted_link(link_options) + space if feeds.include?(:rss)
|
|
|
|
html << text_formatted_link(link_options) + space if feeds.include?(:txt)
|
|
|
|
html << ical_formatted_link(link_options) + space if feeds.include?(:ical)
|
2010-11-27 17:12:09 +01:00
|
|
|
html << title
|
2012-05-03 23:23:31 +02:00
|
|
|
return html.html_safe
|
2010-11-27 17:12:09 +01:00
|
|
|
end
|
|
|
|
|
2013-09-22 17:34:58 +02:00
|
|
|
def all_feed_links(object, symbol)
|
2020-10-10 02:27:42 +03:00
|
|
|
feed_links([:rss, :txt, :ical], { :controller => 'todos', :action => 'index', symbol => object.to_param }, content_tag(:strong, object.name))
|
2013-09-22 17:34:58 +02:00
|
|
|
end
|
|
|
|
|
2010-11-27 17:12:09 +01:00
|
|
|
def all_feed_links_for_project(project)
|
2014-08-14 21:05:05 -05:00
|
|
|
all_feed_links(project, :project_id)
|
2010-11-27 17:12:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def all_feed_links_for_context(context)
|
2013-09-22 17:34:58 +02:00
|
|
|
all_feed_links(context, :context_id)
|
2010-11-27 17:12:09 +01:00
|
|
|
end
|
|
|
|
|
2007-07-30 05:29:18 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def merge_hashes(*hashes)
|
2020-10-27 21:39:19 +02:00
|
|
|
hashes.inject({}) { |result, h| result.merge(h) }
|
2007-07-30 05:29:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def user_token_hash
|
|
|
|
{ :token => current_user.token }
|
|
|
|
end
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|