Commit 902ea9e888a79b9198859829c6a7c02021299ab0

Authored by Francisco Júnior
1 parent f31d0ef4

dspace_plugin : refactoring

Showing 45 changed files with 299 additions and 712 deletions   Show diff stats
plugins/dspace/controllers/dspace_plugin_controller.rb
... ... @@ -7,7 +7,15 @@ class DspacePluginController < PublicController
7 7 item_id = params[:id]
8 8  
9 9 begin
10   - @item = Dspace::Item.get_item_by_id item_id
  10 + @collection = DspacePlugin::Collection.find(collection_id)
  11 + rescue ActiveRecord::RecordNotFound
  12 + render_not_found
  13 + return
  14 + end
  15 +
  16 + begin
  17 + dspace_server = @collection.parent.parent.dspace_server_url
  18 + @item = Dspace::Item.get_item_by_id dspace_server, item_id
11 19 rescue ActiveResource::UnauthorizedAccess
12 20 render_not_found
13 21 return
... ...
plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb
... ... @@ -31,20 +31,12 @@ class DspacePluginMyprofileController < CmsController
31 31 article_data.merge!(params[:article]) if params[:article]
32 32  
33 33 if @type == 'DspacePlugin::Collection'
34   - ids_list = 'dspace_collections_ids'
35   - names_list = 'dspace_collections_names'
  34 + dspace_objects = article_data['dspace_collections']
36 35 elsif @type == 'DspacePlugin::Communityy'
37   - ids_list = 'dspace_communities_ids'
38   - names_list = 'dspace_communities_names'
  36 + dspace_objects = article_data['dspace_communities']
39 37 end
40 38  
41   - index = -1
42   -
43   - article_data[ids_list].each do |id|
44   -
45   - index += 1
46   -
47   - name = article_data[names_list][index]
  39 + dspace_objects.each do |object|
48 40  
49 41 entity = klass.new
50 42  
... ... @@ -55,18 +47,19 @@ class DspacePluginMyprofileController < CmsController
55 47 parent_id = parent.id
56 48 end
57 49  
58   - entity.dspace_community_id = id if @type == 'DspacePlugin::Communityy'
59   -
60   - if @type == 'DspacePlugin::Collection'
61   - entity.dspace_collection_id = id
  50 + if @type == 'DspacePlugin::Communityy'
  51 + entity.dspace_community_id = object['id']
  52 + elsif @type == 'DspacePlugin::Collection'
62 53 entity.dspace_community_id = article_data['dspace_community_id']
  54 + entity.dspace_collection_id = object['id']
  55 + entity.accept_comments = false
63 56 end
64 57  
  58 + entity.name = object['name']
65 59 entity.profile = profile
66 60 entity.author = user
67 61 entity.last_changed_by = user
68 62 entity.created_by = user
69   - entity.name = name
70 63  
71 64 entity.save!
72 65  
... ...
plugins/dspace/lib/dspace/client.rb
... ... @@ -1,16 +0,0 @@
1   -class Dspace::Client
2   -
3   - def initialize(server_url)
4   - @server_url = server_url
5   - end
6   -
7   - def get_collections
8   - Dspace::Collection.get_all_collections_from @server_url
9   - end
10   -
11   - def get_communities
12   - Dspace::Community.get_all_communities_from @server_url
13   - end
14   -
15   -end
16   -
plugins/dspace/lib/dspace/collection.rb
... ... @@ -7,34 +7,9 @@ class Dspace::Collection < Dspace::Resource
7 7 item_list = []
8 8  
9 9 if result.items.count > 0
10   -
11 10 result.items.each { |element|
12   -
13   - item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, element.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   - # date issued
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   - item = DspacePlugin::Item.new
30   -
31   - item.id = element.id
32   - item.name = element.name
33   - item.author = author
34   - item.issue_date = issue_date
35   -
  11 + item = Dspace::Item.get_item_by_id dspace_server, element.id
36 12 item_list << item
37   -
38 13 }
39 14 end
40 15  
... ...
plugins/dspace/lib/dspace/item.rb
... ... @@ -6,8 +6,8 @@ class Dspace::Item &lt; 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/'
  9 + def self.get_item_by_id(dspace_server, item_id)
  10 + self.site = dspace_server
11 11 result = self.find item_id, :params => { :expand => 'metadata' }
12 12  
13 13 item_metadata = Dspace::Item.get_all_item_metadata_from self.site, result.id
... ...
plugins/dspace/lib/dspace_plugin/collection.rb
... ... @@ -18,9 +18,9 @@ class DspacePlugin::Collection &lt; Article
18 18 end
19 19  
20 20 def to_html(options = {})
21   - dspace_collection = self
  21 + dspace_content = self
22 22 proc do
23   - render :file => 'content_viewer/collection', :locals => {:dspace_collection => dspace_collection}
  23 + render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content }
24 24 end
25 25 end
26 26  
... ...
plugins/dspace/lib/dspace_plugin/collection_helper.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +module DspacePlugin::CollectionHelper
  2 +
  3 + include ArticleHelper
  4 +
  5 + def custom_options_for_article(article,tokenized_children)
  6 + @article = article
  7 +
  8 + visibility_options(article,tokenized_children) +
  9 + content_tag('div',
  10 + hidden_field_tag('article[accept_comments]', 0)
  11 + )
  12 + end
  13 +
  14 +end
... ...
plugins/dspace/lib/dspace_plugin/communityy.rb
1   -class DspacePlugin::Communityy < Article
  1 +class DspacePlugin::Communityy < Folder
2 2  
3 3 settings_items :dspace_community_id, :type => :string
4 4  
... ... @@ -17,9 +17,9 @@ class DspacePlugin::Communityy &lt; Article
17 17 end
18 18  
19 19 def to_html(options = {})
20   - dspace_community = self
  20 + dspace_content = self
21 21 proc do
22   - render :file => 'content_viewer/community', :locals => {:dspace_community => dspace_community}
  22 + render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content }
23 23 end
24 24 end
25 25  
... ...
plugins/dspace/lib/dspace_plugin/communityy_helper.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +module DspacePlugin::CommunityyHelper
  2 +
  3 + include ArticleHelper
  4 +
  5 + def custom_options_for_article(article,tokenized_children)
  6 + @article = article
  7 +
  8 + visibility_options(article,tokenized_children) +
  9 + content_tag('div',
  10 + hidden_field_tag('article[accept_comments]', 0)
  11 + )
  12 + end
  13 +
  14 +end
... ...
plugins/dspace/lib/dspace_plugin/dspace_block.rb
... ... @@ -1,35 +0,0 @@
1   -class DspacePlugin::DspaceBlock < Block
2   -
3   - settings_items :dspace_server_url, :type => :string, :default => ""
4   - settings_items :collections, :type => :string, :default => ""
5   -
6   - attr_accessible :dspace_server_url, :collections
7   -
8   - def self.description
9   - _('DSpace library')
10   - end
11   -
12   - def help
13   - _('This block displays a DSpace content.')
14   - end
15   -
16   - def content(args={})
17   - block = self
18   - proc do
19   - dspace_client = Dspace::Client.new(block.dspace_server_url)
20   - collection_items = dspace_client.get_collection_items(block.collections)
21   - if !collection_items.blank?
22   - content_tag('div',
23   - render(:file => 'blocks/dspace', :locals => {:collection_items => collection_items})
24   - )
25   - else
26   - ''
27   - end
28   - end
29   - end
30   -
31   - def cacheable?
32   - false
33   - end
34   -
35   -end
plugins/dspace/lib/dspace_plugin/item.rb
1 1 class DspacePlugin::Item
2 2  
3   - attr_accessor :id, :name, :author, :issue_date, :abstract, :description, :uri, :files
  3 + include DspacePlugin::ItemHelper
  4 +
  5 + attr_accessor :id, :name, :author, :issue_date, :abstract, :description, :uri, :files, :mimetype
4 6  
5 7 def initialize
6 8 self.files = []
... ...
plugins/dspace/lib/dspace_plugin/item_helper.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +module DspacePlugin::ItemHelper
  2 +
  3 + def remove_slash_at_end_url(url)
  4 + url.gsub!(/\/$/,'') if url =~ /\/$/
  5 + url
  6 + end
  7 +
  8 +end
... ...
plugins/dspace/lib/dspace_plugin/library.rb
1   -class DspacePlugin::Library < Blog
  1 +class DspacePlugin::Library < Folder
2 2  
3 3 settings_items :dspace_server_url, :type => :string
4 4  
5 5 attr_accessible :dspace_server_url
6 6  
7 7 def dspace_server_url_valid
  8 +
  9 + if self.dspace_server_url.blank?
  10 + errors.add(:dspace_server_url, _("can't be blank") )
  11 + return
  12 + end
  13 +
8 14 errors.add(self.dspace_server_url, _("is not a valid URL. Please correct it and resubmit.")) unless url_valid?(self.dspace_server_url)
9 15 end
10 16  
... ... @@ -23,9 +29,9 @@ class DspacePlugin::Library &lt; Blog
23 29 end
24 30  
25 31 def to_html(options = {})
26   - dspace_library = self
  32 + dspace_content = self
27 33 proc do
28   - render :file => 'content_viewer/library', :locals => {:dspace_library => dspace_library}
  34 + render :file => 'content_viewer/dspace_content', :locals => { :dspace_content => dspace_content }
29 35 end
30 36 end
31 37  
... ...
plugins/dspace/lib/dspace_plugin/library_helper.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +module DspacePlugin::LibraryHelper
  2 +
  3 + include ArticleHelper
  4 +
  5 + def custom_options_for_article(article,tokenized_children)
  6 + @article = article
  7 +
  8 + visibility_options(article,tokenized_children) +
  9 + content_tag('div',
  10 + hidden_field_tag('article[accept_comments]', 0)
  11 + )
  12 + end
  13 +
  14 +end
... ...
plugins/dspace/lib/ext/article.rb
... ... @@ -1,95 +0,0 @@
1   -require_dependency 'article'
2   -
3   -class Article
4   -
5   - scope :dspace, :conditions => ["articles.published = true and (articles.type != 'UploadedFile' and articles.type != 'Blog' and articles.type != 'RssFeed') OR articles.type is NULL"]
6   -
7   - def self.articles_columns
8   - Article.column_names.map {|c| "articles.#{c}"} .join(",")
9   - end
10   -
11   - def self.most_accessed(owner, limit = nil)
12   - conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id]
13   - result = Article.dspace.find(
14   - :all,
15   - :order => 'hits desc',
16   - :limit => limit,
17   - :conditions => conditions)
18   - result.paginate({:page => 1, :per_page => limit})
19   - end
20   -
21   - def self.most_commented_dspace(owner, limit)
22   - conditions = owner.kind_of?(Environment) ? ["comments_count > 0"] : ["profile_id = ? and comments_count > 0", owner.id]
23   - result = Article.dspace.find(
24   - :all,
25   - :order => 'comments_count desc',
26   - :limit => limit,
27   - :conditions => conditions)
28   - result.paginate({:page => 1, :per_page => limit})
29   - end
30   -
31   - def self.more_positive_votes(owner, limit = nil)
32   - conditions = owner.kind_of?(Environment) ? {'votes.voteable_type' => 'Article'} : ["profile_id = ? and votes.voteable_type = ? ", owner.id, 'Article']
33   - result = Article.dspace.find(
34   - :all,
35   - :order => 'sum(vote) desc',
36   - :group => 'voteable_id, ' + articles_columns,
37   - :limit => limit,
38   - :having => ['sum(vote) > 0'],
39   - :conditions => conditions,
40   - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
41   - result.paginate({:page => 1, :per_page => limit})
42   - end
43   -
44   - def self.more_negative_votes(owner, limit = nil)
45   - conditions = owner.kind_of?(Environment) ? {'votes.voteable_type' => 'Article'} : ["profile_id = ? and votes.voteable_type = 'Article' ", owner.id]
46   - result = Article.dspace.find(
47   - :all,
48   - :order => 'sum(vote) asc',
49   - :group => 'voteable_id, ' + articles_columns,
50   - :limit => limit,
51   - :having => ['sum(vote) < 0'],
52   - :conditions => conditions,
53   - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id'
54   - )
55   - result.paginate({:page => 1, :per_page => limit})
56   - end
57   -
58   - def self.most_liked(owner, limit = nil)
59   - conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article' and vote > 0"] : ["votes.voteable_type = 'Article' and vote > 0 and profile_id = ? ", owner.id]
60   - result = Article.dspace.find(
61   - :all,
62   - :select => articles_columns,
63   - :order => 'count(voteable_id) desc',
64   - :group => 'voteable_id, ' + articles_columns,
65   - :limit => limit,
66   - :conditions => conditions,
67   - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
68   - result.paginate({:page => 1, :per_page => limit})
69   - end
70   -
71   - def self.most_disliked(owner, limit = nil)
72   - conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article' and vote < 0"] : ["votes.voteable_type = 'Article' and vote < 0 and profile_id = ? ", owner.id]
73   - result = Article.dspace.find(
74   - :all,
75   - :order => 'count(voteable_id) desc',
76   - :group => 'voteable_id, ' + articles_columns,
77   - :limit => limit,
78   - :conditions => conditions,
79   - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
80   - result.paginate({:page => 1, :per_page => limit})
81   - end
82   -
83   - def self.most_voted(owner, limit = nil)
84   - conditions = owner.kind_of?(Environment) ? ["votes.voteable_type = 'Article'"] : ["votes.voteable_type = 'Article' and profile_id = ? ", owner.id]
85   - result = Article.dspace.find(
86   - :all,
87   - :select => articles_columns,
88   - :order => 'count(voteable_id) desc',
89   - :group => 'voteable_id, ' + articles_columns,
90   - :limit => limit,
91   - :conditions => conditions,
92   - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id')
93   - result.paginate({:page => 1, :per_page => limit})
94   - end
95   -end
plugins/dspace/public/icons/audio.png 0 → 100644

717 Bytes

plugins/dspace/public/icons/doc.png 0 → 100644

658 Bytes

plugins/dspace/public/icons/image.png 0 → 100644

525 Bytes

plugins/dspace/public/icons/pdf.png 0 → 100644

874 Bytes

plugins/dspace/public/icons/spreadsheet.png 0 → 100644

644 Bytes

plugins/dspace/public/icons/text.png 0 → 100644

419 Bytes

plugins/dspace/public/icons/video.png 0 → 100644

711 Bytes

plugins/dspace/public/javascripts/dspace_plugin.js
  1 +/**
  2 +
1 3 function selectCommunity(element, community_slug) {
2 4 var hidden_field = jQuery('<input>').attr({
3 5 id: 'article_dspace_community_name_',
... ... @@ -9,6 +11,7 @@ function selectCommunity(element, community_slug) {
9 11 jQuery(hidden_field).insertAfter(element);
10 12 }
11 13  
  14 +
12 15 function selectCollection(element, collection_slug) {
13 16 var hidden_field = jQuery('<input>').attr({
14 17 id: 'article_dspace_collection_name_',
... ... @@ -20,6 +23,10 @@ function selectCollection(element, collection_slug) {
20 23 jQuery(hidden_field).insertAfter(element);
21 24 }
22 25  
  26 +function select_action(field_active) {
  27 +}
  28 +**/
  29 +
23 30 jQuery(document).ready(function() {
24 31 url_base = window.location.protocol + '//' + window.location.host;
25 32 forms = jQuery('form');
... ... @@ -29,4 +36,50 @@ jQuery(document).ready(function() {
29 36 forms[f].action = url_action.replace("/cms/new", "/plugin/dspace/new").replace(url_base,'');
30 37 }
31 38 });
  39 +
  40 + function check_fields(check, table_id) {
  41 + var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']")
  42 + for (var i = 0; i < checkboxes.length; i++) {
  43 + if (checkboxes[i].disabled == false) {
  44 + checkboxes[i].checked = check
  45 + }
  46 + }
  47 + }
  48 +
  49 + function verify_checked(field_id){
  50 + var checkboxes = jQuery("#" + field_id + "_fields_conf tbody tr td input[type='checkbox']")
  51 + var allchecked = true;
  52 + for (var j = 1; j < checkboxes.length; j++) {
  53 + if(!checkboxes[j].checked) {
  54 + allchecked = false;
  55 + break;
  56 + }
  57 + }
  58 +
  59 + var checkbox = jQuery("#" + field_id + "_active");
  60 + checkbox.attr("checked", allchecked);
  61 + }
  62 +
  63 +
  64 + function check_all(field_id) {
  65 + jQuery("#" + field_id + "_active").click(function (){
  66 + check_fields(this.checked, field_id + "_fields_conf")
  67 + });
  68 + verify_checked(field_id);
  69 + }
  70 +
  71 + check_all("community");
  72 + check_all("collection");
  73 +
  74 + jQuery("input[type='checkbox']").click(function () {
  75 + var checkbox = jQuery(this).attr("id").split("_");
  76 + verify_checked(checkbox.first());
  77 +
  78 + if(this.checked == false) {
  79 + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false)
  80 + }
  81 +
  82 + jQuery(this).next().attr("disabled", !this.checked);
  83 + })
  84 +
32 85 });
... ...
plugins/dspace/public/style.css
1 1 #dspace_library ul {
2 2 margin: 0;
3   - padding: 0 0 0 20px;
  3 + padding: 0 0 0 5px;
4 4 }
5 5  
6 6 #dspace_library li {
7   - list-style-image: url(/designs/themes/base/imgs/li-recent.gif);
  7 + /**list-style-image: url(/designs/themes/base/imgs/li-recent.gif);*/
  8 + list-style-type: none;
8 9 }
9 10  
10 11 #dspace_library li.item,
... ... @@ -28,7 +29,7 @@
28 29 }
29 30  
30 31 .dspace_item_section {
31   - margin-left: 20px;
  32 + margin: 15px;
32 33 }
33 34  
34 35 .dspace_item_section_title {
... ...
plugins/dspace/test/test_helper.rb
... ... @@ -1 +0,0 @@
1   -require File.dirname(__FILE__) + '/../../../test/test_helper'
plugins/dspace/test/unit/article.rb
... ... @@ -1,148 +0,0 @@
1   -require File.dirname(__FILE__) + '/../test_helper'
2   -
3   -require 'comment_controller'
4   -# Re-raise errors caught by the controller.
5   -class CommentController; def rescue_action(e) raise e end; end
6   -
7   -class DspaceBlockTest < ActiveSupport::TestCase
8   -
9   - include AuthenticatedTestHelper
10   - fixtures :users, :environments
11   -
12   - def setup
13   - @controller = CommentController.new
14   - @request = ActionController::TestRequest.new
15   - @response = ActionController::TestResponse.new
16   - @profile = create_user('testinguser').person
17   - @environment = @profile.environment
18   - end
19   - attr_reader :profile, :environment
20   -
21   - def enable_vote_plugin
22   - enabled = false
23   - environment=Environment.default
24   - if Noosfero::Plugin.all.include?('VotePlugin')
25   - if not environment.enabled_plugins.include?(:vote)
26   - environment.enable_plugin(Vote)
27   - environment.save!
28   - end
29   - enabled = true
30   - end
31   - enabled
32   - end
33   -
34   - should 'list most commented articles' do
35   - Article.delete_all
36   - a1 = create(TextileArticle, :name => "art 1", :profile_id => profile.id)
37   - a2 = create(TextileArticle, :name => "art 2", :profile_id => profile.id)
38   - a3 = create(TextileArticle, :name => "art 3", :profile_id => profile.id)
39   -
40   - 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a2).save! }
41   - 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a3).save! }
42   -
43   - # should respect the order (more commented comes first)
44   - assert_equal a3.name, profile.articles.most_commented_dspace(Environment.default, 3).first.name
45   - # It is a2 instead of a1 since it does not list articles without comments
46   - assert_equal a2.name, profile.articles.most_commented_dspace(Environment.default, 3).last.name
47   - end
48   -
49   -
50   - should 'find the most voted' do
51   - if not enable_vote_plugin
52   - return
53   - end
54   - article = fast_create(Article, {:name=>'2 votes'})
55   - 2.times{
56   - person = fast_create(Person)
57   - person.vote_for(article)
58   - }
59   - article = fast_create(Article, {:name=>'10 votes'})
60   - 10.times{
61   - person = fast_create(Person)
62   - person.vote_for(article)
63   - }
64   - article = fast_create(Article, {:name=>'5 votes'})
65   - 5.times{
66   - person = fast_create(Person)
67   - person.vote_for(article)
68   - }
69   - articles = Article.most_voted(Environment.default, 5)
70   - assert_equal '10 votes', articles.first.name
71   - assert_equal '2 votes', articles.last.name
72   - end
73   -
74   - should 'list the most postive' do
75   - if not enable_vote_plugin
76   - return
77   - end
78   - article = fast_create(Article, {:name=>'23 votes for 20 votes against'})
79   - 20.times{
80   - person = fast_create(Person)
81   - person.vote_against(article)
82   - }
83   - 23.times{
84   - person = fast_create(Person)
85   - person.vote_for(article)
86   - }
87   - article = fast_create(Article, {:name=>'10 votes for 5 votes against'})
88   - 10.times{
89   - person = fast_create(Person)
90   - person.vote_for(article)
91   - }
92   - 5.times{
93   - person = fast_create(Person)
94   - person.vote_against(article)
95   - }
96   - article = fast_create(Article, {:name=>'2 votes against'})
97   - 2.times{
98   - person = fast_create(Person)
99   - person.vote_against(article)
100   - }
101   -
102   - article = fast_create(Article, {:name=>'7 votes for'})
103   - 7.times{
104   - person = fast_create(Person)
105   - person.vote_for(article)
106   - }
107   - articles = Article.more_positive_votes(Environment.default, 5)
108   - assert_equal '7 votes for', articles.first.name
109   - assert_equal '23 votes for 20 votes against', articles.last.name
110   - end
111   -
112   - should 'list the most negative' do
113   - if not enable_vote_plugin
114   - return
115   - end
116   - article = fast_create(Article, {:name=>'23 votes for 29 votes against'})
117   - 29.times{
118   - person = fast_create(Person)
119   - person.vote_against(article)
120   - }
121   - 23.times{
122   - person = fast_create(Person)
123   - person.vote_for(article)
124   - }
125   - article = fast_create(Article, {:name=>'10 votes for 15 votes against'})
126   - 10.times{
127   - person = fast_create(Person)
128   - person.vote_for(article)
129   - }
130   - 15.times{
131   - person = fast_create(Person)
132   - person.vote_against(article)
133   - }
134   - article = fast_create(Article, {:name=>'2 votes against'})
135   - 2.times{
136   - person = fast_create(Person)
137   - person.vote_against(article)
138   - }
139   - article = fast_create(Article, {:name=>'7 votes for'})
140   - 7.times{
141   - person = fast_create(Person)
142   - person.vote_for(article)
143   - }
144   - articles = Article.more_negative_votes(Environment.default, 5)
145   - assert_equal '23 votes for 29 votes against', articles.first.name
146   - assert_equal '2 votes against', articles.last.name
147   - end
148   -end
149 0 \ No newline at end of file
plugins/dspace/test/unit/dspace_plugin_test.rb
... ... @@ -1,29 +0,0 @@
1   -require File.dirname(__FILE__) + '/../test_helper'
2   -
3   -class DspacePluginTest < ActiveSupport::TestCase
4   -
5   - def setup
6   - @plugin = DspacePlugin.new
7   - end
8   -
9   - should 'be a noosfero plugin' do
10   - assert_kind_of Noosfero::Plugin, @plugin
11   - end
12   -
13   - should 'have name' do
14   - assert_equal 'Relevant Content Plugin', DspacePlugin.plugin_name
15   - end
16   -
17   - should 'have description' do
18   - assert_equal _("A plugin that lists the most accessed, most commented, most liked and most disliked contents."), DspacePlugin.plugin_description
19   - end
20   -
21   - should 'have stylesheet' do
22   - assert @plugin.stylesheet?
23   - end
24   -
25   - should "return DspaceBlock in extra_blocks class method" do
26   - assert DspacePlugin.extra_blocks.keys.include?(DspacePlugin::DspaceBlock)
27   - end
28   -
29   -end
plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
... ... @@ -10,10 +10,14 @@
10 10  
11 11 <% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %>
12 12  
13   -<table border="0" style="border-bottom: 1px solid #c0c0c0;">
14   - <tr style="background-color: #f0f0f0; border-bottom: 1px solid #c0c0c0;">
15   - <th style="border-bottom: none;">&nbsp;</th>
16   - <th style="border-bottom: none;" align="left"><%= _('Collection name') %></th>
  13 +<table id="collection_fields_conf" border="0" style="border-bottom: 1px solid #c0c0c0;">
  14 + <tr style="background-color: #f0f0f0; border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;">
  15 + <td style="font-style: italic">
  16 + <%= _("Check/Uncheck All Unlocked")%>
  17 + </td>
  18 + <td align="center">
  19 + <input type="checkbox" id="collection_active" />
  20 + </td>
17 21 </tr>
18 22  
19 23 <% 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 @@
21 25 <% collections.each do |collection| %>
22 26  
23 27 <tr>
24   - <% if dspace_collections_ids.include? collection[1] %>
25   - <td align="center"><%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> </td>
26   - <% else %>
27   - <td align="center"><%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> </td>
28   - <% end %>
29 28 <td>
30 29 <%= collection[0] %>
31 30 </td>
  31 +
  32 + <% if dspace_collections_ids.include? collection[1] %>
  33 + <td align="center">
  34 + <%= check_box_tag "article[dspace_collections][][id]", collection[1], true, :disabled => 'disabled', :id => "collection_id_#{collection[1]}" %>
  35 + <%= hidden_field_tag "article[dspace_collections][][name]", collection[0], :disabled => 'disabled' %>
  36 + </td>
  37 + <% else %>
  38 + <td align="center">
  39 + <%= check_box_tag "article[dspace_collections][][id]", collection[1], false, :id => "collection_id_#{collection[1]}" %>
  40 + <%= hidden_field_tag "article[dspace_collections][][name]", collection[0], :disabled => 'disabled', :id => "collection_name_#{collection[1]}" %>
  41 + </td>
  42 + <% end %>
  43 +
32 44 </tr>
33 45  
34 46 <% end %>
... ...
plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb
... ... @@ -6,10 +6,14 @@
6 6  
7 7 <% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %>
8 8  
9   -<table border="0" style="border-bottom: 1px solid #c0c0c0;">
10   - <tr style="background-color: #f0f0f0; border-bottom: 1px solid #c0c0c0;">
11   - <th style="border-bottom: none;">&nbsp;</th>
12   - <th style="border-bottom: none;" align="left"><%= _('Community name') %></th>
  9 +<table id="community_fields_conf" border="0" style="border-bottom: 1px solid #c0c0c0;">
  10 + <tr style="background-color: #f0f0f0; border-top: 1px solid #c0c0c0; border-bottom: 1px solid #c0c0c0;">
  11 + <td style="font-style: italic">
  12 + <%= _("Check/Uncheck All Unlocked")%>
  13 + </td>
  14 + <td align="center">
  15 + <input type="checkbox" id="community_active" />
  16 + </td>
13 17 </tr>
14 18  
15 19 <% 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 @@
17 21 <% communities.each do |community| %>
18 22  
19 23 <tr>
20   - <% if dspace_communities_ids.include? community[1] %>
21   - <td align="center"><%= check_box_tag "article[dspace_communities_ids][]", community[1], true, :disabled => 'disabled', :onclick => "selectCommunity(this,'#{community[0]}')" %> </td>
22   - <% else %>
23   - <td align="center"><%= check_box_tag "article[dspace_communities_ids][]", community[1], false, :onclick => "selectCommunity(this,'#{community[0]}')" %> </td>
24   - <% end %>
25 24 <td>
26 25 <%= community[0] %>
27 26 </td>
  27 +
  28 + <% if dspace_communities_ids.include? community[1] %>
  29 + <td align="center">
  30 + <%= check_box_tag "article[dspace_communities][][id]", community[1], true, :disabled => 'disabled', :id => "community_id_#{community[1]}" %>
  31 + <%= hidden_field_tag "article[dspace_communities][][name]", community[0], :disabled => 'disabled' %>
  32 + </td>
  33 + <% else %>
  34 + <td align="center">
  35 + <%= check_box_tag "article[dspace_communities][][id]", community[1], false, :id => "community_id_#{community[1]}" %>
  36 + <%= hidden_field_tag "article[dspace_communities][][name]", community[0], :disabled => 'disabled', :id => "community_name_#{community[1]}" %>
  37 + </td>
  38 + <% end %>
  39 +
28 40 </tr>
29 41  
30 42 <% end %>
... ...
plugins/dspace/views/cms/dspace_plugin/_item.html.erb
... ... @@ -1,23 +0,0 @@
1   -<h1><%= _('DSpace Item') %></h1>
2   -
3   -<%= required_fields_message %>
4   -
5   -<%= required f.text_field('name', :size => '64', :maxlength => 150) %>
6   -
7   -<%= hidden_field_tag 'article[parent_id]', @article.parent_id %>
8   -
9   -<% dspace_client = Dspace::Client.new('') %>
10   -
11   -<% collections = dspace_client.get_collections %>
12   -
13   -<%
14   -collections_2 = collections.map { |collection|
15   - item = [_(collection.name), collection.id]
16   -}
17   -%>
18   -
19   -<%= labelled_form_field(_('Collections:'),
20   - select(:article,
21   - :dspace_collection_id,
22   - options_for_select_with_title(collections_2))) %>
23   -
plugins/dspace/views/cms/dspace_plugin/_library.html.erb
1   -<%= error_messages_for 'library' %>
2   -
3   -<h1><%= _('My Library') %></h1>
  1 +<h1><%= _('My DSpace Library') %></h1>
4 2  
5 3 <%= render :file => 'shared/tiny_mce' %>
6 4  
... ... @@ -10,61 +8,4 @@
10 8  
11 9 <%= render :partial => 'general_fields' %>
12 10  
13   -<script type="text/javascript">
14   - function submit_button(index) {
15   - return $("article_slug").form.select("input.submit")[index];
16   - }
17   - function warn_value_change() {
18   - show_warning('article-formitem', "slug-change-confirmation");
19   - disable_button(submit_button(0));
20   - disable_button(submit_button(1));
21   - }
22   - function confirm_change() {
23   - enable_button(submit_button(0));
24   - enable_button(submit_button(1));
25   - hide_warning('slug-change-confirmation');
26   - }
27   - function no_change() {
28   - $("article_slug").value = $("old_article_slug").value;
29   - enable_button(submit_button(0));
30   - enable_button(submit_button(1));
31   - hide_warning('slug-change-confirmation');
32   - }
33   -</script>
34   -
35   -<%= hidden_field_tag 'old_article_slug', @article.slug %>
36   -<div id="article-formitem">
37   - <%= labelled_form_field( _('Address'),
38   - content_tag('code',
39   - url_for(@article.url).gsub(/#{@article.slug}$/, '') +
40   - text_field(:article, :slug, :onchange => "warn_value_change()", :size => 25)
41   - ) +
42   - content_tag('div',
43   - content_tag('strong', _('WARNING!')) + '&nbsp;' +
44   - _("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?") +
45   - content_tag('div',
46   - button_to_function(:ok, _("Yes"), "confirm_change()") + ' ' +
47   - button_to_function(:cancel, _('No'), 'no_change()')
48   - ),
49   - :id => 'slug-change-confirmation',
50   - :class => 'change-confirmation',
51   - :style => 'display: none;'
52   - )
53   - )
54   - %>
55   -</div>
56   -
57   -<%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 10)) %>
58   -
59   -<%= f.fields_for :image_builder, @article.image do |i| %>
60   - <%= file_field_or_thumbnail(_('Cover image:'), @article.image, i)%>
61   - <%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %>
62   -<% end %>
63   -
64   -<% unless @article.image.nil? %>
65   - <%= labelled_check_box(_('Remove cover image'),'remove_image',true,false)%>
66   -<% end %>
67   -
68   -<%= labelled_form_field(_('Show catalog as:'), f.select(:visualization_format, [ [ _('Listing with thumbnail'), 'full'], [ _('Listing without thumbnail'), 'short'], [ _('Type catalog'), 'catalog'] ])) %>
69   -
70   -<%= labelled_form_field(_('Items per page:'), f.select(:posts_per_page, Blog.posts_per_page_options)) %>
  11 +<%= labelled_form_field(_('Description:'), text_area(:article, :body, :cols => 68, :rows => 10)) %>
... ...
plugins/dspace/views/content_viewer/_collection_item.html.erb
... ... @@ -1,3 +0,0 @@
1   -<li class="collection">
2   - <span class="title"><%= link_to collection_item.title, :controller => 'content_viewer', :action => 'view_page', :page => collection_item.path %></span>
3   -</li>
plugins/dspace/views/content_viewer/_community.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<li class="community">
  2 + <span class="title"><%= link_to community.title, :controller => 'content_viewer', :action => 'view_page', :page => community.path %></span>
  3 +</li>
... ...
plugins/dspace/views/content_viewer/_community_item.html.erb
... ... @@ -1,3 +0,0 @@
1   -<li class="community">
2   - <span class="title"><%= link_to community_item.title, :controller => 'content_viewer', :action => 'view_page', :page => community_item.path %></span>
3   -</li>
plugins/dspace/views/content_viewer/_item.html.erb
1 1 <li class="item">
2   - <span class="name"><%= link_to item.name, :controller => 'dspace_plugin', :action => 'view_item', :id => item.id, :collection_id => @page.id %></span><br />
3   - <span class="authors"><%= item.author %></span> <span class="date_issued">(<%= item.issue_date %>)</span>
  2 + <div>
  3 +
  4 + <% if item.files.first.mimetype == 'application/pdf' %>
  5 + <img src="/plugins/dspace/icons/pdf.png" style="display: inline-block;"/>
  6 + <% else %>
  7 + <img src="/plugins/dspace/icons/text.png" style="display: inline-block;"/>
  8 + <% end %>
  9 +
  10 + <div style="display: inline-block; width: 92%;">
  11 + <span class="name"><%= link_to item.name, :controller => 'dspace_plugin', :action => 'view_item', :id => item.id, :collection_id => @page.id %></span><br />
  12 + <span class="authors"><%= item.author %></span> <span class="date_issued">(<%= item.issue_date %>)</span>
  13 + </div>
  14 +
  15 + </div>
4 16 </li>
... ...
plugins/dspace/views/content_viewer/collection.html.erb
... ... @@ -1,10 +0,0 @@
1   -<% collection_id = dspace_collection.dspace_collection_id %>
2   -<% dspace_server = dspace_collection.parent.parent.dspace_server_url %>
3   -
4   -<div id="dspace_library">
5   - <div id="dspace_collection">
6   - <ul id="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/community.html.erb
... ... @@ -1,24 +0,0 @@
1   -<% community_id = dspace_community.dspace_community_id %>
2   -<% dspace_server = dspace_community.parent.dspace_server_url %>
3   -
4   -<div id="dspace_library">
5   -
6   - <% if dspace_community.allow_create?(user) %>
7   -
8   - <div id="actions">
9   - <%= 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 %>
10   - <%= _("Add a %s") % DspacePlugin::Collection.short_description %>
11   - <% end %>
12   - </div>
13   -
14   - <% end %>
15   -
16   - <% collections = dspace_community.collections dspace_server, community_id %>
17   -
18   - <div id="dspace_community">
19   - <ul id="collection_list">
20   - <%= render :partial => 'collection', :collection => collections %>
21   - </ul>
22   - </div>
23   -
24   -</div>
plugins/dspace/views/content_viewer/dspace_content.html.erb 0 → 100644
... ... @@ -0,0 +1,59 @@
  1 +<div id="dspace_library">
  2 +
  3 + <% if dspace_content.allow_create?(user) %>
  4 +
  5 + <div id="actions">
  6 +
  7 + <% if dspace_content.is_a? DspacePlugin::Library %>
  8 +
  9 + <%= 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 %>
  10 + <%= _("Add %s") % DspacePlugin::Communityy.short_description %>
  11 + <% end %>
  12 +
  13 + <% elsif dspace_content.is_a? DspacePlugin::Communityy %>
  14 +
  15 + <%= 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 %>
  16 + <%= _("Add %s") % DspacePlugin::Collection.short_description %>
  17 + <% end %>
  18 +
  19 + <% end %>
  20 +
  21 + </div>
  22 +
  23 + <% end %>
  24 +
  25 + <% if dspace_content.is_a? DspacePlugin::Library %>
  26 +
  27 + <% communities = dspace_content.communities %>
  28 +
  29 + <ul id="communities_list">
  30 + <%= render :partial => 'community', :collection => communities %>
  31 + </ul>
  32 +
  33 + <% elsif dspace_content.is_a? DspacePlugin::Communityy %>
  34 +
  35 + <% community_id = dspace_content.dspace_community_id %>
  36 + <% dspace_server = dspace_content.parent.dspace_server_url %>
  37 +
  38 + <% collections = dspace_content.collections dspace_server, community_id %>
  39 +
  40 + <ul id="collections_list">
  41 + <%= render :partial => 'collection', :collection => collections %>
  42 + </ul>
  43 +
  44 + <% elsif dspace_content.is_a? DspacePlugin::Collection %>
  45 +
  46 + <% collection_id = dspace_content.dspace_collection_id %>
  47 + <% dspace_server = dspace_content.parent.parent.dspace_server_url %>
  48 +
  49 + <div id="dspace_library">
  50 + <div id="dspace_collection">
  51 + <ul id="items_list">
  52 + <%= render :partial => 'item', :collection => dspace_content.items(dspace_server, collection_id) %>
  53 + </ul>
  54 + </div>
  55 + </div>
  56 +
  57 + <% end %>
  58 +
  59 +</div>
... ...
plugins/dspace/views/content_viewer/library.html.erb
... ... @@ -1,19 +0,0 @@
1   -<div id="dspace_library">
2   -
3   - <% if dspace_library.allow_create?(user) %>
4   -
5   - <div id="actions">
6   - <%= 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 %>
7   - <%= _("Add a %s") % DspacePlugin::Communityy.short_description %>
8   - <% end %>
9   - </div>
10   -
11   - <% end %>
12   -
13   - <% communities = dspace_library.communities %>
14   -
15   - <ul id="sortable" class="communities_list">
16   - <%= render :partial => 'community_item', :collection => communities %>
17   - </ul>
18   -
19   -</div>
plugins/dspace/views/dspace_plugin/_item_file.html.erb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +<li>
  2 + <ul class="item_file_attributes_list">
  3 + <li>
  4 + <span><%= _('File:') %></span> <%= link_to item_file.name, dspace_server_url + item_file.retrieve_link, :target => '_blank' %></li>
  5 + <% unless item_file.description.blank? %>
  6 + <li>
  7 + <span><%= _('Description:') %> </span> <%= item_file.description %></li>
  8 + <% end %>
  9 + <li>
  10 + <span><%= _('Size:') %> </span> <%= number_to_human_size( item_file.size_bytes ) %></li>
  11 + </ul>
  12 +</li>
... ...
plugins/dspace/views/dspace_plugin/_item_section.html.erb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +<div class="dspace_item_section">
  2 + <div class="dspace_item_section_title">
  3 + <%= item_section[:title] %>
  4 + </div>
  5 + <div class="dspace_item_section_content">
  6 + <%= item_section[:content] %>
  7 + </div>
  8 +</div>
... ...
plugins/dspace/views/dspace_plugin/view_item.html.erb
1   -<% dspace_server_url = @collection.parent.parent.dspace_server_url %>
2   -
3   -<% if dspace_server_url =~ /\/$/ %>
4   - <% dspace_server_url.gsub!(/\/$/,'') %>
5   -<% end %>
  1 +<% extend DspacePlugin::ItemHelper %>
6 2  
7 3 <div id="article-parent">
8 4 <%= button(:back, _('Go back to %s') % @collection.short_title, @collection.url) %>
... ... @@ -11,58 +7,22 @@
11 7 <div id="dspace_library_item">
12 8  
13 9 <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' %>
  10 + <h1 class="title"><%= @item.name %></h1>
22 11 </div>
23 12  
24   - <br />
  13 + <% item_files = render :partial => 'item_file',
  14 + :locals => { :dspace_server_url => remove_slash_at_end_url(@collection.parent.parent.dspace_server_url) },
  15 + :collection => @item.files %>
25 16  
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>
  17 + <% item_files_content = content_tag('ul', item_files, :id => 'item_files_list') %>
36 18  
37   - <br />
38 19  
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>
  20 + <%= render :partial => 'item_section',
  21 + :collection => [ { :title => _('Authors:'), :content => @item.author },
  22 + { :title => _('Issue date:'), :content => @item.issue_date },
  23 + { :title => _('Abstract:'), :content => @item.abstract },
  24 + { :title => _('Description:'), :content => @item.description },
  25 + { :title => _('URI:'), :content => link_to(@item.uri, @item.uri, :target => '_blank') },
  26 + { :title => _('Files in this item'), :content => item_files_content } ] %>
43 27  
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>
  28 +</div>
... ...
plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_collection.html.erb
... ... @@ -1,38 +0,0 @@
1   -<h1><%= _('DSpace Collections') %></h1>
2   -
3   -<%= hidden_field_tag 'article[parent_id]', @article.parent_id %>
4   -
5   -<%= hidden_field_tag 'article[dspace_community_id]', @article.parent.dspace_community_id %>
6   -
7   -<% dspace_server_url = @article.parent.parent.dspace_server_url %>
8   -
9   -<% community_id = @article.parent.dspace_community_id %>
10   -
11   -<% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %>
12   -
13   -<table border="0" style="border-bottom: 1px solid #c0c0c0;">
14   - <tr style="background-color: #f0f0f0; border-bottom: 1px solid #c0c0c0;">
15   - <th style="border-bottom: none;">&nbsp;</th>
16   - <th style="border-bottom: none;" align="left"><%= _('Collection name') %></th>
17   - </tr>
18   -
19   - <% dspace_collections_ids = DspacePlugin::Collection.find(:all, :conditions => { :parent_id => @article.parent_id}).map { |collection| ids = collection.dspace_collection_id.to_i } %>
20   -
21   - <% collections.each do |collection| %>
22   -
23   - <tr>
24   - <% if dspace_collections_ids.include? collection[1] %>
25   - <td align="center"><%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> </td>
26   - <% else %>
27   - <td align="center"><%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> </td>
28   - <% end %>
29   - <td>
30   - <%= collection[0] %>
31   - </td>
32   - </tr>
33   -
34   - <% end %>
35   -
36   -</table>
37   -
38   -<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %>
plugins/dspace/views/dspace_plugin_myprofile/dspace_plugin/_communityy.html.erb
... ... @@ -1,34 +0,0 @@
1   -<h1><%= _('DSpace Communities') %></h1>
2   -
3   -<%= hidden_field_tag 'article[parent_id]', @article.parent_id %>
4   -
5   -<% dspace_server_url = @article.parent.dspace_server_url %>
6   -
7   -<% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %>
8   -
9   -<table border="0" style="border-bottom: 1px solid #c0c0c0;">
10   - <tr style="background-color: #f0f0f0; border-bottom: 1px solid #c0c0c0;">
11   - <th style="border-bottom: none;">&nbsp;</th>
12   - <th style="border-bottom: none;" align="left"><%= _('Community name') %></th>
13   - </tr>
14   -
15   - <% dspace_communities_ids = DspacePlugin::Communityy.find(:all, :conditions => { :parent_id => @article.parent_id }).map { |community| ids = community.dspace_community_id.to_i } %>
16   -
17   - <% communities.each do |community| %>
18   -
19   - <tr>
20   - <% if dspace_communities_ids.include? community[1] %>
21   - <td align="center"><%= check_box_tag "article[dspace_communities_ids][]", community[1], true, :disabled => 'disabled', :onclick => "selectCommunity(this,'#{community[0]}')" %> </td>
22   - <% else %>
23   - <td align="center"><%= check_box_tag "article[dspace_communities_ids][]", community[1], false, :onclick => "selectCommunity(this,'#{community[0]}')" %> </td>
24   - <% end %>
25   - <td>
26   - <%= community[0] %>
27   - </td>
28   - </tr>
29   -
30   - <% end %>
31   -
32   -</table>
33   -
34   -<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %>
plugins/dspace/views/dspace_plugin_myprofile/edit.html.erb
... ... @@ -1,42 +0,0 @@
1   -<%= error_messages_for 'article' %>
2   -
3   -<div class='<%= (environment.enabled?('media_panel') ? 'with_media_panel' : 'no_media_panel') %>'>
4   -
5   -<%= labelled_form_for 'article', :url => {action: "new_dspace_content"}, :html => { :multipart => true, :class => @type } do |f| %>
6   -
7   - <%= hidden_field_tag("type", @type) if @type %>
8   -
9   - <%= hidden_field_tag('parent_id', @parent_id) if @parent_id %>
10   -
11   - <%= hidden_field_tag('back_to', @back_to) %>
12   -
13   - <%= hidden_field_tag('success_back_to', @success_back_to) %>
14   -
15   - <%= render :partial => partial_for_class(@article.class), :locals => { :f => f } %>
16   -
17   - <% button_bar do %>
18   - <%= submit_button :save, _('Save') %>
19   -
20   - <% if @back_to %>
21   - <%= button :cancel, _('Cancel'), @back_to %>
22   - <% elsif @parent_id || @article.parent %>
23   - <%= button :cancel, _('Cancel'), :action => 'view', :id => @parent_id || @article.parent %>
24   - <% else %>
25   - <%= button :cancel, _('Cancel'), :action => 'index' %>
26   - <% end %>
27   -
28   - <% unless @article.new_record? %>
29   - <%= button :delete, _('Delete'), {:controller => :cms, :action => :destroy, :id => @article},
30   - :method => :post, :confirm => delete_article_message(@article) %>
31   - <% end %>
32   - <% end %>
33   -<% end %>
34   -</div>
35   -
36   -<% if environment.enabled?('media_panel') && [TinyMceArticle, TextileArticle, Event, EnterpriseHomepage].any?{|klass| @article.kind_of?(klass)} %>
37   - <%= render :partial => 'text_editor_sidebar' %>
38   -<% end %>
39   -
40   -<br style='clear: both'/>
41   -
42   -<%= javascript_include_tag "article.js" %>