Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed our own list of formats and started using the sub-classes of …

…RDF::Format instead
  • Loading branch information...
commit a7967c5f20021e37099ff55d9565c424d4335c6b 1 parent d95d662
Nicholas Humfrey authored
Showing with 14 additions and 40 deletions.
  1. +9 −1 dbpedialite.rb
  2. +0 −34 lib/formats.rb
  3. +5 −5 views/alternatives.erb
10 dbpedialite.rb
View
@@ -3,7 +3,6 @@
require 'thing'
require 'category'
require 'wikidata_api'
-require 'formats'
class DbpediaLite < Sinatra::Base
@@ -18,6 +17,15 @@ class DbpediaLite < Sinatra::Base
:schema => 'http://schema.org/'
}
+ FORMATS = [
+ JSON::LD::Format,
+ RDF::JSON::Format,
+ RDF::NTriples::Format,
+ RDF::RDFXML::Format,
+ RDF::TriX::Format,
+ RDF::Turtle::Format,
+ ]
+
def self.extract_vocabularies(graph)
vocabs = {}
graph.predicates.each do |predicate|
34 lib/formats.rb
View
@@ -1,34 +0,0 @@
-class Dbpedialite
- FORMATS = [
- {
- :name => 'JSON',
- :mime => 'application/json',
- :suffix => 'json'
- },
- {
- :name => 'JSON-LD',
- :mime => 'application/ld+json',
- :suffix => 'jsonld'
- },
- {
- :name => 'Turtle',
- :mime => 'text/turtle',
- :suffix => 'ttl'
- },
- {
- :name => 'N-Triples',
- :mime => 'text/plain',
- :suffix => 'nt'
- },
- {
- :name => 'RDF/XML',
- :mime => 'application/rdf+xml',
- :suffix => 'rdf'
- },
- {
- :name => 'TriX',
- :mime => 'application/trix',
- :suffix => 'trix'
- }
- ]
-end
10 views/alternatives.erb
View
@@ -1,13 +1,13 @@
<% content_for :head do %>
- <% Dbpedialite::FORMATS.each do |format| %>
- <link rel="alternate" type="<%= format[:mime] %>" href="<%= object.doc_path(format[:suffix]) %>" title="<%= format[:name] %>" />
+ <% DbpediaLite::FORMATS.each do |format| %>
+ <link rel="alternate" type="<%= format.content_type.first %>" href="<%= object.doc_path(format.file_extension.first) %>" title="<%= format.name %>" />
<% end %>
<% end %>
<div id="alternates">
<h4>Alternative formats:</h4>
- <% Dbpedialite::FORMATS.each_with_index do |format,i| %>
- <%= link_to(format[:name], object.doc_path(format[:suffix])) %>
- <%= '|' unless i == Dbpedialite::FORMATS.count - 1 %>
+ <% DbpediaLite::FORMATS.each_with_index do |format,i| %>
+ <%= link_to(format.name, object.doc_path(format.file_extension.first)) %>
+ <%= '|' unless i == DbpediaLite::FORMATS.count - 1 %>
<% end %>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.