Commit 6950a50d80bde8a2e5cc823bc6383f51f2f03b69
1 parent
51ea425f
Exists in
staging
and in
4 other branches
dspace_plugin : improve ui navigation
Showing
16 changed files
with
98 additions
and
74 deletions
Show diff stats
plugins/dspace/lib/dspace/client.rb
plugins/dspace/lib/dspace/collection.rb
... | ... | @@ -4,18 +4,41 @@ class Dspace::Collection < Dspace::Resource |
4 | 4 | self.site = dspace_server |
5 | 5 | result = self.find collection_id, :params => { :expand => 'items' } |
6 | 6 | |
7 | - #if result.items.count > 0 | |
7 | + item_list = [] | |
8 | 8 | |
9 | - # result.items.each { |item| | |
9 | + if result.items.count > 0 | |
10 | 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 | |
11 | + result.items.each { |element| | |
14 | 12 | |
15 | - # } | |
16 | - #end | |
13 | + item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, element.id | |
17 | 14 | |
18 | - result.items | |
15 | + # author | |
16 | + metadata = item_metadata[0].attributes | |
17 | + if metadata != {} | |
18 | + metadata = Hash[[metadata.map{|k,v| v}]] | |
19 | + author = metadata.has_key?('dc.contributor.author') ? metadata['dc.contributor.author'] : nil | |
20 | + end | |
21 | + | |
22 | + # date issued | |
23 | + metadata = item_metadata[3].attributes | |
24 | + if metadata != {} | |
25 | + metadata = Hash[[metadata.map{|k,v| v}]] | |
26 | + date_issued = metadata.has_key?('dc.date.issued') ? metadata['dc.date.issued'] : nil | |
27 | + end | |
28 | + | |
29 | + item = DspacePlugin::Item.new | |
30 | + | |
31 | + item.id = element.id | |
32 | + item.name = element.name | |
33 | + item.author = author | |
34 | + item.date_issued = date_issued | |
35 | + | |
36 | + item_list << item | |
37 | + | |
38 | + } | |
39 | + end | |
40 | + | |
41 | + item_list | |
19 | 42 | end |
20 | 43 | |
21 | 44 | def self.get_all_collections_from(dspace_server) | ... | ... |
plugins/dspace/lib/dspace/community.rb
1 | 1 | class Dspace::Community < Dspace::Resource |
2 | - self.site = "http://dev.maljr.net:8080/rest/" | |
3 | 2 | |
4 | - def self.get_collections(community_id) | |
3 | + def self.get_all_communities_from(dspace_server) | |
4 | + self.site = dspace_server | |
5 | + self.find(:all) | |
6 | + end | |
7 | + | |
8 | + def self.get_all_collections_from(dspace_server, community_id) | |
9 | + self.site = dspace_server | |
5 | 10 | result = self.find community_id, :params => { :expand => 'collections' } |
6 | 11 | result.collections |
7 | 12 | end | ... | ... |
plugins/dspace/lib/dspace_plugin/communityy.rb
plugins/dspace/lib/dspace_plugin/item.rb
1 | -class DspacePlugin::Item < Article | |
1 | +class DspacePlugin::Item | |
2 | 2 | |
3 | - settings_items :dspace_collection_id, :type => :string | |
4 | - | |
5 | - attr_accessible :dspace_collection_id | |
6 | - | |
7 | - def self.icon_name(article = nil) | |
8 | - 'dspace' | |
9 | - end | |
10 | - | |
11 | - def self.short_description | |
12 | - _("DSpace item") | |
13 | - end | |
14 | - | |
15 | - def self.description | |
16 | - _("Defines a item on DSpace library") | |
17 | - end | |
18 | - | |
19 | - def to_html(options = {}) | |
20 | - dspace_item = self | |
21 | - proc do | |
22 | - render :file => 'content_viewer/item', :locals => {:dspace_item => dspace_item} | |
23 | - end | |
24 | - end | |
3 | + attr_accessor :id, :name, :author, :date_issued | |
25 | 4 | |
26 | 5 | end | ... | ... |
plugins/dspace/lib/dspace_plugin/library.rb
plugins/dspace/public/style.css
... | ... | @@ -6,3 +6,18 @@ |
6 | 6 | #dspace_library li { |
7 | 7 | list-style-image: url(/designs/themes/base/imgs/li-recent.gif); |
8 | 8 | } |
9 | + | |
10 | +#dspace_library li.item, | |
11 | +#dspace_library li.collection { | |
12 | + margin: 10px 0; | |
13 | +} | |
14 | + | |
15 | +#dspace_library li.item span.name, | |
16 | +#dspace_library li.collection span.title, | |
17 | +#dspace_library li.community span.title { | |
18 | + font-weight: bold; | |
19 | +} | |
20 | + | |
21 | +#dspace_library div#actions { | |
22 | + margin: 10px 0; | |
23 | +} | ... | ... |
plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
... | ... | @@ -8,8 +8,6 @@ |
8 | 8 | |
9 | 9 | <% dspace_server_url = @article.parent.server_url %> |
10 | 10 | |
11 | -<%#= hidden_field_tag 'article[server_url]', dspace_server_url %> | |
12 | - | |
13 | 11 | <% dspace_client = Dspace::Client.new(dspace_server_url) %> |
14 | 12 | |
15 | 13 | <% collections = dspace_client.get_collections.map { |collection| item = [_(collection.name), collection.id] } %> |
... | ... | @@ -18,5 +16,3 @@ |
18 | 16 | select(:article, |
19 | 17 | :dspace_collection_id, |
20 | 18 | options_for_select_with_title(collections))) %> |
21 | - | |
22 | -<% #raise collections_2.inspect %> | ... | ... |
plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb
... | ... | @@ -6,19 +6,13 @@ |
6 | 6 | |
7 | 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 | -<% communities = dspace_client.get_communities %> | |
11 | +<% dspace_client = Dspace::Client.new(dspace_server_url) %> | |
12 | 12 | |
13 | -<% | |
14 | -communities_2 = communities.map { |community| | |
15 | - item = [_(community.name), community.id] | |
16 | -} | |
17 | -%> | |
13 | +<% communities = dspace_client.get_communities.map { |community| item = [_(community.name), community.id] } %> | |
18 | 14 | |
19 | 15 | <%= labelled_form_field(_('Communities:'), |
20 | 16 | select(:article, |
21 | 17 | :dspace_community_id, |
22 | - options_for_select_with_title(communities_2))) %> | |
23 | - | |
24 | -<% #raise collections_2.inspect %> | |
18 | + options_for_select_with_title(communities))) %> | ... | ... |
plugins/dspace/views/content_viewer/_collection.html.erb
0 → 100644
plugins/dspace/views/content_viewer/_collection_item.html.erb
1 | -<li> | |
2 | - <h4><%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %> | |
3 | - </h4> | |
1 | +<li class="collection"> | |
2 | + <span class="title"><%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %></span> | |
4 | 3 | </li> | ... | ... |
plugins/dspace/views/content_viewer/_community_item.html.erb
plugins/dspace/views/content_viewer/_item.html.erb
plugins/dspace/views/content_viewer/collection.html.erb
plugins/dspace/views/content_viewer/community.html.erb
1 | -<% dspace_community_id = 5 %> | |
1 | +<% community_id = dspace_community.dspace_community_id %> | |
2 | +<% dspace_server = dspace_community.parent.server_url %> | |
2 | 3 | |
3 | -<% dspace_collections_from_community = Dspace::Community.get_collections(dspace_community_id) %> | |
4 | - | |
5 | -<% dspace_collections_from_community.each { |collection| %> | |
6 | -<br /> | |
7 | -<%= collection.name %> | |
8 | -<br /> | |
9 | -<% } %> | |
4 | +<div id="dspace_library"> | |
5 | + <div id="dspace_community"> | |
6 | + <ul id="collection_list"> | |
7 | + <%= render :partial => 'collection', :collection => dspace_community.collections(dspace_server, community_id) %> | |
8 | + </ul> | |
9 | + </div> | |
10 | +</div> | ... | ... |
plugins/dspace/views/content_viewer/library.html.erb
... | ... | @@ -4,11 +4,9 @@ |
4 | 4 | |
5 | 5 | <% if dspace_library.gather_option == "communities" %> |
6 | 6 | |
7 | - <h3><%= _("Communities") %></h3> | |
8 | - | |
9 | 7 | <% if true %> |
10 | 8 | |
11 | - <div class="library_actions"> | |
9 | + <div id="actions"> | |
12 | 10 | <%= 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 %> |
13 | 11 | <%= _("New %s") % DspacePlugin::Communityy.short_description %> |
14 | 12 | <% end %> |
... | ... | @@ -16,19 +14,19 @@ |
16 | 14 | |
17 | 15 | <% end %> |
18 | 16 | |
17 | + <% communities = dspace_library.communities %> | |
18 | + | |
19 | 19 | <ul id="sortable" class="communities_list"> |
20 | - <%= render :partial => 'community_item', :collection => dspace_library.communities %> | |
20 | + <%= render :partial => 'community_item', :collection => communities %> | |
21 | 21 | </ul> |
22 | 22 | |
23 | 23 | <% end %> |
24 | 24 | |
25 | 25 | <% if dspace_library.gather_option == "collections" %> |
26 | 26 | |
27 | - <h3><%= _("Collections") %></h3> | |
28 | - | |
29 | 27 | <% if true %> |
30 | 28 | |
31 | - <div class="library_actions"> | |
29 | + <div id="actions"> | |
32 | 30 | <%= 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 %> |
33 | 31 | <%= _("New %s") % DspacePlugin::Collection.short_description %> |
34 | 32 | <% end %> |
... | ... | @@ -36,9 +34,13 @@ |
36 | 34 | |
37 | 35 | <% end %> |
38 | 36 | |
39 | - <ul id="collections_list" class="collections_list"> | |
40 | - <%= render :partial => 'collection_item', :collection => dspace_library.collections %> | |
41 | - </ul> | |
37 | + <% collections = dspace_library.collections %> | |
38 | + | |
39 | + <% unless collections.blank? %> | |
40 | + <ul id="collections_list" class="collections_list"> | |
41 | + <%= render :partial => 'collection_item', :collection => collections %> | |
42 | + </ul> | |
43 | + <% end %> | |
42 | 44 | |
43 | 45 | <% end %> |
44 | 46 | ... | ... |