diff --git a/app/views/cms/_event.rhtml b/app/views/cms/_event.rhtml index f6aec62..7013a19 100644 --- a/app/views/cms/_event.rhtml +++ b/app/views/cms/_event.rhtml @@ -15,5 +15,4 @@ <%= labelled_form_field(_('Address:'), text_field(:article, :address)) %> -<%= labelled_form_field(_('Information about the event:'), text_area(:article, :body, :cols => 64, :class => 'mceEditor')) %> - +<%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :body_label => 'Information about the event:'} %> diff --git a/app/views/cms/_textile_article.rhtml b/app/views/cms/_textile_article.rhtml index b9d0eab..9bfa17e 100644 --- a/app/views/cms/_textile_article.rhtml +++ b/app/views/cms/_textile_article.rhtml @@ -5,17 +5,4 @@ <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64')) %> <%= render :partial => 'translatable' %> - -
-<%= button :add, _("Lead"), '#', :id => "lead-button", :style => "margin-left: 0px;" %> -<%= _('Used when a short version of your text is needed.') %> - -
- <%= labelled_form_field(_('Lead'), text_area(:article, 'abstract', :cols => 64, :rows => 10)) %> -
-
- <%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 64, :rows => 30)) %> -
- -<%= javascript_include_tag 'article'%> - +<%= render :partial => 'shared/lead_and_body' %> diff --git a/app/views/cms/_tiny_mce_article.rhtml b/app/views/cms/_tiny_mce_article.rhtml index a4cae6b..e01c722 100644 --- a/app/views/cms/_tiny_mce_article.rhtml +++ b/app/views/cms/_tiny_mce_article.rhtml @@ -12,18 +12,5 @@ <% end %> <%= render :partial => 'translatable' %> - -
- <%= button :add, _("Lead"), '#', :id => "lead-button", :style => "margin-left: 0px;" %> - <%= _('Used when a short version of your text is needed.') %> - -
- <%= labelled_form_field(_('Lead'), text_area(:article, 'abstract', :style => 'width: 100%; height: 200px;', :class => 'mceEditor')) %> -
-
- <%= labelled_form_field(_('Text'), text_area(:article, 'body', :style => 'width:100%; height: 500px;', :class => 'mceEditor')) %> -
- + <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true} %> - -<%= javascript_include_tag 'article' %> diff --git a/app/views/cms/suggest_an_article.rhtml b/app/views/cms/suggest_an_article.rhtml index 443ee4c..2ab614a 100644 --- a/app/views/cms/suggest_an_article.rhtml +++ b/app/views/cms/suggest_an_article.rhtml @@ -16,16 +16,7 @@ <%= required labelled_form_field(_('Email'), text_field(:task, 'email')) %> -
- <%= button :add, _("Lead"), '#', :id => "lead-button", :style => "margin-left: 0px;" %> - <%= _('Used when a short version of your text is needed.') %> - -
- <%= labelled_form_field(_('Lead'), text_area(:task , 'article_abstract', :style => 'width: 100%; height: 200px;', :class => 'mceEditor')) %> -
-
- <%= labelled_form_field(_('Text'), text_area(:task, 'article_body', :style => 'width:100%; height: 500px;', :class => 'mceEditor')) %> -
+ <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :object => :task, :abstract_method => 'article_abstract', :body_method => 'article_body'} %>
<%= labelled_form_field(_("What is the result of '%s = ?'") % @task.captcha.task, text_field(:task, 'captcha_solution')) %> @@ -39,5 +30,3 @@ <%= button :cancel, _('Cancel'), @back_to %> <% end %> <% end %> - -<%= javascript_include_tag 'article' %> diff --git a/app/views/shared/_lead_and_body.rhtml b/app/views/shared/_lead_and_body.rhtml new file mode 100644 index 0000000..ad5ed41 --- /dev/null +++ b/app/views/shared/_lead_and_body.rhtml @@ -0,0 +1,29 @@ +<% object ||= :article %> +<% abstract_label ||= 'Lead' %> +<% abstract_method ||= :abstract %> +<% body_label ||= 'Text' %> +<% body_method ||= :body %> +<% editor_type = defined?(tiny_mce) && tiny_mce ? 'mceEditor' : '' %> +<% lead_id ||= 0%> +<% f ||= false%> + +
+<%= button :add, _("Lead"), '#', :class => "lead-button", :article_id => "#article-lead-"+lead_id.to_s, :style => "margin-left: 0px;" %> +<%= _('Used when a short version of your text is needed.') %> + +
+ <% if f %> + <%= labelled_form_field(_(abstract_label), f.text_area(abstract_method, :style => 'width: 98%; height: 200px;', :class => editor_type)) %> + <% else %> + <%= labelled_form_field(_(abstract_label), text_area(object, abstract_method, :style => 'width: 98%; height: 200px;', :class => editor_type)) %> + <% end %> +
+
+ <% if f %> + <%= labelled_form_field(_(body_label), f.text_area(body_method, :style => 'width: 98%; height: 400px;', :class => editor_type)) %> + <% else %> + <%= labelled_form_field(_(body_label), text_area(object, body_method, :style => 'width: 98%; height: 400px;', :class => editor_type)) %> + <% end %> +
+ +<%= javascript_include_tag 'article'%> diff --git a/app/views/tasks/_approve_article_accept_details.rhtml b/app/views/tasks/_approve_article_accept_details.rhtml index 39129a5..d3862d9 100644 --- a/app/views/tasks/_approve_article_accept_details.rhtml +++ b/app/views/tasks/_approve_article_accept_details.rhtml @@ -4,21 +4,8 @@ <%= select_profile_folder(_('Select the folder where the article must be published'), "tasks[#{task.id}][task]", 'article_parent_id', task.target) %> <%= labelled_form_field(_('Highlight this article'), f.check_box(:highlighted)) %> -
- <% if task.article && task.article.tiny_mce? %> - <%= labelled_form_field(_('Lead'), f.text_area(:abstract, :style => 'width: 482px; height: 200px;', :class => 'mceEditor')) %> - <% else %> - <%= labelled_form_field(_('Lead'), f.text_area(:abstract, :style => 'width: 482px; height: 200px;')) %> - <% end %> -
-<%= _('Used when a short version your text is needed.') %> +<% tiny = task.article && task.article.tiny_mce? ? {:tiny_mce => true} : {} %> +<%= render :partial => 'shared/lead_and_body', :locals => {:lead_id => task.id, :f => f}.merge(tiny)%> -
- <% if task.article && task.article.tiny_mce? %> - <%= labelled_form_field(_('Text'), f.text_area(:body, :style => 'width:482px; height: 500px;', :class => 'mceEditor')) %> - <% else %> - <%= labelled_form_field(_('Text'), f.text_area(:body, :style => 'width:482px; height: 500px;')) %> - <% end %> -
<%= labelled_form_field _('Comment for author'), f.text_field(:closing_statment, :style => 'width: 488px;') %> diff --git a/app/views/tasks/_suggest_article_accept_details.rhtml b/app/views/tasks/_suggest_article_accept_details.rhtml index 0577b72..dd4028b 100644 --- a/app/views/tasks/_suggest_article_accept_details.rhtml +++ b/app/views/tasks/_suggest_article_accept_details.rhtml @@ -9,11 +9,4 @@ <%= select_profile_folder(_('Select the folder where the article must be published'), "tasks[#{task.id}][task]", 'article_parent_id', task.target) %> <%= labelled_form_field(_('Highlight this article'), f.check_box(:highlighted)) %> -
- <%= labelled_form_field(_('Lead'), f.text_area(:article_abstract, :style => 'width: 482px; height: 200px;', :class => 'mceEditor')) %> -
-<%= _('Used when a short version your text is needed.') %> - -
- <%= labelled_form_field(_('Text'), f.text_area(:article_body, :style => 'width:482px; height: 500px;', :class => 'mceEditor')) %> -
+<%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true, :f => f, :abstract_method => 'article_abstract', :body_method => 'article_body', :lead_id => task.id} %> diff --git a/features/events.feature b/features/events.feature index a1c5409..b41d039 100644 --- a/features/events.feature +++ b/features/events.feature @@ -206,3 +206,27 @@ Feature: events When I am on /profile/josesilva/events/2009/10/25 Then I should see "Unpublished event" And I should see "25" link + + Scenario: events have lead field + Given I am logged in as "josesilva" + And I am on josesilva's Event creation + Then I should see "Lead" + + Scenario: events lead should be shown on blogs with short format + Given I am logged in as "josesilva" + And I am on josesilva's control panel + And I follow "Configure blog" + And I select "First paragraph" from "How to display posts:" + And I press "Save" + And I follow "New post" + And I follow "Event" + And I follow "Lead" + And I fill in the following: + | Title | Leaded event | + | Information about the event | This is the real text.| + | Lead | This is the abstract. | + And I press "Save" + When I am on josesilva's blog + Then I should see "Leaded event" + And I should see "This is the abstract." + And I should not see "This is the real text." diff --git a/features/suggest_article.feature b/features/suggest_article.feature index dc64d70..3286ae8 100644 --- a/features/suggest_article.feature +++ b/features/suggest_article.feature @@ -21,3 +21,24 @@ Feature: suggest article And I follow "Process requests" And I should see "suggested the publication of the article" Then I should see "Highlight this article" within ".task_box" + + Scenario: an article is suggested and the admin approve it + Given I am on Sample Community's blog + And I follow "Suggest an article" + And I fill in the following: + | Title | Suggestion | + | Your name | Some Guy | + | Email | someguy@somewhere.com | + | Lead | This is my suggestion's lead | + | Text | I like free software | + And I press "Save" + And I am logged in as "joaosilva" + And I go to Sample Community's control panel + When I follow "Process requests" + Then I should see "suggested the publication of the article: Suggestion." + When I choose "Accept" + And I select "sample-community/Blog" from "Select the folder where the article must be published" + And I press "Apply!" + And I go to Sample Community's blog + Then I should see "Suggestion" + Then I should see "I like free software" diff --git a/features/support/paths.rb b/features/support/paths.rb index 8cbdcfe..a292fca 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -27,6 +27,12 @@ module NavigationHelpers when /^(.*)'s homepage$/ '/%s' % Profile.find_by_name($1).identifier + when /^(.*)'s blog$/ + '/%s/blog' % Profile.find_by_name($1).identifier + + when /^(.*)'s (.+) creation$/ + '/myprofile/%s/cms/new?type=%s' % [Profile.find_by_name($1).identifier,$2] + when /^(.*)'s sitemap/ '/profile/%s/sitemap' % Profile.find_by_name($1).identifier diff --git a/public/javascripts/article.js b/public/javascripts/article.js index 9cf95b4..ff3639c 100644 --- a/public/javascripts/article.js +++ b/public/javascripts/article.js @@ -1,7 +1,8 @@ (function($) { - $("#lead-button").click(function(){ + $(".lead-button").live('click', function(){ + article_id = this.getAttribute("article_id"); $(this).toggleClass('icon-add').toggleClass('icon-remove'); - $('#article-lead').slideToggle(); + $(article_id).slideToggle(); return false; }) $("#body-button").click(function(){ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 7375351..9ef5c9d 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1004,7 +1004,7 @@ code input { font-weight: normal; } -#article-lead, +.article-lead, #article-body-field { margin-top: 10px; display: none; -- libgit2 0.21.2