noosfero | 4 new commits pushed to repository

Antonio Terceiro gitlab at gitlab.com
Fri Feb 13 14:25:59 BRST 2015


Antonio Terceiro pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/7c861d610928df43244e205a129ecbaed8df723b">7c861d61</a> by David Carlos
Creates block's plugin structure

Signed-off-by: David Carlos <ddavidcarlos1392 at gmail.com>
Signed-off-by: Dylan Guedes <djmgguedes at gmail.com>

- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/cdad6671005cfbd3d87af0bcd5f78c7aa0cf46bd">cdad6671</a> by David Carlos
Inprove block code.
  - change lambda to proc in block's content method.
  - remove unnecessary code.
  - add block's css

Signed-off-by: David Carlos <ddavidcarlos1392 at gmail.com>
Signed-off-by: Dylan Guedes <djmgguedes at gmail.com>

- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/4258c807ecd6de056491280dcf74adb7d2b0dd02">4258c807</a> by David Carlos
Unit tests.

Signed-off-by: David Carlos <ddavidcarlos1392 at gmail.com>
Signed-off-by: Dylan Guedes <djmgguedes at gmail.com>

- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/6345edbfc629e8f56c21f8a9d325d02219f0fb45">6345edbf</a> by Antonio Terceiro
Merge branch 'profile_description_block' into 'master'

Profile description block

this plugin adds a block that displays the description field of the profile.

See merge request !464

- - - - -


Changes:

=====================================
plugins/profile_description_block/lib/profile_description_block.rb
=====================================
--- /dev/null
+++ b/plugins/profile_description_block/lib/profile_description_block.rb
@@ -0,0 +1,41 @@
+class ProfileDescriptionBlock < Block
+  settings_items :show_name, :type => :boolean,
+                 :default => false
+
+  attr_accessor :show_name
+
+  def self.description
+    _('Profile Description')
+  end
+
+  def help
+    _('this block displays the description field of the profile')
+  end
+
+  def default_title
+    _('PROFILE DESCRIPTION')
+  end
+
+  def content(args={})
+    description =  if self.owner.description.blank?
+                      "Description field is empty or
+                        not enabled on enviroment"
+                   else
+                      self.owner.description
+                   end
+    block = self
+    s = show_name
+    proc do
+      render(
+        :file => 'blocks/profile_description',
+        :locals => { :block => block, :show_name => s ,
+                     :description => description}
+      )
+    end
+  end
+
+  def cacheable?
+    false
+  end
+
+end

=====================================
plugins/profile_description_block/lib/profile_description_block_plugin.rb
=====================================
--- /dev/null
+++ b/plugins/profile_description_block/lib/profile_description_block_plugin.rb
@@ -0,0 +1,24 @@
+class ProfileDescriptionBlockPlugin < Noosfero::Plugin
+
+  def self.plugin_name
+    # FIXME
+    "Profile Description Block"
+  end
+
+  def self.extra_blocks
+    {
+      ProfileDescriptionBlock  => { :type => [Community, Person] }
+    }
+  end
+
+
+  def self.plugin_description
+    # FIXME
+    _("A plugin that adds a block that show the profile description")
+  end
+
+  def stylesheet?
+    true
+  end
+
+end

=====================================
plugins/profile_description_block/public/style.css
=====================================
--- /dev/null
+++ b/plugins/profile_description_block/public/style.css
@@ -0,0 +1,10 @@
+#content .box-1 .profile-description-block {
+  display: table;
+  width: 100%;
+}
+
+#content .profile-description-block-title {
+  font-family: arial;
+  font-size: 15px;
+  text-align: left;
+}

=====================================
plugins/profile_description_block/test/unit/profile_description_block_test.rb
=====================================
--- /dev/null
+++ b/plugins/profile_description_block/test/unit/profile_description_block_test.rb
@@ -0,0 +1,29 @@
+require File.expand_path(File.dirname(__FILE__) + "/../../../../test/test_helper")
+
+class ProfileDescriptionBlockTest < ActiveSupport::TestCase
+	def setup
+		e = Environment.default
+    e.enabled_plugins = ['ProfileDescriptionPlugin']
+    @person = create_user('test_user').person
+    @profile = Profile.create!(:identifier => '1236',
+                               :name => 'blabla',
+                               :description => "")
+	end
+
+  should 'describe itself' do
+    assert_not_equal Block.description, ProfileDescriptionBlock.description
+  end
+
+  should "show profile description inside block" do
+    new_block = ProfileDescriptionBlock.create!
+    @profile.boxes.first.blocks << new_block
+    block_menssage = "Description field are empty"
+    assert (instance_eval(&Block.last.content).include?(block_menssage)),
+      "description block doesn't show not found description message"
+    description = "This is an test"
+    @profile.update_attribute("description", description)
+    @profile.save!
+    assert (instance_eval(&Block.last.content).include?(description)),
+      "Description block doesn't show profile description"
+  end
+end

=====================================
plugins/profile_description_block/views/blocks/profile_description.html.erb
=====================================
--- /dev/null
+++ b/plugins/profile_description_block/views/blocks/profile_description.html.erb
@@ -0,0 +1,8 @@
+<div class = 'profile-description-block'>
+<div class =  "block-title">
+  <%= block.title %>
+</div>
+<div class = "profile-description-block-title">
+   <%= description %>
+</div>
+</div>

=====================================
test/unit/article_block_test.rb
=====================================
--- a/test/unit/article_block_test.rb
+++ b/test/unit/article_block_test.rb
@@ -1,7 +1,6 @@
 require_relative "../test_helper"
 
 class ArticleBlockTest < ActiveSupport::TestCase
-
   include ApplicationHelper
 
   should 'describe itself' do

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150213/9366c858/attachment-0001.html>


More information about the Noosfero-dev mailing list