Commit 132c1fdd7870b4d62882d2f318a48e1103216205

Authored by AntonioTerceiro
1 parent 0c4d7428

ActionItem24: yet implementing support for different types of articles



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1128 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/cms_controller.rb
... ... @@ -7,7 +7,9 @@ class CmsController < MyProfileController
7 7 include CmsHelper
8 8  
9 9 ARTICLE_TYPES = [
10   - TinyMceArticle
  10 + TinyMceArticle,
  11 + TextileArticle,
  12 + RssFeed
11 13 ]
12 14  
13 15 def view
... ...
app/models/textile_article.rb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +class TextileArticle < Article
  2 +
  3 + def self.short_description
  4 + _('Text article with Textile markup language')
  5 + end
  6 +
  7 + def self.description
  8 + _('Accessible alternative for visually impaired users.')
  9 + end
  10 +
  11 + def to_html
  12 + RedCloth.new(self.body).to_html
  13 + end
  14 +
  15 +end
... ...
app/models/tiny_mce_article.rb
1 1 class TinyMceArticle < Article
  2 +
  3 + def self.short_description
  4 + _('Text article with visual editor.')
  5 + end
  6 +
  7 + def self.description
  8 + _('Not accessible for visually impaired users.')
  9 + end
2 10 end
... ...
app/views/cms/_textile_article.rhtml 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +
  2 +<%# TODO add Textile help here %>
  3 +
  4 +<%= f.text_field('name', :size => '64') %>
  5 +
  6 +<%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %>
  7 +
  8 +<%= f.text_area('abstract', :cols => 64, :rows => 5) %>
  9 +
  10 +<%= f.text_area('body', :cols => 64) %>
  11 +
... ...
app/views/cms/_tiny_mce_article.rhtml
1 1  
  2 +<%= render :file => 'shared/tiny_mce' %>
  3 +
2 4 <%= f.text_field('name', :size => '64') %>
3 5  
4 6 <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %>
... ...
app/views/cms/edit.rhtml
1 1  
2 2  
3   -<%= render :file => 'shared/tiny_mce' %>
4 3  
5 4 <%= error_messages_for 'article' %>
6 5  
... ...
test/functional/cms_controller_test.rb
... ... @@ -56,8 +56,8 @@ class CmsControllerTest &lt; Test::Unit::TestCase
56 56 assert_template 'select_article_type'
57 57  
58 58 # TODO add more types here !!
59   - [ 'TinyMceArticle' ].each do |item|
60   - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=#{item}" }
  59 + [ TinyMceArticle, TextileArticle ].each do |item|
  60 + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=#{item.name}" }
61 61 end
62 62 end
63 63  
... ...
test/unit/textile_article_test.rb 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class TextileArticleTest < Test::Unit::TestCase
  4 +
  5 + def setup
  6 + @profile = create_user('testing').person
  7 + end
  8 + attr_reader :profile
  9 +
  10 + should 'provide a proper short description' do
  11 + # not test the actual text, though
  12 + TextileArticle.stubs(:==).with(Article).returns(true)
  13 + assert_not_equal Article.short_description, TextileArticle.short_description
  14 + end
  15 +
  16 + should 'provide a proper description' do
  17 + # not test the actual text, though
  18 + TextileArticle.stubs(:==).with(Article).returns(true)
  19 + assert_not_equal Article.description, TextileArticle.description
  20 + end
  21 +
  22 + should 'convert Textile to HTML' do
  23 + assert_equal '<p><strong>my text</strong></p>', TextileArticle.new(:body => '*my text*').to_html
  24 + end
  25 +
  26 +end
... ...