Permalink
Browse files

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

…RDF::Format instead
  • Loading branch information...
1 parent d95d662 commit a7967c5f20021e37099ff55d9565c424d4335c6b @njh committed Oct 9, 2013
Showing with 14 additions and 40 deletions.
  1. +9 −1 dbpedialite.rb
  2. +0 −34 lib/formats.rb
  3. +5 −5 views/alternatives.erb
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|
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
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>

0 comments on commit a7967c5

Please sign in to comment.