> ERbが $SAFE に対応できたので、shttpsrv-1.04 を改造して > eRuby ファイル対応にしてみました。 > 近いうちにパッチを出します。 > # eRuby ファイルの拡張子はなんとすれば良いのでしょう? .rhtml?? shttpsrv-1.04 を ERb を扱えるようにするパッチです。 ファイル名が foo.rhtml, foo.rht のときに ERb を使って 文書を生成します。 また、erb.rb 本体も if __FILE__ == $0 の部分を少し修正しました。 ERb クラス自体に変更はありません。 → http://www2a.biglobe.ne.jp/%7Eseki/ruby/erb.rb 咳 -- -- -- Index: shttpsrv.rb =================================================================== RCS file: /home/mas/lib/cvsroot/shttpsrv/shttpsrv.rb,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 shttpsrv.rb *** shttpsrv.rb 1998/11/28 15:06:53 1.1.1.1 --- shttpsrv.rb 1999/03/19 15:22:13 *************** *** 10,15 **** --- 10,16 ---- require "socket" require "base64.rb" require "getopts.rb" + require "erb.rb" def usage(msg = nil) print "ERROR: #{msg}\n" if msg *************** *** 126,132 **** Sdir = Dir.pwd MimeTypes = { ! /^(s?html?|sht)$/i => ['text', 'html'], /^sgml?$/i => ['text', 'x-sgml'], /^(jpg|jpeg|tif|gif)$/i => ['image', '---'], /^xbm$/i => ['image', 'x-xbitmap'], --- 127,133 ---- Sdir = Dir.pwd MimeTypes = { ! /^([sr]?html?|[sr]ht)$/i => ['text', 'html'], /^sgml?$/i => ['text', 'x-sgml'], /^(jpg|jpeg|tif|gif)$/i => ['image', '---'], /^xbm$/i => ['image', 'x-xbitmap'], *************** *** 225,231 **** def ssi?(fname) return nil unless defined? SSIhtml ! SSIhtml.each do |ext| if fname =~ /#{Regexp.quote(ext)}$/i return TRUE end --- 226,242 ---- def ssi?(fname) return nil unless defined? SSIhtml ! SSIhtml.each do |ext| ! if fname =~ /#{Regexp.quote(ext)}$/i ! return TRUE ! end ! end ! nil ! end ! ! def erb?(fname) ! return nil unless defined? ERBhtml ! ERBhtml.each do |ext| if fname =~ /#{Regexp.quote(ext)}$/i return TRUE end *************** *** 738,750 **** ctype, stype = mtype(fname) fstat = File.stat(fname) mtime = strdate(fstat.mtime) ! if !@if_modified || @if_modified < fstat.mtime || ssi?(fname) ####################### File is newer.####################### h = open(fname, "r") h.binmode body = h.read if ssi?(fname) parse_html(body, fname) end h.close --- 749,763 ---- ctype, stype = mtype(fname) fstat = File.stat(fname) mtime = strdate(fstat.mtime) ! if !@if_modified || @if_modified < fstat.mtime || ssi?(fname) || erb?(fname) ####################### File is newer.####################### h = open(fname, "r") h.binmode body = h.read if ssi?(fname) parse_html(body, fname) + elsif erb?(fname) + body = ERb.new(body, 4).result end h.close Index: conf.rb =================================================================== RCS file: /home/mas/lib/cvsroot/shttpsrv/conf.rb,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 conf.rb *** conf.rb 1998/11/28 15:06:53 1.1.1.1 --- conf.rb 1999/03/19 15:23:31 *************** *** 44,49 **** --- 44,52 ---- # set file extensions for server-side includes SSIhtml = [".shtml", ".sht"] + # set file extensions for eRuby + ERBhtml = [".rhtml", ".rht"] + # recommend authentication for access to directories and files # format : "<dir>" => [ "<title>", "Username:Password" ] LimitDir = {