5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/app/controllers/triplify_controller.rb', line 5
def tripleize
t = Tripleizer.new
t.base_uri = t.uri request.env['REQUEST_URI'].to_s
depth = configatron.linked_data_depth.to_i
filename = 'data.n3'
.merge!(
'Content-Type' => 'text/rdf+n3',
'Content-Disposition' => "attachment; filename=\"#{filename}\"",
'Content-Transfer-Encoding' => 'binary'
)
t.output_json = request.content_type.try(:to_sym)==:json
content_type = t.output_json ? 'application/json' : 'text/plain'
render :content_type => content_type , :text => proc { |response, output|
t.output = output
case params[:specs].length
when 0
t.write_rdf_head
all t if depth > -1
when 1
t.base_uri = t.base_uri.to_s[0..t.base_uri.to_s.index(params[:specs][0].to_s)-1]
t.write_rdf_head
model t, params[:specs][0] if depth >0
when 2
t.base_uri = t.base_uri.to_s[0..t.base_uri.to_s.index(params[:specs][0].to_s)-1]
t.write_rdf_head
index t, params[:specs] if depth > 1
end
t_metadata = TriplifyMetadata.new
t_metadata.write_metadata(t)
output.write t.json if t.output_json
}
end
|