Commit af2f1d06a89cd7382be6c8a19896364bc12fddf7
1 parent
61c35502
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
dspace_plugin : refactoring navigation
Showing
11 changed files
with
34 additions
and
64 deletions
Show diff stats
plugins/dspace/lib/dspace/resource.rb
1 | 1 | class Dspace::Resource < ActiveResource::Base |
2 | 2 | |
3 | - %w(site).each do |attr| | |
4 | - define_method(attr) do | |
5 | - Thread.current["#{name}.active_resource.#{attr}"] | |
6 | - end | |
7 | - | |
8 | - if attr.eql?('site') | |
9 | - define_method("#{attr}=") do |site| | |
10 | - @connection = nil | |
11 | - site_uri = "http://localhost:8080/rest/" | |
12 | - Thread.current["#{name}.active_resource.site"] = site_uri | |
13 | - end | |
14 | - end | |
15 | - end | |
16 | - | |
17 | 3 | class << self |
18 | 4 | def element_path(id, prefix_options = {}, query_options = nil) |
19 | 5 | prefix_options, query_options = split_options(prefix_options) if query_options.nil? | ... | ... |
plugins/dspace/lib/dspace_plugin.rb
... | ... | @@ -17,6 +17,8 @@ class DspacePlugin < Noosfero::Plugin |
17 | 17 | if parent.kind_of?(DspacePlugin::Library) |
18 | 18 | types << DspacePlugin::Collection |
19 | 19 | types << DspacePlugin::Communityy |
20 | + elsif parent.kind_of?(DspacePlugin::Communityy) | |
21 | + types << DspacePlugin::Collection | |
20 | 22 | end |
21 | 23 | types |
22 | 24 | else | ... | ... |
plugins/dspace/lib/dspace_plugin/collection.rb
1 | 1 | class DspacePlugin::Collection < Article |
2 | 2 | |
3 | 3 | settings_items :dspace_collection_id, :type => :string |
4 | + settings_items :dspace_community_id, :type => :integer | |
4 | 5 | |
5 | - attr_accessible :dspace_collection_id | |
6 | + attr_accessible :dspace_collection_id, :dspace_community_id | |
6 | 7 | |
7 | 8 | def self.icon_name(article = nil) |
8 | 9 | 'dspace' | ... | ... |
plugins/dspace/lib/dspace_plugin/communityy.rb
plugins/dspace/lib/dspace_plugin/library.rb
1 | 1 | class DspacePlugin::Library < Blog |
2 | 2 | |
3 | 3 | settings_items :dspace_server_url, :type => :string |
4 | - settings_items :gather_option, :type => :string, :default => "collections" | |
5 | 4 | |
6 | - attr_accessible :dspace_server_url, :gather_option | |
5 | + attr_accessible :dspace_server_url | |
7 | 6 | |
8 | 7 | def dspace_server_url_valid |
9 | 8 | errors.add(self.dspace_server_url, _("is not a valid URL. Please correct it and resubmit.")) unless url_valid?(self.dspace_server_url) |
... | ... | @@ -34,10 +33,6 @@ class DspacePlugin::Library < Blog |
34 | 33 | DspacePlugin::Communityy.find(:all) |
35 | 34 | end |
36 | 35 | |
37 | - def collections | |
38 | - DspacePlugin::Collection.find(:all) | |
39 | - end | |
40 | - | |
41 | 36 | protected |
42 | 37 | |
43 | 38 | def url_valid?(url) | ... | ... |
plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
... | ... | @@ -6,11 +6,15 @@ |
6 | 6 | |
7 | 7 | <%= hidden_field_tag 'article[parent_id]', @article.parent_id %> |
8 | 8 | |
9 | -<% dspace_server_url = @article.parent.dspace_server_url %> | |
9 | +<%= hidden_field_tag 'article[dspace_community_id]', @article.parent.dspace_community_id %> | |
10 | 10 | |
11 | -<% dspace_client = Dspace::Client.new(dspace_server_url) %> | |
11 | +<% dspace_server_url = @article.parent.parent.dspace_server_url %> | |
12 | 12 | |
13 | -<% collections = dspace_client.get_collections.map { |collection| item = [_(collection.name), collection.id] } %> | |
13 | +<% community_id = @article.parent.dspace_community_id %> | |
14 | + | |
15 | +<% #dspace_client = Dspace::Client.new(dspace_server_url) %> | |
16 | + | |
17 | +<% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %> | |
14 | 18 | |
15 | 19 | <%= labelled_form_field(_('Collections:'), |
16 | 20 | select(:article, | ... | ... |
plugins/dspace/views/cms/dspace_plugin/_library.html.erb
... | ... | @@ -6,6 +6,8 @@ |
6 | 6 | |
7 | 7 | <%= required f.text_field(:name, :size => '64', :maxlength => 150, :onchange => "updateUrlField(this, 'article_slug')") %> |
8 | 8 | |
9 | +<%= required f.text_field(:dspace_server_url, :size => '150', :maxlength => 150) %> | |
10 | + | |
9 | 11 | <%= render :partial => 'general_fields' %> |
10 | 12 | |
11 | 13 | <script type="text/javascript"> |
... | ... | @@ -66,10 +68,3 @@ |
66 | 68 | <%= labelled_form_field(_('Show catalog as:'), f.select(:visualization_format, [ [ _('Listing with thumbnail'), 'full'], [ _('Listing without thumbnail'), 'short'], [ _('Type catalog'), 'catalog'] ])) %> |
67 | 69 | |
68 | 70 | <%= labelled_form_field(_('Items per page:'), f.select(:posts_per_page, Blog.posts_per_page_options)) %> |
69 | - | |
70 | -<%= required f.text_field(:dspace_server_url, :size => '150', :maxlength => 150) %> | |
71 | - | |
72 | -<%= content_tag( 'div', radio_button( :article, :gather_option, 'collections' ) + content_tag('label', _('Get collections'), :for => 'article_get_collections')) %> | |
73 | - | |
74 | -<%= content_tag( 'div', radio_button( :article, :gather_option, 'communities' ) + content_tag('label', _('Get communities'), :for => 'article_get_collections')) %> | |
75 | - | ... | ... |
plugins/dspace/views/content_viewer/_collection.html.erb
plugins/dspace/views/content_viewer/collection.html.erb
plugins/dspace/views/content_viewer/community.html.erb
... | ... | @@ -2,9 +2,24 @@ |
2 | 2 | <% dspace_server = dspace_community.parent.dspace_server_url %> |
3 | 3 | |
4 | 4 | <div id="dspace_library"> |
5 | + | |
6 | + <% if true %> | |
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 %s") % DspacePlugin::Collection.short_description %> | |
11 | + <% end %> | |
12 | + </div> | |
13 | + | |
14 | + <% end %> | |
15 | + | |
16 | + <% collections = dspace_community.collections dspace_server, community_id %> | |
17 | + | |
5 | 18 | <div id="dspace_community"> |
6 | 19 | <ul id="collection_list"> |
7 | - <%= render :partial => 'collection', :collection => dspace_community.collections(dspace_server, community_id) %> | |
20 | + <%= render :partial => 'collection', :collection => collections %> | |
8 | 21 | </ul> |
9 | 22 | </div> |
23 | + | |
10 | 24 | </div> |
25 | + | ... | ... |
plugins/dspace/views/content_viewer/library.html.erb
1 | 1 | <div id="dspace_library"> |
2 | 2 | |
3 | - <%= content_tag 'div', dspace_library.body %> | |
4 | - | |
5 | - <% if dspace_library.gather_option == "communities" %> | |
6 | - | |
7 | 3 | <% if true %> |
8 | 4 | |
9 | 5 | <div id="actions"> |
10 | 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 %> |
11 | - <%= _("New %s") % DspacePlugin::Communityy.short_description %> | |
7 | + <%= _("Add %s") % DspacePlugin::Communityy.short_description %> | |
12 | 8 | <% end %> |
13 | 9 | </div> |
14 | 10 | |
... | ... | @@ -20,28 +16,4 @@ |
20 | 16 | <%= render :partial => 'community_item', :collection => communities %> |
21 | 17 | </ul> |
22 | 18 | |
23 | - <% end %> | |
24 | - | |
25 | - <% if dspace_library.gather_option == "collections" %> | |
26 | - | |
27 | - <% if true %> | |
28 | - | |
29 | - <div id="actions"> | |
30 | - <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_library.id}), :class => 'button with-text icon-add') do %> | |
31 | - <%= _("New %s") % DspacePlugin::Collection.short_description %> | |
32 | - <% end %> | |
33 | - </div> | |
34 | - | |
35 | - <% end %> | |
36 | - | |
37 | - <% collections = dspace_library.collections %> | |
38 | - | |
39 | - <% unless collections.blank? %> | |
40 | - <ul id="collections_list" class="collections_list"> | |
41 | - <%= render :partial => 'collection_item', :collection => collections %> | |
42 | - </ul> | |
43 | - <% end %> | |
44 | - | |
45 | - <% end %> | |
46 | - | |
47 | 19 | </div> | ... | ... |