Class: Spider::PageController

Inherits:
Controller show all
Includes:
HTTPMixin, StaticContent, Visual, WidgetHelper
Defined in:
lib/spiderfw/controller/page_controller.rb

Direct Known Subclasses

Widget

Instance Attribute Summary

Attributes inherited from Controller

#dispatch_action, #executed_method, #is_target, #request, #response, #scene

Attributes included from Dispatcher

#dispatch_previous

Instance Method Summary collapse

Methods inherited from Controller

#action_target?, #after, app, #before, before, before_methods, before_unless, #call_path, #check_action, controller_action?, controller_actions, default_action, #done, #done=, #done?, #execute, find_resource, find_resource_path, #get_action_method, #get_scene, #init, #inspect, #is_target?, layout_path, option, options, #prepare_scene, #request_path, template_path, url, url=

Methods included from Annotations

included

Methods included from Logger

add, close, close_all, datetime_format, datetime_format=, #debug, debug, debug?, #debug?, enquire_loggers, #error, error, #error?, error?, #fatal, fatal, #fatal?, fatal?, info, #info, info?, #info?, method_missing, open, reopen, send_to_loggers, unknown, #unknown, #warn, warn, warn?, #warn?

Methods included from Dispatcher

#add_chain_item, #can_dispatch?, #dispatch, #dispatch_chain, #dispatch_next, #do_dispatch, included, #route, #routes, #run_chain

Constructor Details

#initialize(request, response, scene = nil) ⇒ PageController

Returns a new instance of PageController.



12
13
14
15
# File 'lib/spiderfw/controller/page_controller.rb', line 12

def initialize(request, response, scene=nil)
    super
    @widgets = {}
end

Instance Method Details

#get_route(path) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/spiderfw/controller/page_controller.rb', line 18

def get_route(path)
    if (path =~ /^[^:]+:([^:\/]+)[:\/]?(.*)$/) # route to widgets
        if (@widgets[$1])
            return Route.new(:path => path, :dest => @widgets[$1], :action => $2)
        end
    elsif (path =~ /_h\/(.+)/) # Route back to home
        return Route.new(:path => path, :dest => Spider::HomeController, :action => $1)
    end
    return super
end