Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 171
- Log:
Initial import of Beast 0.9 from downloaded Tarball. Beast is a Ruby
On Rails based forum application. The original tarball came from the
following location:http://s3.amazonaws.com/beast-forum/beast-0.9.tar.gz
The forum post which announced this version's availability was at:
http://beast.caboo.se/forums/1/topics/446
- Author:
- rool
- Date:
- Fri Mar 02 15:51:55 +0000 2007
- Size:
- 2998 Bytes
1 | require 'ipaddr' |
2 | |
3 | # Copyright (c) 2005 Jamis Buck |
4 | # |
5 | # Permission is hereby granted, free of charge, to any person obtaining |
6 | # a copy of this software and associated documentation files (the |
7 | # "Software"), to deal in the Software without restriction, including |
8 | # without limitation the rights to use, copy, modify, merge, publish, |
9 | # distribute, sublicense, and/or sell copies of the Software, and to |
10 | # permit persons to whom the Software is furnished to do so, subject to |
11 | # the following conditions: |
12 | # |
13 | # The above copyright notice and this permission notice shall be |
14 | # included in all copies or substantial portions of the Software. |
15 | # |
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
19 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
20 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
21 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
22 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
23 | module ExceptionLoggable |
24 | def self.included(target) |
25 | target.extend(ClassMethods) |
26 | end |
27 | |
28 | module ClassMethods |
29 | def consider_local(*args) |
30 | local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) }) |
31 | end |
32 | |
33 | def local_addresses |
34 | addresses = read_inheritable_attribute(:local_addresses) |
35 | unless addresses |
36 | addresses = [IPAddr.new("127.0.0.1")] |
37 | write_inheritable_attribute(:local_addresses, addresses) |
38 | end |
39 | addresses |
40 | end |
41 | |
42 | def exception_data(deliverer=self) |
43 | if deliverer == self |
44 | read_inheritable_attribute(:exception_data) |
45 | else |
46 | write_inheritable_attribute(:exception_data, deliverer) |
47 | end |
48 | end |
49 | end |
50 | |
51 | def local_request? |
52 | remote = IPAddr.new(request.remote_ip) |
53 | !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil? |
54 | end |
55 | |
56 | def render_404(exception) |
57 | respond_to do |type| |
58 | type.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" } |
59 | type.all { render :nothing => true, :status => "404 Not Found" } |
60 | end |
61 | end |
62 | |
63 | def render_500(exception) |
64 | respond_to do |type| |
65 | type.html { render :file => "#{RAILS_ROOT}/public/500.html", :status => "500 Error" } |
66 | type.all { render :nothing => true, :status => "500 Error" } |
67 | end |
68 | end |
69 | |
70 | def rescue_action_in_public(exception) |
71 | case exception |
72 | when ActiveRecord::RecordNotFound, ActionController::UnknownController, ActionController::UnknownAction |
73 | render_404(exception) |
74 | |
75 | else |
76 | render_500(exception) |
77 | log_exception(exception) |
78 | end |
79 | end |
80 | |
81 | def log_exception(exception) |
82 | deliverer = self.class.exception_data |
83 | data = case deliverer |
84 | when nil then {} |
85 | when Symbol then send(deliverer) |
86 | when Proc then deliverer.call(self) |
87 | end |
88 | |
89 | LoggedException.create_from_exception(self, exception) |
90 | end |
91 | end |