Class: 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.
11 12 13 14 15 16 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 11 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.
9 10 11 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 9 def cgi @cgi end |
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
9 10 11 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 9 def conf @conf end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 9 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
9 10 11 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 9 def request @request end |
#tdiary ⇒ Object (readonly)
Returns the value of attribute tdiary.
9 10 11 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 9 def tdiary @tdiary end |
Class Method Details
.run(request, cgi) ⇒ Object
5 6 7 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 5 def self.run( request, cgi ) new( request, cgi ).run end |
Instance Method Details
#run ⇒ Object
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 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/tdiary/dispatcher/update_main.rb', line 18 def run @tdiary = create_tdiary begin head = {}; body = '' if request.mobile_agent? body = conf.to_mobile( tdiary.eval_rhtml( 'i.' ) ) head = { 'Content-Type' => 'text/html', 'charset' => conf.mobile_encoding, 'Content-Length' => body.bytesize.to_s, 'Vary' => 'User-Agent' } else body = tdiary.eval_rhtml head = { 'Content-Type' => 'text/html', 'charset' => conf.encoding, 'Content-Length' => body.bytesize.to_s, 'Vary' => 'User-Agent', 'X-Frame-Options' => 'SAMEORIGIN' } end 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 |