Class: Arachni::UI::Web::Addons::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/ui/web/addon_manager.rb

Overview

Base class for all add-ons.

@author: Tasos “Zapotek” Laskos

<[email protected]>
<[email protected]>

@version: 0.1

Direct Known Subclasses

AutoDeploy, Sample, Scheduler

Instance Method Summary collapse

Constructor Details

#initialize(settings, route) ⇒ Base

Returns a new instance of Base.



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
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/arachni/ui/web/addon_manager.rb', line 29

def initialize( settings, route )
    @settings = settings
    @route    = '/addons/' + route

    @settings.helpers do

        def present( tpl, args )
            views = current_addon.path_views
            trv = ( '../' * views.split( '/' ).size ) + views + tpl.to_s

            erb_args = []
            erb_args << { :layout => true }
            erb_args << { :tpl => trv.to_sym, :addon => addons.by_name( current_addon_name ), :tpl_args => args }

            erb :addon, *erb_args
        end

        def async_present( *args )
            body present( *args )
        end

        def partial( tpl, args )
            views = current_addon.path_views
            trv = ( '../' * views.split( '/' ).size ) + views + tpl.to_s

            erb_args = []
            erb_args << { :layout => false }
            erb_args << args

            erb trv.to_sym, *erb_args
        end

        def current_addon_name
            env['PATH_INFO'].scan( /\/addons\/(.*?)\// ).flatten[0]
        end

        def current_addon
            addons.running[current_addon_name]
        end

    end

end

Instance Method Details

#adelete(path, &block) ⇒ Object



139
140
141
# File 'lib/arachni/ui/web/addon_manager.rb', line 139

def adelete( path, &block )
    settings.adelete( @route + path, &block )
end

#aget(path, &block) ⇒ Object



115
116
117
# File 'lib/arachni/ui/web/addon_manager.rb', line 115

def aget( path, &block )
    settings.aget( @route + path, &block )
end

#apost(path, &block) ⇒ Object



123
124
125
# File 'lib/arachni/ui/web/addon_manager.rb', line 123

def apost( path, &block )
    settings.apost( @route + path, &block )
end

#aput(path, &block) ⇒ Object



131
132
133
# File 'lib/arachni/ui/web/addon_manager.rb', line 131

def aput( path, &block )
    settings.aput( @route + path, &block )
end

#delete(path, &block) ⇒ Object



135
136
137
# File 'lib/arachni/ui/web/addon_manager.rb', line 135

def delete( path, &block )
    settings.delete( @route + path, &block )
end

#get(path, &block) ⇒ Object



111
112
113
# File 'lib/arachni/ui/web/addon_manager.rb', line 111

def get( path, &block )
    settings.get( @route + path, &block )
end

#path_addonObject



81
82
83
# File 'lib/arachni/ui/web/addon_manager.rb', line 81

def path_addon
    Options.instance.dir['lib'] + 'ui/web' + path_root
end

#path_rootObject



73
74
75
# File 'lib/arachni/ui/web/addon_manager.rb', line 73

def path_root
    @route
end

#path_viewsObject



77
78
79
# File 'lib/arachni/ui/web/addon_manager.rb', line 77

def path_views
    path_addon + '/views/'
end

#post(path, &block) ⇒ Object



119
120
121
# File 'lib/arachni/ui/web/addon_manager.rb', line 119

def post( path, &block )
    settings.post( @route + path, &block )
end

#put(path, &block) ⇒ Object



127
128
129
# File 'lib/arachni/ui/web/addon_manager.rb', line 127

def put( path, &block )
    settings.put( @route + path, &block )
end

#runObject



85
86
87
# File 'lib/arachni/ui/web/addon_manager.rb', line 85

def run

end

#settingsObject



107
108
109
# File 'lib/arachni/ui/web/addon_manager.rb', line 107

def settings
   @settings
end

#titleString

This optional method allows you to specify the title which will be used for the menu (in case you want it to be dynamic).

Returns:



95
96
97
# File 'lib/arachni/ui/web/addon_manager.rb', line 95

def title
    ''
end