Class: ICFS::Web::Client
- Inherits:
-
Object
- Object
- ICFS::Web::Client
- Defined in:
- lib/icfs/web/client.rb
Overview
Web Client
Instance Method Summary collapse
-
#call(env) ⇒ Object
A Rack call.
-
#initialize(css, js) ⇒ Client
constructor
New instance.
Constructor Details
#initialize(css, js) ⇒ Client
New instance
32 33 34 35 |
# File 'lib/icfs/web/client.rb', line 32 def initialize(css, js) @css = css.freeze @js = js.freeze end |
Instance Method Details
#call(env) ⇒ Object
A Rack call
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/icfs/web/client.rb', line 43 def call(env) # grab the path components path = env['PATH_INFO'] if path.empty? cmps = [''] else cmps = path.split('/'.freeze, -1) cmps.shift if cmps[0].empty? cmps = [''] if cmps.empty? end env['icfs.cmps'] = cmps # reset env['icfs'].reset case cmps[0] # search when 'case_search' return _call_search(env, 'Case Search'.freeze, 'Case Search'.freeze, QueryCase, ListCase, :case_search, Proc.new{|qu, txt| _a_case_search(env, qu, txt) } ) when 'entry_search' return _call_search(env, 'Entry Search'.freeze, 'Entry Search'.freeze, QueryEntry, ListEntry, :entry_search, Proc.new{|qu, txt| _a_entry_search(env, qu, txt) } ) when 'log_search' return _call_search(env, 'Log Search'.freeze, 'Log Search'.freeze, QueryLog, ListLog, :log_search, Proc.new{|qu, txt| _a_log_search(env, qu, txt) } ) when 'action_search' return _call_search(env, 'Action Search'.freeze, 'Action Search'.freeze, QueryAction, ListAction, :action_search, Proc.new{|qu, txt| _a_action_search(env, qu, txt) } ) when 'index_search' return _call_search(env, 'Index Search'.freeze, 'Index Search'.freeze, QueryIndex, ListIndex, :index_search, Proc.new{|qu, txt| _a_index_search(env, qu, txt) } ) when 'index_lookup'; return _call_index_lookup(env) # aggregations when 'stats' return _call_search(env, 'Stats Search'.freeze, 'Stats Search'.freeze, QueryStats, ListStats, :stats, nil ) when 'case_tags' return _call_search(env, 'Case Tags'.freeze, 'Case Tags Search'.freeze, QueryCaseTags, ListCaseTags, :case_tags, nil ) when 'entry_tags' return _call_search(env, 'Entry Tags'.freeze, 'Entry Tag Search'.freeze, QueryEntryTags, ListEntryTags, :entry_tags, nil ) when 'action_tags' return _call_search(env, 'Action Tags'.freeze, 'Action Tag Search'.freeze, QueryActionTags, ListActionTags, :action_tags, nil ) when 'index_tags' return _call_search(env, 'Index Tags'.freeze, 'Index Tag Search'.freeze, QueryIndexTags, ListIndexTags, :index_tags, nil ) # forms when 'case_create'; return _call_case_create(env) when 'case_edit'; return _call_case_edit(env) when 'entry_edit'; return _call_entry_edit(env) when 'index_edit'; return _call_index_edit(env) when 'config_edit'; return _call_config_edit(env) # view when 'home', ''; return _call_home(env) when 'case'; return _call_case(env) when 'entry'; return _call_entry(env) when 'log'; return _call_log(env) when 'action'; return _call_action(env) when 'index'; return _call_index(env) when 'file'; return _call_file(env) # info page when 'info'; return _call_info(env) # not supported path else env['icfs.page'] = 'Invalid'.freeze raise(Error::NotFound, 'Invalid request'.freeze) end rescue Error::NotFound => e return _resp_notfound( env, 'Not found: %s'.freeze % Rack::Utils.escape_html(e.) ) rescue Error::Perms => e return _resp_forbidden( env, 'Forbidden: %s'.freeze % Rack::Utils.escape_html(e.) ) rescue Error::Conflict => e return _resp_conflict( env, 'Conflict: %s'.freeze % Rack::Utils.escape_html(e.) ) rescue Error::Value => e return _resp_badreq( env, 'Invalid values: %s'.freeze % Rack::Utils.escape_html(e.) ) rescue Error::Interface => e return _resp_badreq(env, Rack::Utils.escape_html(e.)) end |