Commit 84a50fe97684117607766b87cb36b5619080458d

Authored by Victor Costa
2 parents 5c4a31aa f01caac4

Merge branch 'virtuoso_integration' into stable

plugins/virtuoso/lib/virtuoso_plugin/triples_template.rb
@@ -28,7 +28,7 @@ class VirtuosoPlugin::TriplesTemplate < Article @@ -28,7 +28,7 @@ class VirtuosoPlugin::TriplesTemplate < Article
28 def to_html(options = {}) 28 def to_html(options = {})
29 article = self 29 article = self
30 proc do 30 proc do
31 - render :file => 'content_viewer/triples_template', :locals => {:article => article} 31 + render :file => 'content_viewer/triples_template', :locals => {:article => article, :page => params[:npage]}
32 end 32 end
33 end 33 end
34 34
@@ -36,11 +36,17 @@ class VirtuosoPlugin::TriplesTemplate < Article @@ -36,11 +36,17 @@ class VirtuosoPlugin::TriplesTemplate < Article
36 @plugin ||= VirtuosoPlugin.new(self) 36 @plugin ||= VirtuosoPlugin.new(self)
37 end 37 end
38 38
  39 + attr_reader :results
  40 +
39 def template_content(page=1) 41 def template_content(page=1)
40 begin 42 begin
41 - results = plugin.virtuoso_readonly_client.query(query).paginate({:per_page => per_page, :page => page}) 43 + @results ||= plugin.virtuoso_readonly_client.query(query).paginate({:per_page => per_page, :page => page})
42 liquid_template = Liquid::Template.parse(template) 44 liquid_template = Liquid::Template.parse(template)
43 - rendered_template = liquid_template.render('results' => results) 45 + rendered_template = liquid_template.render('results' => results,
  46 + 'total_pages' => results.total_pages,
  47 + 'current_page' => results.current_page,
  48 + 'per_page' => results.per_page,
  49 + 'total_entries' => results.total_entries)
44 transform_html(rendered_template) 50 transform_html(rendered_template)
45 rescue => ex 51 rescue => ex
46 logger.info ex.to_s 52 logger.info ex.to_s
plugins/virtuoso/test/unit/dspace_harvest_test.rb
@@ -7,7 +7,7 @@ class DspaceHarvestTest < ActiveSupport::TestCase @@ -7,7 +7,7 @@ class DspaceHarvestTest < ActiveSupport::TestCase
7 end 7 end
8 8
9 attr_reader :environment 9 attr_reader :environment
10 - 10 +
11 def mock_settings 11 def mock_settings
12 { :virtuoso_uri=>"http://virtuoso.noosfero.com", 12 { :virtuoso_uri=>"http://virtuoso.noosfero.com",
13 :virtuoso_username=>"username", 13 :virtuoso_username=>"username",
@@ -20,44 +20,44 @@ class DspaceHarvestTest < ActiveSupport::TestCase @@ -20,44 +20,44 @@ class DspaceHarvestTest < ActiveSupport::TestCase
20 {"dspace_uri"=>"http://dspace3.noosfero.com"} 20 {"dspace_uri"=>"http://dspace3.noosfero.com"}
21 ] 21 ]
22 } 22 }
23 - end 23 + end
24 24
25 should 'create delayed job when start' do 25 should 'create delayed job when start' do
26 - harvest = VirtuosoPlugin::DspaceHarvest.new(environment) 26 + harvest = VirtuosoPlugin::DspaceHarvest.new(environment, "http://dspace1.noosfero.com")
27 assert !harvest.find_job.present? 27 assert !harvest.find_job.present?
28 harvest.start 28 harvest.start
29 assert harvest.find_job.present? 29 assert harvest.find_job.present?
30 end 30 end
31 31
32 should 'not duplicate harvest job' do 32 should 'not duplicate harvest job' do
33 - harvest = VirtuosoPlugin::DspaceHarvest.new(environment) 33 + harvest = VirtuosoPlugin::DspaceHarvest.new(environment, "http://dspace1.noosfero.com")
34 assert_difference "harvest.find_job.count", 1 do 34 assert_difference "harvest.find_job.count", 1 do
35 5.times { harvest.start } 35 5.times { harvest.start }
36 end 36 end
37 end 37 end
38 - 38 +
39 should 'harvest all dspaces from start' do 39 should 'harvest all dspaces from start' do
40 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true) 40 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true)
41 end 41 end
42 - 42 +
43 should 'try to harvest all dspaces from start without any setting' do 43 should 'try to harvest all dspaces from start without any setting' do
44 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true) 44 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true)
45 end 45 end
46 - 46 +
47 should 'try to harvest all dspaces from start with mock configuration' do 47 should 'try to harvest all dspaces from start with mock configuration' do
48 @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, mock_settings) 48 @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, mock_settings)
49 @settings.save! 49 @settings.save!
50 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true) 50 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true)
51 end 51 end
52 - 52 +
53 should 'try to harvest all dspaces without any setting' do 53 should 'try to harvest all dspaces without any setting' do
54 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, false) 54 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, false)
55 end 55 end
56 - 56 +
57 should 'try to harvest all dspaces with mock configuration' do 57 should 'try to harvest all dspaces with mock configuration' do
58 @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, mock_settings) 58 @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, mock_settings)
59 @settings.save! 59 @settings.save!
60 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, false) 60 VirtuosoPlugin::DspaceHarvest.harvest_all(environment, false)
61 - end 61 + end
62 62
63 end 63 end
plugins/virtuoso/views/content_viewer/triples_template.html.erb
@@ -3,5 +3,7 @@ @@ -3,5 +3,7 @@
3 </div> 3 </div>
4 4
5 <div class="results"> 5 <div class="results">
6 - <%= article.template_content %> 6 + <%= article.template_content(page) %>
7 </div> 7 </div>
  8 +
  9 +<%= will_paginate(article.results, :param_name => 'npage')%>