Class: RoadForest::TypeHandlers::RDFa
- Inherits:
-
RDFHandler
- Object
- Handler
- RDFHandler
- RoadForest::TypeHandlers::RDFa
- Includes:
- Graph::Normalization
- Defined in:
- lib/roadforest/type-handlers/rdfa.rb
Overview
text/html;q=1;rdfa image/svg+xml;q=1;rdfa application/xhtml+xml;q=1;rdfa text/html image/svg+xml application/xhtml+xml
Constant Summary
Constants included from Graph::Normalization
Instance Attribute Summary collapse
-
#haml_options ⇒ Object
Returns the value of attribute haml_options.
- #tilt_cache ⇒ Object
- #valise ⇒ Object
Instance Method Summary collapse
Methods included from Graph::Normalization
#expand_curie, #expand_curie_pair, #interned_uri, #literal, #normalize_context, #normalize_property, #normalize_resource, #normalize_statement, #normalize_term, #normalize_tuple, #normalize_uri, #relevant_prefixes_for_graph, #root_url, #uri, #vocabularies_in_graph
Methods inherited from RDFHandler
#child_for_interface, #get_output
Methods inherited from Handler
#add_child_to, #build_response, #child_for_interface, #get_output, #parse_for, #render_for, #update_interface
Instance Attribute Details
#haml_options ⇒ Object
Returns the value of attribute haml_options.
17 18 19 |
# File 'lib/roadforest/type-handlers/rdfa.rb', line 17 def @haml_options end |
#tilt_cache ⇒ Object
25 26 27 |
# File 'lib/roadforest/type-handlers/rdfa.rb', line 25 def tilt_cache @tilt_cache ||= ::Tilt::Cache.new end |
#valise ⇒ Object
19 20 21 22 23 |
# File 'lib/roadforest/type-handlers/rdfa.rb', line 19 def valise @valise ||= Valise.define do ro up_to("lib") + "roadforest" end end |
Instance Method Details
#local_to_network(base_uri, rdf) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/roadforest/type-handlers/rdfa.rb', line 29 def local_to_network(base_uri, rdf) raise "Invalid base uri: #{base_uri}" if base_uri.nil? debug = [] templates = RDFaWriter::TemplateHandler.new templates.valise = valise templates.template_cache = tilt_cache templates. = engine = RDFaWriter::RenderEngine.new(rdf, debug) do |engine| #engine.graph_name = nil #was: rdf.context engine.base_uri = base_uri engine.standard_prefixes = true engine.template_handler = templates #engine.style_name = options[:haml] #engine.lang = options[:lang] engine.top_classes = [::RDF::RDFS.Class] engine.predicate_order = [::RDF.type, ::RDF::RDFS.label, ::RDF::DC.title] engine.heading_predicates = [::RDF::RDFS.label, ::RDF::DC.title] end prefixes = relevant_prefixes_for_graph(rdf) prefixes.keys.each do |prefix| prefixes[prefix.to_sym] = prefixes[prefix] end engine.prefixes.merge! prefixes engine.prefixes.keys.each do |key| if key.is_a? String engine.prefixes[key.to_sym] = engine.prefixes.delete(key) end end result = engine.render_document #puts "\n#{__FILE__}:#{__LINE__} => \n#{debug.join("\n")}" return result end |
#network_to_local(base_uri, source) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/roadforest/type-handlers/rdfa.rb', line 69 def network_to_local(base_uri, source) raise "Invalid base uri: #{base_uri.inspect}" if base_uri.nil? graph = ::RDF::Graph.new reader = ::RDF::RDFa::Reader.new(source.to_s, :base_uri => base_uri.to_s) reader.each_statement do |statement| graph.insert(statement) end graph end |