diff --git a/plugins/dspace/controllers/dspace_plugin_controller.rb b/plugins/dspace/controllers/dspace_plugin_controller.rb index f7b753b..509e9d9 100644 --- a/plugins/dspace/controllers/dspace_plugin_controller.rb +++ b/plugins/dspace/controllers/dspace_plugin_controller.rb @@ -7,7 +7,15 @@ class DspacePluginController < PublicController item_id = params[:id] begin - @item = Dspace::Item.get_item_by_id item_id + @collection = DspacePlugin::Collection.find(collection_id) + rescue ActiveRecord::RecordNotFound + render_not_found + return + end + + begin + dspace_server = @collection.parent.parent.dspace_server_url + @item = Dspace::Item.get_item_by_id dspace_server, item_id rescue ActiveResource::UnauthorizedAccess render_not_found return diff --git a/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb b/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb index ec133aa..380cfa1 100644 --- a/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb +++ b/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb @@ -31,20 +31,12 @@ class DspacePluginMyprofileController < CmsController article_data.merge!(params[:article]) if params[:article] if @type == 'DspacePlugin::Collection' - ids_list = 'dspace_collections_ids' - names_list = 'dspace_collections_names' + dspace_objects = article_data['dspace_collections'] elsif @type == 'DspacePlugin::Communityy' - ids_list = 'dspace_communities_ids' - names_list = 'dspace_communities_names' + dspace_objects = article_data['dspace_communities'] end - index = -1 - - article_data[ids_list].each do |id| - - index += 1 - - name = article_data[names_list][index] + dspace_objects.each do |object| entity = klass.new @@ -55,18 +47,19 @@ class DspacePluginMyprofileController < CmsController parent_id = parent.id end - entity.dspace_community_id = id if @type == 'DspacePlugin::Communityy' - - if @type == 'DspacePlugin::Collection' - entity.dspace_collection_id = id + if @type == 'DspacePlugin::Communityy' + entity.dspace_community_id = object['id'] + elsif @type == 'DspacePlugin::Collection' entity.dspace_community_id = article_data['dspace_community_id'] + entity.dspace_collection_id = object['id'] + entity.accept_comments = false end + entity.name = object['name'] entity.profile = profile entity.author = user entity.last_changed_by = user entity.created_by = user - entity.name = name entity.save! diff --git a/plugins/dspace/lib/dspace/client.rb b/plugins/dspace/lib/dspace/client.rb deleted file mode 100644 index a8edce1..0000000 --- a/plugins/dspace/lib/dspace/client.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Dspace::Client - - def initialize(server_url) - @server_url = server_url - end - - def get_collections - Dspace::Collection.get_all_collections_from @server_url - end - - def get_communities - 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 4dfbab6..5c3a7de 100644 --- a/plugins/dspace/lib/dspace/collection.rb +++ b/plugins/dspace/lib/dspace/collection.rb @@ -7,34 +7,9 @@ class Dspace::Collection < Dspace::Resource item_list = [] if result.items.count > 0 - result.items.each { |element| - - item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, element.id - - # 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}]] - issue_date = 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.issue_date = issue_date - + item = Dspace::Item.get_item_by_id dspace_server, element.id item_list << item - } end diff --git a/plugins/dspace/lib/dspace/item.rb b/plugins/dspace/lib/dspace/item.rb index 98d5109..ffc9470 100644 --- a/plugins/dspace/lib/dspace/item.rb +++ b/plugins/dspace/lib/dspace/item.rb @@ -6,8 +6,8 @@ class Dspace::Item < Dspace::Resource result.metadata end - def self.get_item_by_id(item_id) - self.site = 'http://dspace.maljr.net/rest/' + def self.get_item_by_id(dspace_server, item_id) + self.site = dspace_server result = self.find item_id, :params => { :expand => 'metadata' } item_metadata = Dspace::Item.get_all_item_metadata_from self.site, result.id diff --git a/plugins/dspace/lib/dspace_plugin/collection.rb b/plugins/dspace/lib/dspace_plugin/collection.rb index 5141853..ea5522e 100644 --- a/plugins/dspace/lib/dspace_plugin/collection.rb +++ b/plugins/dspace/lib/dspace_plugin/collection.rb @@ -18,9 +18,9 @@ class DspacePlugin::Collection < Article end def to_html(options = {}) - dspace_collection = self + dspace_content = self proc do - render :file => 'content_viewer/collection', :locals => {:dspace_collection => dspace_collection} + render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content } end end diff --git a/plugins/dspace/lib/dspace_plugin/collection_helper.rb b/plugins/dspace/lib/dspace_plugin/collection_helper.rb new file mode 100644 index 0000000..7b155e5 --- /dev/null +++ b/plugins/dspace/lib/dspace_plugin/collection_helper.rb @@ -0,0 +1,14 @@ +module DspacePlugin::CollectionHelper + + include ArticleHelper + + def custom_options_for_article(article,tokenized_children) + @article = article + + visibility_options(article,tokenized_children) + + content_tag('div', + hidden_field_tag('article[accept_comments]', 0) + ) + end + +end diff --git a/plugins/dspace/lib/dspace_plugin/communityy.rb b/plugins/dspace/lib/dspace_plugin/communityy.rb index 1274636..9a80040 100644 --- a/plugins/dspace/lib/dspace_plugin/communityy.rb +++ b/plugins/dspace/lib/dspace_plugin/communityy.rb @@ -1,4 +1,4 @@ -class DspacePlugin::Communityy < Article +class DspacePlugin::Communityy < Folder settings_items :dspace_community_id, :type => :string @@ -17,9 +17,9 @@ class DspacePlugin::Communityy < Article end def to_html(options = {}) - dspace_community = self + dspace_content = self proc do - render :file => 'content_viewer/community', :locals => {:dspace_community => dspace_community} + render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content } end end diff --git a/plugins/dspace/lib/dspace_plugin/communityy_helper.rb b/plugins/dspace/lib/dspace_plugin/communityy_helper.rb new file mode 100644 index 0000000..b518101 --- /dev/null +++ b/plugins/dspace/lib/dspace_plugin/communityy_helper.rb @@ -0,0 +1,14 @@ +module DspacePlugin::CommunityyHelper + + include ArticleHelper + + def custom_options_for_article(article,tokenized_children) + @article = article + + visibility_options(article,tokenized_children) + + content_tag('div', + hidden_field_tag('article[accept_comments]', 0) + ) + end + +end diff --git a/plugins/dspace/lib/dspace_plugin/dspace_block.rb b/plugins/dspace/lib/dspace_plugin/dspace_block.rb deleted file mode 100644 index 3838050..0000000 --- a/plugins/dspace/lib/dspace_plugin/dspace_block.rb +++ /dev/null @@ -1,35 +0,0 @@ -class DspacePlugin::DspaceBlock < Block - - settings_items :dspace_server_url, :type => :string, :default => "" - settings_items :collections, :type => :string, :default => "" - - attr_accessible :dspace_server_url, :collections - - def self.description - _('DSpace library') - end - - def help - _('This block displays a DSpace content.') - end - - def content(args={}) - block = self - proc do - dspace_client = Dspace::Client.new(block.dspace_server_url) - collection_items = dspace_client.get_collection_items(block.collections) - if !collection_items.blank? - content_tag('div', - render(:file => 'blocks/dspace', :locals => {:collection_items => collection_items}) - ) - else - '' - end - end - end - - def cacheable? - false - end - -end diff --git a/plugins/dspace/lib/dspace_plugin/item.rb b/plugins/dspace/lib/dspace_plugin/item.rb index 064f8c1..609da1d 100644 --- a/plugins/dspace/lib/dspace_plugin/item.rb +++ b/plugins/dspace/lib/dspace_plugin/item.rb @@ -1,6 +1,8 @@ class DspacePlugin::Item - attr_accessor :id, :name, :author, :issue_date, :abstract, :description, :uri, :files + include DspacePlugin::ItemHelper + + attr_accessor :id, :name, :author, :issue_date, :abstract, :description, :uri, :files, :mimetype def initialize self.files = [] diff --git a/plugins/dspace/lib/dspace_plugin/item_helper.rb b/plugins/dspace/lib/dspace_plugin/item_helper.rb new file mode 100644 index 0000000..aaa0c7b --- /dev/null +++ b/plugins/dspace/lib/dspace_plugin/item_helper.rb @@ -0,0 +1,8 @@ +module DspacePlugin::ItemHelper + + def remove_slash_at_end_url(url) + url.gsub!(/\/$/,'') if url =~ /\/$/ + url + end + +end diff --git a/plugins/dspace/lib/dspace_plugin/library.rb b/plugins/dspace/lib/dspace_plugin/library.rb index 4a13073..e39ab38 100644 --- a/plugins/dspace/lib/dspace_plugin/library.rb +++ b/plugins/dspace/lib/dspace_plugin/library.rb @@ -1,10 +1,16 @@ -class DspacePlugin::Library < Blog +class DspacePlugin::Library < Folder settings_items :dspace_server_url, :type => :string attr_accessible :dspace_server_url def dspace_server_url_valid + + if self.dspace_server_url.blank? + errors.add(:dspace_server_url, _("can't be blank") ) + return + end + errors.add(self.dspace_server_url, _("is not a valid URL. Please correct it and resubmit.")) unless url_valid?(self.dspace_server_url) end @@ -23,9 +29,9 @@ class DspacePlugin::Library < Blog end def to_html(options = {}) - dspace_library = self + dspace_content = self proc do - render :file => 'content_viewer/library', :locals => {:dspace_library => dspace_library} + render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content } end end diff --git a/plugins/dspace/lib/dspace_plugin/library_helper.rb b/plugins/dspace/lib/dspace_plugin/library_helper.rb new file mode 100644 index 0000000..c756ec8 --- /dev/null +++ b/plugins/dspace/lib/dspace_plugin/library_helper.rb @@ -0,0 +1,14 @@ +module DspacePlugin::LibraryHelper + + include ArticleHelper + + def custom_options_for_article(article,tokenized_children) + @article = article + + visibility_options(article,tokenized_children) + + content_tag('div', + hidden_field_tag('article[accept_comments]', 0) + ) + end + +end diff --git a/plugins/dspace/lib/ext/article.rb b/plugins/dspace/lib/ext/article.rb deleted file mode 100644 index 659fe60..0000000 --- a/plugins/dspace/lib/ext/article.rb +++ /dev/null @@ -1,95 +0,0 @@ -require_dependency 'article' - -class Article - - scope :dspace, :conditions => ["articles.published = true and (articles.type != 'UploadedFile' and articles.type != 'Blog' and articles.type != 'RssFeed') OR articles.type is NULL"] - - def self.articles_columns - Article.column_names.map {|c| "articles.#{c}"} .join(",") - end - - def self.most_accessed(owner, limit = nil) - conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id] - result = Article.dspace.find( - :all, - :order => 'hits desc', - :limit => limit, - :conditions => conditions) - result.paginate({:page => 1, :per_page => limit}) - end - - def self.most_commented_dspace(owner, limit) - conditions = owner.kind_of?(Environment) ? ["comments_count > 0"] : ["profile_id = ? and comments_count > 0", owner.id] - result = Article.dspace.find( - :all, - :order => 'comments_count desc', - :limit => limit, - :conditions => conditions) - result.paginate({:page => 1, :per_page => limit}) - end - - def self.more_positive_votes(owner, limit = nil) - conditions = owner.kind_of?(Environment) ? {'votes.voteable_type' => 'Article'} : ["profile_id = ? and votes.voteable_type = ? ", owner.id, 'Article'] - result = Article.dspace.find( - :all, - :order => 'sum(vote) desc', - :group => 'voteable_id, ' + articles_columns, - :limit => limit, - :having => ['sum(vote) > 0'], - :conditions => conditions, - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id') - result.paginate({:page => 1, :per_page => limit}) - end - - def self.more_negative_votes(owner, limit = nil) - conditions = owner.kind_of?(Environment) ? {'votes.voteable_type' => 'Article'} : ["profile_id = ? and votes.voteable_type = 'Article' ", owner.id] - result = Article.dspace.find( - :all, - :order => 'sum(vote) asc', - :group => 'voteable_id, ' + articles_columns, - :limit => limit, - :having => ['sum(vote) < 0'], - :conditions => conditions, - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id' - ) - result.paginate({:page => 1, :per_page => limit}) - end - - def self.most_liked(owner, limit = nil) - conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article' and vote > 0"] : ["votes.voteable_type = 'Article' and vote > 0 and profile_id = ? ", owner.id] - result = Article.dspace.find( - :all, - :select => articles_columns, - :order => 'count(voteable_id) desc', - :group => 'voteable_id, ' + articles_columns, - :limit => limit, - :conditions => conditions, - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id') - result.paginate({:page => 1, :per_page => limit}) - end - - def self.most_disliked(owner, limit = nil) - conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article' and vote < 0"] : ["votes.voteable_type = 'Article' and vote < 0 and profile_id = ? ", owner.id] - result = Article.dspace.find( - :all, - :order => 'count(voteable_id) desc', - :group => 'voteable_id, ' + articles_columns, - :limit => limit, - :conditions => conditions, - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id') - result.paginate({:page => 1, :per_page => limit}) - end - - def self.most_voted(owner, limit = nil) - conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article'"] : ["votes.voteable_type = 'Article' and profile_id = ? ", owner.id] - result = Article.dspace.find( - :all, - :select => articles_columns, - :order => 'count(voteable_id) desc', - :group => 'voteable_id, ' + articles_columns, - :limit => limit, - :conditions => conditions, - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id') - result.paginate({:page => 1, :per_page => limit}) - end -end diff --git a/plugins/dspace/public/icons/audio.png b/plugins/dspace/public/icons/audio.png new file mode 100644 index 0000000..fc4e198 Binary files /dev/null and b/plugins/dspace/public/icons/audio.png differ diff --git a/plugins/dspace/public/icons/doc.png b/plugins/dspace/public/icons/doc.png new file mode 100644 index 0000000..ff31c47 Binary files /dev/null and b/plugins/dspace/public/icons/doc.png differ diff --git a/plugins/dspace/public/icons/image.png b/plugins/dspace/public/icons/image.png new file mode 100644 index 0000000..83b32b4 Binary files /dev/null and b/plugins/dspace/public/icons/image.png differ diff --git a/plugins/dspace/public/icons/pdf.png b/plugins/dspace/public/icons/pdf.png new file mode 100644 index 0000000..9b5123c Binary files /dev/null and b/plugins/dspace/public/icons/pdf.png differ diff --git a/plugins/dspace/public/icons/spreadsheet.png b/plugins/dspace/public/icons/spreadsheet.png new file mode 100644 index 0000000..06103e5 Binary files /dev/null and b/plugins/dspace/public/icons/spreadsheet.png differ diff --git a/plugins/dspace/public/icons/text.png b/plugins/dspace/public/icons/text.png new file mode 100644 index 0000000..ff069ff Binary files /dev/null and b/plugins/dspace/public/icons/text.png differ diff --git a/plugins/dspace/public/icons/video.png b/plugins/dspace/public/icons/video.png new file mode 100644 index 0000000..cfe02b5 Binary files /dev/null and b/plugins/dspace/public/icons/video.png differ diff --git a/plugins/dspace/public/javascripts/dspace_plugin.js b/plugins/dspace/public/javascripts/dspace_plugin.js index 6ff6bfe..83e0367 100644 --- a/plugins/dspace/public/javascripts/dspace_plugin.js +++ b/plugins/dspace/public/javascripts/dspace_plugin.js @@ -1,3 +1,5 @@ +/** + function selectCommunity(element, community_slug) { var hidden_field = jQuery('').attr({ id: 'article_dspace_community_name_', @@ -9,6 +11,7 @@ function selectCommunity(element, community_slug) { jQuery(hidden_field).insertAfter(element); } + function selectCollection(element, collection_slug) { var hidden_field = jQuery('').attr({ id: 'article_dspace_collection_name_', @@ -20,6 +23,10 @@ function selectCollection(element, collection_slug) { jQuery(hidden_field).insertAfter(element); } +function select_action(field_active) { +} +**/ + jQuery(document).ready(function() { url_base = window.location.protocol + '//' + window.location.host; forms = jQuery('form'); @@ -29,4 +36,50 @@ jQuery(document).ready(function() { forms[f].action = url_action.replace("/cms/new", "/plugin/dspace/new").replace(url_base,''); } }); + + function check_fields(check, table_id) { + var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']") + for (var i = 0; i < checkboxes.length; i++) { + if (checkboxes[i].disabled == false) { + checkboxes[i].checked = check + } + } + } + + function verify_checked(field_id){ + var checkboxes = jQuery("#" + field_id + "_fields_conf tbody tr td input[type='checkbox']") + var allchecked = true; + for (var j = 1; j < checkboxes.length; j++) { + if(!checkboxes[j].checked) { + allchecked = false; + break; + } + } + + var checkbox = jQuery("#" + field_id + "_active"); + checkbox.attr("checked", allchecked); + } + + + function check_all(field_id) { + jQuery("#" + field_id + "_active").click(function (){ + check_fields(this.checked, field_id + "_fields_conf") + }); + verify_checked(field_id); + } + + check_all("community"); + check_all("collection"); + + jQuery("input[type='checkbox']").click(function () { + var checkbox = jQuery(this).attr("id").split("_"); + verify_checked(checkbox.first()); + + if(this.checked == false) { + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) + } + + jQuery(this).next().attr("disabled", !this.checked); + }) + }); diff --git a/plugins/dspace/public/style.css b/plugins/dspace/public/style.css index b5a477e..dbabb59 100644 --- a/plugins/dspace/public/style.css +++ b/plugins/dspace/public/style.css @@ -1,10 +1,11 @@ #dspace_library ul { margin: 0; - padding: 0 0 0 20px; + padding: 0 0 0 5px; } #dspace_library li { - list-style-image: url(/designs/themes/base/imgs/li-recent.gif); + /**list-style-image: url(/designs/themes/base/imgs/li-recent.gif);*/ + list-style-type: none; } #dspace_library li.item, @@ -28,7 +29,7 @@ } .dspace_item_section { - margin-left: 20px; + margin: 15px; } .dspace_item_section_title { diff --git a/plugins/dspace/test/test_helper.rb b/plugins/dspace/test/test_helper.rb deleted file mode 100644 index cca1fd3..0000000 --- a/plugins/dspace/test/test_helper.rb +++ /dev/null @@ -1 +0,0 @@ -require File.dirname(__FILE__) + '/../../../test/test_helper' diff --git a/plugins/dspace/test/unit/article.rb b/plugins/dspace/test/unit/article.rb deleted file mode 100644 index 64ecbcb..0000000 --- a/plugins/dspace/test/unit/article.rb +++ /dev/null @@ -1,148 +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 - - def enable_vote_plugin - enabled = false - environment=Environment.default - if Noosfero::Plugin.all.include?('VotePlugin') - if not environment.enabled_plugins.include?(:vote) - environment.enable_plugin(Vote) - environment.save! - end - enabled = true - end - enabled - end - - should 'list most commented articles' do - Article.delete_all - a1 = create(TextileArticle, :name => "art 1", :profile_id => profile.id) - a2 = create(TextileArticle, :name => "art 2", :profile_id => profile.id) - a3 = create(TextileArticle, :name => "art 3", :profile_id => profile.id) - - 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a2).save! } - 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a3).save! } - - # should respect the order (more commented comes first) - assert_equal a3.name, profile.articles.most_commented_dspace(Environment.default, 3).first.name - # It is a2 instead of a1 since it does not list articles without comments - assert_equal a2.name, profile.articles.most_commented_dspace(Environment.default, 3).last.name - end - - - should 'find the most voted' do - if not enable_vote_plugin - return - end - article = fast_create(Article, {:name=>'2 votes'}) - 2.times{ - person = fast_create(Person) - person.vote_for(article) - } - article = fast_create(Article, {:name=>'10 votes'}) - 10.times{ - person = fast_create(Person) - person.vote_for(article) - } - article = fast_create(Article, {:name=>'5 votes'}) - 5.times{ - person = fast_create(Person) - person.vote_for(article) - } - articles = Article.most_voted(Environment.default, 5) - assert_equal '10 votes', articles.first.name - assert_equal '2 votes', articles.last.name - end - - should 'list the most postive' do - if not enable_vote_plugin - return - end - article = fast_create(Article, {:name=>'23 votes for 20 votes against'}) - 20.times{ - person = fast_create(Person) - person.vote_against(article) - } - 23.times{ - person = fast_create(Person) - person.vote_for(article) - } - article = fast_create(Article, {:name=>'10 votes for 5 votes against'}) - 10.times{ - person = fast_create(Person) - person.vote_for(article) - } - 5.times{ - person = fast_create(Person) - person.vote_against(article) - } - article = fast_create(Article, {:name=>'2 votes against'}) - 2.times{ - person = fast_create(Person) - person.vote_against(article) - } - - article = fast_create(Article, {:name=>'7 votes for'}) - 7.times{ - person = fast_create(Person) - person.vote_for(article) - } - articles = Article.more_positive_votes(Environment.default, 5) - assert_equal '7 votes for', articles.first.name - assert_equal '23 votes for 20 votes against', articles.last.name - end - - should 'list the most negative' do - if not enable_vote_plugin - return - end - article = fast_create(Article, {:name=>'23 votes for 29 votes against'}) - 29.times{ - person = fast_create(Person) - person.vote_against(article) - } - 23.times{ - person = fast_create(Person) - person.vote_for(article) - } - article = fast_create(Article, {:name=>'10 votes for 15 votes against'}) - 10.times{ - person = fast_create(Person) - person.vote_for(article) - } - 15.times{ - person = fast_create(Person) - person.vote_against(article) - } - article = fast_create(Article, {:name=>'2 votes against'}) - 2.times{ - person = fast_create(Person) - person.vote_against(article) - } - article = fast_create(Article, {:name=>'7 votes for'}) - 7.times{ - person = fast_create(Person) - person.vote_for(article) - } - articles = Article.more_negative_votes(Environment.default, 5) - assert_equal '23 votes for 29 votes against', articles.first.name - assert_equal '2 votes against', articles.last.name - end -end \ No newline at end of file diff --git a/plugins/dspace/test/unit/dspace_plugin_test.rb b/plugins/dspace/test/unit/dspace_plugin_test.rb deleted file mode 100644 index 08087c5..0000000 --- a/plugins/dspace/test/unit/dspace_plugin_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class DspacePluginTest < ActiveSupport::TestCase - - def setup - @plugin = DspacePlugin.new - end - - should 'be a noosfero plugin' do - assert_kind_of Noosfero::Plugin, @plugin - end - - should 'have name' do - assert_equal 'Relevant Content Plugin', DspacePlugin.plugin_name - end - - should 'have description' do - assert_equal _("A plugin that lists the most accessed, most commented, most liked and most disliked contents."), DspacePlugin.plugin_description - end - - should 'have stylesheet' do - assert @plugin.stylesheet? - end - - should "return DspaceBlock in extra_blocks class method" do - assert DspacePlugin.extra_blocks.keys.include?(DspacePlugin::DspaceBlock) - end - -end diff --git a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb index d4b1d20..d672f5a 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb @@ -10,10 +10,14 @@ <% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %> - - - - +
 <%= _('Collection name') %>
+ + + <% dspace_collections_ids = DspacePlugin::Collection.find(:all, :conditions => { :parent_id => @article.parent_id}).map { |collection| ids = collection.dspace_collection_id.to_i } %> @@ -21,14 +25,22 @@ <% collections.each do |collection| %> - <% if dspace_collections_ids.include? collection[1] %> - - <% else %> - - <% end %> + + <% if dspace_collections_ids.include? collection[1] %> + + <% else %> + + <% end %> + <% end %> diff --git a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb index ef3ecd8..91d7185 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb @@ -6,10 +6,14 @@ <% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %> -
+ <%= _("Check/Uncheck All Unlocked")%> + + +
<%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> <%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> <%= collection[0] %> + <%= check_box_tag "article[dspace_collections][][id]", collection[1], true, :disabled => 'disabled', :id => "collection_id_#{collection[1]}" %> + <%= hidden_field_tag "article[dspace_collections][][name]", collection[0], :disabled => 'disabled' %> + + <%= check_box_tag "article[dspace_collections][][id]", collection[1], false, :id => "collection_id_#{collection[1]}" %> + <%= hidden_field_tag "article[dspace_collections][][name]", collection[0], :disabled => 'disabled', :id => "collection_name_#{collection[1]}" %> +
- - - +
 <%= _('Community name') %>
+ + + <% dspace_communities_ids = DspacePlugin::Communityy.find(:all, :conditions => { :parent_id => @article.parent_id }).map { |community| ids = community.dspace_community_id.to_i } %> @@ -17,14 +21,22 @@ <% communities.each do |community| %> - <% if dspace_communities_ids.include? community[1] %> - - <% else %> - - <% end %> + + <% if dspace_communities_ids.include? community[1] %> + + <% else %> + + <% end %> + <% end %> diff --git a/plugins/dspace/views/cms/dspace_plugin/_item.html.erb b/plugins/dspace/views/cms/dspace_plugin/_item.html.erb deleted file mode 100644 index 9a34721..0000000 --- a/plugins/dspace/views/cms/dspace_plugin/_item.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -

<%= _('DSpace Item') %>

- -<%= required_fields_message %> - -<%= required f.text_field('name', :size => '64', :maxlength => 150) %> - -<%= hidden_field_tag 'article[parent_id]', @article.parent_id %> - -<% dspace_client = Dspace::Client.new('') %> - -<% collections = dspace_client.get_collections %> - -<% -collections_2 = collections.map { |collection| - item = [_(collection.name), collection.id] -} -%> - -<%= labelled_form_field(_('Collections:'), - select(:article, - :dspace_collection_id, - options_for_select_with_title(collections_2))) %> - diff --git a/plugins/dspace/views/cms/dspace_plugin/_library.html.erb b/plugins/dspace/views/cms/dspace_plugin/_library.html.erb index e648d30..9d88cd7 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_library.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_library.html.erb @@ -1,6 +1,4 @@ -<%= error_messages_for 'library' %> - -

<%= _('My Library') %>

+

<%= _('My DSpace Library') %>

<%= render :file => 'shared/tiny_mce' %> @@ -10,61 +8,4 @@ <%= render :partial => 'general_fields' %> - - -<%= hidden_field_tag 'old_article_slug', @article.slug %> -
- <%= labelled_form_field( _('Address'), - content_tag('code', - url_for(@article.url).gsub(/#{@article.slug}$/, '') + - text_field(:article, :slug, :onchange => "warn_value_change()", :size => 25) - ) + - content_tag('div', - content_tag('strong', _('WARNING!')) + ' ' + - _("You are about to change the address, and this will break external links to this blog or to posts inside it. Do you really want to change?") + - content_tag('div', - button_to_function(:ok, _("Yes"), "confirm_change()") + ' ' + - button_to_function(:cancel, _('No'), 'no_change()') - ), - :id => 'slug-change-confirmation', - :class => 'change-confirmation', - :style => 'display: none;' - ) - ) - %> -
- -<%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 10)) %> - -<%= f.fields_for :image_builder, @article.image do |i| %> - <%= file_field_or_thumbnail(_('Cover image:'), @article.image, i)%> - <%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %> -<% end %> - -<% unless @article.image.nil? %> - <%= labelled_check_box(_('Remove cover image'),'remove_image',true,false)%> -<% end %> - -<%= labelled_form_field(_('Show catalog as:'), f.select(:visualization_format, [ [ _('Listing with thumbnail'), 'full'], [ _('Listing without thumbnail'), 'short'], [ _('Type catalog'), 'catalog'] ])) %> - -<%= labelled_form_field(_('Items per page:'), f.select(:posts_per_page, Blog.posts_per_page_options)) %> +<%= labelled_form_field(_('Description:'), text_area(:article, :body, :cols => 68, :rows => 10)) %> diff --git a/plugins/dspace/views/content_viewer/_collection_item.html.erb b/plugins/dspace/views/content_viewer/_collection_item.html.erb deleted file mode 100644 index b7245c5..0000000 --- a/plugins/dspace/views/content_viewer/_collection_item.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
  • - <%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %> -
  • diff --git a/plugins/dspace/views/content_viewer/_community.html.erb b/plugins/dspace/views/content_viewer/_community.html.erb new file mode 100644 index 0000000..8f9024c --- /dev/null +++ b/plugins/dspace/views/content_viewer/_community.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to community.title, :controller => 'content_viewer', :action => 'view_page', :page => community.path %> +
  • diff --git a/plugins/dspace/views/content_viewer/_community_item.html.erb b/plugins/dspace/views/content_viewer/_community_item.html.erb deleted file mode 100644 index f5f2ad0..0000000 --- a/plugins/dspace/views/content_viewer/_community_item.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
  • - <%= 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 e7aeec8..5cff69c 100644 --- a/plugins/dspace/views/content_viewer/_item.html.erb +++ b/plugins/dspace/views/content_viewer/_item.html.erb @@ -1,4 +1,16 @@
  • - <%= link_to item.name, :controller => 'dspace_plugin', :action => 'view_item', :id => item.id, :collection_id => @page.id %>
    - <%= item.author %> (<%= item.issue_date %>) +
    + + <% if item.files.first.mimetype == 'application/pdf' %> + + <% else %> + + <% end %> + +
    + <%= link_to item.name, :controller => 'dspace_plugin', :action => 'view_item', :id => item.id, :collection_id => @page.id %>
    + <%= item.author %> (<%= item.issue_date %>) +
    + +
  • diff --git a/plugins/dspace/views/content_viewer/collection.html.erb b/plugins/dspace/views/content_viewer/collection.html.erb deleted file mode 100644 index 211ac45..0000000 --- a/plugins/dspace/views/content_viewer/collection.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% collection_id = dspace_collection.dspace_collection_id %> -<% dspace_server = dspace_collection.parent.parent.dspace_server_url %> - -
    -
    - -
    -
    diff --git a/plugins/dspace/views/content_viewer/community.html.erb b/plugins/dspace/views/content_viewer/community.html.erb deleted file mode 100644 index 4049eb4..0000000 --- a/plugins/dspace/views/content_viewer/community.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<% community_id = dspace_community.dspace_community_id %> -<% dspace_server = dspace_community.parent.dspace_server_url %> - -
    - - <% if dspace_community.allow_create?(user) %> - -
    - <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_community.id}), :class => 'button with-text icon-add') do %> - <%= _("Add a %s") % DspacePlugin::Collection.short_description %> - <% end %> -
    - - <% end %> - - <% collections = dspace_community.collections dspace_server, community_id %> - -
    - -
    - -
    diff --git a/plugins/dspace/views/content_viewer/dspace_content.html.erb b/plugins/dspace/views/content_viewer/dspace_content.html.erb new file mode 100644 index 0000000..df9f0c0 --- /dev/null +++ b/plugins/dspace/views/content_viewer/dspace_content.html.erb @@ -0,0 +1,59 @@ +
    + + <% if dspace_content.allow_create?(user) %> + +
    + + <% if dspace_content.is_a? DspacePlugin::Library %> + + <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Communityy", :parent_id => dspace_content.id}), :class => 'button with-text icon-add') do %> + <%= _("Add %s") % DspacePlugin::Communityy.short_description %> + <% end %> + + <% elsif dspace_content.is_a? DspacePlugin::Communityy %> + + <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_content.id}), :class => 'button with-text icon-add') do %> + <%= _("Add %s") % DspacePlugin::Collection.short_description %> + <% end %> + + <% end %> + +
    + + <% end %> + + <% if dspace_content.is_a? DspacePlugin::Library %> + + <% communities = dspace_content.communities %> + + + + <% elsif dspace_content.is_a? DspacePlugin::Communityy %> + + <% community_id = dspace_content.dspace_community_id %> + <% dspace_server = dspace_content.parent.dspace_server_url %> + + <% collections = dspace_content.collections dspace_server, community_id %> + + + + <% elsif dspace_content.is_a? DspacePlugin::Collection %> + + <% collection_id = dspace_content.dspace_collection_id %> + <% dspace_server = dspace_content.parent.parent.dspace_server_url %> + +
    +
    +
      + <%= render :partial => 'item', :collection => dspace_content.items(dspace_server, collection_id) %> +
    +
    +
    + + <% end %> + +
    diff --git a/plugins/dspace/views/content_viewer/library.html.erb b/plugins/dspace/views/content_viewer/library.html.erb deleted file mode 100644 index 0800839..0000000 --- a/plugins/dspace/views/content_viewer/library.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -
    - - <% if dspace_library.allow_create?(user) %> - -
    - <%= 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 %> - <%= _("Add a %s") % DspacePlugin::Communityy.short_description %> - <% end %> -
    - - <% end %> - - <% communities = dspace_library.communities %> - - - -
    diff --git a/plugins/dspace/views/dspace_plugin/_item_file.html.erb b/plugins/dspace/views/dspace_plugin/_item_file.html.erb new file mode 100644 index 0000000..c7416d3 --- /dev/null +++ b/plugins/dspace/views/dspace_plugin/_item_file.html.erb @@ -0,0 +1,12 @@ +
  • + +
  • diff --git a/plugins/dspace/views/dspace_plugin/_item_section.html.erb b/plugins/dspace/views/dspace_plugin/_item_section.html.erb new file mode 100644 index 0000000..1450111 --- /dev/null +++ b/plugins/dspace/views/dspace_plugin/_item_section.html.erb @@ -0,0 +1,8 @@ +
    +
    + <%= item_section[:title] %> +
    +
    + <%= item_section[:content] %> +
    +
    diff --git a/plugins/dspace/views/dspace_plugin/view_item.html.erb b/plugins/dspace/views/dspace_plugin/view_item.html.erb index 732cc22..459d892 100644 --- a/plugins/dspace/views/dspace_plugin/view_item.html.erb +++ b/plugins/dspace/views/dspace_plugin/view_item.html.erb @@ -1,8 +1,4 @@ -<% dspace_server_url = @collection.parent.parent.dspace_server_url %> - -<% if dspace_server_url =~ /\/$/ %> - <% dspace_server_url.gsub!(/\/$/,'') %> -<% end %> +<% extend DspacePlugin::ItemHelper %>
    <%= button(:back, _('Go back to %s') % @collection.short_title, @collection.url) %> @@ -11,58 +7,22 @@
    - <%= content_tag 'h1', @item.name, :class => 'title' %> -
    - -
    - -
    - <%= content_tag 'div', _('Authors:'), :class => 'dspace_item_section_title' %> - <%= content_tag 'div', @item.author, :class => 'dspace_item_section_value' %> +

    <%= @item.name %>

    -
    + <% item_files = render :partial => 'item_file', + :locals => { :dspace_server_url => remove_slash_at_end_url(@collection.parent.parent.dspace_server_url) }, + :collection => @item.files %> -
    - <%= content_tag 'div', _('Issue date:'), :class => 'dspace_item_section_title' %> - <%= content_tag 'div', @item.issue_date, :class => 'dspace_item_section_value' %> -
    -
    - -
    - <%= content_tag 'div', _('Abstract:'), :class => 'dspace_item_section_title' %> - <%= content_tag 'div', @item.abstract, :class => 'dspace_item_section_value' %> -
    + <% item_files_content = content_tag('ul', item_files, :id => 'item_files_list') %> -
    -
    - <%= content_tag 'div', _('Description:'), :class => 'dspace_item_section_title' %> - <%= content_tag 'div', @item.description, :class => 'dspace_item_section_value' %> -
    + <%= render :partial => 'item_section', + :collection => [ { :title => _('Authors:'), :content => @item.author }, + { :title => _('Issue date:'), :content => @item.issue_date }, + { :title => _('Abstract:'), :content => @item.abstract }, + { :title => _('Description:'), :content => @item.description }, + { :title => _('URI:'), :content => link_to(@item.uri, @item.uri, :target => '_blank') }, + { :title => _('Files in this item'), :content => item_files_content } ] %> -
    - -
    - <%= content_tag 'div', _('URI:'), :class => 'dspace_item_section_title' %> - <%= content_tag 'div', link_to(@item.uri, @item.uri), :class => 'dspace_item_section_value' %> -
    - -
    - -
    - <%= content_tag 'div', _('Files in this item'), :class => 'dspace_item_section_title' %> -
      - <% @item.files.each do |file| %> -
    • -
        -
      • File: <%= link_to file.name, dspace_server_url + file.retrieve_link %>
      • -
      • Description: <%= file.description %>
      • -
      • Size: <%= number_to_human_size( file.size_bytes ) %>
      • -
      -
    • - <% end %> -
    -
    - -
    +
    diff --git a/plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_collection.html.erb b/plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_collection.html.erb deleted file mode 100644 index d4b1d20..0000000 --- a/plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_collection.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -

    <%= _('DSpace Collections') %>

    - -<%= hidden_field_tag 'article[parent_id]', @article.parent_id %> - -<%= hidden_field_tag 'article[dspace_community_id]', @article.parent.dspace_community_id %> - -<% dspace_server_url = @article.parent.parent.dspace_server_url %> - -<% community_id = @article.parent.dspace_community_id %> - -<% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %> - -
    + <%= _("Check/Uncheck All Unlocked")%> + + +
    <%= check_box_tag "article[dspace_communities_ids][]", community[1], true, :disabled => 'disabled', :onclick => "selectCommunity(this,'#{community[0]}')" %> <%= check_box_tag "article[dspace_communities_ids][]", community[1], false, :onclick => "selectCommunity(this,'#{community[0]}')" %> <%= community[0] %> + <%= check_box_tag "article[dspace_communities][][id]", community[1], true, :disabled => 'disabled', :id => "community_id_#{community[1]}" %> + <%= hidden_field_tag "article[dspace_communities][][name]", community[0], :disabled => 'disabled' %> + + <%= check_box_tag "article[dspace_communities][][id]", community[1], false, :id => "community_id_#{community[1]}" %> + <%= hidden_field_tag "article[dspace_communities][][name]", community[0], :disabled => 'disabled', :id => "community_name_#{community[1]}" %> +
    - - - - - - <% dspace_collections_ids = DspacePlugin::Collection.find(:all, :conditions => { :parent_id => @article.parent_id}).map { |collection| ids = collection.dspace_collection_id.to_i } %> - - <% collections.each do |collection| %> - - - <% if dspace_collections_ids.include? collection[1] %> - - <% else %> - - <% end %> - - - - <% end %> - -
     <%= _('Collection name') %>
    <%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> <%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> - <%= collection[0] %> -
    - -<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %> diff --git a/plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_communityy.html.erb b/plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_communityy.html.erb deleted file mode 100644 index ef3ecd8..0000000 --- a/plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_communityy.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -

    <%= _('DSpace Communities') %>

    - -<%= hidden_field_tag 'article[parent_id]', @article.parent_id %> - -<% dspace_server_url = @article.parent.dspace_server_url %> - -<% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %> - - - - - - - - <% dspace_communities_ids = DspacePlugin::Communityy.find(:all, :conditions => { :parent_id => @article.parent_id }).map { |community| ids = community.dspace_community_id.to_i } %> - - <% communities.each do |community| %> - - - <% if dspace_communities_ids.include? community[1] %> - - <% else %> - - <% end %> - - - - <% end %> - -
     <%= _('Community name') %>
    <%= check_box_tag "article[dspace_communities_ids][]", community[1], true, :disabled => 'disabled', :onclick => "selectCommunity(this,'#{community[0]}')" %> <%= check_box_tag "article[dspace_communities_ids][]", community[1], false, :onclick => "selectCommunity(this,'#{community[0]}')" %> - <%= community[0] %> -
    - -<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %> diff --git a/plugins/dspace/views/dspace_plugin_myprofile/edit.html.erb b/plugins/dspace/views/dspace_plugin_myprofile/edit.html.erb deleted file mode 100644 index 757a94f..0000000 --- a/plugins/dspace/views/dspace_plugin_myprofile/edit.html.erb +++ /dev/null @@ -1,42 +0,0 @@ -<%= error_messages_for 'article' %> - -
    '> - -<%= labelled_form_for 'article', :url => {action: "new_dspace_content"}, :html => { :multipart => true, :class => @type } do |f| %> - - <%= hidden_field_tag("type", @type) if @type %> - - <%= hidden_field_tag('parent_id', @parent_id) if @parent_id %> - - <%= hidden_field_tag('back_to', @back_to) %> - - <%= hidden_field_tag('success_back_to', @success_back_to) %> - - <%= render :partial => partial_for_class(@article.class), :locals => { :f => f } %> - - <% button_bar do %> - <%= submit_button :save, _('Save') %> - - <% if @back_to %> - <%= button :cancel, _('Cancel'), @back_to %> - <% elsif @parent_id || @article.parent %> - <%= button :cancel, _('Cancel'), :action => 'view', :id => @parent_id || @article.parent %> - <% else %> - <%= button :cancel, _('Cancel'), :action => 'index' %> - <% end %> - - <% unless @article.new_record? %> - <%= button :delete, _('Delete'), {:controller => :cms, :action => :destroy, :id => @article}, - :method => :post, :confirm => delete_article_message(@article) %> - <% end %> - <% end %> -<% end %> -
    - -<% if environment.enabled?('media_panel') && [TinyMceArticle, TextileArticle, Event, EnterpriseHomepage].any?{|klass| @article.kind_of?(klass)} %> - <%= render :partial => 'text_editor_sidebar' %> -<% end %> - -
    - -<%= javascript_include_tag "article.js" %> -- libgit2 0.21.2