Class: Web::Wiki::Request
Overview
:nodoc:
Defined Under Namespace
Classes: Action
Constant Summary collapse
- @@actions =
{}
Instance Attribute Summary collapse
-
#content_template ⇒ Object
Returns the value of attribute content_template.
-
#page ⇒ Object
Returns the value of attribute page.
-
#template ⇒ Object
Returns the value of attribute template.
-
#vars ⇒ Object
Returns the value of attribute vars.
-
#wiki ⇒ Object
Returns the value of attribute wiki.
Class Method Summary collapse
Instance Method Summary collapse
- #download_file(basedir, requested_asset) ⇒ Object
- #handle_request ⇒ Object
-
#initialize(wiki) ⇒ Request
constructor
A new instance of Request.
Constructor Details
Instance Attribute Details
#content_template ⇒ Object
Returns the value of attribute content_template.
329 330 331 |
# File 'lib/web/wiki.rb', line 329 def content_template @content_template end |
#page ⇒ Object
Returns the value of attribute page.
329 330 331 |
# File 'lib/web/wiki.rb', line 329 def page @page end |
#template ⇒ Object
Returns the value of attribute template.
329 330 331 |
# File 'lib/web/wiki.rb', line 329 def template @template end |
#vars ⇒ Object
Returns the value of attribute vars.
329 330 331 |
# File 'lib/web/wiki.rb', line 329 def vars @vars end |
#wiki ⇒ Object
Returns the value of attribute wiki.
329 330 331 |
# File 'lib/web/wiki.rb', line 329 def wiki @wiki end |
Class Method Details
Instance Method Details
#download_file(basedir, requested_asset) ⇒ Object
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/web/wiki.rb', line 438 def download_file( basedir, requested_asset ) self.template = nil self.content_template = nil basedir = File.( basedir ) requested_asset = File.( File.join(basedir, requested_asset.gsub( /\\/, "/") ) ) # security check on the requested_asset -- # it must be underneath the basedir if ( requested_asset.index( basedir ) == 0 && \ File.exists?( requested_asset ) ) # deliver the file Web.content_type = Web.get_mime_type( requested_asset ) Web.write File.open(requested_asset, "r" ) { |f| f.read } Web.flush else Web.status = "404"; Web.write "404 File Not Found" Web.flush end end |
#handle_request ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/web/wiki.rb', line 364 def handle_request cmd = Web["action"] cmd = "default" if cmd.empty? || cmd == "view_revision" cmd = "download_resource" if Web::path_info =~ /^\/resources\// cmd = "default" unless Web::Wiki::pref("allowed_actions").include?(cmd) Request.actions[cmd].call(self) unless @handled Web.template_include_path << Web::Wiki::pref("resource_dir") self.vars["content_template"] = self.content_template Web.print_template( self.template, self.vars ) if self.template @handled = true end end |