ig3tool 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ig3tool +1 -1
- data/lib/glade/sales.glade +84 -84
- data/lib/ui/{internewindow.rb → OLD_internewindow.rb} +0 -0
- data/lib/ui/{memberswindow.rb → OLD_memberswindow.rb} +0 -0
- data/lib/ui/{productswindow.rb → OLD_productswindow.rb} +0 -0
- data/lib/ui/gladehelper.rb +3 -2
- data/lib/ui/{newinterne.rb → interne.rb} +2 -1
- data/lib/ui/peoplewindow.rb +1 -1
- data/lib/ui/printingwindow.rb +6 -6
- data/lib/ui/protjes.rb +6 -0
- data/lib/ui/saleswindow.rb +72 -25
- data/lib/ui/toolwindow.rb +3 -3
- metadata +70 -95
- data/lib/actions/bib.rb +0 -295
- data/lib/actions/bitching.rb +0 -19
- data/lib/actions/cultuur.rb +0 -3
- data/lib/actions/interne.rb +0 -98
- data/lib/actions/kaching.rb +0 -90
- data/lib/actions/people.rb +0 -178
- data/lib/actions/printing.rb +0 -125
- data/lib/actions/product.rb +0 -154
- data/lib/bib.rb +0 -94
- data/lib/billing.rb +0 -112
- data/lib/bitching.rb +0 -49
- data/lib/config.rb +0 -19
- data/lib/horrible_hack.rb +0 -15
- data/lib/interne.rb +0 -111
- data/lib/ldap.rb +0 -104
- data/lib/log.rb +0 -25
- data/lib/membership.rb +0 -32
- data/lib/mymd5.rb +0 -95
- data/lib/people.rb +0 -143
- data/lib/printing.rb +0 -238
- data/lib/request.rb +0 -14
- data/lib/sales.rb +0 -158
- data/lib/utils.rb +0 -106
- data/lib/web.rb +0 -98
data/lib/web.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
module Ig3tool
|
2
|
-
|
3
|
-
require 'mongrel'
|
4
|
-
require 'yaml'
|
5
|
-
require 'facets'
|
6
|
-
|
7
|
-
class WebHandler < Mongrel::HttpHandler
|
8
|
-
def decode_body(request)
|
9
|
-
if request.params[Mongrel::Const::REQUEST_METHOD] == "POST" then
|
10
|
-
type = request.params['CONTENT_TYPE'].sub(/;.*/,'')
|
11
|
-
res = case type
|
12
|
-
when "application/x-yaml","text/yaml", "text/x-yaml"
|
13
|
-
YAML.load request.body
|
14
|
-
when "application/x-www-form-urlencoded"
|
15
|
-
Mongrel::HttpRequest.query_parse request.body.read
|
16
|
-
else
|
17
|
-
warn "Warning: don't know how to handle Content-Type: #{type}"
|
18
|
-
{}
|
19
|
-
end
|
20
|
-
res.stringify_keys!
|
21
|
-
else
|
22
|
-
{}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def process(request, response)
|
27
|
-
path = request.params[Mongrel::Const::PATH_INFO]
|
28
|
-
|
29
|
-
# strip leading /, convert all remaining / to _
|
30
|
-
(path, params) = path.split('//')
|
31
|
-
params = (params || "").split("/")
|
32
|
-
command = path.tr('/', '_').sub(/_+$/,'').sub(/^_+/,"")
|
33
|
-
|
34
|
-
puts "Handling request for #{path}; params: #{params.inspect}"
|
35
|
-
|
36
|
-
begin
|
37
|
-
|
38
|
-
if command.empty? then
|
39
|
-
response.start(503) do |head,out|
|
40
|
-
messages = Ig3tool::Actions.public_methods.reject {|x| Object.respond_to? x or x.starts_with? "_" }
|
41
|
-
out << "Please enter a query. Possible commands: #{messages.sort.join(', ')}"
|
42
|
-
end
|
43
|
-
return
|
44
|
-
else
|
45
|
-
type = request.params[Mongrel::Const::REQUEST_METHOD]
|
46
|
-
extra = decode_body request
|
47
|
-
extra.update( :from_uri => params, :given_uri => params.size, :type => type)
|
48
|
-
puts "Extra params: #{extra.inspect}"
|
49
|
-
|
50
|
-
command = command + '!' if type == 'POST'
|
51
|
-
|
52
|
-
if command != "wannabe!" and command != "register!"
|
53
|
-
raise Token, "you need a key" if params.size < 1
|
54
|
-
token = params[0]
|
55
|
-
raise Token, "invalid key" if not Bitch.can_request?(params[0])
|
56
|
-
end
|
57
|
-
|
58
|
-
r = Ig3tool::Request.new
|
59
|
-
r.bitch = Bitch.bitch(token)
|
60
|
-
r.request = "REQ: " + command
|
61
|
-
r.request += " ; " + params.join(", ")
|
62
|
-
r.request += " ; " + extra.to_a.map{|e| e.join(" => ")}.join(", ")
|
63
|
-
r.save!
|
64
|
-
|
65
|
-
answer = Ig3tool::Actions.send(command, extra)
|
66
|
-
raised = false
|
67
|
-
end
|
68
|
-
|
69
|
-
rescue IG3Error, NoMethodError => boom
|
70
|
-
answer = { "type" => boom.class.to_s, "message" => boom.message }
|
71
|
-
raised = true
|
72
|
-
rescue Exception => boom
|
73
|
-
warn "==== EXCEPTION ===="
|
74
|
-
warn "ERROR OCCURED: #{boom.to_s}\n"
|
75
|
-
warn "Backtrace: \n"
|
76
|
-
warn boom.backtrace.collect {|x| "\t"+x}.join("\n")
|
77
|
-
warn "==== EXCEPTION ===="
|
78
|
-
answer = { "type" => "InternalError", "message" => boom.to_s, "backtrace" => boom.backtrace }
|
79
|
-
raised = true
|
80
|
-
end
|
81
|
-
|
82
|
-
code = raised ? 500 : 200
|
83
|
-
response.start(code) do |head,out|
|
84
|
-
case request.params['HTTP_ACCEPT']
|
85
|
-
when /text\/x-yaml/, /text\/yaml/, /application\/yaml/
|
86
|
-
head["Content-Type"] = "application/yaml"
|
87
|
-
out << answer.to_yaml
|
88
|
-
|
89
|
-
else # text dump
|
90
|
-
head["Content-Type"] = "text/plain"
|
91
|
-
out << answer.inspect
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|