diff --exclude=CVS -uNr hiki/ChangeLog hiki.new/ChangeLog --- hiki/ChangeLog 2004-06-11 23:49:36.000000000 +0900 +++ hiki.new/ChangeLog 2004-06-15 23:10:49.000000000 +0900 @@ -1,6 +1,36 @@ +2004-06-15 Kazuhiko + * style/default/html_formatter.rb: auto_link まわりの mod_ruby 対 + 応の修正 thanks to OZAWA Sakuro + +2004-06-12 Kazuhiko + * misc/hikifarm/hikifarm.conf, misc/hikifarm/index.cgi: 設定項目 + 'cgi_name' を新設 + * misc/hikifarm/index.cgi: 生成する Hiki CGI の require 'hiki' を + load 'hiki.cgi' に修正 + + * hiki.cgi, hiki/aliaswiki.rb, hiki/command.rb, + hiki/hiki_formatter.rb, hiki/interwiki.rb, hiki/page.rb, + hiki/plugin.rb, hiki/pluginutil.rb, hiki/util.rb, + hiki/db/flatfile.rb, misc/hikifarm/hiki.conf, + misc/hikifarm/hikifarm.conf, misc/hikifarm/index.cgi, + misc/plugin/bbs.rb, misc/plugin/comment.rb, misc/plugin/cvs.rb, + misc/plugin/history.rb, misc/plugin/local_css.rb, + misc/plugin/pagerank.rb, misc/plugin/rss.rb, + misc/plugin/search.rb, misc/plugin/svn.rb, + misc/plugin/attach/attach.cgi, misc/plugin/attach/attach.rb, + plugin/00default.rb, style/default/html_formatter.rb, + style/default/parser.rb, style/rd+/html_formatter.rb, + style/rd+/parser.rb, style/rd+/rd2html.rb: mod_ruby 対応 + * hiki/config.rb: Config クラス用ファイルを新設 + * hiki/global.rb: Config#default に移行したため消去 + * hikiconf.rb.sample, doc/INSTALL.txt, doc/VERSIONUP.txt: ドキュメ + ントの修正 + 2004-06-11 Kazuhiko - * misc/plugin/rss.rb: site_name, author_name をエスケープするように修正 - * misc/plugin/pagerank.rb, misc/plugin/rss.rb, misc/plugin/src.rb: CGI ヘッダの後に不要な改行の出力をしないように修正 + * misc/plugin/rss.rb: site_name, author_name をエスケープするよう + に修正 + * misc/plugin/pagerank.rb, misc/plugin/rss.rb, misc/plugin/src.rb: + CGI ヘッダの後に不要な改行の出力をしないように修正 2004-06-10 Kazuhiko * hiki/util.rb (save_config): エスケープして保存するように修正 diff --exclude=CVS -uNr hiki/doc/INSTALL.txt hiki.new/doc/INSTALL.txt --- hiki/doc/INSTALL.txt 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/doc/INSTALL.txt 2004-06-15 23:10:49.000000000 +0900 @@ -63,9 +63,9 @@ !!hikiconf.rbの作成 次に、''hikiconf.rb.sample''を''hikiconf.rb''にリネームして、内容を書き換えます。これはRubyスクリプトとして、CGIに直接読み込まれます。(requireされます) -Hikiの主要な設定はCGI経由で行えるので、最低限書き換えるべきなのは最初に出てくる''$data_path''だけです。 +Hikiの主要な設定はCGI経由で行えるので、最低限書き換えるべきなのは最初に出てくる''@data_path''だけです。 - $data_path = '/home/foo/hiki/data' + @data_path = '/home/foo/hiki/data' ''hikiconf.rb''には、他にもいろいろな設定項目を記述できます。詳細については、''hikiconf.rb.sample''中のコメントを参照してください。 diff --exclude=CVS -uNr hiki/doc/VERSIONUP.txt hiki.new/doc/VERSIONUP.txt --- hiki/doc/VERSIONUP.txt 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/doc/VERSIONUP.txt 2004-06-15 23:10:49.000000000 +0900 @@ -1,7 +1,7 @@ !バージョンアップの方法 バージョンアップの方法は比較的簡単ですが、操作ミスなどで貴重なデータを -失わないようhikiconf.rbの$data_pathで指定したディレクトリ配下のファイルは +失わないようhikiconf.rbの@data_pathで指定したディレクトリ配下のファイルは どこかにバックアップしておいてください。 では、バージョンアップの手順を示します。 @@ -26,9 +26,9 @@ アーカイブ中のdata/text/TextFormattingRulesというファイルは書式の変更や 追加などで変更される可能性があります。このため、このファイルはhikiconf.rb -の$data_pathで指定したデータ格納用ディレクトリ配下へコピーします。 +の@data_pathで指定したデータ格納用ディレクトリ配下へコピーします。 -$data_pathに'/home/foo/hiki'が指定されているとすると、 +@data_pathに'/home/foo/hiki'が指定されているとすると、 $ cp data/text/TextFormattingRules /home/foo/hiki/text/ diff --exclude=CVS -uNr hiki/doc/rd+/README hiki.new/doc/rd+/README --- hiki/doc/rd+/README 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/doc/rd+/README 2004-06-15 23:10:49.000000000 +0900 @@ -15,17 +15,17 @@ (RDToolが必要とするライブラリもインストールしておく) (2) Hikiをインストールする(Hikiが必要とするライブラリもインストールしておく) (3) Hikiの動作確認 -(4) hikiconf.rbの$styleを以下のように変更する - $style = 'rd+' +(4) hikiconf.rbの@styleを以下のように変更する + @style = 'rd+' (5) rd+ styleの動作確認 == オプション RDスタイルでは以下のオプションを用意しています。hikiconf.rbに記述してください。 ---- $options['rd.header_depth'] +--- @options['rd.header_depth'] ヘッダの階層を指定できます。'='がh2に、'=='がh3にしたい場合は以下のようにします。 - $options['rd.header_depth'] = 2 + @options['rd.header_depth'] = 2 なお、デフォルトで'='がh1になります。タイトル表示部分もh1ですので表示上、バランスを調整するときに使いましょう。 diff --exclude=CVS -uNr hiki/hiki/aliaswiki.rb hiki.new/hiki/aliaswiki.rb --- hiki/hiki/aliaswiki.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/aliaswiki.rb 2004-06-15 23:10:49.000000000 +0900 @@ -9,8 +9,9 @@ attr_reader :aliaswiki_names - def initialize(db) + def initialize(db, conf) @db = db + @conf = conf @aliaswiki_names = Hash::new load_aliaswiki_names end @@ -26,7 +27,7 @@ private def load_aliaswiki_names - n = @db.load( $aliaswiki_name ) || '' + n = @db.load( @conf.aliaswiki_name ) || '' n.scan( ALIASWIKI_NAME_RE ) do |i| @aliaswiki_names[i[0]] = i[1] end diff --exclude=CVS -uNr hiki/hiki/command.rb hiki.new/hiki/command.rb --- hiki/hiki/command.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/hiki/command.rb 2004-06-15 23:34:14.000000000 +0900 @@ -7,9 +7,7 @@ require 'hiki/util' require 'hiki/plugin' require 'hiki/aliaswiki' -require "style/#{$style}/parser" require "hiki/hiki_formatter" -require "messages/#{$lang}" include Amrita include Hiki::Util @@ -17,10 +15,11 @@ module Hiki class Command - def initialize(cgi, db) + def initialize(cgi, db, conf) @db = db @params = cgi.params @cgi = cgi + @conf = conf @cmd = @params['c'][0] @p = case @params.keys.size when 0 @@ -34,12 +33,12 @@ @params['p'][0] ? @params['p'][0] : nil end end - @page = Hiki::Page::new( cgi ) - @aliaswiki = AliasWiki::new( @db ) + @page = Hiki::Page::new( cgi, @conf ) + @aliaswiki = AliasWiki::new( @db, @conf ) @p = @aliaswiki.original_name(@p).to_euc if @p - options = $options || Hash.new( '' ) + options = @conf.options || Hash.new( '' ) options['page'] = @p options['db'] = @db options['cgi'] = cgi @@ -47,7 +46,7 @@ options['command'] = @cmd ? @cmd : 'view' options['params'] = @params - @plugin = Plugin::new( options ) + @plugin = Plugin::new( options, @conf ) @db.plugin = @plugin load_plugin( @plugin ) @@ -76,7 +75,7 @@ begin send( "cmd_#{@cmd}" ) rescue NameError - if $use_plugin and @plugin.plugin_command.index(@cmd) and @plugin.respond_to?(@cmd) + if @conf.use_plugin and @plugin.plugin_command.index(@cmd) and @plugin.respond_to?(@cmd) @plugin.send( @cmd ) else raise #"undefined command #{@cmd}" @@ -92,25 +91,25 @@ private def template( cmd = @cmd ) - "#{$template_path }/#{$template[cmd]}" + "#{@conf.template_path }/#{@conf.template[cmd]}" end def themes - Dir::glob("#{$theme_path }/*/*.css".untaint).sort.collect {|t| File::basename(t, '.css')} + Dir::glob("#{@conf.theme_path }/*/*.css".untaint).sort.collect {|t| File::basename(t, '.css')} end def generate_page( data ) - data[:cgi_name] = $cgi_name + data[:cgi_name] = @conf.cgi_name data[:body_enter] = @body_enter @page.template = template @page.contents = data - data[:last_modified] = Time::now unless data[:last_modified] + data[:last_modified] = Time::now unless data[:last_modified] print @page.page( @plugin ) end def cmd_theme - $theme = @params['theme'][0] + @conf.theme = @params['theme'][0] @cmd = 'view' dispatch end @@ -131,11 +130,11 @@ html = nil text = @db.load( @p ) - parser = Parser::new + parser = Parser::new( @conf ) tokens = parser.parse( text ) - formatter = HikiFormatter::new( tokens, @db, @plugin ) + formatter = HikiFormatter::new( tokens, @db, @plugin, @conf ) contents, toc = formatter.to_s, formatter.toc - if $hilight_keys + if @conf.hilight_keys word = @params['key'][0] if word && word.size > 0 contents = hilighten(contents, word.unescape.split) @@ -145,8 +144,7 @@ @db.set_references( @p, formatter.references ) @db.increment_hitcount( @p ) ref = @db.get_references( @p ) - - data = Hiki::Util::get_common_data( @db, @plugin ) + data = Hiki::Util::get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) pg_title = @plugin.page_name(@p) @@ -193,7 +191,7 @@ %Q!#{@plugin.hiki_anchor(k.escape, display_text)}: #{format_date(f[k][:last_modified] )}#{msg_freeze_mark if f[k][:freeze]}! } - data = Hiki::Util::get_common_data( @db, @plugin ) + data = Hiki::Util::get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:title] = title( msg_index ) @@ -205,7 +203,7 @@ def cmd_recent list, last_modified = get_recent - data = Hiki::Util::get_common_data( @db, @plugin ) + data = Hiki::Util::get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:title] = title( msg_recent ) @@ -252,8 +250,8 @@ formatter = nil if @cmd == 'preview' - p = Hiki::Parser::new.parse( text.gsub(/\r\n/, "\n") ) - formatter = HikiFormatter.new( p, @db, @plugin ) + p = Hiki::Parser::new( @conf ).parse( text.gsub(/\r\n/, "\n") ) + formatter = HikiFormatter.new( p, @db, @plugin, @conf ) preview_text = formatter.to_s save_button = '' elsif @cmd == 'conflict' @@ -268,7 +266,7 @@ text = ( @db.load( page ) || '' ) unless text md5hex = @params['md5hex'][0] || @db.md5hex( page ) - data = Hiki::Util::get_common_data( @db, @plugin ) + data = Hiki::Util::get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) @plugin.text = text @@ -298,7 +296,7 @@ diff = @db.diff( @p ) differ = diff ? HikiFormatter::diff( diff, @db.load_backup(@p) || '' ) : msg_no_recent - data = Hiki::Util::get_common_data( @db, @plugin ) + data = Hiki::Util::get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:title] = title("#{@p.escapeHTML} #{msg_diff}") @@ -309,7 +307,7 @@ def cmd_save( page, text, md5hex ) pass_check = false if p = @params['password'][0] - pass_check = true if $password.size == 0 || p.crypt( $password ) == $password + pass_check = true if @conf.password.size == 0 || p.crypt( @conf.password ) == @conf.password end subject = '' @@ -351,7 +349,7 @@ end if text.size == 0 && pass_check - data = get_common_data( @db, @plugin ) + data = get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:title] = msg_delete @@ -368,12 +366,12 @@ word = @params['key'][0] if word && word.size > 0 total, l = @db.search(word) - if $hilight_keys - l.collect! {|p| @plugin.make_anchor("#{$cgi_name}?cmd=view&p=#{p[0].escape}&key=#{word.split.join('+').escape}", @plugin.page_name(p[0])) + " - #{p[1]}"} + if @conf.hilight_keys + l.collect! {|p| @plugin.make_anchor("#{@conf.cgi_name}?cmd=view&p=#{p[0].escape}&key=#{word.split.join('+').escape}", @plugin.page_name(p[0])) + " - #{p[1]}"} else l.collect! {|p| @plugin.hiki_anchor( p[0].escape, @plugin.page_name(p[0])) + " - #{p[1]}"} end - data = get_common_data( @db, @plugin ) + data = get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:cmd] = a( :value => 'search' ) @@ -390,7 +388,7 @@ data[:list] = nil end else - data = get_common_data( @db, @plugin ) + data = get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:cmd] = a( :value => 'search' ) data[:title] = title( msg_search ) @@ -409,9 +407,9 @@ p = @params['key'][0] if p @p = @aliaswiki.original_name(p).to_euc - if /^\./ =~ @p || @p.size > $max_name_size || @p.size == 0 + if /^\./ =~ @p || @p.size > @conf.max_name_size || @p.size == 0 @params['key'][0] = nil - cmd_create( msg_invalid_filename( $max_name_size) ) + cmd_create( msg_invalid_filename( @conf.max_name_size) ) return end @@ -425,7 +423,7 @@ cmd_edit( @p ) end else - data = get_common_data( @db, @plugin ) + data = get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:cmd] = a( :value => 'create' ) data[:title] = title( msg_create ) @@ -444,9 +442,9 @@ if @params['saveconf'][0] admin_save_config else - if $password.size > 0 + if @conf.password.size > 0 key = @params['key'][0] - if !key || (key && key.crypt( $password ) != $password) + if !key || (key && key.crypt( @conf.password ) != @conf.password) admin_enter_password return end @@ -456,42 +454,42 @@ end def admin_config( msg=nil ) - data = get_common_data( @db, @plugin ) + data = get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) - data[:site_name] = $site_name || '' - data[:author_name] = $author_name || '' - data[:mail] = $mail || '' + data[:site_name] = @conf.site_name || '' + data[:author_name] = @conf.author_name || '' + data[:mail] = @conf.mail || '' data[:msg] = msg - s = $mail_on_update ? :mail_on_update : :no_mail + s = @conf.mail_on_update ? :mail_on_update : :no_mail data[:mail_on_update] = msg_mail_on data[:no_mail] = msg_mail_off data[s] = a( :selected => "selected" ) - s = $use_sidebar ? :use_sidebar : :no_sidebar + s = @conf.use_sidebar ? :use_sidebar : :no_sidebar data[:use_sidebar] = msg_use data[:no_sidebar] = msg_unuse data[s] = a( :selected => "selected" ) - s = $auto_link ? :use_auto_link : :no_auto_link + s = @conf.auto_link ? :use_auto_link : :no_auto_link data[:use_auto_link] = msg_use data[:no_auto_link] = msg_unuse data[s] = a( :selected => "selected" ) data[:theme] = themes.collect! do |t| - if $theme == t + if @conf.theme == t a(:value => t, :selected => "selected") {t} else a(:value => t) {t} end end - data[:theme_url] = $theme_url - data[:theme_path] = $theme_path + data[:theme_url] = @conf.theme_url + data[:theme_path] = @conf.theme_path generate_page( data ) end def admin_enter_password - data = get_common_data( @db, @plugin ) + data = get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) data[:cmd] = a( :value => 'admin' ) @@ -506,38 +504,38 @@ end def admin_save_config - $site_name = @params['site_name'][0] - $author_name = @params['author_name'][0] - $mail = @params['mail'][0] + @conf.site_name = @params['site_name'][0] + @conf.author_name = @params['author_name'][0] + @conf.mail = @params['mail'][0] old_password = @params['old_password'][0] password1 = @params['password1'][0] password2 = @params['password2'][0] - $mail_on_update = @params['mail_on_update'][0] == "true" - $theme = @params['theme'][0] - $use_sidebar = @params['sidebar'][0] == "true" - $main_class = @params['main_class'][0] - $main_class = 'main' if $main_class == '' - $sidebar_class = @params['sidebar_class'][0] - $sidebar_class = 'sidebar' if $sidebar_class == '' - $auto_link = @params['auto_link'][0] == "true" - $theme_url = @params['theme_url'][0] - $theme_path = @params['theme_path'][0] + @conf.mail_on_update = @params['mail_on_update'][0] == "true" + @conf.theme = @params['theme'][0] + @conf.use_sidebar = @params['sidebar'][0] == "true" + @conf.main_class = @params['main_class'][0] + @conf.main_class = 'main' if @conf.main_class == '' + @conf.sidebar_class = @params['sidebar_class'][0] + @conf.sidebar_class = 'sidebar' if @conf.sidebar_class == '' + @conf.auto_link = @params['auto_link'][0] == "true" + @conf.theme_url = @params['theme_url'][0] + @conf.theme_path = @params['theme_path'][0] if password1.size > 0 - if ($password.size > 0 && old_password.crypt( $password ) != $password) || + if (@conf.password.size > 0 && old_password.crypt( @conf.password ) != @conf.password) || (password1 != password2) admin_config( msg_invalid_password ) return end salt = [rand(64),rand(64)].pack("C*").tr("\x00-\x3f","A-Za-z0-9./") - $password = password1.crypt( salt ) + @conf.password = password1.crypt( salt ) end - save_config + @conf.save_config admin_config( msg_save_config ) end def load_plugin( plugin ) - ["#{$plugin_path}/*.rb", "#{$plugin_path}/#{$lang}/*.rb"].each do |d| + ["#{@conf.plugin_path}/*.rb", "#{@conf.plugin_path}/#{@conf.lang}/*.rb"].each do |d| Dir::glob( d ).sort.each do |f| next unless test(?f, f.untaint) @@ -570,7 +568,7 @@ end def cmd_plugin(redirect_mode = true) - return unless $use_plugin + return unless @conf.use_plugin plugin = @params['plugin'][0] result = true diff --exclude=CVS -uNr hiki/hiki/config.rb hiki.new/hiki/config.rb --- hiki/hiki/config.rb 1970-01-01 09:00:00.000000000 +0900 +++ hiki.new/hiki/config.rb 2004-06-16 00:21:30.000000000 +0900 @@ -0,0 +1,115 @@ +# $Id: page.rb,v 1.4 2004/02/15 02:48:35 hitoshi Exp $ +# Copyright (C) 2004 Kazuhiko +# +# TADA Tadashi holds the copyright of Config class. + +HIKI_VERSION = '0.8-devel-20040615' + +module Hiki + PATH = "#{File::dirname(File::dirname(__FILE__))}" + + class Config + def initialize + load + default + load_cgi_conf + + instance_variables.each do |v| + v.sub!( /@/, '' ) + instance_eval( <<-SRC + def #{v} + @#{v} + end + def #{v}=(p) + @#{v} = p + end + SRC + ) + end + end + + def save_config + File::open(self.config_file, "w") do |f| + %w(site_name author_name mail theme password theme_url sidebar_class main_class theme_path mail_on_update use_sidebar auto_link).each do |c| + f.puts( %Q|@#{c} = #{self.send(c).inspect}| ) + end + end + end + + private + # loading hikiconf.rb in current directory + def load + @secure = true unless @secure + @options = {} + eval( File::open( "hikiconf.rb" ){|f| f.read }.untaint, binding, "(hikiconf.rb)", 1 ) + + @data_path += '/' if /\/$/ !~ @data_path + @index_page = '' unless @index_page + @use_plugin = false unless @use_plugin + @author_name = '' unless @author_name + @main_on_update = false unless @main_on_update + @use_sidebar = false unless @use_sidebar + @main_class = 'main' unless @main_class + @sidebar_class = 'sidebar' unless @sidebar_class + @style = 'default' unless @style + end + + # loading hiki.conf in @data_path. + def load_cgi_conf + raise 'No @data_path variable.' unless @data_path + raise 'Do not set @data_path as same as Hiki system directory.' if @data_path == "#{PATH}/" + + begin + eval( File::open( "#{@data_path}hiki.conf" ){|f| f.read }.untaint, binding, "(hiki.conf)", 1 ) + rescue IOError, Errno::ENOENT + end + end + + def default + @template_path = "#{PATH}/template/#{@lang}" + @plugin_path = "#{PATH}/plugin" + @config_file = "#{@data_path}/hiki.conf" + + @side_menu = 'SideMenu' + @interwiki_name = 'InterWikiName' + @aliaswiki_name = 'AliasWikiName' + @formatting_rule = 'TextFormattingRules' + + # 'flat file database' + @pages_path = "#{@data_path}/text" + @backup_path = "#{@data_path}/backup" + @info_db = "#{@data_path}/info.db" + + @template = {'view' => 'view.html', + 'index' => 'list.html', + 'edit' => 'edit.html', + 'recent' => 'list.html', + 'diff' => 'diff.html', + 'search' => 'form.html', + 'create' => 'form.html', + 'admin' => 'adminform.html', + 'save' => 'success.html', + 'password'=> 'form.html' + } + + @max_name_size = 50 + @password = '' + end + + def method_missing( *m ) + if m.length == 1 then + instance_eval( <<-SRC + def #{m[0]} + @#{m[0]} + end + def #{m[0]}=( p ) + @#{m[0]} = p + end + SRC + ) + end + nil + end + end +end + diff --exclude=CVS -uNr hiki/hiki/db/flatfile.rb hiki.new/hiki/db/flatfile.rb --- hiki/hiki/db/flatfile.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/hiki/db/flatfile.rb 2004-06-15 23:10:49.000000000 +0900 @@ -9,9 +9,10 @@ module Hiki class HikiDB < HikiDBBase - def initialize - create_infodb unless test(?e, $info_db) - @info = PTStore::new( $info_db ) + def initialize( conf ) + @conf = conf + create_infodb unless test(?e, @conf.info_db) + @info = PTStore::new( @conf.info_db ) end def store( page, text, md5 ) @@ -70,7 +71,7 @@ end def pages - Dir.glob( "#{$pages_path}/*" ).delete_if {|f| !test(?f, f.untaint)}.collect! {|f| + Dir.glob( "#{@conf.pages_path}/*" ).delete_if {|f| !test(?f, f.untaint)}.collect! {|f| File::basename( f ).unescape } end @@ -79,11 +80,11 @@ # info DB # ============== def create_infodb - @info = PTStore::new( $info_db ) + @info = PTStore::new( @conf.info_db ) @info.transaction do pages.each do |a| r = default - r[:last_modified] = File::mtime( "#{$pages_path}/#{a.escape}".untaint ) + r[:last_modified] = File::mtime( "#{@conf.pages_path}/#{a.escape}".untaint ) @info[a.escape] = r end end @@ -97,7 +98,7 @@ end def infodb_exist? - test( ?e, $info_db ) + test( ?e, @conf.info_db ) end def info( p ) @@ -213,11 +214,11 @@ end def textdir(s) - ( $pages_path + '/' + s.escape ).untaint + ( @conf.pages_path + '/' + s.escape ).untaint end def backupdir(s) - ( $backup_path + '/' + s.escape ).untaint + ( @conf.backup_path + '/' + s.escape ).untaint end end end diff --exclude=CVS -uNr hiki/hiki/global.rb hiki.new/hiki/global.rb --- hiki/hiki/global.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/global.rb 1970-01-01 09:00:00.000000000 +0900 @@ -1,31 +0,0 @@ -# $Id: global.rb,v 1.3 2004/02/15 02:48:35 hitoshi Exp $ -# Copyright (C) 2002-2003 TAKEUCHI Hitoshi - -$template_path = "#{$path}/template/#{$lang}" -$plugin_path = "#{$path}/plugin" -$config_file = "#{$data_path}/hiki.conf" - -$side_menu = 'SideMenu' -$interwiki_name = 'InterWikiName' -$aliaswiki_name = 'AliasWikiName' -$formatting_rule = 'TextFormattingRules' - -# 'flat file database' -$pages_path = "#{$data_path}/text" -$backup_path = "#{$data_path}/backup" -$info_db = "#{$data_path}/info.db" - -$template = {'view' => 'view.html', - 'index' => 'list.html', - 'edit' => 'edit.html', - 'recent' => 'list.html', - 'diff' => 'diff.html', - 'search' => 'form.html', - 'create' => 'form.html', - 'admin' => 'adminform.html', - 'save' => 'success.html', - 'password'=> 'form.html' - } - -$max_name_size = 50 -$password = '' diff --exclude=CVS -uNr hiki/hiki/hiki_formatter.rb hiki.new/hiki/hiki_formatter.rb --- hiki/hiki/hiki_formatter.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/hiki_formatter.rb 2004-06-15 23:10:49.000000000 +0900 @@ -2,8 +2,6 @@ # Copyright (C) 2003 TAKEUCHI Hitoshi module Hiki - require "style/#{$style}/html_formatter" - class HikiFormatter < HTMLFormatter def apply_tdiary_theme(html) section = '' diff --exclude=CVS -uNr hiki/hiki/interwiki.rb hiki.new/hiki/interwiki.rb --- hiki/hiki/interwiki.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/interwiki.rb 2004-06-15 23:10:49.000000000 +0900 @@ -10,8 +10,9 @@ attr_reader :interwiki_names - def initialize(db, plugin) + def initialize(db, plugin, conf) @db = db + @conf = conf @plugin = plugin @interwiki_names = Hash::new @@ -54,7 +55,7 @@ private def load_interwiki_names - n = @db.load( $interwiki_name ) || '' + n = @db.load( @conf.interwiki_name ) || '' n.scan( INTERWIKI_NAME_RE ) do |i| e = i.size > 2 ? i[2] : 'none' @interwiki_names[i[0]] = {:url => i[1], :encoding => e} diff --exclude=CVS -uNr hiki/hiki/page.rb hiki.new/hiki/page.rb --- hiki/hiki/page.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/page.rb 2004-06-15 23:10:49.000000000 +0900 @@ -7,8 +7,9 @@ class Page attr_accessor :template, :contents - def initialize(cgi) + def initialize(cgi, conf) @cgi = cgi + @conf = conf @template = nil @contents = nil end @@ -25,7 +26,7 @@ end def page( plugin ) - $title = @contents[:title] + plugin.title = @contents[:title] @contents[:header] = plugin.header_proc.sanitize @contents[:body_leave] = plugin.body_leave_proc.sanitize @contents[:footer] = plugin.footer_proc.sanitize @@ -38,11 +39,12 @@ # end header['Last-Modified'] = CGI::rfc1123_date(@contents[:last_modified]) header['type'] = 'text/html' - header['charset'] = $charset + header['charset'] = @conf.charset header['Content-Length'] = html.size.to_s - header['Content-Language'] = $lang + header['Content-Language'] = @conf.lang header['Pragma'] = 'no-cache' header['Cache-Control'] = 'no-cache' +#STDERR.puts header.inspect;exit response = @cgi.header(header) response += html if /HEAD/i !~ @cgi.request_method response diff --exclude=CVS -uNr hiki/hiki/parser.rb hiki.new/hiki/parser.rb --- hiki/hiki/parser.rb 2003-03-24 17:10:48.000000000 +0900 +++ hiki.new/hiki/parser.rb 2004-06-15 23:10:49.000000000 +0900 @@ -85,7 +85,7 @@ when /^\s(.*)/ @cur_stack.push( {:e => :pre, :s => $1} ) when /^#{PLUGIN}\s*$/ - if $use_plugin + if @conf.use_plugin @cur_stack.push( {:e => :plugin, :method => $1, :param => $2} ) else inline( line ) @@ -159,7 +159,7 @@ str = $' @cur_stack.push ( {:e => :reference, :href => href, :s => href} ) when PLUGIN_RE - if $use_plugin + if @conf.use_plugin @cur_stack.push( {:e => :inline_plugin, :method => $1, :param => $2} ) str = $' else diff --exclude=CVS -uNr hiki/hiki/plugin.rb hiki.new/hiki/plugin.rb --- hiki/hiki/plugin.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/plugin.rb 2004-06-15 23:10:49.000000000 +0900 @@ -7,46 +7,13 @@ require 'hiki/util' module Hiki - class Config - def initialize - instance_variables.each do |v| - v.sub!( '@', '' ) - instance_eval( <<-SRC - def #{v} - @#{v} - end - def #{v}=(p) - @#{v} = p - end - SRC - ) - end - end - - def charset( mobile = false ) - case $lang - when 'en' - 'ISO-8859-1' - else - if mobile then - 'Shift_JIS' - else - 'EUC-JP' - end - end - end - - def mobile_agent? - %r[(DoCoMo|J-PHONE|UP\.Browser|ASTEL|PDXGW|Palmscape|Xiino|sharp pda browser|Windows CE|L-mode)]i =~ ENV['HTTP_USER_AGENT'] - end - end - class Plugin attr_reader :toc_f, :plugin_command - attr_accessor :text + attr_accessor :text, :title - def initialize( options ) + def initialize( options, conf ) @options = options + @conf = conf set_tdiary_env @plugin_method_list = [] @@ -85,7 +52,7 @@ end def update_proc - return unless $use_plugin + return unless @conf.use_plugin @update_procs.each do |proc| begin @@ -96,7 +63,7 @@ end def delete_proc - return unless $use_plugin + return unless @conf.use_plugin @delete_procs.each do |proc| begin @@ -107,7 +74,7 @@ end def body_enter_proc - return '' unless $use_plugin + return '' unless @conf.use_plugin r = [] @body_enter_procs.each do |proc| @@ -121,7 +88,7 @@ end def body_leave_proc - return '' unless $use_plugin + return '' unless @conf.use_plugin r = [] @body_leave_procs.each do |proc| @@ -135,7 +102,7 @@ end def page_attribute_proc - return '' unless $use_plugin + return '' unless @conf.use_plugin r = [] @page_attribute_procs.each do |proc| @@ -149,7 +116,7 @@ end def footer_proc -# return '' unless $use_plugin +# return '' unless @conf.use_plugin r = [] @footer_procs.each do |proc| @@ -163,7 +130,7 @@ end def edit_proc - return '' unless $use_plugin + return '' unless @conf.use_plugin r = [] @edit_procs.each do |proc| @@ -177,7 +144,7 @@ end def form_proc - return '' unless $use_plugin + return '' unless @conf.use_plugin r = [] @form_procs.each do |proc| @@ -191,7 +158,7 @@ end def menu_proc - return '' unless $use_plugin + return '' unless @conf.use_plugin r = [] @menu_procs.each do |proc| @@ -300,12 +267,12 @@ @date = Time::now @cookies = [] - @options['cache_path'] = $cache_path + @options['cache_path'] = @conf.cache_path @options['mode'] = "day" -# @options['author_name'] = $author_name || 'anonymous' -# @options['author_mail'] = $mail -# @options['index_page'] = $index_page -# @options['html_title'] = $site_name +# @options['author_name'] = @conf.author_name || 'anonymous' +# @options['author_mail'] = @conf.mail +# @options['index_page'] = @conf.index_page +# @options['html_title'] = @conf.site_name @options['years'] = {} @options['diaries'] = nil, @options['date'] = Time::now diff --exclude=CVS -uNr hiki/hiki/pluginutil.rb hiki.new/hiki/pluginutil.rb --- hiki/hiki/pluginutil.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/hiki/pluginutil.rb 2004-06-15 23:10:49.000000000 +0900 @@ -15,8 +15,8 @@ module Hiki module Util module_function - def apply_plugin(str, plugin) - return str unless $use_plugin + def apply_plugin(str, plugin, conf) + return str unless conf.use_plugin method, *args = methodwords(str) begin if plugin.respond_to?(method) && !Object.method_defined?(method) diff --exclude=CVS -uNr hiki/hiki/storage.rb hiki.new/hiki/storage.rb --- hiki/hiki/storage.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/hiki/storage.rb 2004-06-15 23:10:49.000000000 +0900 @@ -44,7 +44,7 @@ text = load(page) || '' unlink(page) begin - send_updating_mail(page, 'delete', text) if $mail_on_update + send_updating_mail(page, 'delete', text) if @conf.mail_on_update rescue end end diff --exclude=CVS -uNr hiki/hiki/util.rb hiki.new/hiki/util.rb --- hiki/hiki/util.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/hiki/util.rb 2004-06-15 23:10:49.000000000 +0900 @@ -6,8 +6,6 @@ require 'net/smtp' require 'amrita/template' require 'hiki/algorithm/diff' -require "style/#{$style}/parser" -require "hiki/hiki_formatter" class String def to_euc @@ -95,56 +93,40 @@ def plugin_error( method, e ) msg = "#{e.class}(#{e.message}): #{method.escapeHTML}
" - msg << "#{e.backtrace.join("
\n")}
" if $plugin_debug + msg << "#{e.backtrace.join("
\n")}
" if @conf.plugin_debug msg end - def save_config - File::open($config_file, "w") do |f| - %w($site_name $author_name $mail $theme $password $theme_url $sidebar_class $main_class $theme_path $mail_on_update $use_sidebar $auto_link).each do |c| - f.puts( %Q|#{c} = #{eval(c).inspect}| ) if c - end - end - end - - def load_config - begin - conf = File::readlines( $config_file ).join - eval( conf.untaint, binding, $config_file, 1 ) - rescue - end - end - def cmdstr( cmd, param ) "?c=#{cmd};#{param}" end def title( s ) - "#{$site_name.escapeHTML} - #{s}" + "#{@conf.site_name.escapeHTML} - #{s}" end def view_title( s ) - %Q!#{s.escapeHTML}! + %Q!#{s.escapeHTML}! end def format_date( tm ) tm.strftime(msg_time_format).sub(/#DAY#/, "(#{msg_day[tm.wday]})") end - def get_common_data( db, plugin ) + def get_common_data( db, plugin, conf ) data = Hash::new - $generator = "Hiki #{HIKI_VERSION}" - data[:author_name] = $author_name - data[:view_style] = $use_sidebar ? $main_class : 'hiki' # for tDiary theme - data[:cgi_name] = $cgi_name - if $use_sidebar - parser = Parser::new - m = db.load( $side_menu ) || '' + conf.generator = "Hiki #{HIKI_VERSION}" + data[:author_name] = conf.author_name + data[:view_style] = conf.use_sidebar ? conf.main_class : 'hiki' # for tDiary theme + data[:cgi_name] = conf.cgi_name + if conf.use_sidebar + parser = Parser::new( conf ) + m = db.load( conf.side_menu ) || '' t = parser.parse( m ) - f = HikiFormatter::new( t, db, plugin, 's' ) + f = HikiFormatter::new( t, db, plugin, conf, 's' ) data[:sidebar] = {:menu => f.to_s.sanitize} - data[:main_class] = $main_class - data[:sidebar_class] = $sidebar_class + data[:main_class] = conf.main_class + data[:sidebar_class] = conf.sidebar_class else data[:sidebar] = nil end @@ -175,11 +157,11 @@ end def sendmail(subject, body) - return unless $mail || $smtp_server - Net::SMTP.start($smtp_server, 25) {|smtp| - smtp.send_mail < 'text/plain' ) + else + print "Content-Type: text/plain\n\n" + end + puts "#$! (#{$!.class})\n" puts $@.join( "\n" ) end diff --exclude=CVS -uNr hiki/hikiconf.rb.sample hiki.new/hikiconf.rb.sample --- hiki/hikiconf.rb.sample 2004-06-11 23:49:36.000000000 +0900 +++ hiki.new/hikiconf.rb.sample 2004-06-15 23:10:49.000000000 +0900 @@ -11,19 +11,19 @@ # ディレクトリを指定します。 # このディレクトリの「全ファイル」と「全ディレクトリ」は、WWWサーバの # 権限で書き込めるパーミッションにしておく必要があります。 -$data_path = 'path to data' +@data_path = 'path to data' # トップページの URL【オプション】 # トップページのURLを指定します。 -$index_page = 'http://www.example.net/hiki/' +@index_page = 'http://www.example.net/hiki/' # メールサーバ名【オプション】 -# メールサーバ名を指定します。$mail_on_updateがtrueの場合に有効です。 -$smtp_server = 'localhost' +# メールサーバ名を指定します。@mail_on_updateがtrueの場合に有効です。 +@smtp_server = 'localhost' # プラグインを使うかどうかの指定【オプション】 # 使用する場合には true、使用しない場合は false を指定します。 -$use_plugin = true +@use_plugin = true #==================================================================== # 管理画面から変更できる項目 @@ -32,45 +32,45 @@ #==================================================================== # サイト名 # あなたのサイト名称を指定します。ページタイトルなどに表示されます。 -$site_name = 'hoge hoge' +@site_name = 'hoge hoge' # サイト管理者名 # サイト管理者の名前を指定します。フッタに表示されます。 -$author_name = '名無しさん' +@author_name = '名無しさん' # メール通知の有無 -# trueにするとページの更新時、$smtp_serverのサーバにより$mail宛に +# trueにするとページの更新時、@smtp_serverのサーバにより@mail宛に # 変更内容がメールで送信されます。 -$mail_on_update = false +@mail_on_update = false # 更新通知先メールアドレス # 更新内容を送信するメールアドレス -$mail = 'hoge@example.net' +@mail = 'hoge@example.net' # テーマ # 使用するテーマ -$theme = 'hiki' +@theme = 'hiki' # テーマのURL -$theme_url = 'theme' +@theme_url = 'theme' # テーマが存在するパス -$theme_path = 'theme' +@theme_path = 'theme' # サイドバー # サイドバーをサポートしていないテーマを使用する場合、 # falseを設定します。 -$use_sidebar = true +@use_sidebar = true # メインエリアのクラス名(CSS) # メインエリアのクラス名を設定します。 -$main_class = 'main' +@main_class = 'main' # サイドバーのクラス名(CSS) # サイドバーのクラス名を設定します。 -$sidebar_class = 'sidebar' +@sidebar_class = 'sidebar' # オートリンク # 既存ページ名の自動リンク機能を使用する場合には true を指定します。 -$auto_link = false +@auto_link = false #========================================= # 変更可能項目 @@ -78,33 +78,32 @@ # キャッシュディレクトリ【オプション】 # プラグインで使われるキャッシュ用のディレクトリを指定する -$cache_path = "#{$data_path}/cache" +@cache_path = "#{@data_path}/cache" # スタイル【オプション】 # デフォルト以外のスタイルを使いたい場合は、そのスタイル名を指定します。 # 現状 default と rd+ を指定することができます。 -$style = 'default' +@style = 'default' # 更新通知元メールアドレス【オプション】 # 更新通知メールの From に指定するアドレスです。 -#$mail_from = 'from@mail.address.hoge' +#@mail_from = 'from@mail.address.hoge' # キーワードハイライト【オプション】 -$hilight_keys = true +@hilight_keys = true -$charset = 'EUC-JP' -$lang = 'ja' -$database_type = 'flatfile' -$cgi_name = 'hiki.cgi' -$options = {} # この行は変更しないでください。 +@charset = 'EUC-JP' +@lang = 'ja' +@database_type = 'flatfile' +@cgi_name = 'hiki.cgi' +@options = {} # この行は変更しないでください。 # プラグインのデバッグ時に true にします。 -$plugin_debug = false +@plugin_debug = false # プラグインに渡すオプションを記述します 【オプション】 # プラグインによってはオプションを渡すことで挙動を変えることができます。 # 詳しくは各プラグインのドキュメントを参照してください。 # # 記述例 -# $options['amazon.aid'] = 'amazon-01' - +# @options['amazon.aid'] = 'amazon-01' diff --exclude=CVS -uNr hiki/misc/hikifarm/README hiki.new/misc/hikifarm/README --- hiki/misc/hikifarm/README 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/misc/hikifarm/README 2004-06-15 23:10:49.000000000 +0900 @@ -55,7 +55,7 @@ 「__my_wiki_name__」というキーワードが生成されたWikiサイト名に置き変わ るようになっているところがミソです。 -また、$mailに「Wiki名@hikifarm.quickml.com」が入っています。更新情報を +また、@mailに「Wiki名@hikifarm.quickml.com」が入っています。更新情報を [[QuickML|http://www.quickml.com/]]で配信するための設定です。必要に応 じて書き換えてください(配信無用ならnilにする)。 diff --exclude=CVS -uNr hiki/misc/hikifarm/hiki.conf hiki.new/misc/hikifarm/hiki.conf --- hiki/misc/hikifarm/hiki.conf 2004-06-11 23:49:25.000000000 +0900 +++ hiki.new/misc/hikifarm/hiki.conf 2004-06-15 23:10:49.000000000 +0900 @@ -1,32 +1,32 @@ -$data_path = "/home/foo/var/hiki/#{__my_wiki_name__}" -$index_page = "http://www.tada/#{__my_wiki_name__}/" -$repos_root = $cvsroot = (defined? repos_root) ? "#{repos_root}" : "#{cvsroot}" -$farm_page = "../" -$smtp_server = 'mail.example.com' -$use_plugin = true -$cache_path = "#{$data_path}/cache" -$site_name = "#{__my_wiki_name__}'s Wiki" -$author_name = '' -$mail_on_update = false -$mail = "#{__my_wiki_name__}@hikifarm.quickml.com" -$theme = 'hiki' -$theme_url = '../theme' -$theme_path = '../theme' -$use_sidebar = false -$main_class = 'main' -$sidebar_class = 'sidebar' -$auto_link = true -$hilight_keys = true +@data_path = "/home/foo/var/hiki/#{__my_wiki_name__}" +@index_page = "http://www.tada/#{__my_wiki_name__}/" +@repos_root = @cvsroot = (defined? repos_root) ? "#{repos_root}" : "#{cvsroot}" +@farm_page = "../" +@smtp_server = 'mail.example.com' +@use_plugin = true +@cache_path = "#{@data_path}/cache" +@site_name = "#{__my_wiki_name__}'s Wiki" +@author_name = '' +@mail_on_update = false +@mail = "#{__my_wiki_name__}@hikifarm.quickml.com" +@theme = 'hiki' +@theme_url = '../theme' +@theme_path = '../theme' +@use_sidebar = false +@main_class = 'main' +@sidebar_class = 'sidebar' +@auto_link = true +@hilight_keys = true -$style = 'default' -$mail_from = 'foo@example.com' +@style = 'default' +@mail_from = 'foo@example.com' -$charset = 'EUC-JP' -$lang = 'ja' -$database_type = 'flatfile' +@charset = 'EUC-JP' +@lang = 'ja' +@database_type = 'flatfile' -$cgi_name = './' +@cgi_name = './' -$plugin_debug = false +@plugin_debug = false -$options = {} # for tDiary plugin +@options = {} # for tDiary plugin diff --exclude=CVS -uNr hiki/misc/hikifarm/hikifarm.conf hiki.new/misc/hikifarm/hikifarm.conf --- hiki/misc/hikifarm/hikifarm.conf 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/misc/hikifarm/hikifarm.conf 2004-06-15 23:10:49.000000000 +0900 @@ -28,7 +28,7 @@ # HikiFarmのタイトルとCSS、管理者の名前とメール title = "HogeHogeWiki" -css = 'theme/default/default.css' +css = 'theme/hiki/hiki.css' author = 'ほげほげ' mail = 'foo@example.com' @@ -36,3 +36,6 @@ # ファイル名を指定する header = nil footer = nil + +# HikiのCGIファイル名 +cgi_name = index.rb diff --exclude=CVS -uNr hiki/misc/hikifarm/index.cgi hiki.new/misc/hikifarm/index.cgi --- hiki/misc/hikifarm/index.cgi 2004-06-11 23:49:06.000000000 +0900 +++ hiki.new/misc/hikifarm/index.cgi 2004-06-15 23:10:49.000000000 +0900 @@ -21,10 +21,12 @@ header = nil footer = nil +cgi_name = 'index.rb' + author = '' mail = '' -eval( open( 'hikifarm.conf' ){|f|f.read} ) +eval( open( 'hikifarm.conf' ){|f|f.read.untaint} ) @ruby = ruby @hiki = hiki @default_pages = default_pages @@ -63,15 +65,15 @@ #-------------------------------------------------------------------- -HIKIFARM_VERSION = '0.2.0' +HIKIFARM_VERSION = '0.3.0' def index( wiki ) <<-INDEX #!#{@ruby} hiki='' -eval( open( '../hikifarm.conf' ){|f|f.read} ) +eval( open( '../hikifarm.conf' ){|f|f.read.untaint} ) $:.unshift "\#{hiki}" -require 'hiki' +load "\#{hiki}/hiki.cgi" INDEX end @@ -88,9 +90,9 @@ def conf( wiki ) < /dev/null 2>&1" ) ensure - Dir.chdir( oldpwd ) + Dir.chdir( oldpwd.untaint ) end end def imported?( wiki ) @@ -152,7 +154,7 @@ Dir.chdir( '..' ) system( "cvs -d #{@root} co -d text #{wiki} > /dev/null 2>&1" ) ensure - Dir.chdir( oldpwd ) + Dir.chdir( oldpwd.untaint ) end end def update( wiki ) @@ -161,7 +163,7 @@ Dir.chdir( "#{@data_path}/#{wiki}/text" ) system( "cvs -d #{@root} update > /dev/null 2>&1" ) ensure - Dir.chdir( oldpwd ) + Dir.chdir( oldpwd.untaint ) end end end @@ -219,9 +221,9 @@ end end -def create_wiki( wiki, data_path ) - Dir.mkdir( wiki ) - File.open( "#{wiki}/index.cgi", 'w' ) do |f| +def create_wiki( wiki, hiki, cgi_name, data_path ) + Dir.mkdir( wiki.untaint ) + File.open( "#{wiki}/#{cgi_name}", 'w' ) do |f| f.puts( index( wiki ) ) f.chmod( 0744 ) end @@ -234,7 +236,7 @@ Dir.mkdir( "#{data_path}/#{wiki}/backup" ) Dir.mkdir( "#{data_path}/#{wiki}/cache" ) Dir["#{@default_pages}/*"].each do |file| - next unless File.file?( file ) + next unless File.file?( file.untaint ) File.open( file ) do |i| File.open( "#{data_path}/#{wiki}/text/#{File.basename file}", 'w' ) do |o| o.write( i.read ) @@ -249,7 +251,7 @@ r << %Q|Wiki の名前タイトル最終更新時刻| wikilist = [] Dir['*'].each do |wiki| - next unless FileTest::directory?( wiki ) + next unless FileTest::directory?( wiki.untaint ) next if FileTest::symlink?( wiki ) next unless FileTest::file?( "#{wiki}/hikiconf.rb" ) if not @repos.imported?( wiki ) then @@ -261,14 +263,14 @@ file = '' begin File::open( "#{data_path}/#{wiki}/hiki.conf" ) do |conf| - if /^\$site_name\s*=\s*"([^"]*)"$/ =~ conf.read then + if /^\@site_name\s*=\s*"([^"]*)"$/ =~ conf.read then title = $1 end end rescue title = "#{wiki}'s Wiki" end - Dir["#{data_path}/#{wiki}/text/*"].sort{ |a,b| File.mtime(a) <=> File.mtime(b) }.reverse.each do |f| + Dir["#{data_path}/#{wiki}/text/*"].sort{ |a,b| File.mtime(a.untaint) <=> File.mtime(b.untaint) }.reverse.each do |f| next if File.basename(f) == "CVS" || !File.size?(f) mtime = File.mtime(f) file = f.gsub(/.*\//, '') @@ -326,9 +328,9 @@ begin wiki = cgi.params['wiki'][0] raise '英数字のみ指定できます' unless /\A[a-zA-Z0-9]+\z/ =~ wiki - create_wiki( wiki, data_path ) + create_wiki( wiki, hiki, cgi_name, data_path ) rescue - msg = $!.to_s + msg = %Q|#{$!.to_s}\n#{$@.join("\n")}| end end @@ -381,7 +383,7 @@ #{footer_content if footer_content} diff --exclude=CVS -uNr hiki/misc/plugin/attach/attach.cgi hiki.new/misc/plugin/attach/attach.cgi --- hiki/misc/plugin/attach/attach.cgi 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/misc/plugin/attach/attach.cgi 2004-06-15 23:10:49.000000000 +0900 @@ -21,11 +21,11 @@ cache_path = "#{params['cache_path'][0].read}/attach" begin - Dir.mkdir(cache_path) unless test(?e, cache_path) + Dir.mkdir(cache_path) unless test(?e, cache_path.untaint) attach_path = "#{cache_path}/#{page}" Dir.mkdir(attach_path) unless test(?e, attach_path) - open("#{attach_path}/#{CGI.escape(NKF.nkf('-e', filename))}", "wb") do |f| + open("#{attach_path}/#{CGI.escape(NKF.nkf('-e', filename))}".untaint, "wb") do |f| f.print params['attach_file'][0].read end rescue Exception @@ -33,7 +33,7 @@ if params['refresh'][0] then url=params['refresh'][0].read else - url=$cgi_name + url='./' end redirect(cgi, "#{url}?c=#{command}&p=#{page}") end @@ -59,7 +59,7 @@ if params['refresh'][0] then url=params['refresh'][0].read else - url=$cgi_name + url='./' end redirect(cgi, "#{url}?c=#{command}&p=#{page}") end diff --exclude=CVS -uNr hiki/misc/plugin/attach/attach.rb hiki.new/misc/plugin/attach/attach.rb --- hiki/misc/plugin/attach/attach.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/misc/plugin/attach/attach.rb 2004-06-15 23:10:49.000000000 +0900 @@ -27,12 +27,12 @@ command = @command == 'create' ? 'edit' : @command < -
+
- +
@@ -65,19 +65,19 @@ def attach_anchor_string(string, file_name, page=@page) s = %Q!! + s << %Q!#{@conf.cgi_name}#{cmdstr('plugin', "plugin=attach_download;p=#{page.escape};file_name=#{file_name.escape}")}">! s << %Q!#{if string then string.escapeHTML else file_name.escapeHTML end}! end def attach_anchor(file_name, page=@page) s = %Q!! + s << %Q!#{@conf.cgi_name}#{cmdstr('plugin', "plugin=attach_download;p=#{page.escape};file_name=#{file_name.escape}")}">! s << %Q!#{file_name.escapeHTML}! end def attach_image_anchor(file_name, page=@page) s = %Q!#{file_name.escapeHTML}! + s << %Q!#{@conf.cgi_name}#{cmdstr('plugin', "plugin=attach_download;p=#{page.escape};file_name=#{file_name.escape}")}">! s << %Q!! end @@ -92,7 +92,7 @@ rescue end s = %Q!! end @@ -131,9 +131,11 @@ extname = /\.([^.]+)$/.match(file_name.downcase).to_a[1] mime_type = mime_types[extname] - print "Content-Type: #{mime_type}\n" - print "Last-Modified: #{CGI::rfc1123_date(File.mtime(attach_file.untaint))}\n" - print %Q!Content-Disposition: filename="#{file_name.to_sjis}"\n\n! + header = Hash::new + header['Content-Type'] = mime_type + header['Last-Modified'] = CGI::rfc1123_date(File.mtime(attach_file.untaint)) + header['Content-Disposition'] = %Q|filename="#{file_name.to_sjis}"| + print @cgi.header(header) print open(attach_file.untaint, "rb").read nil end @@ -142,7 +144,7 @@ tabstop = ' ' * (@options['attach.tabstop'] ? @options['attach.tabstop'].to_i : 2) if file_name =~ /\.(txt|rd|rb|c|pl|py|sh|java|html|htm|css|xml|xsl)\z/i - file = "#{$cache_path}/attach/#{page.escape}/#{file_name.escape}" + file = "#{@conf.cache_path}/attach/#{page.escape}/#{file_name.escape}" s = %Q!
!
     s << File::readlines(file).join.escapeHTML.gsub(/^\t+/) {|t| tabstop * t.size}.to_euc
     s << %Q!
! @@ -187,7 +189,7 @@ s << %Q!

#{attach_files_label}: \n! files.each do |file_name| f = file_name.unescape - case $charset + case @conf.charset when 'EUC-JP' f = file_name.unescape.to_euc when 'Shift_JIS' @@ -203,16 +205,16 @@ def attach_show_page_files_checkbox s = '' if (files = attach_page_files).size > 0 - s << %Q! + s << %Q! - +

#{attach_files_label}: ! files.each do |file_name| f = file_name.unescape - case $charset + case @conf.charset when 'EUC-JP' f = file_name.unescape.to_euc when 'Shift_JIS' diff --exclude=CVS -uNr hiki/misc/plugin/bbs.rb hiki.new/misc/plugin/bbs.rb --- hiki/misc/plugin/bbs.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/misc/plugin/bbs.rb 2004-06-15 23:10:49.000000000 +0900 @@ -29,7 +29,7 @@ def bbs @bbs_num += 1 < +

#{bbs_name_label}: #{bbs_subject_label}:
diff --exclude=CVS -uNr hiki/misc/plugin/comment.rb hiki.new/misc/plugin/comment.rb --- hiki/misc/plugin/comment.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/misc/plugin/comment.rb 2004-06-15 23:10:49.000000000 +0900 @@ -31,7 +31,7 @@ @comment_num += 1 < +
#{comment_name_label}: diff --exclude=CVS -uNr hiki/misc/plugin/cvs.rb hiki.new/misc/plugin/cvs.rb --- hiki/misc/plugin/cvs.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/misc/plugin/cvs.rb 2004-06-15 23:10:49.000000000 +0900 @@ -4,21 +4,21 @@ #===== update_proc add_update_proc { - cvs_commit if $repos_root + cvs_commit if @conf.repos_root } #===== delete_proc add_delete_proc { - cvs_delete if $repos_root + cvs_delete if @conf.repos_root } #----- cvs commit on updating def cvs_commit oldpwd = Dir.pwd.untaint begin - Dir.chdir( "#{$data_path}/text" ) - system( "cvs -d #{$repos_root} add -- #{@page.escape} > /dev/null 2>&1".untaint ) - system( "cvs -d #{$repos_root} ci -m '#{ENV['REMOTE_ADDR']} - #{ENV['REMOTE_HOST']}' > /dev/null 2>&1".untaint ) + Dir.chdir( "#{@conf.data_path}/text" ) + system( "cvs -d #{@conf.repos_root} add -- #{@page.escape} > /dev/null 2>&1".untaint ) + system( "cvs -d #{@conf.repos_root} ci -m '#{ENV['REMOTE_ADDR']} - #{ENV['REMOTE_HOST']}' > /dev/null 2>&1".untaint ) ensure Dir.chdir( oldpwd ) end @@ -28,9 +28,9 @@ def cvs_delete oldpwd = Dir.pwd.untaint begin - Dir.chdir( "#{$data_path}/text" ) - system( "cvs -d #{$repos_root} remove -- #{@page.escape} > /dev/null 2>&1".untaint ) - system( "cvs -d #{$repos_root} ci -m '#{ENV['REMOTE_ADDR']} - #{ENV['REMOTE_HOST']}' > /dev/null 2>&1".untaint ) + Dir.chdir( "#{@conf.data_path}/text" ) + system( "cvs -d #{@conf.repos_root} remove -- #{@page.escape} > /dev/null 2>&1".untaint ) + system( "cvs -d #{@conf.repos_root} ci -m '#{ENV['REMOTE_ADDR']} - #{ENV['REMOTE_HOST']}' > /dev/null 2>&1".untaint ) ensure Dir.chdir( oldpwd ) end diff --exclude=CVS -uNr hiki/misc/plugin/history.rb hiki.new/misc/plugin/history.rb --- hiki/misc/plugin/history.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/misc/plugin/history.rb 2004-06-15 23:10:49.000000000 +0900 @@ -23,8 +23,8 @@ * history_src あるリビジョンのソースを表示 * history_diff 任意のリビジョン間の差分を表示 実際には、 - $cgi_name?c=history;p=FrontPage や - $cgi_name?c=plugin;plugin=history_diff;p=FrontPage;r=2 + @conf.cgi_name?c=history;p=FrontPage や + @conf.cgi_name?c=plugin;plugin=history_diff;p=FrontPage;r=2 のように使用します。 * 履歴にはブランチ等が現れないことを前提にしています。 @@ -38,7 +38,7 @@ === notice Hikifarmを使用している場合、hiki.confに -$repos_type = (defined? repos_type) ? "#{repos_type}" : nil +@conf.repos_type = (defined? repos_type) ? "#{repos_type}" : nil を追加してください。-- Yas CSSでspan.add_line, span.del_lineを設定すると、変更箇所の文字属性を変更できます。 @@ -57,22 +57,22 @@ end def history - h = Hiki::History::new(@cgi, @db) + h = Hiki::History::new(@cgi, @db, @conf) h.history end def history_src - h = Hiki::History::new(@cgi, @db) + h = Hiki::History::new(@cgi, @db, @conf) h.history_src end def history_diff - h = Hiki::History::new(@cgi, @db) + h = Hiki::History::new(@cgi, @db, @conf) h.history_diff end add_body_enter_proc(Proc.new do - if $repos_root then + if @conf.repos_root then add_plugin_command('history', history_label, {'p' => true}) else '' @@ -84,11 +84,11 @@ private def history_repos_type - $repos_type # 'cvs' or 'svn' + @conf.repos_type # 'cvs' or 'svn' end def history_repos_root - $repos_root # hiki.conf + @conf.repos_root # hiki.conf end def history_label @@ -125,7 +125,7 @@ cmdlog = '' oldpwd = Dir.pwd.untaint begin - Dir.chdir( "#{$pages_path}" ) + Dir.chdir( "#{@conf.pages_path}" ) # うーん... まあとりあえず。 cmdlog = `#{cmd_string.untaint}` ensure @@ -137,11 +137,11 @@ # Subroutine to output proper HTML for Hiki. def history_output (s) # Imported codes from hiki/command.rb::cmd_view() - parser = Parser::new + parser = Parser::new( @conf ) tokens = parser.parse( s ) - formatter = HikiFormatter::new( tokens, @db, @plugin ) - @page = Page::new( @cgi ) - data = Util::get_common_data( @db, @plugin ) + formatter = HikiFormatter::new( tokens, @db, @plugin, @conf ) + @page = Page::new( @cgi, @conf ) + data = Util::get_common_data( @db, @plugin, @conf ) @plugin.hiki_menu(data, @cmd) pg_title = @plugin.page_name(@p) data[:title] = title( "#{pg_title} - #{history_label}") @@ -205,17 +205,17 @@ sources << " #{history_th_label[0].escapeHTML}#{history_th_label[1].escapeHTML}#{history_th_label[2].escapeHTML}#{history_th_label[3].escapeHTML}#{history_th_label[4].escapeHTML}\n" revisions.each do |rev,time,changes,log| # time << " GMT" - op = "[View this version] " + op = "[View this version] " op << "[Diff to " case history_repos_type when 'cvs' - op << "current" unless revisions.size == rev + op << "current" unless revisions.size == rev op << " | " unless (revisions.size == rev || rev == 1) - op << "previous" unless rev == 1 + op << "previous" unless rev == 1 when 'svn' - op << "current" unless prevdiff == 1 + op << "current" unless prevdiff == 1 op << " | " unless (prevdiff == 1 || prevdiff >= diffrevs.size) - op << "previous" unless prevdiff >= diffrevs.size + op << "previous" unless prevdiff >= diffrevs.size end op << "]" log.gsub!(/=============================================================================/, '') @@ -255,8 +255,8 @@ # construct output sources sources = '' sources << "\n" sources << "
\n"
       sources << cmdlog.escapeHTML
@@ -295,7 +295,7 @@
       # construct output sources
       sources = ''
       sources << "\n
\n" sources << "#{history_add_line_label.escapeHTML}
\n" sources << "#{history_delete_line_label.escapeHTML}
\n" diff --exclude=CVS -uNr hiki/misc/plugin/local_css.rb hiki.new/misc/plugin/local_css.rb --- hiki/misc/plugin/local_css.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/misc/plugin/local_css.rb 2004-06-15 23:10:49.000000000 +0900 @@ -10,16 +10,16 @@ The local stylesheet is loaded after the original and can overwrite CSS properties. !Options -!!$options['local.css'] +!!@conf.options['local.css'] Local stylesheet to be read. Default: 'local.css' EOS end add_header_proc { - local_css = $options['local.css'] || 'local.css' + local_css = @conf.options['local.css'] || 'local.css' local_theme_url = theme_url.sub(/(.*\/).*\.css$/, "\\1#{local_css}") <<-EOS - + EOS } diff --exclude=CVS -uNr hiki/misc/plugin/pagerank.rb hiki.new/misc/plugin/pagerank.rb --- hiki/misc/plugin/pagerank.rb 2004-06-11 02:13:18.000000000 +0900 +++ hiki.new/misc/plugin/pagerank.rb 2004-06-15 23:10:49.000000000 +0900 @@ -21,7 +21,7 @@ # PageRank table: default "%2.6f" # # @options["pagerank.pagetitle"]: string -# PageRank page title: default "PageRank: #{$site_name}" +# PageRank page title: default "PageRank: #{@conf.site_name}" # # @options["pagerank.showfrom"]: true or false # show "linked from" column if true: default true @@ -41,13 +41,13 @@ def PageRank.menu_label 'PageRank' end -def PageRank.default_options +def PageRank.default_options( conf ) { "pagerank.algorithm" => "google-original", "pagerank.dvalue" => 0.85, "pagerank.tablealign" => "left", "pagerank.rankformat" => "%2.6f", - "pagerank.pagetitle" => "PageRank: #{$site_name}", + "pagerank.pagetitle" => "PageRank: #{conf.site_name}", "pagerank.showfrom" => true, "pagerank.maxpages" => nil, "pagerank.showtime" => false, @@ -324,15 +324,15 @@ header = Hash::new header['Last-Modified'] = CGI::rfc1123_date(Time.now) header['type'] = 'text/html' - header['charset'] = $charset - header['Content-Language'] = $lang + header['charset'] = @conf.charset + header['Content-Language'] = @conf.lang header['Pragma'] = 'no-cache' header['Cache-Control'] = 'no-cache' print @cgi.header(header) - options = PageRank.default_options + options = PageRank.default_options( @conf ) options.update(@options) - stylesheet = $theme_url + "/" + $theme + "/" + $theme + ".css" + stylesheet = @conf.theme_url + "/" + @conf.theme + "/" + @conf.theme + ".css" align = options["pagerank.tablealign"] title = options["pagerank.pagetitle"] @@ -365,7 +365,7 @@ # print pagerank table def pagerank(pagerank_options = @options) - options = PageRank.default_options + options = PageRank.default_options( @conf ) options.update(pagerank_options) pr = PageRank.new page_names = @db.pages diff --exclude=CVS -uNr hiki/misc/plugin/rss.rb hiki.new/misc/plugin/rss.rb --- hiki/misc/plugin/rss.rb 2004-06-11 23:49:37.000000000 +0900 +++ hiki.new/misc/plugin/rss.rb 2004-06-15 23:10:49.000000000 +0900 @@ -18,14 +18,14 @@ last_modified = pages[0].values[0][:last_modified] items = < + - - #{CGI::escapeHTML($site_name)} : #{rss_recent_label} - #{$index_page}?c=recent - #{CGI::escapeHTML($site_name)} #{rss_recent_label} + + #{CGI::escapeHTML(@conf.site_name)} : #{rss_recent_label} + #{@conf.index_page}?c=recent + #{CGI::escapeHTML(@conf.site_name)} #{rss_recent_label} ja - Copyright (C) #{CGI::escapeHTML($author_name)} + Copyright (C) #{CGI::escapeHTML(@conf.author_name)} #{last_modified.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")} @@ -36,8 +36,8 @@ name = p.keys[0] items << ' ' - uri = "#{$index_page}?#{name.escape}" - items << %Q!! + uri = "#{@conf.index_page}?#{name.escape}" + items << %Q!\n! item_list << < @@ -59,8 +59,8 @@ header = Hash::new header['Last-Modified'] = CGI::rfc1123_date(last_modified) header['type'] = 'text/xml' - header['charset'] = $charset - header['Content-Language'] = $lang + header['charset'] = @conf.charset + header['Content-Language'] = @conf.lang header['Pragma'] = 'no-cache' header['Cache-Control'] = 'no-cache' print @cgi.header(header) diff --exclude=CVS -uNr hiki/misc/plugin/search.rb hiki.new/misc/plugin/search.rb --- hiki/misc/plugin/search.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/misc/plugin/search.rb 2004-06-15 23:10:49.000000000 +0900 @@ -13,7 +13,7 @@ def search < + #{search_key_label}:
diff --exclude=CVS -uNr hiki/misc/plugin/src.rb hiki.new/misc/plugin/src.rb --- hiki/misc/plugin/src.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/misc/plugin/src.rb 2004-06-15 23:10:49.000000000 +0900 @@ -31,7 +31,7 @@ header['Last-Modified'] = CGI::rfc1123_date(Time.now) header['type'] = 'text/html' header['charset'] = 'EUC-jp' - header['Content-Language'] = $lang + header['Content-Language'] = @conf.lang header['Pragma'] = 'no-cache' header['Cache-Control'] = 'no-cache' print @cgi.header(header) diff --exclude=CVS -uNr hiki/misc/plugin/svn.rb hiki.new/misc/plugin/svn.rb --- hiki/misc/plugin/svn.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/misc/plugin/svn.rb 2004-06-15 23:10:49.000000000 +0900 @@ -5,19 +5,19 @@ #===== update_proc add_update_proc { - svn_commit if $repos_root + svn_commit if @conf.repos_root } #===== delete_proc add_delete_proc { - svn_delete if $repos_root + svn_delete if @conf.repos_root } #----- Subversion commit on updating def svn_commit oldpwd = Dir.pwd.untaint begin - Dir.chdir( "#{$data_path}/text" ) + Dir.chdir( "#{@conf.data_path}/text" ) system( "svn add -- #{@page.escape} > /dev/null 2>&1".untaint ) system( "svn propdel svn:mime-type -- #{@page.escape} > /dev/null 2>&1".untaint ) system( "svn ci -m '#{ENV['REMOTE_ADDR']} - #{ENV['REMOTE_HOST']}' > /dev/null 2>&1".untaint ) @@ -30,7 +30,7 @@ def svn_delete oldpwd = Dir.pwd.untaint begin - Dir.chdir( "#{$data_path}/text" ) + Dir.chdir( "#{@conf.data_path}/text" ) system( "svn remove -- #{@page.escape} > /dev/null 2>&1".untaint ) system( "svn ci -m '#{ENV['REMOTE_ADDR']} - #{ENV['REMOTE_HOST']}' > /dev/null 2>&1".untaint ) ensure diff --exclude=CVS -uNr hiki/plugin/00default.rb hiki.new/plugin/00default.rb --- hiki/plugin/00default.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/plugin/00default.rb 2004-06-15 23:10:49.000000000 +0900 @@ -20,12 +20,12 @@ #============================== #===== hiki_url def hiki_url(page) - "#{$cgi_name}?#{page.escape}" + "#{@conf.cgi_name}?#{page.escape}" end #===== hiki_anchor def hiki_anchor( page, display_text ) - make_anchor("#{$cgi_name}?#{page}", display_text) + make_anchor("#{@conf.cgi_name}?#{page}", display_text) end #===== make_anchor @@ -79,7 +79,7 @@ #===== update_proc add_update_proc { - updating_mail if $mail_on_update + updating_mail if @conf.mail_on_update } #----- send a mail on updating @@ -103,10 +103,10 @@ def hiki_header s = < - - - #{$title} + + + + #{title} EOS @@ -127,9 +127,9 @@ def hiki_footer <Hiki #{HIKI_VERSION}.
-Powered by Ruby #{RUBY_VERSION} and +Powered by Ruby #{RUBY_VERSION}#{if /ruby/i =~ ENV['GATEWAY_INTERFACE'] then ' with mod_ruby' end} and Amrita.
-Founded by #{$author_name.escapeHTML}.
+Founded by #{@conf.author_name.escapeHTML}.
EOS end @@ -143,16 +143,16 @@ menu = [] editable = %w(view edit diff) - menu << %Q!#{msg_create}! - menu << %Q!#{msg_edit}! if editable.index(command) && @page - menu << %Q!#{msg_diff}! if editable.index(command) && @page + menu << %Q!#{msg_create}! + menu << %Q!#{msg_edit}! if editable.index(command) && @page + menu << %Q!#{msg_diff}! if editable.index(command) && @page menu << %Q!#{hiki_anchor( 'FrontPage', page_name('FrontPage') )}! - menu << %Q!#{msg_index}! - menu << %Q!#{msg_search}! - menu << %Q!#{msg_recent_changes}! + menu << %Q!#{msg_index}! + menu << %Q!#{msg_search}! + menu << %Q!#{msg_recent_changes}! @plugin_menu.each do |c| next if c[:option].has_key?('p') && !editable.index(command) - cmd = %Q!#{msg_admin}! + menu << %Q!#{msg_admin}! data[:tools] = menu.collect! {|i| %Q!#{i}! }.join(" \n").sanitize end diff --exclude=CVS -uNr hiki/style/default/html_formatter.rb hiki.new/style/default/html_formatter.rb --- hiki/style/default/html_formatter.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/style/default/html_formatter.rb 2004-06-15 23:10:49.000000000 +0900 @@ -51,17 +51,18 @@ MAP[:table_data_open] = '' MAP[:table_data_close] = '' - def initialize( s, db, plugin, suffix = 'l') + def initialize( s, db, plugin, conf, suffix = 'l') @tokens = s @db = db @plugin = plugin + @conf = conf @suffix = suffix @toc_cnt = 0 @toc = Array::new @references = Array::new - @interwiki = InterWiki::new( @db, plugin ) - @aliaswiki = AliasWiki::new( @db ) - @auto_links = get_auto_links if $auto_link + @interwiki = InterWiki::new( @db, plugin, @conf ) + @aliaswiki = AliasWiki::new( @db, @conf ) + @auto_links = get_auto_links if @conf.auto_link end def HTMLFormatter::diff( d, src ) @@ -102,7 +103,7 @@ end def flush_normal_text(text, pre) - if not pre and $auto_link + if not pre and @conf.auto_link auto_link(text) else text @@ -143,7 +144,7 @@ @references << t[:href] else missing_anchor_title = msg_missing_anchor_title % [ disp.escapeHTML ] - outer_alias = @interwiki.outer_alias(t[:href]) || "#{disp.escapeHTML}?" + outer_alias = @interwiki.outer_alias(t[:href]) || "#{disp.escapeHTML}?" html << outer_alias end toc_title << t[:href] if toc_level > 0 @@ -169,7 +170,7 @@ html << s end rescue Exception => e - if $plugin_debug + if @conf.plugin_debug html << e.message else html << plugin_error( t[:method], $! ) @@ -286,7 +287,7 @@ end def call_plugin_method( t ) - return nil unless $use_plugin + return nil unless @conf.use_plugin method = t[:method] args = nil diff --exclude=CVS -uNr hiki/style/default/parser.rb hiki.new/style/default/parser.rb --- hiki/style/default/parser.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/style/default/parser.rb 2004-06-15 23:10:49.000000000 +0900 @@ -51,7 +51,8 @@ TABLE_RE = /^#{TABLE}/ DEFLIST_RE = /#{DEFLIST}/ - def initialize + def initialize( conf ) + @conf = conf @stack = HikiStack::new @cur_stack = HikiStack::new @last_blocktype = [] @@ -182,7 +183,7 @@ str = $' @cur_stack.push( {:e => :reference, :href => href, :s => href} ) when PLUGIN_RE - if $use_plugin + if @conf.use_plugin @cur_stack.push( {:e => :inline_plugin, :method => $1, :param => $2} ) str = $' else diff --exclude=CVS -uNr hiki/style/rd+/html_formatter.rb hiki.new/style/rd+/html_formatter.rb --- hiki/style/rd+/html_formatter.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/style/rd+/html_formatter.rb 2004-06-15 23:10:49.000000000 +0900 @@ -16,12 +16,13 @@ module Hiki class HTMLFormatter - def initialize( s, db, plugin, suffix = 'l') + def initialize( s, db, plugin, conf, suffix = 'l') @tokens = s @db = db @plugin = plugin - @interwiki = InterWiki::new(@db, @plugin) - @visitor = Hiki::RD2HTMLVisitor.new(@plugin, @db) + @conf = conf + @interwiki = InterWiki::new(@db, @plugin, @conf) + @visitor = Hiki::RD2HTMLVisitor.new(@plugin, @db, @conf) end def HTMLFormatter::diff( d, src ) diff --exclude=CVS -uNr hiki/style/rd+/parser.rb hiki.new/style/rd+/parser.rb --- hiki/style/rd+/parser.rb 2004-02-15 11:48:35.000000000 +0900 +++ hiki.new/style/rd+/parser.rb 2004-06-15 23:10:49.000000000 +0900 @@ -10,6 +10,9 @@ module Hiki class Parser + def initialize( conf ) + end + def parse(s) begin RD::RDTree.new("=begin\n#{s}\n=end\n\n") diff --exclude=CVS -uNr hiki/style/rd+/rd2html.rb hiki.new/style/rd+/rd2html.rb --- hiki/style/rd+/rd2html.rb 2004-06-11 23:49:38.000000000 +0900 +++ hiki.new/style/rd+/rd2html.rb 2004-06-15 23:10:49.000000000 +0900 @@ -27,11 +27,12 @@ ESC_WORD = '_h_i-k-i_' ESC_WORD_RE = /#{ESC_WORD}/ - def initialize(plugin, db) + def initialize(plugin, db, conf) super() @title = "Untitled" @plugin = plugin @db = db + @conf = conf @references = Array.new @regex = nil @toc = [] @@ -44,7 +45,7 @@ end #InterWikiName - @anchorlist = AnchorList.new(@db.load($interwiki_name), plugin) + @anchorlist = AnchorList.new(@db.load(@conf.interwiki_name), plugin) end def get_anchor(element) @@ -78,11 +79,11 @@ method = $1 ret = '' begin - ret = Hiki::Util.apply_plugin(method, @plugin) + ret = Hiki::Util.apply_plugin(method, @plugin, @conf) ret.gsub!(@regex_modulenames, "\\&#{ESC_WORD}") if @regex_modulenames rescue Exception err = "Plugin Error: #{$!}" #
#{match.to_s.escapeHTML}
" - if $plugin_debug + if @conf.plugin_debug err += "

Back trace

"
             $!.backtrace.each do |v|
               err += v + "\n"
@@ -149,7 +150,7 @@
                 ret = @plugin.hiki_anchor(target, name)
               end
             else
-              ret = %Q[#{name}?]
+              ret = %Q[#{name}?]
             end
             ret
           else
@@ -177,7 +178,7 @@
       label = hyphen_escape(element.label)
       @toc.push({'level' => element.level, 'index' => anchor, 'title' => title})
       depth = element.level
-      depth += $options['rd.header_depth'] - 1 if $options['rd.header_depth']
+      depth += @conf.options['rd.header_depth'] - 1 if @conf.options['rd.header_depth']
       %Q[#{a_name_href(anchor, title)}] +
       %Q[]
     end
@@ -254,7 +255,7 @@
             label.gsub!(@regex_modulenames, "\\&#{ESC_WORD}")
           end
           escaped = label.escape
-          content + %Q[?]
+          content + %Q[?]
         end
       end
     end