Permalink
Browse files

now can specify config_path

git-svn-id: http://svn.sourceforge.jp/svnroot/hiki/hiki/branches/rack@1089 684b846f-27f2-41ea-b66a-77a1bafa84c1
  • Loading branch information...
okkez
okkez committed Nov 24, 2009
1 parent e8b8e48 commit 73b76b932ab64e24d3efbe300d6cdfca847ee932
Showing with 14 additions and 8 deletions.
  1. +2 −2 hiki.ru
  2. +4 −1 hiki/app.rb
  3. +4 −1 hiki/attachment.rb
  4. +4 −4 hiki/config.rb
View
@@ -12,8 +12,8 @@ use Rack::CommonLogger
use Rack::Static, :urls => ['/theme'], :root => '.'
map '/' do
- run Hiki::App.new
+ run Hiki::App.new('hikiconf.rb')
end
map '/attach' do
- run Hiki::Attachment.new
+ run Hiki::Attachment.new('hikiconf.rb')
end
View
@@ -9,12 +9,15 @@
module Hiki
class App
+ def initialize(config_path = 'hikiconf.rb')
+ @config_path = config_path
+ end
def call(env)
request = Rack::Request.new(env)
# TODO use Rack::Request#env or other methods instead of ENV
# HACK replace ENV values to web application environment
env.each{|k,v| ENV[k] = v.to_s unless /\Arack\./ =~ k }
- conf = Hiki::Config.new
+ conf = Hiki::Config.new(@config_path)
response = nil
if %r|text/xml| =~ request.content_type and request.post?
server = Hiki::XMLRPCServer.new(conf, request)
View
@@ -10,11 +10,14 @@
module Hiki
class Attachment
include ::Hiki::Util
+ def initialize(config_path)
+ @config_path = config_path
+ end
def call(env)
request = Hiki::Request.new(env)
# HACK replace ENV values to web application environment
env.each{|k,v| ENV[k] = v unless /\Arack\./ =~ k }
- conf = Hiki::Config.new
+ conf = Hiki::Config.new(@config_path)
response = attach_file(request, conf)
response.finish
end
View
@@ -23,8 +23,8 @@ module Hiki
class Config
include ::Hiki::Util
- def initialize
- load
+ def initialize(config_path = 'hikiconf.rb')
+ load(config_path)
load_cgi_conf
load_messages
@@ -123,9 +123,9 @@ def read_template( cmd )
private
# loading hikiconf.rb in current directory
- def load
+ def load(config_path = 'hikiconf.rb')
@options = {}
- eval( File.open( "hikiconf.rb" ){|f| f.read }.untaint, binding, "(hikiconf.rb)", 1 )
+ eval( File.open(config_path){|f| f.read }.untaint, binding, "(#{config_path})", 1 )
formaterror if $data_path
raise 'No @data_path variable.' unless @data_path

0 comments on commit 73b76b9

Please sign in to comment.