From 2fb52e758001899f83431960ab228ef013e36b2d Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 3 Jun 2013 17:45:19 +0200 Subject: head request now ignores modified entry --- lib/4store.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/4store.rb b/lib/4store.rb index 77fa045..fddc785 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -16,7 +16,7 @@ module OpenTox end def self.head uri - sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {<#{uri}> <#{RDF::DC.modified}> ?o.} }" + sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {<#{uri}> ?p ?o.} }" rdf = query sparql, 'application/sparql-results+xml' resource_not_found_error "#{uri} not found." unless rdf.match("#{uri}") rdf -- cgit v1.2.3 From ff7fb1ec3739903cb4229a30f175cab532225fae Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 5 Jun 2013 11:56:15 +0200 Subject: fixed dataset representation for html requests --- lib/4store.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/4store.rb b/lib/4store.rb index fddc785..578ce13 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -97,12 +97,12 @@ module OpenTox prefixes = {:rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"} ['OT', 'DC', 'XSD', 'OLO'].each{|p| prefixes[p.downcase.to_sym] = eval("RDF::#{p}.to_s") } # TODO: fails for large datasets?? multi_cell_call - turtle = RDF::Turtle::Writer.for(:turtle).buffer(:prefixes => prefixes) do |writer| - rdf.each{|statement| writer << statement} + turtle = RDF::Writer.for(:turtle).buffer(:prefixes => prefixes) do |writer| + writer << rdf end - regex = Regexp.new '(https?:\/\/[\S]+)([>"])' - turtle = "" + turtle.gsub( regex, '\1\2' ).gsub(/\n/,'
') + "" if mime_type =~ /html/ and !turtle.empty? - turtle + #regex = Regexp.new '(https?:\/\/[\S]+)([>"])' + #turtle = "" + turtle.gsub( regex, '\1\2' ).gsub(/\n/,'
') + "" if mime_type =~ /html/ and !turtle.empty? + turtle.to_html if mime_type =~ /html/ and !turtle.empty? end else # TODO: check if this prevents SPARQL injections -- cgit v1.2.3 From 8271c3e72430d16a7edfd2a2d87066716c94b423 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 5 Jun 2013 16:21:06 +0200 Subject: fixed turtle output --- lib/4store.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/4store.rb b/lib/4store.rb index 578ce13..7c6be09 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -88,21 +88,24 @@ module OpenTox when "text/plain", "application/rdf+xml" RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => mime_type).body when /html|turtle/ - # TODO: fix and improve nt = RestClient.get(sparql_uri, :params => { :query => sparql }, :accept => "text/plain").body # 4store returns ntriples for turtle rdf = RDF::Graph.new RDF::Reader.for(:ntriples).new(nt) do |reader| reader.each_statement { |statement| rdf << statement } end - prefixes = {:rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"} - ['OT', 'DC', 'XSD', 'OLO'].each{|p| prefixes[p.downcase.to_sym] = eval("RDF::#{p}.to_s") } - # TODO: fails for large datasets?? multi_cell_call - turtle = RDF::Writer.for(:turtle).buffer(:prefixes => prefixes) do |writer| - writer << rdf + if !rdf.empty? + prefixes = {:rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"} + ['OT', 'DC', 'XSD', 'OLO'].each{|p| prefixes[p.downcase.to_sym] = eval("RDF::#{p}.to_s") } + # TODO: fails for large datasets?? multi_cell_call + turtle = RDF::Writer.for(:turtle).buffer(:prefixes => prefixes) do |writer| + writer << rdf + end + regex = Regexp.new '(https?:\/\/[\S]+)([>"])' + turtle = "" + turtle.gsub( regex, '\1\2' ).gsub(/\n/,'
') + "" if mime_type =~ /html/ and !turtle.empty? + turtle + else + rdf end - #regex = Regexp.new '(https?:\/\/[\S]+)([>"])' - #turtle = "" + turtle.gsub( regex, '\1\2' ).gsub(/\n/,'
') + "" if mime_type =~ /html/ and !turtle.empty? - turtle.to_html if mime_type =~ /html/ and !turtle.empty? end else # TODO: check if this prevents SPARQL injections -- cgit v1.2.3