diff --git a/plugins/dspace/lib/dspace/client.rb b/plugins/dspace/lib/dspace/client.rb
index ffbfdee..db3d3c6 100644
--- a/plugins/dspace/lib/dspace/client.rb
+++ b/plugins/dspace/lib/dspace/client.rb
@@ -3,8 +3,13 @@ class Dspace::Client
def initialize(dspace_server_url)
end
- def get_collection_items(collection)
- collection_items = Dspace::Collection.find(:all)
+ def get_collections
+ Dspace::Collection.find(:all)
+ end
+
+ def get_communities
+ Dspace::Community.find(:all)
end
end
+
diff --git a/plugins/dspace/lib/dspace/collection.rb b/plugins/dspace/lib/dspace/collection.rb
index 5e473a1..d37d4b2 100644
--- a/plugins/dspace/lib/dspace/collection.rb
+++ b/plugins/dspace/lib/dspace/collection.rb
@@ -1,4 +1,9 @@
class Dspace::Collection < Dspace::Resource
- self.site = "http://localhost:8080/rest/"
- self.element_name = "collections"
+ self.site = "http://dev.maljr.net:8080/rest/"
+
+ def self.get_items(collection_id)
+ result = self.find collection_id, :params => { :expand => 'items' }
+ result.items
+ end
+
end
diff --git a/plugins/dspace/lib/dspace/community.rb b/plugins/dspace/lib/dspace/community.rb
new file mode 100644
index 0000000..1e6c138
--- /dev/null
+++ b/plugins/dspace/lib/dspace/community.rb
@@ -0,0 +1,9 @@
+class Dspace::Community < Dspace::Resource
+ self.site = "http://dev.maljr.net:8080/rest/"
+
+ def self.get_collections(community_id)
+ result = self.find community_id, :params => { :expand => 'collections' }
+ result.collections
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin.rb b/plugins/dspace/lib/dspace_plugin.rb
index 01b70b2..bf13365 100644
--- a/plugins/dspace/lib/dspace_plugin.rb
+++ b/plugins/dspace/lib/dspace_plugin.rb
@@ -8,12 +8,24 @@ class DspacePlugin < Noosfero::Plugin
_("A plugin that add a DSpace library feature to noosfero.")
end
- def self.extra_blocks
- { DspacePlugin::DspaceBlock => {:type => ['community', 'profile'] } }
+ def content_types
+ if context.respond_to?(:params) && context.params
+ types = []
+ parent_id = context.params[:parent_id]
+ types << DspacePlugin::Library if context.profile.community? && !parent_id
+ parent = parent_id ? context.profile.articles.find(parent_id) : nil
+ if parent.kind_of?(DspacePlugin::Library)
+ types << DspacePlugin::Collection
+ types << DspacePlugin::Communityy
+ end
+ types
+ else
+ [DspacePlugin::Library, DspacePlugin::Collection, DspacePlugin::Communityy]
+ end
end
def stylesheet?
- true
+ false
end
def self.has_admin_url?
diff --git a/plugins/dspace/lib/dspace_plugin/collection.rb b/plugins/dspace/lib/dspace_plugin/collection.rb
new file mode 100644
index 0000000..4ef2035
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/collection.rb
@@ -0,0 +1,26 @@
+class DspacePlugin::Collection < Article
+
+ settings_items :dspace_collection_id, :type => :string
+
+ attr_accessible :dspace_collection_id
+
+ def self.icon_name(article = nil)
+ 'dspace'
+ end
+
+ def self.short_description
+ _("Collection")
+ end
+
+ def self.description
+ _("Defines a collection on DSpace library")
+ end
+
+ def to_html(options = {})
+ dspace_collection = self
+ proc do
+ render :file => 'content_viewer/collection', :locals => {:dspace_collection => dspace_collection}
+ end
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin/communityy.rb b/plugins/dspace/lib/dspace_plugin/communityy.rb
new file mode 100644
index 0000000..3443685
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/communityy.rb
@@ -0,0 +1,26 @@
+class DspacePlugin::Communityy < Article
+
+ settings_items :dspace_community_id, :type => :string
+
+ attr_accessible :dspace_community_id
+
+ def self.icon_name(article = nil)
+ 'dspace'
+ end
+
+ def self.short_description
+ _("Community")
+ end
+
+ def self.description
+ _("Defines a community on DSpace library")
+ end
+
+ def to_html(options = {})
+ dspace_community = self
+ proc do
+ render :file => 'content_viewer/community', :locals => {:dspace_community => dspace_community}
+ end
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin/item.rb b/plugins/dspace/lib/dspace_plugin/item.rb
new file mode 100644
index 0000000..ce03f56
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/item.rb
@@ -0,0 +1,26 @@
+class DspacePlugin::Item < Article
+
+ settings_items :dspace_collection_id, :type => :string
+
+ attr_accessible :dspace_collection_id
+
+ def self.icon_name(article = nil)
+ 'dspace'
+ end
+
+ def self.short_description
+ _("DSpace item")
+ end
+
+ def self.description
+ _("Defines a item on DSpace library")
+ end
+
+ def to_html(options = {})
+ dspace_item = self
+ proc do
+ render :file => 'content_viewer/item', :locals => {:dspace_item => dspace_item}
+ end
+ end
+
+end
diff --git a/plugins/dspace/lib/dspace_plugin/library.rb b/plugins/dspace/lib/dspace_plugin/library.rb
new file mode 100644
index 0000000..73ec731
--- /dev/null
+++ b/plugins/dspace/lib/dspace_plugin/library.rb
@@ -0,0 +1,31 @@
+class DspacePlugin::Library < Blog
+
+ settings_items :server_url, :type => :string, :default => "http://dspace.example.com/"
+ settings_items :gather_option, :type => :string, :default => "collections"
+
+ attr_accessible :server_url, :gather_option
+
+ def self.icon_name(article = nil)
+ 'dspace'
+ end
+
+ def self.short_description
+ _("DSpace library")
+ end
+
+ def self.description
+ _("Defines a DSpace library")
+ end
+
+ def to_html(options = {})
+ dspace_library = self
+ proc do
+ render :file => 'content_viewer/library', :locals => {:dspace_library => dspace_library}
+ end
+ end
+
+ def bli
+ 'bli'
+ end
+
+end
diff --git a/plugins/dspace/public/style.css b/plugins/dspace/public/style.css
deleted file mode 100644
index c7dc261..0000000
--- a/plugins/dspace/public/style.css
+++ /dev/null
@@ -1,79 +0,0 @@
-#content .dspace-plugin_dspace-block {
- padding: 10px 0px 10px 10px;
- word-wrap: break-word;
-}
-
-.dspace-plugin_dspace-block ul {
- margin: 0px;
- padding: 0px 0px 0px 20px;
-}
-.dspace-plugin_dspace-block li {
- margin: 0px;
- padding: 0px;
- list-style: none
-}
-.dspace-plugin_dspace-block a {
- text-decoration: none;
-}
-.dspace-plugin_dspace-block .block-footer-content {
- font-size: 10px;
-}
-.dspace-plugin_dspace-block .block-footer-content a:hover {
- text-decoration: underline;
-}
-
-.dspace-plugin_dspace-block p {
- text-align:center;
-}
-
-.dspace-plugin_dspace-block p.like{
- background-image: url('images/positive-hand.png');
- background-repeat: no-repeat;
- min-width: 50px;
- text-align:center;
-}
-
-.dspace-plugin_dspace-block p.dislike{
- background-image: url('images/negative-hand.png');
- background-repeat: no-repeat;
- min-width: 50px;
- text-align:center;
-}
-
-
-.dspace-plugin_dspace-block {
- //overflow: hidden;
- display: block;
- width: 100%;
-}
-
-
-.dspace-cover img {
- width: 100%;
-}
-
-.dspace-plugin_dspace-block span.title {
- display: block;
- margin: 20px 0px 0px;
- padding: 0px 0px 0px 20px;
-}
-
-.dspace-plugin_dspace-block span.title.mread {
-
-}
-
-.dspace-plugin_dspace-block span.title.mcommented {
-
-}
-
-.dspace-plugin_dspace-block span.title.mliked {
-
-}
-
-.dspace-plugin_dspace-block span.title.mdisliked {
-
-}
-
-.dspace-plugin_dspace-block span.title.mvoted {
-
-}
diff --git a/plugins/dspace/test/unit/dspace_block_test.rb b/plugins/dspace/test/unit/dspace_block_test.rb
deleted file mode 100644
index 24f8b49..0000000
--- a/plugins/dspace/test/unit/dspace_block_test.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-require 'comment_controller'
-# Re-raise errors caught by the controller.
-class CommentController; def rescue_action(e) raise e end; end
-
-class DspaceBlockTest < ActiveSupport::TestCase
-
- include AuthenticatedTestHelper
- fixtures :users, :environments
-
- def setup
- @controller = CommentController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
-
- @profile = create_user('testinguser').person
- @environment = @profile.environment
- end
- attr_reader :profile, :environment
-
- should 'have a default title' do
- dspace_block = DspacePlugin::DspaceBlock.new
- block = Block.new
- assert_not_equal block.default_title, dspace_block.default_title
- end
-
- should 'have a help tooltip' do
- dspace_block = DspacePlugin::DspaceBlock.new
- block = Block.new
- assert_not_equal "", dspace_block.help
- end
-
- should 'describe itself' do
- assert_not_equal Block.description, DspacePlugin::DspaceBlock.description
- end
-
- should 'is editable' do
- block = DspacePlugin::DspaceBlock.new
- assert block.editable?
- end
-
- should 'expire' do
- assert_equal DspacePlugin::DspaceBlock.expire_on, {:environment=>[:article], :profile=>[:article]}
- end
-
-end
diff --git a/plugins/dspace/views/blocks/dspace.html.erb b/plugins/dspace/views/blocks/dspace.html.erb
deleted file mode 100644
index 9ba8433..0000000
--- a/plugins/dspace/views/blocks/dspace.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-<% collection_items.each do |item| %>
- <%= item.name %>
-<% end %>
-
diff --git a/plugins/dspace/views/box_organizer/dspace_plugin/_dspace_block.html.erb b/plugins/dspace/views/box_organizer/dspace_plugin/_dspace_block.html.erb
deleted file mode 100644
index 0c31333..0000000
--- a/plugins/dspace/views/box_organizer/dspace_plugin/_dspace_block.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= labelled_form_field _('DSpace/API Url:'), text_field(:block, :dspace_server_url) %>
-
-<%= labelled_form_field _('Colletions:'), text_field(:block, :collections) %>
diff --git a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
new file mode 100644
index 0000000..b475f81
--- /dev/null
+++ b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
@@ -0,0 +1,24 @@
+