Commit 3d6e53c7d761c69192959756ed32230909180008
1 parent
9fee0433
Exists in
master
and in
29 other branches
ActionItem24: checkpoint
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1139 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
14 changed files
with
70 additions
and
11 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
app/controllers/public/content_viewer_controller.rb
| ... | ... | @@ -21,7 +21,14 @@ class ContentViewerController < PublicController |
| 21 | 21 | |
| 22 | 22 | if @page.mime_type != 'text/html' |
| 23 | 23 | headers['Content-Type'] = @page.mime_type |
| 24 | - render :text => @page.data, :layout => false | |
| 24 | + data = @page.data | |
| 25 | + | |
| 26 | + # TODO test the condition | |
| 27 | + if data.nil? | |
| 28 | + raise "No data for file" | |
| 29 | + end | |
| 30 | + | |
| 31 | + render :text => data, :layout => false | |
| 25 | 32 | return |
| 26 | 33 | end |
| 27 | 34 | ... | ... |
app/models/rss_feed.rb
| ... | ... | @@ -69,8 +69,9 @@ class RssFeed < Article |
| 69 | 69 | xml.rss(:version=>"2.0") do |
| 70 | 70 | xml.channel do |
| 71 | 71 | xml.title(_("%s's RSS feed") % (self.profile.name)) |
| 72 | + # FIXME link to profile | |
| 72 | 73 | xml.link("http://www.yourDomain.com") |
| 73 | - xml.description('Description here') | |
| 74 | + xml.description(_("%s's content published at %s") % [self.profile.name, self.profile.environment.name]) | |
| 74 | 75 | xml.language("pt_BR") |
| 75 | 76 | for article in articles |
| 76 | 77 | unless self == article |
| ... | ... | @@ -83,6 +84,7 @@ class RssFeed < Article |
| 83 | 84 | end |
| 84 | 85 | # rfc822 |
| 85 | 86 | xml.pubDate(article.created_on.rfc2822) |
| 87 | + # FIXME link to article | |
| 86 | 88 | xml.link("http://www.yourDomain.com/linkToYourPost") |
| 87 | 89 | xml.guid("http://www.yourDomain.com/linkToYourPost") |
| 88 | 90 | end | ... | ... |
app/models/uploaded_file.rb
| 1 | 1 | class UploadedFile < Article |
| 2 | 2 | |
| 3 | 3 | # FIXME need to define min/max file size |
| 4 | - has_attachment :thumbnails => { :icon => [24,24] } | |
| 4 | + has_attachment :thumbnails => { :icon => [24,24] }, :storage => :file_system | |
| 5 | 5 | |
| 6 | 6 | def icon_name |
| 7 | 7 | self.image? ? public_filename(:icon) : self.content_type.gsub('/', '-') |
| ... | ... | @@ -19,4 +19,14 @@ class UploadedFile < Article |
| 19 | 19 | _('Upload any kind of file you want.') |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | + alias :orig_set_filename :filename= | |
| 23 | + def filename=(value) | |
| 24 | + orig_set_filename(value) | |
| 25 | + self.name = self.filename | |
| 26 | + end | |
| 27 | + | |
| 28 | + def data | |
| 29 | + File.read(self.full_filename) | |
| 30 | + end | |
| 31 | + | |
| 22 | 32 | end | ... | ... |
app/views/cms/_rss_feed.rhtml
| ... | ... | @@ -2,6 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | <%= labelled_form_field(_('Limit of articles'), f.text_field(:limit)) %> |
| 4 | 4 | |
| 5 | -<%= labelled_form_field(_('Use as item description:'), f.select(:feed_item_description, [ [ _('Article body'), 'body'], [ _('Article abstract'), 'abstract']])) %> | |
| 5 | +<%= labelled_form_field(_('Use as item description:'), f.select(:feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %> | |
| 6 | 6 | |
| 7 | 7 | <%= labelled_form_field(_('Include:'), f.select(:include, [ [ _('All articles'), 'all' ], [ _('Only articles child of the same article as the feed'), 'parent_and_children']] )) %> | ... | ... |
app/views/cms/_textile_article.rhtml
app/views/cms/_tiny_mce_article.rhtml
app/views/cms/edit.rhtml
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | |
| 4 | 4 | <%= error_messages_for 'article' %> |
| 5 | 5 | |
| 6 | -<% labelled_form_for 'article', @article do |f| %> | |
| 6 | +<% labelled_form_for 'article', @article, :html => { :multipart => true } do |f| %> | |
| 7 | 7 | |
| 8 | 8 | <%= hidden_field_tag("type", params[:type]) if params[:type] %> |
| 9 | 9 | |
| ... | ... | @@ -11,6 +11,9 @@ |
| 11 | 11 | |
| 12 | 12 | <%= render :partial => partial_for_class(@article.class), :locals => { :f => f } %> |
| 13 | 13 | |
| 14 | + <%# TODO display the tooltip (title below) in a directly visible way %> | |
| 15 | + <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %> | |
| 16 | + | |
| 14 | 17 | <%= design_display_button_submit('save', _('Save')) %> |
| 15 | 18 | <%= design_display_button('cancel', _('Cancel'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %> |
| 16 | 19 | <% end %> | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +this is a sample text file | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -163,11 +163,17 @@ class CmsControllerTest < Test::Unit::TestCase |
| 163 | 163 | end |
| 164 | 164 | |
| 165 | 165 | should 'be able to upload a file' do |
| 166 | - flunk 'pending' | |
| 166 | + assert_difference UploadedFile, :count do | |
| 167 | + post :new, :type => UploadedFile.name, :profile => profile.identifier, :article => { :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')} | |
| 168 | + end | |
| 167 | 169 | end |
| 168 | 170 | |
| 169 | 171 | should 'be able to update an uploaded file' do |
| 170 | 172 | flunk 'pending' |
| 171 | 173 | end |
| 172 | 174 | |
| 175 | + should 'not offer to create children if article does not accept them' do | |
| 176 | + flunk 'pending' | |
| 177 | + end | |
| 178 | + | |
| 173 | 179 | end | ... | ... |
test/unit/article_test.rb
| ... | ... | @@ -158,4 +158,12 @@ class ArticleTest < Test::Unit::TestCase |
| 158 | 158 | assert_equal 'An article of type "MyClass"', klass.description |
| 159 | 159 | end |
| 160 | 160 | |
| 161 | + should 'indicate wheter children articles are allowed or not' do | |
| 162 | + flunk 'pending' | |
| 163 | + end | |
| 164 | + | |
| 165 | + should 'provide a url to itself' do | |
| 166 | + flunk 'pending' | |
| 167 | + end | |
| 168 | + | |
| 161 | 169 | end | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -217,6 +217,10 @@ class ProfileTest < Test::Unit::TestCase |
| 217 | 217 | assert_equal blocks - profile_blocks, Design::Block.count |
| 218 | 218 | end |
| 219 | 219 | |
| 220 | + should 'provide url to itself' do | |
| 221 | + flunk 'pending' | |
| 222 | + end | |
| 223 | + | |
| 220 | 224 | private |
| 221 | 225 | |
| 222 | 226 | def assert_invalid_identifier(id) | ... | ... |
test/unit/rss_feed_test.rb
| ... | ... | @@ -106,6 +106,14 @@ class RssFeedTest < Test::Unit::TestCase |
| 106 | 106 | assert_no_match /<item><title>article 2<\/title>/, rss |
| 107 | 107 | end |
| 108 | 108 | |
| 109 | + should 'provide link to profile' do | |
| 110 | + flunk 'pending' | |
| 111 | + end | |
| 112 | + | |
| 113 | + should 'provide link to each article' do | |
| 114 | + flunk 'pending' | |
| 115 | + end | |
| 116 | + | |
| 109 | 117 | should 'be able to indicate maximum number of items' do |
| 110 | 118 | profile = create_user('testuser').person |
| 111 | 119 | a1 = profile.articles.build(:name => 'article 1'); a1.save! | ... | ... |
test/unit/uploaded_file_test.rb
| ... | ... | @@ -32,4 +32,17 @@ class UploadedFileTest < Test::Unit::TestCase |
| 32 | 32 | assert_not_equal Article.short_description, UploadedFile.short_description |
| 33 | 33 | end |
| 34 | 34 | |
| 35 | + should 'set name from uploaded filename' do | |
| 36 | + file = UploadedFile.new | |
| 37 | + file.filename = 'test.txt' | |
| 38 | + assert_equal 'test.txt', file.name | |
| 39 | + end | |
| 40 | + | |
| 41 | + should 'provide file content as data' do | |
| 42 | + file = UploadedFile.new | |
| 43 | + file.expects(:full_filename).returns('myfilename') | |
| 44 | + File.expects(:read).with('myfilename').returns('my data') | |
| 45 | + assert_equal 'my data', file.data | |
| 46 | + end | |
| 47 | + | |
| 35 | 48 | end | ... | ... |