Class: TDiary::Dispatcher::UpdateMain
- Inherits:
-
Object
- Object
- TDiary::Dispatcher::UpdateMain
- Defined in:
- lib/tdiary/dispatcher/update_main.rb
Instance Attribute Summary collapse
-
#cgi ⇒ Object
readonly
Returns the value of attribute cgi.
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#tdiary ⇒ Object
readonly
Returns the value of attribute tdiary.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request, cgi) ⇒ UpdateMain
constructor
A new instance of UpdateMain.
- #run ⇒ Object
Constructor Details
#initialize(request, cgi) ⇒ UpdateMain
Returns a new instance of UpdateMain.
10 11 12 13 14 15 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 10 def initialize( request, cgi ) @request = request @cgi = cgi @conf = TDiary::Configuration::new( cgi, request ) @params = request.params end |
Instance Attribute Details
#cgi ⇒ Object (readonly)
Returns the value of attribute cgi.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def cgi @cgi end |
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def conf @conf end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def request @request end |
#tdiary ⇒ Object (readonly)
Returns the value of attribute tdiary.
8 9 10 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 8 def tdiary @tdiary end |
Class Method Details
.run(request, cgi) ⇒ Object
4 5 6 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 4 def self.run( request, cgi ) new( request, cgi ).run end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 17 def run @tdiary = create_tdiary begin head = {}; body = '' body = tdiary.eval_rhtml head = { 'Content-Type' => 'text/html; charset=UTF-8', 'charset' => conf.encoding, 'Content-Length' => body.bytesize.to_s, 'Vary' => 'User-Agent', 'X-Frame-Options' => 'SAMEORIGIN' } body = ( request.head? ? '' : body ) TDiary::Response.new( body, 200, head ) rescue TDiary::ForceRedirect head = { #'Location' => $!.path 'Content-Type' => 'text/html', } body = %Q[ <html> <head> <meta http-equiv="refresh" content="1;url=#{$!.path}"> <title>moving...</title> </head> <body>Wait or <a href="#{$!.path}">Click here!</a></body> </html>] head['cookie'] = tdiary. if tdiary..size > 0 # TODO return code should be 302? (current behaviour returns 200) TDiary::Response.new( body, 200, head ) end end |