-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwikiwatcher.ru
94 lines (79 loc) · 2.22 KB
/
wikiwatcher.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env rackup
#require 'profile'
#prerequisites:
# unix-style OS, ruby 1.8.6, rubygems 0.9+, camping 1.9+ (i.e. git), activerecord 2.0.2+, rack 0.3.0+
#to run:
# change establish_connection line to connect to your database, then run:
# rackup camping.ru
# ensure your VirtualHost files have <subdomain>.example.com pointing to localhost:9292/<subdomain>/ .
require '_configuration'
require 'rubygems'
require 'active_record'
#require 'mysqlplus'
#class Mysql; alias :query :async_query; end
require 'will_paginate'
require 'ostruct'
$:.unshift Pathname.new('./lib/camping/lib/').realpath
require 'camping'
require 'camping/server'
require 'lib/markaby/lib/markaby'
class Fixnum
alias_method :xchr_old, :xchr
def xchr
@@XChar_Cache ||= (0..255).map{|x| x.send :xchr_old}
@@XChar_Cache[self] or xchr_old
end
end
module TBIBase
def self.included(base)
base.class_eval <<-END
def r404(p=env.PATH)
r(404, "<h3>Oops! Page could not be found.</h3>")
end
def r500(k,m,x)
puts $!
puts $!.backtrace
r(500, "<h3>Oops! An error occured; please try again.</h3>")
end
alias_method :initialize_without_rootfix, :initialize
def initialize_with_rootfix(env)
initialize_without_rootfix(env)
@root = ''
end
alias_method :initialize, :initialize_with_rootfix
END
end
end
Thread.new do
while(true)
sleep(300)
GC.start
end
end
Camping::Models::Base.establish_connection(DBCONN)
=begin
Camping::Models::Base.establish_connection(
:adapter => 'mysql',
:database => 'camping',
:username => 'root',
:password => '',
:host => 'localhost',
:pool => 50
)
=end
Camping::Models.create_schema
Camping::Models::Session.create_schema if Camping::Models.const_defined?(:Session)
ActiveRecord::Base.logger = Logger.new(STDOUT)
Dir.glob("*.rb").each do |file|
next unless file == 'wikiwatcher.rb'
next if file[0, 1] == '_'
# puts file
title = File.basename(file)[/^([\w_]+)/,1].gsub /_/,''
load file
klass = Object.const_get(Object.constants.grep(/^#{title}$/i)[0]) rescue nil
unless klass.nil?
klass::Base.send(:include, TBIBase)
klass.create if klass.respond_to? :create
map("/#{title.downcase}") { run klass }
end
end