Commit 51ea425feec53e8dc9b2fd263b3127e417a2f315

Authored by Francisco Júnior
1 parent 9365fa9e

dspace_plugin : improve ui navigation

plugins/dspace/lib/dspace/client.rb
1 class Dspace::Client 1 class Dspace::Client
2 2
3 - def initialize(dspace_server_url) 3 + def initialize(server_url)
  4 + @server_url = server_url
4 end 5 end
5 6
6 def get_collections 7 def get_collections
7 - Dspace::Collection.find(:all) 8 + Dspace::Collection.get_all_collections_from @server_url
8 end 9 end
9 10
10 def get_communities 11 def get_communities
plugins/dspace/lib/dspace/collection.rb
1 class Dspace::Collection < Dspace::Resource 1 class Dspace::Collection < Dspace::Resource
2 - self.site = "http://dev.maljr.net:8080/rest/"  
3 2
4 - def self.get_items(collection_id) 3 + def self.get_all_items_from(dspace_server, collection_id)
  4 + self.site = dspace_server
5 result = self.find collection_id, :params => { :expand => 'items' } 5 result = self.find collection_id, :params => { :expand => 'items' }
  6 +
  7 + #if result.items.count > 0
  8 +
  9 + # result.items.each { |item|
  10 +
  11 + # item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, item.id
  12 + #raise item_metadata.count.inspect
  13 + # raise item_metadata.inspect
  14 +
  15 + # }
  16 + #end
  17 +
6 result.items 18 result.items
7 end 19 end
8 20
  21 + def self.get_all_collections_from(dspace_server)
  22 + self.site = dspace_server
  23 + self.find(:all)
  24 + end
  25 +
9 end 26 end
plugins/dspace/lib/dspace/item.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class Dspace::Item < Dspace::Resource
  2 +
  3 + def self.get_all_item_metadata_from(dspace_server, item_id)
  4 + self.site = dspace_server
  5 + result = self.find item_id, :params => { :expand => 'metadata' }
  6 + result.metadata
  7 + end
  8 +
  9 +end
plugins/dspace/lib/dspace_plugin.rb
@@ -25,7 +25,7 @@ class DspacePlugin &lt; Noosfero::Plugin @@ -25,7 +25,7 @@ class DspacePlugin &lt; Noosfero::Plugin
25 end 25 end
26 26
27 def stylesheet? 27 def stylesheet?
28 - false 28 + true
29 end 29 end
30 30
31 def self.has_admin_url? 31 def self.has_admin_url?
plugins/dspace/lib/dspace_plugin/collection.rb
@@ -23,4 +23,8 @@ class DspacePlugin::Collection &lt; Article @@ -23,4 +23,8 @@ class DspacePlugin::Collection &lt; Article
23 end 23 end
24 end 24 end
25 25
  26 + def items(dspace_server, collection_id)
  27 + Dspace::Collection.get_all_items_from dspace_server, collection_id
  28 + end
  29 +
26 end 30 end
plugins/dspace/lib/dspace_plugin/library.rb
@@ -25,7 +25,11 @@ class DspacePlugin::Library &lt; Blog @@ -25,7 +25,11 @@ class DspacePlugin::Library &lt; Blog
25 end 25 end
26 26
27 def communities 27 def communities
28 - [] 28 + DspacePlugin::Communities.find(:all)
  29 + end
  30 +
  31 + def collections
  32 + DspacePlugin::Collection.find(:all)
29 end 33 end
30 34
31 end 35 end
plugins/dspace/public/style.css 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +#dspace_library ul {
  2 + margin: 0;
  3 + padding: 0 0 0 20px;
  4 +}
  5 +
  6 +#dspace_library li {
  7 + list-style-image: url(/designs/themes/base/imgs/li-recent.gif);
  8 +}
plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
@@ -6,19 +6,17 @@ @@ -6,19 +6,17 @@
6 6
7 <%= hidden_field_tag 'article[parent_id]', @article.parent_id %> 7 <%= hidden_field_tag 'article[parent_id]', @article.parent_id %>
8 8
9 -<% dspace_client = Dspace::Client.new('') %> 9 +<% dspace_server_url = @article.parent.server_url %>
10 10
11 -<% collections = dspace_client.get_collections %> 11 +<%#= hidden_field_tag 'article[server_url]', dspace_server_url %>
12 12
13 -<%  
14 -collections_2 = collections.map { |collection|  
15 - item = [_(collection.name), collection.id]  
16 -}  
17 -%> 13 +<% dspace_client = Dspace::Client.new(dspace_server_url) %>
  14 +
  15 +<% collections = dspace_client.get_collections.map { |collection| item = [_(collection.name), collection.id] } %>
18 16
19 <%= labelled_form_field(_('Collections:'), 17 <%= labelled_form_field(_('Collections:'),
20 select(:article, 18 select(:article,
21 :dspace_collection_id, 19 :dspace_collection_id,
22 - options_for_select_with_title(collections_2))) %> 20 + options_for_select_with_title(collections))) %>
23 21
24 <% #raise collections_2.inspect %> 22 <% #raise collections_2.inspect %>
plugins/dspace/views/content_viewer/_collection_item.html.erb 0 → 100644
@@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
  1 +<li>
  2 + <h4><%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %>
  3 + </h4>
  4 +</li>
plugins/dspace/views/content_viewer/_item.html.erb 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +<li>
  2 + <h5><%= item.name %></h5>
  3 +</li>
plugins/dspace/views/content_viewer/collection.html.erb
1 -<% dspace_collection_id = 7 %> 1 +<% collection_id = dspace_collection.dspace_collection_id %>
  2 +<% dspace_server = dspace_collection.parent.server_url %>
2 3
3 -<% dspace_items_from_collection = Dspace::Collection.get_items(dspace_collection_id) %>  
4 -  
5 -<% dspace_items_from_collection.each { |item| %>  
6 -<br />  
7 -<%= item.name %>  
8 -<br />  
9 -<% } %> 4 +<div id="dspace_library">
  5 + <div id="dspace_collection">
  6 + <ul id="items_list" class="items_list">
  7 + <%= render :partial => 'item', :collection => dspace_collection.items(dspace_server, collection_id) %>
  8 + </ul>
  9 + </div>
  10 +</div>
plugins/dspace/views/content_viewer/library.html.erb
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 2
3 <%= content_tag 'div', dspace_library.body %> 3 <%= content_tag 'div', dspace_library.body %>
4 4
  5 + <% if dspace_library.gather_option == "communities" %>
  6 +
5 <h3><%= _("Communities") %></h3> 7 <h3><%= _("Communities") %></h3>
6 8
7 <% if true %> 9 <% if true %>
@@ -18,10 +20,13 @@ @@ -18,10 +20,13 @@
18 <%= render :partial => 'community_item', :collection => dspace_library.communities %> 20 <%= render :partial => 'community_item', :collection => dspace_library.communities %>
19 </ul> 21 </ul>
20 22
  23 + <% end %>
  24 +
  25 + <% if dspace_library.gather_option == "collections" %>
21 26
22 <h3><%= _("Collections") %></h3> 27 <h3><%= _("Collections") %></h3>
23 28
24 - <% if true %> 29 + <% if true %>
25 30
26 <div class="library_actions"> 31 <div class="library_actions">
27 <%= 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 %> 32 <%= 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 %>
@@ -29,6 +34,12 @@ @@ -29,6 +34,12 @@
29 <% end %> 34 <% end %>
30 </div> 35 </div>
31 36
  37 + <% end %>
  38 +
  39 + <ul id="collections_list" class="collections_list">
  40 + <%= render :partial => 'collection_item', :collection => dspace_library.collections %>
  41 + </ul>
  42 +
32 <% end %> 43 <% end %>
33 44
34 </div> 45 </div>