diff options
author | mguetlein <martin.guetlein@gmail.com> | 2010-09-13 13:29:09 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2010-09-13 13:29:09 +0200 |
commit | eb5d72a15942b2367c2c1178a0a50d10261c5132 (patch) | |
tree | 0487d593ef884e68d87b03a886a7cd19f8d0bd35 /report | |
parent | ede7b60f62fb4385ce1358f49e92dd325ed251f6 (diff) |
fix report dtd - v3
Diffstat (limited to 'report')
-rw-r--r-- | report/report_application.rb | 18 | ||||
-rw-r--r-- | report/xml_report.rb | 5 |
2 files changed, 17 insertions, 6 deletions
diff --git a/report/report_application.rb b/report/report_application.rb index b8f7eed..31f5ac6 100644 --- a/report/report_application.rb +++ b/report/report_application.rb @@ -17,12 +17,23 @@ def perform end end +def get_docbook_resource(filepath) + perform do |rs| + halt 404,"not found: "+filepath unless File.exist?(filepath) + types = MIME::Types.type_for(filepath) + content_type(types[0].content_type) if types and types.size>0 and types[0] + result = body(File.new(filepath)) + end +end -get '/'+ENV['REPORT_DTD'] do - content_type "application/xml-dtd" - body(File.new(ENV['REPORT_DTD'])) +get '/'+ENV['DOCBOOK_DIRECTORY']+'/:subdir/:resource' do + path_array = request.env['REQUEST_URI'].split("/") + get_docbook_resource ENV['DOCBOOK_DIRECTORY']+"/"+path_array[-2]+"/"+path_array[-1] end +get '/'+ENV['DOCBOOK_DIRECTORY']+'/:resource' do + get_docbook_resource ENV['DOCBOOK_DIRECTORY']+"/"+request.env['REQUEST_URI'].split("/")[-1] +end get '/report/:type/css_style_sheet/?' do perform do |rs| @@ -30,7 +41,6 @@ get '/report/:type/css_style_sheet/?' do end end - get '/report/?' do perform do |rs| content_type "text/uri-list" diff --git a/report/xml_report.rb b/report/xml_report.rb index 50c9007..110c2a9 100644 --- a/report/xml_report.rb +++ b/report/xml_report.rb @@ -1,7 +1,8 @@ require "report/xml_report_util.rb" -ENV['REPORT_DTD'] = "docbook-xml-4.5/docbookx.dtd" unless ENV['REPORT_DTD'] +ENV['DOCBOOK_DIRECTORY'] = "docbook-xml-4.5" unless ENV['DOCBOOK_DIRECTORY'] +ENV['REPORT_DTD'] = "docbookx.dtd" unless ENV['REPORT_DTD'] #transfer to absolute path #ENV['REPORT_DTD'] = File.expand_path(ENV['REPORT_DTD']) if File.exist?(ENV['REPORT_DTD']) @@ -23,7 +24,7 @@ module Reports @doc = Document.new decl = XMLDecl.new @doc << decl - type = DocType.new('article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "'+$sinatra.url_for('/'+ENV['REPORT_DTD'], :full)+'"') + type = DocType.new('article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "'+$sinatra.url_for('/'+ENV['DOCBOOK_DIRECTORY']+'/'+ENV['REPORT_DTD'], :full)+'"') @doc << type @root = Element.new("article") |