<%= _('Content tagged with "%s"') % @tag %>
++<%= link_to image_tag('icons-mime/rss-feed.png', :alt => _('Feed for this tag'), :title => _('Feed for this tag')), tag_feed_path, :class => 'blog-feed-link'%> +
+ <% cache_timeout(@tag_cache_key, 4.hour.from_now) do %>-
diff --git a/config/routes.rb b/config/routes.rb
index 0f172e9..2c42c82 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -65,6 +65,9 @@ ActionController::Routing::Routes.draw do |map|
# invite
map.invite 'profile/:profile/invite/:action', :controller => 'invite', :profile => /#{Noosfero.identifier_format}/
+ # feeds per tag
+ map.tag_feed 'profile/:profile/tag/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.*/, :profile => /#{Noosfero.identifier_format}/
+
# public profile information
map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/
diff --git a/features/profile_tags.feature b/features/profile_tags.feature
new file mode 100644
index 0000000..43fd80f
--- /dev/null
+++ b/features/profile_tags.feature
@@ -0,0 +1,20 @@
+Feature: profile tags
+ As a Noosfero user
+ I want to to view content tagged
+ So that I can follow the subjects I care about
+
+ Background:
+ Given the following users
+ | login |
+ | terceiro |
+ And the following articles
+ | owner | name | body | tag_list |
+ | terceiro | text 1 | text 1 content | tag1, tag2 |
+ | terceiro | text 2 | text 2 content | tag1, tag3 |
+
+ Scenario: tag feed
+ When I go to terceiro's profile
+ And I follow "tag1"
+ And I follow "Feed for this tag"
+ Then I should see "text 1"
+ And I should see "text 2"
diff --git a/features/support/paths.rb b/features/support/paths.rb
index 3417932..8514042 100644
--- a/features/support/paths.rb
+++ b/features/support/paths.rb
@@ -30,6 +30,9 @@ module NavigationHelpers
when /^(.*)'s sitemap/
'/profile/%s/sitemap' % Profile.find_by_name($1).identifier
+ when /^(.*)'s profile/
+ '/profile/%s' % Profile.find_by_name($1).identifier
+
when /^login page$/
'/account/login'
diff --git a/lib/feed_writer.rb b/lib/feed_writer.rb
new file mode 100644
index 0000000..ee6eb89
--- /dev/null
+++ b/lib/feed_writer.rb
@@ -0,0 +1,37 @@
+class FeedWriter
+
+ include ActionController::UrlWriter
+
+ def write(articles, options = {})
+ result = ""
+ xml = Builder::XmlMarkup.new(:target => result)
+
+ xml.instruct! :xml, :version=>"1.0"
+ xml.rss(:version=>"2.0") do
+ xml.channel do
+ xml.title(options[:title] || _('Feed'))
+ if options[:link]
+ xml.link(options[:link])
+ end
+ if options[:description]
+ xml.description(options[:description])
+ end
+ for article in articles
+ xml.item do
+ xml.title(article.name)
+ xml.description(article.to_html)
+ if article.created_at
+ # rfc822
+ xml.pubDate(article.created_at.rfc2822)
+ end
+ # link to article
+ xml.link(url_for(article.url))
+ xml.guid(url_for(article.url))
+ end
+ end
+ end
+ end
+
+ result
+ end
+end
diff --git a/test/unit/blog_test.rb b/test/unit/blog_test.rb
index 8d357b6..b055d07 100644
--- a/test/unit/blog_test.rb
+++ b/test/unit/blog_test.rb
@@ -32,12 +32,6 @@ class BlogTest < ActiveSupport::TestCase
assert_kind_of RssFeed, b.feed
end
- should 'include articles body in feed by default' do
- p = create_user('testuser').person
- b = Blog.create!(:profile => p, :name => 'blog_feed_test')
- assert_equal 'body', b.feed.feed_item_description
- end
-
should 'save feed options' do
p = create_user('testuser').person
p.articles << Blog.new(:profile => p, :name => 'blog_feed_test')
diff --git a/test/unit/feed_writer_test.rb b/test/unit/feed_writer_test.rb
new file mode 100644
index 0000000..6d72558
--- /dev/null
+++ b/test/unit/feed_writer_test.rb
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class FeedWriterTest < Test::Unit::TestCase
+
+ should 'generate feeds' do
+ articles = []
+ profile = fast_create(:profile, :identifier => "tagger")
+ articles << fast_create(:article, :name => 'text 1', :slug => 'text-1', :path => 'text-1', :profile_id => profile.id)
+ articles << fast_create(:article, :name => 'text 2', :slug => 'text-2', :path => 'text-2', :profile_id => profile.id)
+ writer = FeedWriter.new
+
+ feed = writer.write(articles)
+ assert_match('text 1', feed)
+ assert_match('/tagger/' + articles.first.slug, feed)
+ end
+
+ should 'use title, link and description' do
+ writer = FeedWriter.new
+ rss = writer.write([], :title => "my title", :description => "my description", :link => "http://example.com/")
+ assert_match("my title", rss)
+ assert_match("my description", rss)
+ assert_match("http://example.com/", rss)
+ end
+
+end
+
diff --git a/test/unit/rss_feed_test.rb b/test/unit/rss_feed_test.rb
index 8d6f5cd..680710a 100644
--- a/test/unit/rss_feed_test.rb
+++ b/test/unit/rss_feed_test.rb
@@ -62,24 +62,6 @@ class RssFeedTest < Test::Unit::TestCase
feed.data
end
- should 'be able to choose to put abstract or entire body on feed' do
- profile = create_user('testuser').person
- a1 = profile.articles.build(:name => 'article 1', 'abstract' => 'my abstract', 'body' => 'my text'); a1.save!
-
- feed = RssFeed.new(:name => 'testfeed')
- feed.profile = profile
- feed.save!
-
- rss = feed.data
- assert_match /