diff --git a/plugins/dspace/lib/dspace/client.rb b/plugins/dspace/lib/dspace/client.rb index 0301d79..a8edce1 100644 --- a/plugins/dspace/lib/dspace/client.rb +++ b/plugins/dspace/lib/dspace/client.rb @@ -9,7 +9,7 @@ class Dspace::Client end def get_communities - Dspace::Community.find(:all) + Dspace::Community.get_all_communities_from @server_url end end diff --git a/plugins/dspace/lib/dspace/collection.rb b/plugins/dspace/lib/dspace/collection.rb index 4aa7684..479a543 100644 --- a/plugins/dspace/lib/dspace/collection.rb +++ b/plugins/dspace/lib/dspace/collection.rb @@ -4,18 +4,41 @@ class Dspace::Collection < Dspace::Resource self.site = dspace_server result = self.find collection_id, :params => { :expand => 'items' } - #if result.items.count > 0 + item_list = [] - # result.items.each { |item| + if result.items.count > 0 - # item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, item.id - #raise item_metadata.count.inspect - # raise item_metadata.inspect + result.items.each { |element| - # } - #end + item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, element.id - result.items + # author + metadata = item_metadata[0].attributes + if metadata != {} + metadata = Hash[[metadata.map{|k,v| v}]] + author = metadata.has_key?('dc.contributor.author') ? metadata['dc.contributor.author'] : nil + end + + # date issued + metadata = item_metadata[3].attributes + if metadata != {} + metadata = Hash[[metadata.map{|k,v| v}]] + date_issued = metadata.has_key?('dc.date.issued') ? metadata['dc.date.issued'] : nil + end + + item = DspacePlugin::Item.new + + item.id = element.id + item.name = element.name + item.author = author + item.date_issued = date_issued + + item_list << item + + } + end + + item_list end def self.get_all_collections_from(dspace_server) diff --git a/plugins/dspace/lib/dspace/community.rb b/plugins/dspace/lib/dspace/community.rb index 1e6c138..2727447 100644 --- a/plugins/dspace/lib/dspace/community.rb +++ b/plugins/dspace/lib/dspace/community.rb @@ -1,7 +1,12 @@ class Dspace::Community < Dspace::Resource - self.site = "http://dev.maljr.net:8080/rest/" - def self.get_collections(community_id) + def self.get_all_communities_from(dspace_server) + self.site = dspace_server + self.find(:all) + end + + def self.get_all_collections_from(dspace_server, community_id) + self.site = dspace_server result = self.find community_id, :params => { :expand => 'collections' } result.collections end diff --git a/plugins/dspace/lib/dspace_plugin/communityy.rb b/plugins/dspace/lib/dspace_plugin/communityy.rb index 3443685..fa6c0c7 100644 --- a/plugins/dspace/lib/dspace_plugin/communityy.rb +++ b/plugins/dspace/lib/dspace_plugin/communityy.rb @@ -23,4 +23,8 @@ class DspacePlugin::Communityy < Article end end + def collections(dspace_server, community_id) + Dspace::Community.get_all_collections_from dspace_server, community_id + end + end diff --git a/plugins/dspace/lib/dspace_plugin/item.rb b/plugins/dspace/lib/dspace_plugin/item.rb index ce03f56..4e566ee 100644 --- a/plugins/dspace/lib/dspace_plugin/item.rb +++ b/plugins/dspace/lib/dspace_plugin/item.rb @@ -1,26 +1,5 @@ -class DspacePlugin::Item < Article +class DspacePlugin::Item - 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 + attr_accessor :id, :name, :author, :date_issued end diff --git a/plugins/dspace/lib/dspace_plugin/library.rb b/plugins/dspace/lib/dspace_plugin/library.rb index 0059312..3bef566 100644 --- a/plugins/dspace/lib/dspace_plugin/library.rb +++ b/plugins/dspace/lib/dspace_plugin/library.rb @@ -25,7 +25,7 @@ class DspacePlugin::Library < Blog end def communities - DspacePlugin::Communities.find(:all) + DspacePlugin::Communityy.find(:all) end def collections diff --git a/plugins/dspace/public/style.css b/plugins/dspace/public/style.css index 848628d..2cd59ba 100644 --- a/plugins/dspace/public/style.css +++ b/plugins/dspace/public/style.css @@ -6,3 +6,18 @@ #dspace_library li { list-style-image: url(/designs/themes/base/imgs/li-recent.gif); } + +#dspace_library li.item, +#dspace_library li.collection { + margin: 10px 0; +} + +#dspace_library li.item span.name, +#dspace_library li.collection span.title, +#dspace_library li.community span.title { + font-weight: bold; +} + +#dspace_library div#actions { + margin: 10px 0; +} diff --git a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb index ea07b9c..224d0fc 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb @@ -8,8 +8,6 @@ <% dspace_server_url = @article.parent.server_url %> -<%#= hidden_field_tag 'article[server_url]', dspace_server_url %> - <% dspace_client = Dspace::Client.new(dspace_server_url) %> <% collections = dspace_client.get_collections.map { |collection| item = [_(collection.name), collection.id] } %> @@ -18,5 +16,3 @@ select(:article, :dspace_collection_id, options_for_select_with_title(collections))) %> - -<% #raise collections_2.inspect %> diff --git a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb index 99da06f..1e1c754 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb @@ -6,19 +6,13 @@ <%= hidden_field_tag 'article[parent_id]', @article.parent_id %> -<% dspace_client = Dspace::Client.new('') %> +<% dspace_server_url = @article.parent.server_url %> -<% communities = dspace_client.get_communities %> +<% dspace_client = Dspace::Client.new(dspace_server_url) %> -<% -communities_2 = communities.map { |community| - item = [_(community.name), community.id] -} -%> +<% communities = dspace_client.get_communities.map { |community| item = [_(community.name), community.id] } %> <%= labelled_form_field(_('Communities:'), select(:article, :dspace_community_id, - options_for_select_with_title(communities_2))) %> - -<% #raise collections_2.inspect %> + options_for_select_with_title(communities))) %> diff --git a/plugins/dspace/views/content_viewer/_collection.html.erb b/plugins/dspace/views/content_viewer/_collection.html.erb new file mode 100644 index 0000000..9499940 --- /dev/null +++ b/plugins/dspace/views/content_viewer/_collection.html.erb @@ -0,0 +1,3 @@ +
  • + <%= collection.name %>
    +
  • diff --git a/plugins/dspace/views/content_viewer/_collection_item.html.erb b/plugins/dspace/views/content_viewer/_collection_item.html.erb index 77a2857..b7245c5 100644 --- a/plugins/dspace/views/content_viewer/_collection_item.html.erb +++ b/plugins/dspace/views/content_viewer/_collection_item.html.erb @@ -1,4 +1,3 @@ -
  • -

    <%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %> -

    +
  • + <%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %>
  • diff --git a/plugins/dspace/views/content_viewer/_community_item.html.erb b/plugins/dspace/views/content_viewer/_community_item.html.erb index 4effa19..f5f2ad0 100644 --- a/plugins/dspace/views/content_viewer/_community_item.html.erb +++ b/plugins/dspace/views/content_viewer/_community_item.html.erb @@ -1 +1,3 @@ -hello! +
  • + <%= link_to community_item.title, :controller => 'content_viewer', :action => 'view_page', :page => community_item.path %> +
  • diff --git a/plugins/dspace/views/content_viewer/_item.html.erb b/plugins/dspace/views/content_viewer/_item.html.erb index e1fad0c..324a5ea 100644 --- a/plugins/dspace/views/content_viewer/_item.html.erb +++ b/plugins/dspace/views/content_viewer/_item.html.erb @@ -1,3 +1,4 @@ -
  • -
    <%= item.name %>
    +
  • + <%= item.name %>
    + <%= item.author %> (<%= item.date_issued %>)
  • diff --git a/plugins/dspace/views/content_viewer/collection.html.erb b/plugins/dspace/views/content_viewer/collection.html.erb index bc7ae1a..4a63989 100644 --- a/plugins/dspace/views/content_viewer/collection.html.erb +++ b/plugins/dspace/views/content_viewer/collection.html.erb @@ -3,7 +3,7 @@
    -
    diff --git a/plugins/dspace/views/content_viewer/community.html.erb b/plugins/dspace/views/content_viewer/community.html.erb index ca484b9..051248a 100644 --- a/plugins/dspace/views/content_viewer/community.html.erb +++ b/plugins/dspace/views/content_viewer/community.html.erb @@ -1,9 +1,10 @@ -<% dspace_community_id = 5 %> +<% community_id = dspace_community.dspace_community_id %> +<% dspace_server = dspace_community.parent.server_url %> -<% dspace_collections_from_community = Dspace::Community.get_collections(dspace_community_id) %> - -<% dspace_collections_from_community.each { |collection| %> -
    -<%= collection.name %> -
    -<% } %> +
    +
    +
      + <%= render :partial => 'collection', :collection => dspace_community.collections(dspace_server, community_id) %> +
    +
    +
    diff --git a/plugins/dspace/views/content_viewer/library.html.erb b/plugins/dspace/views/content_viewer/library.html.erb index 5db04ae..3f5c994 100644 --- a/plugins/dspace/views/content_viewer/library.html.erb +++ b/plugins/dspace/views/content_viewer/library.html.erb @@ -4,11 +4,9 @@ <% if dspace_library.gather_option == "communities" %> -

    <%= _("Communities") %>

    - <% if true %> -
    +
    <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Communityy", :parent_id => dspace_library.id}), :class => 'button with-text icon-add') do %> <%= _("New %s") % DspacePlugin::Communityy.short_description %> <% end %> @@ -16,19 +14,19 @@ <% end %> + <% communities = dspace_library.communities %> +
      - <%= render :partial => 'community_item', :collection => dspace_library.communities %> + <%= render :partial => 'community_item', :collection => communities %>
    <% end %> <% if dspace_library.gather_option == "collections" %> -

    <%= _("Collections") %>

    - <% if true %> -
    +
    <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_library.id}), :class => 'button with-text icon-add') do %> <%= _("New %s") % DspacePlugin::Collection.short_description %> <% end %> @@ -36,9 +34,13 @@ <% end %> -
      - <%= render :partial => 'collection_item', :collection => dspace_library.collections %> -
    + <% collections = dspace_library.collections %> + + <% unless collections.blank? %> +
      + <%= render :partial => 'collection_item', :collection => collections %> +
    + <% end %> <% end %> -- libgit2 0.21.2