Commit bf10913873ac01a116979d2c2b6655eddc4193c3
1 parent
af2f1d06
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
dspace_plugin : improve viewing dspace item
Showing
8 changed files
with
199 additions
and
5 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | +class DspacePluginController < PublicController | |
| 2 | + append_view_path File.join(File.dirname(__FILE__) + '/../views') | |
| 3 | + | |
| 4 | + def view_item | |
| 5 | + @collection = DspacePlugin::Collection.find(params[:collection_id]) | |
| 6 | + @item = Dspace::Item.get_item_by_id 6 | |
| 7 | + end | |
| 8 | + | |
| 9 | +end | ... | ... |
plugins/dspace/lib/dspace/collection.rb
| ... | ... | @@ -23,7 +23,7 @@ class Dspace::Collection < Dspace::Resource |
| 23 | 23 | metadata = item_metadata[3].attributes |
| 24 | 24 | if metadata != {} |
| 25 | 25 | metadata = Hash[[metadata.map{|k,v| v}]] |
| 26 | - date_issued = metadata.has_key?('dc.date.issued') ? metadata['dc.date.issued'] : nil | |
| 26 | + issue_date = metadata.has_key?('dc.date.issued') ? metadata['dc.date.issued'] : nil | |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | 29 | item = DspacePlugin::Item.new |
| ... | ... | @@ -31,7 +31,7 @@ class Dspace::Collection < Dspace::Resource |
| 31 | 31 | item.id = element.id |
| 32 | 32 | item.name = element.name |
| 33 | 33 | item.author = author |
| 34 | - item.date_issued = date_issued | |
| 34 | + item.issue_date = issue_date | |
| 35 | 35 | |
| 36 | 36 | item_list << item |
| 37 | 37 | ... | ... |
plugins/dspace/lib/dspace/item.rb
| ... | ... | @@ -6,4 +6,82 @@ class Dspace::Item < Dspace::Resource |
| 6 | 6 | result.metadata |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | + def self.get_item_by_id(item_id) | |
| 10 | + self.site = 'http://dspace.maljr.net/rest/' | |
| 11 | + result = self.find item_id, :params => { :expand => 'metadata' } | |
| 12 | + | |
| 13 | + item_metadata = Dspace::Item.get_all_item_metadata_from self.site, result.id | |
| 14 | + | |
| 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 | + # issue date | |
| 23 | + metadata = item_metadata[3].attributes | |
| 24 | + if metadata != {} | |
| 25 | + metadata = Hash[[metadata.map{|k,v| v}]] | |
| 26 | + issue_date = metadata.has_key?('dc.date.issued') ? metadata['dc.date.issued'] : nil | |
| 27 | + end | |
| 28 | + | |
| 29 | + # uri | |
| 30 | + metadata = item_metadata[4].attributes | |
| 31 | + if metadata != {} | |
| 32 | + metadata = Hash[[metadata.map{|k,v| v}]] | |
| 33 | + uri = metadata.has_key?('dc.identifier.uri') ? metadata['dc.identifier.uri'] : nil | |
| 34 | + end | |
| 35 | + | |
| 36 | + # description | |
| 37 | + metadata = item_metadata[5].attributes | |
| 38 | + if metadata != {} | |
| 39 | + metadata = Hash[[metadata.map{|k,v| v}]] | |
| 40 | + abstract = metadata.has_key?('dc.description') ? metadata['dc.description'] : nil | |
| 41 | + end | |
| 42 | + | |
| 43 | + # abstract | |
| 44 | + metadata = item_metadata[6].attributes | |
| 45 | + if metadata != {} | |
| 46 | + metadata = Hash[[metadata.map{|k,v| v}]] | |
| 47 | + description = metadata.has_key?('dc.description.abstract') ? metadata['dc.description.abstract'] : nil | |
| 48 | + end | |
| 49 | + | |
| 50 | + item = DspacePlugin::Item.new | |
| 51 | + | |
| 52 | + item.id = result.id | |
| 53 | + item.name = result.name | |
| 54 | + item.author = author | |
| 55 | + item.issue_date = issue_date | |
| 56 | + item.abstract = abstract | |
| 57 | + item.description = description | |
| 58 | + item.uri = uri | |
| 59 | + | |
| 60 | + ### BITSTREAMS | |
| 61 | + | |
| 62 | + item_bitstreams = self.find item_id, :params => { :expand => 'bitstreams' } | |
| 63 | + | |
| 64 | + bitstreams = item_bitstreams.bitstreams | |
| 65 | + | |
| 66 | + bitstreams.each do |bs| | |
| 67 | + bitstream = DspacePlugin::Bitstream.new | |
| 68 | + bitstream.id = bs.attributes[:id] | |
| 69 | + bitstream.name = bs.attributes[:name] | |
| 70 | + bitstream.description = bs.attributes[:description] | |
| 71 | + bitstream.mimetype = bs.attributes[:mimeType] | |
| 72 | + bitstream.size_bytes = bs.attributes[:sizeBytes] | |
| 73 | + bitstream.retrieve_link = bs.attributes[:retrieveLink] | |
| 74 | + bitstream.format = bs.attributes[:format] | |
| 75 | + bitstream.link = bs.attributes[:link] | |
| 76 | + | |
| 77 | + #raise bitstream.to_yaml | |
| 78 | + | |
| 79 | + item.files << bitstream | |
| 80 | + | |
| 81 | + end | |
| 82 | + | |
| 83 | + item | |
| 84 | + | |
| 85 | + end | |
| 86 | + | |
| 9 | 87 | end | ... | ... |
plugins/dspace/lib/dspace_plugin/item.rb
plugins/dspace/public/style.css
| ... | ... | @@ -21,3 +21,32 @@ |
| 21 | 21 | #dspace_library div#actions { |
| 22 | 22 | margin: 10px 0; |
| 23 | 23 | } |
| 24 | + | |
| 25 | +#dspace_library_item { | |
| 26 | + /*8border: 1px solid green;*/ | |
| 27 | +} | |
| 28 | + | |
| 29 | +.dspace_item_section { | |
| 30 | + margin-left: 20px; | |
| 31 | +} | |
| 32 | + | |
| 33 | +.dspace_item_section_title { | |
| 34 | + margin: 0px; | |
| 35 | + font-weight: bold; | |
| 36 | + border-bottom: 1px solid #c0c0c0; | |
| 37 | +} | |
| 38 | + | |
| 39 | +#dspace_library_item ul { | |
| 40 | + list-style-type: none; | |
| 41 | +} | |
| 42 | + | |
| 43 | +#dspace_library_item ul#item_files_list, | |
| 44 | +#dspace_library_item ul.item_file_attributes_list { | |
| 45 | + margin: 0; | |
| 46 | + padding: 0; | |
| 47 | +} | |
| 48 | + | |
| 49 | +#dspace_library_item ul#item_files_list > li { | |
| 50 | + margin: 5px 0; | |
| 51 | +} | |
| 52 | + | ... | ... |
plugins/dspace/views/content_viewer/_item.html.erb
| 1 | 1 | <li class="item"> |
| 2 | - <span class="name"><%= item.name %></span><br /> | |
| 3 | - <span class="authors"><%= item.author %></span> <span class="date_issued">(<%= item.date_issued %>)</span> | |
| 2 | + <!--span class="name"><%#= item.name %></span><br /--> | |
| 3 | + <span class="name"><%= link_to item.name, :controller => 'dspace_plugin', :action => 'view_item', :id => item.id, :collection_id => @page.id %></span><br /> | |
| 4 | + <span class="authors"><%= item.author %></span> <span class="date_issued">(<%= item.issue_date %>)</span> | |
| 4 | 5 | </li> | ... | ... |
| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | +<% dspace_server_url = @collection.parent.parent.dspace_server_url %> | |
| 2 | + | |
| 3 | +<% if dspace_server_url =~ /\/$/ %> | |
| 4 | + <% dspace_server_url.gsub!(/\/$/,'') %> | |
| 5 | +<% end %> | |
| 6 | + | |
| 7 | +<div id="article-parent"> | |
| 8 | + <%= button(:back, _('Go back to %s') % @collection.short_title, @collection.url) %> | |
| 9 | +</div> | |
| 10 | + | |
| 11 | +<div id="dspace_library_item"> | |
| 12 | + | |
| 13 | + <div id="dspace_item_title"> | |
| 14 | + <%= content_tag 'h1', @item.name, :class => 'title' %> | |
| 15 | + </div> | |
| 16 | + | |
| 17 | + <br /> | |
| 18 | + | |
| 19 | + <div class="dspace_item_section"> | |
| 20 | + <%= content_tag 'div', _('Authors:'), :class => 'dspace_item_section_title' %> | |
| 21 | + <%= content_tag 'div', @item.author, :class => 'dspace_item_section_value' %> | |
| 22 | + </div> | |
| 23 | + | |
| 24 | + <br /> | |
| 25 | + | |
| 26 | + <div class="dspace_item_section"> | |
| 27 | + <%= content_tag 'div', _('Issue date:'), :class => 'dspace_item_section_title' %> | |
| 28 | + <%= content_tag 'div', @item.issue_date, :class => 'dspace_item_section_value' %> | |
| 29 | + </div> | |
| 30 | + <br /> | |
| 31 | + | |
| 32 | + <div class="dspace_item_section"> | |
| 33 | + <%= content_tag 'div', _('Abstract:'), :class => 'dspace_item_section_title' %> | |
| 34 | + <%= content_tag 'div', @item.abstract, :class => 'dspace_item_section_value' %> | |
| 35 | + </div> | |
| 36 | + | |
| 37 | + <br /> | |
| 38 | + | |
| 39 | + <div class="dspace_item_section"> | |
| 40 | + <%= content_tag 'div', _('Description:'), :class => 'dspace_item_section_title' %> | |
| 41 | + <%= content_tag 'div', @item.description, :class => 'dspace_item_section_value' %> | |
| 42 | + </div> | |
| 43 | + | |
| 44 | + <br /> | |
| 45 | + | |
| 46 | + <div class="dspace_item_section"> | |
| 47 | + <%= content_tag 'div', _('URI:'), :class => 'dspace_item_section_title' %> | |
| 48 | + <%= content_tag 'div', link_to(@item.uri, @item.uri), :class => 'dspace_item_section_value' %> | |
| 49 | + </div> | |
| 50 | + | |
| 51 | + <br /> | |
| 52 | + | |
| 53 | + <div class="dspace_item_section"> | |
| 54 | + <%= content_tag 'div', _('Files in this item'), :class => 'dspace_item_section_title' %> | |
| 55 | + <ul id="item_files_list"> | |
| 56 | + <% @item.files.each do |file| %> | |
| 57 | + <li> | |
| 58 | + <ul class="item_file_attributes_list"> | |
| 59 | + <li><span>File:</span> <%= link_to file.name, dspace_server_url + file.retrieve_link %></li> | |
| 60 | + <li><span>Description:</span> <%= file.description %></li> | |
| 61 | + <li><span>Size:</span> <%= number_to_human_size( file.size_bytes ) %></li> | |
| 62 | + </ul> | |
| 63 | + </li> | |
| 64 | + <% end %> | |
| 65 | + </ul> | |
| 66 | + </div> | |
| 67 | + | |
| 68 | +<div> | ... | ... |