/[pkg-tdiary]/squeeze/update.rb
ViewVC logotype

Contents of /squeeze/update.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 207 - (show annotations) (download)
Mon Nov 15 03:07:10 2010 UTC (2 years, 6 months ago) by daigo-guest
File size: 2994 byte(s)
Branch for Squeeze
1 #!/usr/bin/env ruby
2 #
3 # update.rb $Revision: 1.21 $
4 #
5 # Copyright (C) 2001-2003, TADA Tadashi <sho@spc.gr.jp>
6 # You can redistribute it and/or modify it under GPL2.
7 #
8 BEGIN { $defout.binmode }
9 $KCODE = 'n'
10
11 begin
12 if FileTest::symlink?( __FILE__ ) then
13 org_path = File::dirname( File::readlink( __FILE__ ) )
14 else
15 org_path = File::dirname( __FILE__ )
16 end
17 $:.unshift( org_path.untaint )
18 require 'tdiary'
19
20 @cgi = CGI::new
21 conf = TDiary::Config::new(@cgi)
22 tdiary = nil
23
24 begin
25 if @cgi.valid?( 'append' )
26 tdiary = TDiary::TDiaryAppend::new( @cgi, 'show.rhtml', conf )
27 elsif @cgi.valid?( 'edit' )
28 tdiary = TDiary::TDiaryEdit::new( @cgi, 'update.rhtml', conf )
29 elsif @cgi.valid?( 'replace' )
30 tdiary = TDiary::TDiaryReplace::new( @cgi, 'show.rhtml', conf )
31 elsif @cgi.valid?( 'appendpreview' ) or @cgi.valid?( 'replacepreview' )
32 tdiary = TDiary::TDiaryPreview::new( @cgi, 'preview.rhtml', conf )
33 elsif @cgi.valid?( 'plugin' )
34 tdiary = TDiary::TDiaryFormPlugin::new( @cgi, 'update.rhtml', conf )
35 elsif @cgi.valid?( 'comment' )
36 tdiary = TDiary::TDiaryShowComment::new( @cgi, 'update.rhtml', conf )
37 elsif @cgi.valid?( 'saveconf' )
38 tdiary = TDiary::TDiarySaveConf::new( @cgi, 'conf.rhtml', conf )
39 elsif @cgi.valid?( 'conf' )
40 tdiary = TDiary::TDiaryConf::new( @cgi, 'conf.rhtml', conf )
41 elsif @cgi.valid?( 'referer' )
42 tdiary = TDiary::TDiaryConf::new( @cgi, 'referer.rhtml', conf )
43 else
44 tdiary = TDiary::TDiaryForm::new( @cgi, 'update.rhtml', conf )
45 end
46 rescue TDiary::TDiaryError
47 tdiary = TDiary::TDiaryForm::new( @cgi, 'update.rhtml', conf )
48 end
49
50 begin
51 head = body = ''
52 if @cgi.mobile_agent? then
53 body = conf.to_mobile( tdiary.eval_rhtml( 'i.' ) )
54 head = @cgi.header(
55 'status' => '200 OK',
56 'type' => 'text/html',
57 'charset' => conf.mobile_encoding,
58 'Content-Length' => body.size.to_s,
59 'Vary' => 'User-Agent'
60 )
61 else
62 body = tdiary.eval_rhtml
63 head = @cgi.header(
64 'status' => '200 OK',
65 'type' => 'text/html',
66 'charset' => conf.encoding,
67 'Content-Length' => body.size.to_s,
68 'Vary' => 'User-Agent'
69 )
70 end
71 print head
72 print body if /HEAD/i !~ @cgi.request_method
73 rescue TDiary::ForceRedirect
74 head = {
75 #'Location' => $!.path
76 'type' => 'text/html',
77 }
78 head['cookie'] = tdiary.cookies if tdiary.cookies.size > 0
79 print @cgi.header( head )
80 print %Q[
81 <html>
82 <head>
83 <meta http-equiv="refresh" content="1;url=#{$!.path}">
84 <title>moving...</title>
85 </head>
86 <body>Wait or <a href="#{$!.path}">Click here!</a></body>
87 </html>]
88 end
89
90 rescue Exception
91 if @cgi then
92 print @cgi.header( 'status' => '500 Internal Server Error', 'type' => 'text/html' )
93 else
94 print "Status: 500 Internal Server Error\n"
95 print "Content-Type: text/html\n\n"
96 end
97 puts "<h1>500 Internal Server Error</h1>"
98 puts "<pre>"
99 puts CGI::escapeHTML( "#{$!} (#{$!.class})" )
100 puts ""
101 puts CGI::escapeHTML( $@.join( "\n" ) )
102 puts "</pre>"
103 puts "<div>#{' ' * 500}</div>"
104 end
105

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5