Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 58 lines (52 sloc) 1.45 kb
1b8b693 add all files.
tadatadashi authored
1 #!/usr/bin/env ruby
112f229 fix magic comment insert line.
hsbt authored
2 # -*- coding: utf-8; -*-
87da5df * wiki_parser.rb: remove #!... line.
tadatadashi authored
3 #
dc913fb fix header bug(e.g. typo, nameerror, obsoleted).
hsbt authored
4 # index.rb
87da5df * wiki_parser.rb: remove #!... line.
tadatadashi authored
5 #
c621edb replaces unused mail address.
hsbt authored
6 # Copyright (C) 2001-2009, TADA Tadashi <t@tdtds.jp>
92261bd @tdtds fix #445: license notation exactly
tdtds authored
7 # You can redistribute it and/or modify it under GPL2 or any later version.
87da5df * wiki_parser.rb: remove #!... line.
tadatadashi authored
8 #
bdd7be4 replaced $defout to $stdout. ($defout is obsolete in ruby1.8)
hsbt authored
9 BEGIN { $stdout.binmode }
1b8b693 add all files.
tadatadashi authored
10
11 begin
12 if FileTest::symlink?( __FILE__ ) then
c804fee @hsbt integrate to untaint load-path
hsbt authored
13 org_path = File::dirname( File::readlink( __FILE__ ) )
1b8b693 add all files.
tadatadashi authored
14 else
c804fee @hsbt integrate to untaint load-path
hsbt authored
15 org_path = File::dirname( __FILE__ )
1b8b693 add all files.
tadatadashi authored
16 end
22a5872 @hsbt fix condition for library path
hsbt authored
17 $:.unshift( (org_path + '/lib').untaint ) unless $:.include?( org_path + '/lib' )
1738964 @hsbt merge tdiary-request
hsbt authored
18 require 'tdiary'
15b37d6 $:.unshift orig_path.
tadatadashi authored
19
d4c5ae7 @kdmsnr fixed the error of tsukkomi from mobile phone.
kdmsnr authored
20 encoding_error = {}
2f3d466 @hsbt converted Ruby 1.9 like hash syntax
hsbt authored
21 cgi = CGI::new(accept_charset: "UTF-8") do |name, value|
d4c5ae7 @kdmsnr fixed the error of tsukkomi from mobile phone.
kdmsnr authored
22 encoding_error[name] = value
23 end
24 if encoding_error.empty?
25 @cgi = cgi
26 else
2f3d466 @hsbt converted Ruby 1.9 like hash syntax
hsbt authored
27 @cgi = CGI::new(accept_charset: 'shift_jis')
d4c5ae7 @kdmsnr fixed the error of tsukkomi from mobile phone.
kdmsnr authored
28 @cgi.params = cgi.params
29 end
65c709e @hsbt Content-Type is moved to dispatcher
hsbt authored
30
1738964 @hsbt merge tdiary-request
hsbt authored
31 request = TDiary::Request.new( ENV, @cgi )
32 status, headers, body = TDiary::Dispatcher.index.dispatch_cgi( request, @cgi )
65c709e @hsbt Content-Type is moved to dispatcher
hsbt authored
33
7edf5e9 @kakutani TDiary::Dispatcher#dispatch_cgi returns Rack style array.
kakutani authored
34 TDiary::Dispatcher.send_headers( status, headers )
6cda2f1 @hsbt to use Rack::Handler::CGI.send_body instead of stolen method
hsbt authored
35 ::Rack::Handler::CGI.send_body(body)
1b8b693 add all files.
tadatadashi authored
36 rescue Exception
800e218 * index.rb, update.rb: no 'Content-Type' in error message running on mo...
tadatadashi authored
37 if @cgi then
3dcb977 * index.rb: support ETag and If-None-Match header, and delete cache con...
tadatadashi authored
38 print @cgi.header( 'status' => CGI::HTTP_STATUS['SERVER_ERROR'], 'type' => 'text/html' )
800e218 * index.rb, update.rb: no 'Content-Type' in error message running on mo...
tadatadashi authored
39 else
5fcb7a0 * index.rb, update.rb: return status 500 on error. thanks Masahiro Saka...
tadatadashi authored
40 print "Status: 500 Internal Server Error\n"
41 print "Content-Type: text/html\n\n"
800e218 * index.rb, update.rb: no 'Content-Type' in error message running on mo...
tadatadashi authored
42 end
5fcb7a0 * index.rb, update.rb: return status 500 on error. thanks Masahiro Saka...
tadatadashi authored
43 puts "<h1>500 Internal Server Error</h1>"
44 puts "<pre>"
035a3d2 * index.rb, update.rb: escape HTML for error page.
tadatadashi authored
45 puts CGI::escapeHTML( "#{$!} (#{$!.class})" )
1b8b693 add all files.
tadatadashi authored
46 puts ""
035a3d2 * index.rb, update.rb: escape HTML for error page.
tadatadashi authored
47 puts CGI::escapeHTML( $@.join( "\n" ) )
5fcb7a0 * index.rb, update.rb: return status 500 on error. thanks Masahiro Saka...
tadatadashi authored
48 puts "</pre>"
f92f4a8 * index.rb, update.rb: return status 500 on error when "MSIE" also.
tadatadashi authored
49 puts "<div>#{' ' * 500}</div>"
1b8b693 add all files.
tadatadashi authored
50 end
51
88e35eb added emacs Local Variables.
hsbt authored
52 # Local Variables:
53 # mode: ruby
54 # indent-tabs-mode: t
55 # tab-width: 3
56 # ruby-indent-level: 3
57 # End:
Something went wrong with that request. Please try again.