=======================================================2005-08-30(Tue)
10:31	back
23:31	back.

----------------------------------------------------------------------
input type submit 


----------------------------------------------------------------------
#      div = [:div, {:class=>"wema", :id=>"wysiwyg_toolbar",
#	  :style=>"right:0px; top:20px;"}]
#      div << [:div, {:class=>"menubar"},
#	[:span, {:class=>"handle"}, "handle"],
#	[:span, {:class=>"close"}, " "]] # noop

----------------------------------------------------------------------
http://colinux:9190/HelloQwik/ActTheme.html
* e[}
* e[}I@\
I\ȃe[}ꗗ\܂B
 {{theme_list}}
{{theme_list}}

----------------------------------------------------------------------
      #bogus_char = "\xa0"
      #html.gsub!(bogus_char, "")
      #html = html.gsub(/\xa0/s, "")
     #ar << WysiwygGenerator.warning
      #div = plg_event

----------------------------------------------------------------------
  def attributes_str
    attr = get_attr
    hash_to_str(attr)
  end

  private

  def hash_to_str(src)
    h = {}
    src.each {|k, v|
      next if v.nil?
      h[k.to_s] = v.to_s
    }
    h
  end

      # test_hash_to_str
      t_make_public(Array, :hash_to_str)
      ok_eq({"a"=>"b"}, e.hash_to_str({:a=>:b}))
----------------------------------------------------------------------
  def nu_attr
    attr = self[1]
    return attr if attr.is_a?(Hash)
    return {}
  end

  def nu_get_attr(k=nil)
    attr = {}
    i = 1
    while self[i].is_a?(Hash)
      attr.update(self[i])
      i += 1
    end
    return attr if k.nil?
    return attr[k]
  end
----------------------------------------------------------------------
BenchĂ݂B
% ruby bench-session.rb
Finished in 98.044248 seconds.
----------------------------------------------------------------------
colinux% ruby bench-session.rb
Finished in 10.082087 seconds.

colinux% ruby -runprof bench-session.rb > & t2
use clock(3) for profiling
Finished in 24.076777 seconds.

  %%   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 20.38    5.070     5.070   172879     0.03     0.74  Array#each
  7.96    7.050     1.980   113700     0.02     0.60  WabisabiGetModule.traverse_element
  6.03    8.550     1.500    22500     0.07     0.11  Qwik::InlineTokenizer#tokenize
  5.51    9.920     1.370   791716     0.00     0.00  Kernel.is_a?
  5.35   11.250     1.330      900     1.48     4.23  Qwik::TextTokenizer#tokenize
  4.70   12.420     1.170   104200     0.01     0.02  WabisabiGetModule.get_attr
  3.54   13.300     0.880   293600     0.00     0.00  StringScanner#scan

get_attrPĂ݂B
Finished in 23.484908 seconds.

  %%   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 21.44    5.220     5.220   172879     0.03     0.69  Array#each
  7.64    7.080     1.860   113700     0.02     0.54  WabisabiGetModule.traverse_element
  7.19    8.830     1.750    22500     0.08     0.11  Qwik::InlineTokenizer#tokenize
  5.87   10.260     1.430      900     1.59     4.31  Qwik::TextTokenizer#tokenize
  4.56   11.370     1.110   755116     0.00     0.00  Kernel.is_a?
  3.90   12.320     0.950   293600     0.00     0.00  StringScanner#scan
  3.86   13.260     0.940   104200     0.01     0.02  WabisabiAttrModule.get_attr
ق̂ƑȂA܂ςĂȂˁB
----------------------------------------------------------------------
  def nuget_a_path(path)
    if /\A(.*)\[(.+)\]\z/ =~ path
      tag = $1
      select = $2
      if /\A@([a-z]+)='([a-z]+)'\z/ =~ select
	attr = $1
	value = $2
	return get_has_attr(attr.intern, value)
      end
    end
    return get_tag(path)
  end
----------------------------------------------------------------------
html-to-wiki.rb
#
# Copyright (C) 2003-2005 Kouichirou Eto
#     All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of 
# the GNU General Public License version 2.
#

$LOAD_PATH.unshift("../../compat") unless $LOAD_PATH.include?("../../compat")
require "htree"
$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
#require "qwik/htree-get"
#require "qwik/htree-to-wabisabi"

module Qwik
  class NuHtmlToWiki
    def self.translate(text)
      htree = HTree(text)
      parse_block(htree)
    end

    private

    def self.parse_block(elem)
      str = ""
      elem.each_child {|e|
	case e
	when HTree::Text
	  t = e.to_s
	  next if t == "\r\n" || t == "\n"
	  qp "What? "+e.class.to_s+" : "+e.to_s
	when HTree::Elem
	  str << parse_block_elem(e)
	else
	  qp "What? "+e.class.to_s+" : "+e.to_s
	end
      }
      str
    end

    SIMPLE_BLOCK = {
      "H2"=>["* ", "\n"],
      "H3"=>["** ", "\n"],
      "H4"=>["*** ", "\n"],
      "H5"=>["**** ", "\n"],
      "H6"=>["***** ", "\n"],
      "P"=>["", "\n\n"],
    }

    def self.parse_block_elem(e)
      n = e.element_name.to_s

      if SIMPLE_BLOCK[n]
	head, tail = SIMPLE_BLOCK[n]
	return head+parse_span(e)+tail
      end

      case n
      when "PRE"
	return parse_pre(e)
      when "BLOCKQUOTE"
	return parse_blockquote(e)
      when "PLUGIN"
	attr = e.attributes_str
	#attr = e.attr
	param = attr["param"]
	method = attr["method"]
	#data = e.text
	data = e.extract_text.to_s
	str = ""
	str << "{{"+method
	str << "("+param+")" if param && param != ""
	str << "\n"+data+"\n" if data && data != ""
	str << "}}\n"
	return str
      else
#	qp "What? "+e.class.to_s+" : "+e.to_s
	return ""
      end
    end

    def self.parse_pre(elem)
      str = ""
      elem.each_child {|e|
	str << " "+e.to_s+"\n"
      }
      str
    end

    def self.parse_blockquote(elem)
      str = parse_block(elem)
      str.map {|line|
	"> "+line
      }.join
    end

    def self.parse_span(elem)
      str = ""
      elem.each_child {|e|
	case e
	when HTree::Text
	  str << e.to_s
	when HTree::Elem
	  str << parse_span_elem(e)
	else
	  qp "What? "+e.class.to_s+" : "+e.to_s
	end
      }
      str
    end

    def self.parse_span_elem(e)
      n = e.element_name.to_s
      case n
      when "A"
	attr = e.attributes_str
	href = attr["href"]
	if href =~ /\A([A-Za-z0-9]+)\.html\z/
	  href = $1
	end
	#text = e.text
	text = e.extract_text.to_s
	str = ""
	str << "[["+text
	str << "|"+href if href != text
	str << "]]"
	return str
      when "IMG"
	attr = e.attributes_str
	src = attr["src"]
	return "[["+src+"]]"
      when "EM"
	return "''"+parse_span(e)+"''"
      when "STRONG"
	return "'''"+parse_span(e)+"'''"
      when "DEL"
	return "=="+parse_span(e)+"=="
      else
	qp "What? "+e.class.to_s+" : "+e.to_s
	return ""
      end
    end

  end
end

if $0 == __FILE__
  require "qwik/testunit"
  $debug = true
end

if defined?($debug) && $debug
#  class TestHtmlToWiki < Test::Unit::TestCase
  class TestHtmlToWiki
    def ok(e, html)
      ok_eq(e, Qwik::HtmlToWiki.translate(html))
    end

    def test_html_to_wikitext
      # test div
      ok("* h\n", "<H2>h</H2>")
      ok("** h\n", "<H3>h</H3>")
      ok("p\n\n", "<P>p</P>")
      ok("p\n\np2\n\n", "<P>p</P><P>p2</P>")
      #ok("", "<UL><LI>li</LI></UL>")
      #ok("", "<UL><LI>li1</LI><UL><LI>li2</LI></UL></UL>")
      #ok("", "<DL><DT>dt<DD>dd</DD></DL>")
      #ok("", "<DL><DT>dt1<DD>dd1><DT>dt2<DD>dd2</DD></DL>")
      ok("> pB\n> \n", "<BLOCKQUOTE><P>pB</P></BLOCKQUOTE>")
      ok("> * h\n", "<BLOCKQUOTE><H2>h</H2></BLOCKQUOTE>")
      ok("> x\n> \n> y\n> \n", "<BLOCKQUOTE><P>x</P><P>y</P></BLOCKQUOTE>")

      # test span
      ok("Go [[FrontPage]].\n\n",
	     '<P>Go <A href="FrontPage.html">FrontPage</A>.</P>')
      ok("Go [[qwikWeb|http://example.com/]].\n\n", '<P>Go <A href="http://example.com/">qwikWeb</A>.</P>')
      ok("''''A'''ɋ'''A====\n\n", '<P><EM></EM>A<STRONG>ɋ</STRONG>A<DEL></DEL></P>')
      ok("[[http://example.com/.theme/new.png]]\n\n", '<P><IMG alt=new src="http://example.com/.theme/new.png"></P>')
      ok("[[FrontPage]] [[Yahoo!|http://www.yahoo.co.jp/]]\n\n{{recent(1)}}\n", '<P><A href="FrontPage.html">FrontPage</A> <A href="http://www.yahoo.co.jp/">Yahoo!</A></P><PLUGIN param="1" method="recent"></PLUGIN>')

      s = <<'EOT'
<H2>FrontPage</H2>
<P>͐VKqwikWebTCg̓ƂȂy[WłB</P>
<H3>g</H3>
<P>y[W̏̕ɂuҏWvƂNǂƁÃy[W̕ҏW[hɂȂ܂B</P>
<P>\ꂽeLXg̓eύXAuSavev{^NbNƁÃy[W̓eύX܂B</P>
<H3>Lq@</H3>
<P>y[W̓e̓eLXgŏĂA̋LɂČoȂǂ̎w܂Bڂ́A<A href="TextFormat.html">TextFormat</A>B</P>
<H3>qwikWeb</H3>
<P>ڂ́A<A href="http://example.com/">qwikWeb</A>z[y[WB</P>
EOT

      org = <<'EOT'
* FrontPage
͐VKqwikWebTCg̓ƂȂy[WłB

** g
y[W̏̕ɂuҏWvƂNǂƁA
̃y[W̕ҏW[hɂȂ܂B

\ꂽeLXg̓eύXAuSavev{^NbNƁA
̃y[W̓eύX܂B

** Lq@
y[W̓e̓eLXgŏĂA
̋LɂČoȂǂ̎w܂B
ڂ́A[[TextFormat]]B

** qwikWeb
ڂ́A[[qwikWeb|http://example.com/]]z[y[WB
EOT

      e = <<'EOT'
* FrontPage
͐VKqwikWebTCg̓ƂȂy[WłB

** g
y[W̏̕ɂuҏWvƂNǂƁÃy[W̕ҏW[hɂȂ܂B

\ꂽeLXg̓eύXAuSavev{^NbNƁÃy[W̓eύX܂B

** Lq@
y[W̓e̓eLXgŏĂA̋LɂČoȂǂ̎w܂Bڂ́A[[TextFormat]]B

** qwikWeb
ڂ́A[[qwikWeb|http://example.com/]]z[y[WB

EOT

      ok(e, s)

      s = <<'EOT'
<H2>ꗗȈՔ</H2>
<P>ڍׂȐ<A href="TextFormat.html">TextFormat</A>񂭂B</P>
<H3>o2</H3>
<H4>o3</H4>
<H5>o4</H5>
<H6>o5</H6>
<UL>
<LI>ӏx1
<UL>
<LI>ӏx2
<UL>
<LI>ӏx3</LI></UL></LI></UL></LI></UL>
<OL>
<LI>Xg1
<OL>
<LI>Xg2
<OL>
<LI>Xg3</LI></OL></LI></OL></LI></OL><PRE>`ς݃eLXgB</PRE>
<BLOCKQUOTE>
<P>pB</P></BLOCKQUOTE>
<DL>
<DT>Wiki
<DD>݉\Weby[W
<DT>QuickML
<DD>ȒPɍ郁[OXgVXe</DD></DL>
<TABLE>
<TBODY>
<TR>
<TD>1-1</TD>
<TD>1-2</TD>
<TD>1-3</TD></TR>
<TR>
<TD>2-1</TD>
<TD>2-2</TD>
<TD>2-3</TD></TR></TBODY></TABLE>
<P><EM></EM>A<STRONG>ɋ</STRONG>A<DEL></DEL> <IMG alt=new src="http://example.com/.theme/new.png"> <A href="FrontPage.html">FrontPage</A> <A href="http://www.yahoo.co.jp/">Yahoo!</A></P><PLUGIN param="1" method="recent"></PLUGIN>
EOT

      org = <<'EOT'
* ꗗȈՔ
ڍׂȐ[[TextFormat]]񂭂B
** o2
*** o3
**** o4
***** o5
- ӏx1
-- ӏx2
--- ӏx3
+ Xg1
++ Xg2
+++ Xg3
 `ς݃eLXgB
> pB
:Wiki:݉\Weby[W
:QuickML:ȒPɍ郁[OXgVXe
,1-1,1-2,1-3
,2-1,2-2,2-3
''''A'''ɋ'''A====
[[new|http://example.com/.theme/new.png]]
[[FrontPage]]
[[Yahoo!|http://www.yahoo.co.jp/]]
{{recent(1)}}
EOT

      e = <<'EOT'
* ꗗȈՔ
ڍׂȐ[[TextFormat]]񂭂B

** o2
*** o3
**** o4
***** o5
 `ς݃eLXgB
> pB
> 
''''A'''ɋ'''A==== [[http://example.com/.theme/new.png]]

{{recent(1)}}
EOT

      ok(e, s)

    end
  end
end

----------------------------------------------------------------------

    # ============================== old
    def self.nu_parse_block(wabisabi)
      str = ""
      wabisabi.each_child {|e|
	qp e
	if e.is_a?(String)
	  t = e.to_s
	  next if t == "\r\n" || t == "\n"
	  qp "What? "+e.class.to_s+" : "+e.to_s
	elsif e.is_a?(Array)
	  str << parse_block(e)		# Recursive.
	else
	  qp "What? "+e
	end
      }
      return str
    end

    def self.nunu_parse_block(e)
      n = e[0]

      if n.nil?
	return ""
      end

      qp n

      if SIMPLE_BLOCK[n]
	head, tail = SIMPLE_BLOCK[n]
	return head+parse_span(e)+tail
      end

      case n
      when "PRE"
	return parse_pre(e)
      when "BLOCKQUOTE"
	return parse_blockquote(e)
      when "PLUGIN"
	attr = e.attributes_str
	#attr = e.attr
	param = attr["param"]
	method = attr["method"]
	#data = e.text
	data = e.extract_text.to_s
	str = ""
	str << "{{"+method
	str << "("+param+")" if param && param != ""
	str << "\n"+data+"\n" if data && data != ""
	str << "}}\n"
	return str
      else
#	qp "What? "+e.class.to_s+" : "+e.to_s
	return ""
      end
    end

=======================================================2005-08-28(Sun)

----------------------------------------------------------------------
pagedb
#
# Copyright (C) 2003-2005 Kouichirou Eto
#     All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of 
# the GNU General Public License version 2.
#

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/db-filesystem"
require "qwik/berkeleydb"

module Qwik
  class PageDB < FileSystemDB; end
 #class PageDB < BerkeleyDB; end
end

=======================================================2005-08-27(Sat)

----------------------------------------------------------------------
    def nu_each_by_key(key)
      @backup_path.check_directory
      ar = []
      @backup_path.each_entry {|file|
	f = @backup_path+file
	next unless f.file?
	base = file.to_s
	if /\A([0-9]+)_#{key}\z/ =~ base # end with key ?
	  time = Time.at($1.to_i)
	  v = get(key, time)
	  ar << [v, time]
	end
      }

      ar.sort_by {|v, time|
	time
      }.each {|v, time|
	yield(v, time)
      }
    end
----------------------------------------------------------------------
    # old
=begin
    # URL
    def domainurl
      return "http://"+@hostname+"/"
    end

    def url(k=nil)
      u = domainurl
      u += urlpath
      u += k+".html" if k
      return u
    end

    def urlpath
      siteurl = self.siteconfig["siteurl"]
      return "" if top_site? || external_site? || ! siteurl.empty?
      return @sitename+"/"
    end

    # ML
    def ml
      return "info@"+@sitename if external_site?
      return @sitename+"@"+@hostname
    end
=end

    # external qwik site
    def external_site?
      return true if @sitename.include?(".")
      return true if ! self.siteconfig["siteurl"].empty?
      return false
    end

      @hostname = @config.default_hostname
#      @hostname = @sitename if external_site?
    def init_url
    end
----------------------------------------------------------------------
	if site.external_site? || # do not convert if external site 
	    site.is_open? || # do not convert if open site
	    site.siteconfig["redirect"] != "true"
	#Resolver.set_attr(w, {:class=>"external"})
	  #Resolver.set_attr(w, {:href=>href})

----------------------------------------------------------------------
      t_with_site("e.com") {
	site = Qwik::Site.new(@config, @memory, "e.com")
	ok_res([[:a, {:href=>"http://e.com/", :class=>"external"},"e"]],
	       [[:a, {:href=>"http://e.com/"}, "e"]], site)
	site.erase_all
      }

----------------------------------------------------------------------
#      t_with_site("e.com") {
#	res = session("/e.com/")
#	site = @memory.farm.get_site("e.com")
#	site.member.add(DEFAULT_USER)
#	page = site.create("_SiteConfig")
#	page.store(":siteurl:http://e.com/")
#	res = session("/e.com/")
        @action.instance_eval {
	  @site = site
	}

----------------------------------------------------------------------
      #domainurl = @site.domainurl
      #siteurl = @site.url
      #mail.from = @site.ml

----------------------------------------------------------------------
    def with_dir(sitename)
      dir = ("./"+sitename+"/").path
      dir.setup
      yield
      dir.teardown
    end


----------------------------------------------------------------------
     #site = @memory.farm.get_site("test")
      #ok_eq("info@e.com", site.ml)
	#ok_eq("e.com", site.title)
#      }
#      t_with_site("e.com") {
#	site = @memory.farm.get_site("e.com")

=======================================================2005-08-26(Fri)

----------------------------------------------------------------------
#      page = self[k] if k
#      u += page.url if page
----------------------------------------------------------------------
#      xml << [:"!DOCTYPE", "rss", "PUBLIC",
#	"-//Netscape Communications//DTD RSS 0.91//EN",
#	"http://my.netscape.com/publish/formats/rss-0.91.dtd"]
----------------------------------------------------------------------
    def nu_c_add_br(str)
      ignore_chars = [?\s, ?-, ?*, ?>, ?|, ?,, ?{, ?}]
      str.map {|line|
	line.chomp!
	line = line+"~" unless ignore_chars.include?(line[0])
	line
      }.join("\n")+"\n"
    end

#      str = c_add_br(str)
#      tokens = TextTokenizer.tokenize(str)
----------------------------------------------------------------------
  class TestParserWithFormat < Test::Unit::TestCase
    def ok(e, str)
      tokens = Qwik::TextTokenizer.tokenize(str)
      tokens = Qwik::TextParser.make_tree(tokens)
      ok_eq(e, tokens)
      #ok_eq(e, tokens.rb_format_xml(-1, -1))
    end
  end

=======================================================2005-08-25(Thu)

----------------------------------------------------------------------
      #ok(["[[]]"], "[[]]")
      #ok(["[", "[", "]]"], "[[]]")

=======================================================2005-08-22(Mon)

----------------------------------------------------------------------
    # ============================== thumb
    def nu_thumb_generate(f)
      org_file = @site.attach.path(f)
      attach_dir = @site.attach.path("")
      thumb_dir = attach_dir+".thumb"
      thumb_dir.check_directory
      thumb = thumb_dir+f

      if ! thumb.exist?
	convert = CONVERT_PATH
	return nil if ! convert.path.exist?
	s = THUMB_SIZE
	geom = "#{s}x#{s}"
	cmd = "#{convert} -resize #{geom} #{org_file.to_s} #{thumb.to_s}"
#	qp cmd
	system cmd
      end

      return ".attach/.thumb/"+f.to_s
    end
    def nuthumb_generate(f)
      files = @site.files(@req.base)
      org = files.path(f)
      files_dir = files.path("")
      thumb_dir = files_dir+".thumb"
      thumb_dir.check_directory
      thumb = thumb_dir+f

      if ! thumb.exist?
	convert = CONVERT_PATH
	return nil if ! convert.path.exist?
	s = THUMB_SIZE
	geom = "#{s}x#{s}"
	cmd = "#{convert} -size #{geom} #{org.to_s} -resize #{geom} #{thumb.to_s}"
	system cmd
      end

      return @req.base+".files/.thumb/"+f.to_s
    end

    def nu_is_image?(ext)
      ext.downcase!
      mimetype = @res.mimetypes[ext]
      return false if mimetype.nil?
      genre, spec = mimetype.split("/")
      return genre == "image"
    end
----------------------------------------------------------------------
      #qp str
      #config_str = "ImageHeightPercent=#{_ImageHeightPercent}&BackgroundColor=#{_BackgroundColor}&ImageBorderWidth=#{_ImageBorderWidth}&ImageBorderColor=#{_ImageBorderColor}&ArrowColor=#{_ArrowColor}&ScreenBorderColor=#{_ScreenBorderColor}&ScrollbarColor=#{_ScrollbarColor}"
      #return config_str
----------------------------------------------------------------------
    def newpage_valid_as_pagekey?(t)
      /\A[_A-Za-z0-9]+\z/ =~ t
    end

=======================================================2005-08-20(Sat)

----------------------------------------------------------------------
      #hash = QuickML::Config.load_config_file
      #hash[:data_dir] = "."
    #qp @ml_dir
----------------------------------------------------------------------
      #:domain => "qwik.jp",
      #:postmaster => "info@qwik.jp",
      #:data_dir => base_dir+"/data",
      #:pid_file => base_dir+"/log/quickml.pid",
      #:log_file => base_dir+"/log/quickml-log",
      #:confirm_ml_creation => true, # for confirming ML creation.
#require "qwik/ml-quickml"
----------------------------------------------------------------------
  def xchomp!
    self.chomp!("\n")
    self.chomp!("\r")
  end
----------------------------------------------------------------------
class String
  def normalize_eol!
    self.xchomp!
    self << "\n"
  end
end
----------------------------------------------------------------------
      # test_xchomp!
      str = "t"
      str.xchomp!
      ok_eq("t", str)

      str = "t\r"
      str.xchomp!
      ok_eq("t", str)

      str = "t\n"
      str.xchomp!
      ok_eq("t", str)
----------------------------------------------------------------------
  def chompp!
    self.sub!(/[\n\r]+\z/, "")
  end

      str.chompp!
      ok_eq("", str)

  if ! method_defined?(:xchomp)
  end

=======================================================2005-08-19(Fri)

---------------------------------------------------------------------
	  #bodytext = bodytext.chomp.chomp+"\n"
----------------------------------------------------------------------
#    def new_mail(mail_from, add_recipient, body)
#      QuickML::Mail.create(mail_from, add_recipient, body)
#    end
2005-08-19T14:28:33 win 2005@eto.com "GET /HelloQwik/.theme/s5/qwikworld/bg-slide.jpg" 200 -                                                                   
----------------------------------------------------------------------
    //g_debug.p(ele);
    //alert(update_html);
	//alert(new_md5);
	  //div.innerHTML = xh.responseText;
	  //div.innerHTML = "updated";
	  //div.innerHTML = "updated "+new_md5;
	  //sleep 1;
	  //g_watcher_env.start();	// restart again.
  //alert('hi');
----------------------------------------------------------------------
    //g_debug.p("start get "+this.pagename);
    //var div = getById("body");
    //if (!div) return;
	//g_debug.p("set html");

=======================================================2005-08-18(Thu)

----------------------------------------------------------------------
    def nufiles
      @files = @pages.files(@key) unless defined? @files
      return @files
    end
----------------------------------------------------------------------
/usr/lib/ruby/1.8/timeout.rb:43:in `rbuf_fill': execution expired (Timeout::Error)
        from /usr/lib/ruby/1.8/net/protocol.rb:196:in `timeout'
        from /usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
        from /usr/lib/ruby/1.8/net/protocol.rb:196:in `rbuf_fill'
        from /usr/lib/ruby/1.8/net/protocol.rb:160:in `readuntil'
        from /usr/lib/ruby/1.8/net/protocol.rb:171:in `readline'
        from /usr/lib/ruby/1.8/net/http.rb:1614:in `read_status_line'
        from /usr/lib/ruby/1.8/net/http.rb:1603:in `read_new'
        from /usr/lib/ruby/1.8/net/http.rb:832:in `request'
         ... 30 levels...
        from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in `run'
        from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'
        from /usr/lib/ruby/1.8/test/unit.rb:285
        from /usr/lib/ruby/1.8/test/unit.rb:283
----------------------------------------------------------------------
    def nu_monitor_message(title)
      @res.status = 200
      @res["Cache-Control"] = "no-cache, must-revalidate"
      @res["Pragma"] = "no-cache"
      w = [[:"!DOCTYPE", "html", "PUBLIC",
	  "-//W3C//DTD HTML 4.01 Transitional//EN",
	  "http://www.w3.org/TR/html4/loose.dtd"],
	[:html,
	  [:head,
	    [:title, title]],
	  [:body,
	    [:div, {:class=>"event"}, title]]]]
      w = w.format_xml.sjistou8 if ! $debug
      @res.body = w
    end
----------------------------------------------------------------------
    def nuevent_tell(event)
      time, user, key, ext, cmd = event
      msg = ",#{time},#{user},#{key},#{ext},#{cmd}\n"
      return event_send(msg)
    end

    def nu_event_tell(event)
      time, user, key, ext, cmd = event
      if cmd == "save"
	return event_tell_save(event)
      end
      msg = ",#{time},#{user},#{key},#{ext},#{cmd}\n"
      return event_send(msg)
    end
----------------------------------------------------------------------
#      ok_eq([:div, {:id=>"map",
#		       :style=>"width: 696px; height: 382px;"}, ""], w[3])
----------------------------------------------------------------------
/*
  margin: 0 3px;
  padding: 0 0 0 0;
  border: 1px solid #0f0;
  line-height: 100%;
*/
/*
  padding: 0;
  border: 1px solid #00f;
  margin: 0 3px;
  padding: 0 0 0 0;
  background-color: #bbe;
  line-height: 100%;
*/
/*
  border: 1px solid #f00;
  border: 0;
  margin: 0 1em;
  padding: 10px 0 10px 0;
  line-height: 100%;
  background-color: #bbe;
  padding: 4px 4px;
  height: 100px;
  margin: 0px 0px 0px 4px;
  padding: 4px 0px 4px 4px;
  border-left: 3px outset #99c;
  background-color: #bbe;
  */
/*
  margin: 0 0;
  padding: 4px 4px;
*/
/*
  margin: 0 1em;
  padding: 1em;
   */
----------------------------------------------------------------------
    def nu_wysiwyg_save
      html = @req.query["text"]
      contents = "<html>\n"+html+"\n</html>\n"
      return ext_save(contents)		# in act-edit.rb
    end
----------------------------------------------------------------------
//this.win  = this.xp.getById(this.id);
  //this.form = this.xp.getById("frm");
    //alert(this.win);
    //g_debug.p("setWemaPosition");
    //g_debug.pa(id);
    //g_debug.pa(this.env.wemas);
    //g_debug.pa(this.env.wemas.get(id));
    //g_debug.pa(w);
    //alert("id is "+id);
  //var o = this.xp.getById(id);
  //var t = this.xp.getById(to);
//this.obj   = this.xp.getById(this.id);
  //return this.xp.getZIndex(this.obj);
    //g_debug.pa(this.wlist);
    //g_debug.pa(id);
    //g_debug.pa(this.wlist[id]);
    //g_debug.p(wlist);
    //g_debug.pa(wlist);
      //alert("id is "+id);
      //g_debug.pa(id);
	//g_debug.pa(h[id]);
      //this.wlist[id].style.zIndex = z;
  //g_debug.pa(this.wemas);
    //g_debug.pa(this.wemas);
  //this.xp.setAttr(body, "ondblclick", "wema_dblClick;")
    //alert("mouseDown "+e+o);
    //alert("mouseDown "+e+o);
    //alert("mouseDown "+e+o);
    //alert("startDragging "+o.id);
    //this.wemas.getCurDragging().style.zIndex = 2;
    //alert("wema mouseMove");
    //alert("typeof qwik_onmousemove = "+typeof qwik_onmousemove);
    //alert("dblClick");
    //this.xp.setZIndex(o, 2);
    //var o = this.xp.getById(id);
    //this.xp.setZIndex(o, 0);
  //var w = document.createElement("div");
  //w.outerHTML = str;
  //document.body.appendChild(w);
----------------------------------------------------------------------
#      return if defined?(@event_defined)
#      @event_defined = true

=======================================================2005-08-17(Wed)

----------------------------------------------------------------------
listener
each {|action|
	if action == listener
	end
	if sitename == target_sitename
	  yield(action)
	end
      }
      sitename, first = @listener.shift
      first.event_disconnect
----------------------------------------------------------------------
      len = @listener.length
      if MAX_LISTENER < len
	first = @listener.shift
	first.event_disconnect	# Kick out him first.
	# And also, disconnect current listener.
	return false	# failed to connect
      end
      return true
      @events << event
----------------------------------------------------------------------
      #qp sitetitle
	#sitetitle = ""
#	qp sitetitle
      #qp sitetitle
----------------------------------------------------------------------
     #return c_notice(_("Attach file"), "FrontPage.html"){div} # why?
      #px("//div[@class='msg']", 0)
      #px(nil, 0)
#      assert_instance_of(File, @res.body)
#      str = @res.body.read
#      @res.body.close # important
      #px("//ul", 0)
#      px("//div[@class='msg']", 0)
#      ok_xp([], "//div[@class='msg']")
#      assert_instance_of(File, @res.body)
#      str = @res.body.read
#      @res.body.close # important

----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto
# test module for QuickML testing.
----------------------------------------------------------------------
  def nu_load_files(base)
    Dir.glob(base+"-*.rb") {|filename|
      require filename
    }
  end
----------------------------------------------------------------------
=begin
    class TestCase
      alias ok_eq assert_equal
    end
=end
----------------------------------------------------------------------
    def self.nu_tokenize(str)
----------------------------------------------------------------------
      #term = TERMINAL_REGEXP
----------------------------------------------------------------------
#    begin
#    rescue
#      pp f.content_type
#      pp "error"
#    end
----------------------------------------------------------------------
#require "qwik/util-time"
----------------------------------------------------------------------
    def initialize(body)
      @body = body
      @body.freeze
    end
    attr_reader :body

    def valid?
      return CSS.valid?(@body)
    end
----------------------------------------------------------------------
  def prepare_site
    if ! File.exist?("../../data/test")
      Dir.mkdir("../../data/test")
    end
  end
----------------------------------------------------------------------
  def nu_ok_in(e, xpath, res=@res)
    elem = res.body.get_path(xpath)
    return ok_eq(e, nil) if elem.nil?

    s = elem.inside
    return ok_eq(e, nil) if s.nil?

    if e.is_a? Array
      s = s.get_single
      return ok_eq(e, s)
    end

    if s.is_a? Array
      s = s.format_xml
    else
      s = s.to_s
    end

    return ok_eq_or_match(e, s)
  end
----------------------------------------------------------------------
    #attr = hash_to_str(attr)
----------------------------------------------------------------------
  def hash_to_str(src)
    h = {}
    src.each {|k, v|
      k = k.to_s
      next if k == "xmlns"
      h[k] = v.to_s
    }
    return h
  end
  private :hash_to_str
----------------------------------------------------------------------
    if w.nil?
      puts "nil"
      return
    end
----------------------------------------------------------------------
    #res = session("/test/#{page.key}.html") {|req|
----------------------------------------------------------------------
    #page = @site.create_new if page.nil?
    #qp page.key
    #res = session("/test/#{page.key}.html") {|req|
----------------------------------------------------------------------
    else
#      t_site_open
----------------------------------------------------------------------
	#qp base
	  #f.unlink
	  #erase_db(f)
      if /\.db\z/ =~ base
	if /\A__/ =~ base
	else
	end
	next
      end
----------------------------------------------------------------------
  def get_uri(uri)
    str = ""
    begin
      str = open(uri) {|f| f.read }
    rescue OpenURI::HTTPError
      puts "error"
      exit
    end
    return str
  end
----------------------------------------------------------------------
TestConfig
#<Qwik::Config:0xb77c7810
 @accesslog_file="/home/eto/qwik/log/access.log",
 @bind_address="127.0.0.1",
 @cache_dir="/home/eto/qwik/cache",
 @config_file="/home/eto/qwik/etc/config.txt",
 @data_dir="/home/eto/qwik/data",
 @db="fsdb",
 @debug=true,
 @default_hostname="example.com",
 @default_sitename="www",
 @etc_dir="/home/eto/qwik/etc",
 @generation_file="/home/eto/qwik/etc/generation.txt",
 @grave_dir="/home/eto/qwik/grave",
 @lib_dir="/home/eto/qwik/lib",
 @log_dir="/home/eto/qwik/log",
 @log_file="/home/eto/qwik/log/qwikweb.log",
 @pass_file="/home/eto/qwik/etc/password.txt",
 @pid_file="/home/eto/qwik/log/qwikweb.pid",
 @port="9190",
 @public_host="example.com",
 @public_port="9190",
 @qlog_file="/home/eto/qwik/log/qwik-access.log",
 @qrcode_dir="/home/eto/qwik/lib/qrcode",
 @qwiklib_dir="/home/eto/qwik/lib/qwik",
 @smtp_host="127.0.0.1",
 @smtp_port="25",
 @ssl=false,
 @super_dir="/home/eto/qwik/lib/super",
 @template_dir="/home/eto/qwik/lib/template",
 @test=true,
 @theme_dir="/home/eto/qwik/lib/theme">

RealConfig
#<Qwik::Config:0xb7858004
 @accesslog_file="/home/eto/qwik/log/access.log",
 @bind_address="127.0.0.1",
 @cache_dir="/home/eto/qwik/cache",
 @config_file="/home/eto/qwik/etc/config.txt",
 @data_dir="/home/eto/qwik/data",
 @db="fsdb",
 @debug=false,
 @default_hostname="example.com",
 @default_sitename="www",
 @etc_dir="/home/eto/qwik/etc",
 @generation_file="/home/eto/qwik/etc/generation.txt",
 @grave_dir="/home/eto/qwik/grave",
 @lib_dir="/home/eto/qwik/lib",
 @log_dir="/home/eto/qwik/log",
 @log_file="/home/eto/qwik/log/qwikweb.log",
 @pass_file="/home/eto/qwik/etc/password.txt",
 @pid_file="/home/eto/qwik/log/qwikweb.pid",
 @port="9190",
 @public_host="example.com",
 @public_port="9190",
 @qlog_file="/home/eto/qwik/log/qwik-access.log",
 @qrcode_dir="/home/eto/qwik/lib/qrcode",
 @qwiklib_dir="/home/eto/qwik/lib/qwik",
 @smtp_host="127.0.0.1",
 @smtp_port="25",
 @ssl=false,
 @super_dir="/home/eto/qwik/lib/super",
 @template_dir="/home/eto/qwik/lib/template",
 @test=false,
 @theme_dir="/home/eto/qwik/lib/theme">

----------------------------------------------------------------------
http://127.0.0.1:9190/
http://colinux:9190/
----------------------------------------------------------------------
      #pp webrick_conf[:Port]
----------------------------------------------------------------------
#      assert_instance_of(File, wres.body)
#      assert_match(%r|^/*|, wres.body.read)
#      wres.body.close

=======================================================2005-08-16(Tue)

----------------------------------------------------------------------
Running make install
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/UseMod.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/Kwiki.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/Oddmuse.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/DocuWiki.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/MediaWiki.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/MoinMoin.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/TikiWiki.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/PhpWiki.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/PmWiki.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/SnipSnap.pm
Installing /usr/local/share/perl/5.8.7/HTML/WikiConverter/WakkaWiki.pm
Installing /usr/local/man/man3/HTML::WikiConverter::Oddmuse.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::WakkaWiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::PmWiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::TikiWiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::UseMod.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::PhpWiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::Kwiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::DocuWiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::MediaWiki.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::MoinMoin.3pm
Installing /usr/local/man/man3/HTML::WikiConverter::SnipSnap.3pm
Writing /usr/local/lib/perl/5.8.7/auto/HTML/WikiConverter/.packlist
Appending installation info to /usr/local/lib/perl/5.8.7/perllocal.pod
  /usr/bin/make install  -- OK

----------------------------------------------------------------------
/*
 border-bottom: 1px dotted;
*/
/*
 scrollbar-3d-light-color: #000;
 scrollbar-arrow-color: #000;
 scrollbar-base-color: #000;
 scrollbar-dark-shadow-color: #000;
 scrollbar-face-color: #000;
 scrollbar-highlight-color: #000;
 scrollbar-shadow-color: #000;
*/
/*
 margin-left: 0.5em;
*/
/*
 margin-bottom: 0.66em;
*/
/*
 margin: 0.33em 0;
 font-size: smaller;
*/
/*
 color: rgb(49%,47%,66%);
*/

/*
 font-size: 1.66em;
 margin: 0 -15% 1em 0;
 padding: 0.5em 15% 0.06125em 0;
*/

/*
 width: 88%;
 padding: 1em 7% 2em 5%;
*/
----------------------------------------------------------------------
#    def initialize(config, action)
#      @config = config
#      @action = action
#      @page = nil
#    end
    def self.html_css(href, media, id)
      return [:link, {:rel=>"stylesheet", :href=>href,
	  :type=>"text/css", :media=>media, :id=>id}]
    end
      # test_is_title?
#      ok_eq(true, c.is_title?([:h1, "h"]))
#      ok_eq(false, c.is_title?([:h2, "h"]))
#      ok_eq([:div, {:class=>"slide"}, [:h1, "h"]],
#	    c.div_slide([:h1, "h"]))
----------------------------------------------------------------------
#      gen = ZipGenerator.new
#      path = gen.generate(@config, @site, self)
----------------------------------------------------------------------
#    def initialize(config, site, action)
#      @config, @site, @action = config, site, action
#    end
----------------------------------------------------------------------
      #site_path = get_sitepath
	#qp file, local
----------------------------------------------------------------------
#    zip = res.body
#    assert_instance_of(File, zip)
#    str = zip.read
#    zip.close
#      e = zis.get_next_entry
#      ok_eq(nil, e)
----------------------------------------------------------------------
#     @action.generate_html(page.key) if !html_path.exist?
----------------------------------------------------------------------
#      qp interval
#	qp sitename
	#site = @farm[sitename] # oOĂ!
#	  qp "do send_site", sitename
#      qp "rep is", rep
#      qp "list is", list
----------------------------------------------------------------------
#    def modulobe_prepare_thumbnail(file)
#      base = file.basename(".mdlb").to_s+".gif"
#      return "#{@req.base}.files/.thumb/#{base}"
#    end
----------------------------------------------------------------------
#require "qwik/wabisabi-get"
----------------------------------------------------------------------
    def nu_html_to_wabisabi(str)
      html = "<html>"+str+"</html>"
      htree = HTree(html)
      first_child = htree.children[0]
      wabisabi = first_child.to_wabisabi       #pp wabisabi
      wabisabi_child = wabisabi.inside         #pp wabisabi_child
      v = wabisabi_child.check_valid
      if v == true
	return wabisabi_child
      else
	return "can not use ["+v.to_s+"]"
      end
    end
#    page = @site.create_new
#    str = "{{show_history}}"
#    page.store(str)
----------------------------------------------------------------------
    #pw("//body")
    #pw("//form")
----------------------------------------------------------------------
    #pw("//form")
    # test_ring_message_form
    #ok_xp("", "//body")
    #pw("//div[@class='section']")
    #px("//div[@class='main']")
    #px("//div[@class='day']")
    #px("//div[@class='day'][4]")
    #px("//div[@class='day'][4]//dd")
    #ok_in("Hi", "//div[@class='day'][4]//dd")
----------------------------------------------------------------------
#    ring_prepare_mock_data
#    page = @site.create("_RingMember")
#    page.store(",user@e.com,Test User,Alan Smithy,ei,1990,1,0")
#    page.store(",user@e.com,\n,gu@example.com,user@e.com\n,fellow@example.com,user@e.com\n")
----------------------------------------------------------------------
  RING_TEST_DATA = {
    "RingInviteMember" =>	"{{ring_invite_form}}",
    "RingInviteMemberList" =>	"{{ring_invite_list}}",
    "RingMakePage" =>		"{{ring_make_form}}",
  }
  def ring_prepare_mock_data
    RING_TEST_DATA.each {|k, v|
      page = @site.create(k)
      page.store(v)
    }
  end
----------------------------------------------------------------------
#!/usr/bin/env ruby -w
#
# Copyright (C) 2003-2005 Kouichirou Eto
#     All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of 
# the GNU General Public License version 2.
#

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/test-common"
require "qwik/act-ring-invite"
require "qwik/act-ring-maker"
require "qwik/act-ring-msg"

if $0 == __FILE__
  $debug = true
end

class CheckRing < Test::Unit::TestCase
  include TestSession
end
----------------------------------------------------------------------
    #ring_prepare_mock_data
    #res = session("/test/RingInviteMember.html")
    #assert_rattr({:action=>"RingInviteMember.ring_invite", :method=>"POST"},
    #res = session("/test/RingInviteMember.ring_invite?guest_mail=invalid@mailaddress")
    #res = session("/test/RingInviteMember.ring_invite?guest_mail=gu@example.com&message=҂܂")
    #res = session("/test/RingInviteMember.ring_invite?guest_mail=fellow@example.com&message=҂܂")
    #res = session("/test/RingMakePage.html") {|req|
    #assert_rattr({:action=>"RingMakePage.ring_make", :method=>"POST"},
    #ok_in(/gu@example.com/, "//div[@class='section']//dt")
    #res = session("/test/RingMakePage.ring_make?page=RingMakePage&username=QXg&realname=RcY&faculty=&year=1990") {|req|
----------------------------------------------------------------------
    #assert_match(/|fe@e.com|tF[|user@e.com|҂ł|\d+|/s, @site["_RingInvitedMember"].load)
----------------------------------------------------------------------
  def ring_copy_test_data
    src  = $test_org_data_dir.path+"ring.sfc.keio.ac.jp"
    dest = @dir
    raise if ! src.exist?
    src.each_entry {|file|
      if /^Ring/ =~ file || /_SideMenu/ =~ file
	next if /^RingInvitedMember/ =~ file
	next if /^RingMember/ =~ file

	srcfile = src+file
	str = srcfile.open("rb"){|f| f.read }

	destfile = dest+file
	destfile.open("wb"){|f| f.print str }
      end
    }
  end
      $test_org_data_dir = config.data_dir.dup
    begin
#      ring_copy_test_data
    rescue
      puts "No original data found." if $0 == __FILE__
      return	# Do not raise error
    end
----------------------------------------------------------------------
	# same as above.
----------------------------------------------------------------------
    #pw("//form")
    #pw("//form/table")
    #pw("//form/table/tr")
    #pw("//form/table/tr/td")
    #pw("//html")
    #pw("//div[@class='section']")
#		 @site["RingInvitedMember"].load)
    assert_match(/,gu@example.com,,user@e.com,҂܂/,
		 @site["_RingInvitedMember"].load)
    # FIXME: The URL should be changed.
   #url = "http://ring.sfc.keio.ac.jp/.getpass?mail=gu@example.com"
   #url = "http://ring.sfc.keio.ac.jp/GetPass.html?mail=fellow@example.com"
   #url = "http://ring.sfc.keio.ac.jp/.getpass?mail=fellow@example.com"


=======================================================2005-08-15(Mon)

----------------------------------------------------------------------
      #editor = WysiwygEditor.new(self)
     #editor_html = editor.get_html(pagename, str)
     #now = Time.now.to_i.to_s
     #now = @req.start_time.to_i.to_s
----------------------------------------------------------------------
  class WysiwygEditor
    def initialize(action)
      @action = action
    end
    def _(s)
      @action._(s)
    end
    private
  end
----------------------------------------------------------------------
 ondblclick="wema_dblClick(this);"o
----------------------------------------------------------------------
      #ar << editor_html
      #ar << help_html
#	href = "/"+href
#	      [:input, {:type=>"submit", :value=>_("Save")}]],
#	    [:p, _("Draw Line")+": ", text("ln")],
#     ar = [_("Text color")+": ", [:input, {:id=>"tc", :name=>"tc"}]]
#     ar = [_("Background")+": ", [:input, {:id=>"bg", :name=>"bg"}]]
      #ok_wi([], "{{wema}}")
----------------------------------------------------------------------
#	puts html
----------------------------------------------------------------------
#      qp "open_db "+path.to_s
#	  if /\A__/ =~ pa.to_s
#	return open_db(path)
#      qp "db_get "+k
#      lpt = last_page_time
#      if max < lpt # last_page_time is newer than files.
#	max = lpt
#      end
#      assert_instance_of(Qwik::BackupBDB, @pagedb.backupdb)
----------------------------------------------------------------------
#require "qwik/qrcode-html"
	#if ! @site.attach.exist?(f)
      # @site.attach.put(f, png)
     #path = @config.lib_dir+"/qrcode"
#     @qrcodehtml = ::QRCodeHtml.new(path)
#    def generate_htree(d)
#      @qrcodehtml.generate_htree_from_data(generate_data(d))
#    end
     #str = @site.attach.path("qrcode-test.png").open {|f| f.read }
----------------------------------------------------------------------
#      if is_image?(ext)
#	thumb = thumb_generate(f)
#	if thumb # else, go through
#	  return ref_html(src, "thumb", thumb, alt, alt)
#	end
#      end
----------------------------------------------------------------------
=begin
      png = "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000\001\000\000\000\001\010\002\000\000\000\220wS\336\000\000\000\fIDATx\332c\370\377\377?\000\005\376\002\3763\022\225\024\000\000\000\000IEND\256B`\202"
      @site.attach.put("1x1.png", png)
      ok_wi([:div, {:class=>"ref"},
		    [:a, {:href=>".attach/1x1.png"},
		      [:img, {:alt=>"1x1.png", :class=>"thumb",
			  :src=>".attach/.thumb/1x1.png"}],
		      [:br], "1x1.png"]],
		  "{{ref(1x1.png)}}")
=end
----------------------------------------------------------------------
     #res = session("/test/.ring_new?id=gotz@1996.sfc.ne.jp&mail=gotz@gotz.jp")
----------------------------------------------------------------------
      #ok_wi([], "{{show_tags}}")
----------------------------------------------------------------------
#	_("Post-it"), ": ",
#	[:a, {:href=>"javascript:wema_editor_show()"}, _("New Post-it")],
#	" (", [:a, {:href=>"javascript:wema_help_show()"}, _("help")], ")"]
----------------------------------------------------------------------
#      desc = [[:h3, _("Title") + ": " + title],
#	[:p, _("Author") + ": " + author],
#	[:p, _("Comment"), ": ", comment]]
#      desc = [[:h3, title],
#	[:p, {:style=>"text-align:left;"},
#	  [:a, {:href=>href}, _("Download")]],
#	[:br],

/*
  border: 0;
  border: 1px solid #f60;
*/
/*
  border: 1px solid #f30;
*/
/*
  border: 1px solid #f30;
*/
/*
  line-height: 1.0;
*/
/*
  color: #f60;
*/
/*
  border: 1px solid #f30;
*/
----------------------------------------------------------------------
    def monitor_ok(ev)
      ar = [:event]
      ar << [:title, ev[:title]] if ev[:title]
      ar << [:cmd, ev[:cmd]] if ev[:cmd]
      ar << [:pagename, ev[:pagename]] if ev[:pagename]
      @res.status = 200
      @res.body = ar
    end
    # ========== test
    def act_viewmonitor # for test
      return c_notice("monitor")
    end
  # not yet
  class Event
    def initialize
    end
  end
----------------------------------------------------------------------
    def nu_plg_hmenu
      ar = []
      menu_define_style(ar)	# Define style first.
      content = yield
      w = c_res(content)
      ar << [:div, {:class=>"hmenu"}, w]
      return ar
    end
----------------------------------------------------------------------
=begin
      size = "40"
      ar = []
      1.times {
	ar << [:input, {:type=>"file", :name=>"content", :size=>size}]
	ar << [:br]
      }
      ar << [:input, {:type=>"submit", :value=>_("Attach")}]
      form = [:form, {:action=>pagename+".files",
	    :method=>"POST", :enctype=>"multipart/form-data"},
	  *ar]
=end

=======================================================2005-08-14(Sun)

----------------------------------------------------------------------
      #w = c_get("TextFormat")
      #w = login_show_login_page("http://example.com/HelloQwik/")
----------------------------------------------------------------------
      #if ! MailAddress.new(mail).valid?
----------------------------------------------------------------------
  def generate_html(d) # not use
    generate_html_from_data(@qrcode.make_qrcode(d))
  end
----------------------------------------------------------------------
#    def valid?
#      return MailAddress.valid?(@mail)
#    end
#    def normalize
#      return MailAddress.normalize(@mail)
#    end
#    def normalize!
#      @mail = normalize
#    end
----------------------------------------------------------------------
    def test_all
      ma = Qwik::MailAddress.new("user@e.com")
#      ok_eq("user@e.com", ma.to_s)
    end
    def initialize(mail)
      @mail = mail.to_s
    end
#    def to_s
#      @mail
#    end
----------------------------------------------------------------------
#    def obfuscate
#      return MailAddress.obfuscate(@mail)
#    end

=======================================================2005-08-14(Sun)

=======================================================2005-08-13(Sat)

----------------------------------------------------------------------
/cvsroot/qwik/qwik/lib/qwik/act-ref.rb,v  <--  act-ref.rb
/cvsroot/qwik/qwik/lib/qwik/act-sitelog.rb,v  <--  act-sitelog.rb
/cvsroot/qwik/qwik/lib/qwik/act-surface.rb,v  <--  act-surface.rb
/cvsroot/qwik/qwik/lib/qwik/act-time-walker.rb,v  <--  act-time-walker.rb
/cvsroot/qwik/qwik/lib/qwik/act-toc.rb,v  <--  act-toc.rb
/cvsroot/qwik/qwik/lib/qwik/act-url.rb,v  <--  act-url.rb
/cvsroot/qwik/qwik/lib/qwik/act-wema.rb,v  <--  act-wema.rb
----------------------------------------------------------------------
      # See a page.
#      res = session("/test/1.html")
      #pw("//div[@class='comment']")
      #pw("//div[@class='files']")
#      ok_xp([:div, {:class=>"files"},
#		     [:h5, [:a, {:href=>"1.files"}, "Files"]]],
#		   "//div[@class='files']")
----------------------------------------------------------------------
#	    " (", [:a, {:href=>base+"?c=del&f="+file}, _("del")], ")"]]
      #if @req.query["c"] == "del"
#      end
    # @req.base = "FrontPage"	# Already set in request.rb
	#page = @site[@req.base]
	#if !page.files.exist?(filename)
      #qp file.to_s, type
	#[:form, {:method=>"POST", :action=>"#{@req.base}.files"},
#	  [:input, {:type=>"hidden", :name=>"c", :value=>"del"}],

=======================================================2005-08-12(Fri)

----------------------------------------------------------------------
http://colinux:9190/HelloQwik/ActAlbum.html
  border: 1px solid #ccc;
  border: 1px solid #f00;
  text-align: right;
div.table_edit div.submit {
}
----------------------------------------------------------------------
ActCounter.txt
ActHatenaPoint.txt
ActMComment.txt
ActMenu.txt
ActPlan.txt
ActSchedule.txt
ActTableEdit.txt
----------------------------------------------------------------------
  alert("hi!");
  //d_debug.p(newcols);
  alert(newcols);
    //alert(newcol.style.display);
    if (newcol.style.display == "none"){
      newcol.style.display = "block";
    }

=======================================================2005-08-11(Thu)

----------------------------------------------------------------------
    def nu
      c_plain("counter") { "" }
      head = @res.body.get_path("//head")
      head.clear
      head << :head
      head << div
      body = @res.body.get_path("//body")
      body.clear
      body << :body
      body << div
#      footer= @res.body.get_path("//div[@class='footer']")
#      footer.clear
#      header= @res.body.get_path("//div[@class='header']")
#      header.clear
      pp @res.body
      return nil
    end

=======================================================2005-08-08(Mon)

----------------------------------------------------------------------
      #style = "width: 690px; height: 382px;"
#      style = "width: 600px; height: 322px;"
----------------------------------------------------------------------
    # http://colinux:9190/HelloQwik/ActAlbum.html
=begin
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=Shift-JIS">
<TITLE>Ȃ߂炩Ao</TITLE>
</HEAD>
<BODY bgcolor=#000000>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH=100% HEIGHT=100% id=album ALIGN="">
<PARAM NAME=movie VALUE=album.swf>
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#000000>
<EMBED src=album.swf quality=high bgcolor=#000000 WIDTH=100% HEIGHT=100% NAME=album ALIGN="" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED>
</OBJECT>
</BODY>
</HTML>
=end
----------------------------------------------------------------------
      return
      files.put("2.jpg", png)
      page = @site.create_new
      page.store("{{album}}")
      res = session("/test/1.album/album.swf")
      assert_equal("application/x-shockwave-flash", res["Content-Type"])
      assert_match(/\ACWS/, res.body)
      res = session("/test/1.album/photo.txt")
      assert_equal("text/plain", res["Content-Type"])
      assert_equal("../1.files/1.jpg\n../1.files/2.jpg\n", res.body)
----------------------------------------------------------------------
#      param = res.body.get_path("//div[@class='album']/param")
#      assert_equal([:param, {:name=>"movie",
#		       :value=>"1.album/album.swf"}], param)
      #ok_wi([:span, "You can only use a table."], "{{album}}")
----------------------------------------------------------------------
    def ext_swf
      method = "#{@req.base}_#{@req.ext}"
      return self.send(method) if self.respond_to?(method)
      return c_nerror("error"){}
    end

    # http://colinux:9190/aist-bunkyo/TowerOfHanoi.album/album.swf
    def album_swf
      return theme_send_file("swf/album.swf")
    end

    def ext_txt
      method = "#{@req.base}_#{@req.ext}"
      return self.send(method) if self.respond_to?(method)
      return c_nerror("error"){}
    end

    # http://colinux:9190/aist-bunkyo/config.txt
    def config_txt
      send_txt("confg.txt")
    end

    # http://colinux:9190/aist-bunkyo/photo.txt
    def photo_txt
      str = album_generate_photo_txt
      send_txt(str)
    end

    def send_txt(str)
      @res["Content-Type"] = "text/plain"
      @res.body = str
    end
----------------------------------------------------------------------
    def ext_album
      args = @req.path_args
      return c_nerror("error"){} if args.empty? || 1 < args.length
      file = args[0]
      if file == "album.swf"
      elsif file == "photo.txt"
	return album_photo_txt
      end
      return c_nerror("error"){"error"}
    end

    def album_photo_txt
----------------------------------------------------------------------
http://colinux:9190/qwik-users/.time_walker
----------------------------------------------------------------------
#	plugin = Action.plugin_parse_content(para)
#	qp plugin
#	plugin << "add comment"
#	plugin << comment
#	plugin
----------------------------------------------------------------------
      #px("//div[@class='day'][2]/h2", 0)
      #px("//div[@class='day']", 0)
      #px("//div[@class='main']", 0)
      #assert_xml("h2 of 2", "//div[@class='day'][3]/h2")
----------------------------------------------------------------------
	#qp contents, md5hex
	#page.store(contents, md5hex) # STORE
----------------------------------------------------------------------
      if msg.nil? || msg == ""
	return comment_form
      end
      #user = plg_login_user
      #c_monitor("comment") # COMMENT
----------------------------------------------------------------------
      #date = @req.start_time.format_date
      #content = "- #{date} '''[[#{user}]]''' : #{msg}\n"
      #content = "- #{date} '''#{user}''' : #{msg}\n"
      #content = ":#{date} '''#{user}''':\n#{msg}\n"
      c_monitor("hcomment") # COMMENT
----------------------------------------------------------------------
/*
  margin: 0;
  padding: 0;
  backround-image: transparent;
*/
/*
  background-color: #efe;
*/
/*
  padding-left: 10px;
*/
/*
  color: #0f0;
  color: #000;
  background-color: #eff;
*/
/*
  width: 120px;
  left: 0.5em;
  top: 0.5em;
*/
/*
  background-color: #cfc;
*/
/*
  padding: 2px 0px 2px 5px;
*/
/*
  width: 115px;
  border-bottom: 1px solid #930;
*/
/*
  background-color: #ffc;
  background-color: #cff;
  background-color: #ffd;
*/
----------------------------------------------------------------------
/*
  width: 6em;
  width: 100px;
  height: 1.5em;
*/
/*
  width: 100px;
*/
----------------------------------------------------------------------
/* ============================== original */
/****S̈ʒǔ****/
DIV#menu{
    position: absolute;
    width: 100%;
    z-index: 100;
    font-size: 14px;
}

/****Cj[pX^C****/
ul.main{
    margin: 0px;
    padding: 0px;
    width: 100%;
    position: relative;
    list-style: none;
    text-align: center;
}

/*ʏ펞*/
.main li.off{
    position: relative;
    float: left;
    height: 1em;
    width: 100px;
    overflow: hidden;
    border: 1px solid #993300;
    background-color: #FFFFFF;
}

/*WJ*/
.main li.on{
    float: left;
    overflow: hidden;
    width: 100px;
    background-color: #FFFFD5;
    border: 1px solid #993300;
}

.main>li.on{
overflow: visible;
}

/*NX^C*/
.main a{
    display: block;
    text-decoration: none;
}
.main a:hover{
    background-color: #FFFFD5;
}

/****Tuj[pX^C****/
ol.sub{
    margin: 0px;
    padding: 0px;
    position: relative;
    left: 0.5em;
    top: 0.5em;
    width: 120px;
    border: 1px solid #993300;
    border-bottom: 0px solid #993300;
    background-color: #FFCCCC;
    list-style: none;
    text-align: left;
}
.sub li{
/*KvɉĒǉ*/
}
.sub a{
    padding: 2px 0px 2px 5px;
    display: block;
    width: 115px;
    border-bottom: 1px solid #993300;
}	
.sub a:hover{
    background-color: #FFFFEC;
}
----------------------------------------------------------------------
  font-size: 14px;
/****Cj[pX^C****/
----------------------------------------------------------------------
/* Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.
This is free software with ABSOLUTELY NO WARRANTY.
You can redistribute it and/or modify it under the terms of the GNU GPL2. */

/* ============================== new */

div.hmenu {
/*
  position :absolute;
  width: 100%;
  z-index: 100;
*/
}





/* ============================== original */

div#menu{
  position:absolute;/**/
  width:100%;/**/
  z-index:100;/**/
  font-size:14px;/**/
}

/****Cj[pX^C****/
ul.main{
  margin:0px;/**/
  padding:0px;/**/
  width:100%;/**/
  position:relative;/*~*/
  list-style:none;/**/
  text-align:center;/**/
}

/*ʏ펞*/
.main li.off{
  position:relative;/*~*/
  float:left;/*~*/
  height:1em;/**/
  width:100px;/**/
  overflow:hidden;/*~*/
  border:1px solid #993300;/**/
  background-color:#FFFFFF;/**/
}

/*WJ*/
.main li.on{
  float:left;/*~*/
  overflow:hidden;/*~*/
  width:100px;/**/
  background-color:#FFFFD5;/**/
  border:1px solid #993300;/**/
}

.main>li.on{
  overflow:visible;/*~*/
}

/*NX^C*/
.main a{
  display:block;/**/
  text-decoration:none;/**/
}
.main a:hover{
  background-color:#FFFFD5;/**/
}

/****Tuj[pX^C****/
ol.sub{
  margin:0px;/**/
  padding:0px;/**/
  position:relative;/*~*/
  left:0.5em;/**/
  top:0.5em;/**/
  width:120px;/**/
  border:1px solid #993300;/**/
  border-bottom:0px solid #993300;/**/
  background-color:#FFCCCC;/**/
  list-style:none;/**/
  text-align:left;/**/
}

.sub li{
  /*KvɉĒǉ*/
}

.sub a{
  padding:2px 0px 2px 5px;/**/
  display:block;/**/
  width:115px;/**/
  border-bottom:1px solid #993300;/**/
}	

.sub a:hover{
  background-color:#FFFFEC;/**/
}

/* end */

----------------------------------------------------------------------
    def nu_plg_counter
      if FileTest.file?("log/count.log") 
	copn=open("log/count.log","rb")
	@now=copn.read
	copn.close
	@now = @now.to_i		#^ϊ
      else
	@now=0
      end

      @now = @now + 1

      cout=open("log/count.log","wb")
      cout.print "#{@now}\n"
      cout.close

      $LOAD_PATH
      @now
    end

----------------------------------------------------------------------
	:NU_INVITE_FORM => "|Ȃ̃[|{{ring_show(mail)}}|
|Ȃ̃[U|{{ring_show(user)}}|
|Ȃ̖O|{{ring_show(name)}}|
|[|{{textarea(tomail,40,4,guest@example.com)}}|
|҂l̃[AhX͂ĂB|
|bZ[W|{{textarea(message,40,7,SFC-Ringɏ҂܂B)}}|
|̕ʂƋɁA҂lɑ܂B̕ʂƋɏҏꗗɕ\܂B|
||{{submit( ҂! )}}|",
	:NU_MAKER_FORM => '|[|{{ring_show(mail)}}|
|[Ul[|{{input(username)}}|
|SFC-Ringŕ\閼OłBAt@xbgAЂ炪ȁAȁAȂǂg܂BLA󔒂͎g܂B: katokanAJgJAƂAAȂǂȂǁB|
|{|{{input(realname)}}|
|ww|{{select(faculty,,,Ō,EfBA)}}|
|wNx|{{select(year,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003)}}|
||{{submit( o^! )}}|',
----------------------------------------------------------------------
      #mail = plg_ring_show("mail")
      #qp mail
----------------------------------------------------------------------
      w = c_res(":#{_r(:USER_NAME)} E-mail:{{ring_see(name)}} <{{ring_see(mail)}}>
:#{_r(:USER_NYUGAKU)}:{{ring_see(year)}}#{_r(:USER_YEAR)} {{ring_see(faculty)}}
")
      #pp w
      #assert_xml("error", "//div[@class='section']")
      #px("//div[@class='section']", 0)
#      assert_wiki("<a href=\"1.html\">t</a>", "{{ring_link('t@e.com')}}")
----------------------------------------------------------------------
    color: #000 ! important;
  a:link	{ color: #000 ! important; }
  a:visited	{ color: #000 ! important; }

=======================================================2005-08-07(Sun)

----------------------------------------------------------------------
     #assert_equal([], tl.site_max)
     #assert_equal([], tl.page_max)
----------------------------------------------------------------------
      #return nil if pages.length == 0
	  #year, month, mday = Action.tag_parse_date(tag)
	  #if year
	    #pages << [page, year, month, mday]
	#return [year, month, mday]
	date = 
	#date = Time.local(year.to_i, month.to_i, mday.to_i)
----------------------------------------------------------------------
	#return "#{month}-#{mday}"
      #str = ""
	#str << "- #{year}-#{month}-#{mday} [[#{title}|#{key}]]\n"
      #ul = c_parse(str)
      #now_month = now.month
      #now_mday  = now.mday
      #return date.strftime("%M/%d")
      #return "#{month}/#{mday}"
----------------------------------------------------------------------
css nobr
----------------------------------------------------------------------
(dest=nil)
      goback = info+"#{_r(:MAKER_GOBACK_AND_CONFIRM)}\n"
      info = "
:#{_r(:USER)}:#{username}
:#{_r(:REALNAME)}:#{realname}
"
#      w = c_res("** #{_r(:MAKER_REGISTERD)}#{info}[[#{_r(:MAKER_THE_PAGE)}|#{newkey}]]#{_r(:MAKER_SEE)}\n")
#      pp w
----------------------------------------------------------------------
	return c_res("** #{_r(:MAKER_NOT_REGISTERD)
}#{goback}")
----------------------------------------------------------------------
      #newpage = ring_make_template(user)
----------------------------------------------------------------------
    def nu_plg_ring_make_go(arg=nil)
      mail = @req.user

      page = c_get_superpage(RING_MEMBER)
      page = @site.create(RING_MEMBER) if page.nil?
      if page.wikidb.exist?(mail)
	return c_res("** #{_r(:MAKER_ALREADY_REGISTERD)}")
      end

      user    = @req.query["username"]
      name    = @req.query["realname"]
      faculty = @req.query["faculty"]
      year    = @req.query["year"]
      info = "
:#{_r(:USER)}:#{user}
:#{_r(:REALNAME)}:#{name}
"
      goback = info+"#{_r(:MAKER_GOBACK_AND_CONFIRM)}
"
      if !user || user.empty? || !name || name.empty?
	return c_res("** #{_r(:MAKER_NOT_REGISTERD)}#{goback}")
      end

      newpage = ring_make_template(user)
      pagename = newpage.key

      now = @req.start_time
      page.wikidb.add(mail, user, name, faculty, year, pagename, now.to_i)

      return c_res("** #{_r(:MAKER_REGISTERD)}#{info}[[#{_r(:MAKER_THE_PAGE)}|#{pagename}]]#{_r(:MAKER_SEE)}
")
    end
----------------------------------------------------------------------
      #w = plg_tableform(dest){ _r(:MAKER_FORM) }
#require "qwik/act-tableform"
----------------------------------------------------------------------
	user     = plg_ring_user(host_mail, "user")
	pagename = plg_ring_user(host_mail, "pagename")
	if pagename
	  user_link = [:a, {:href=>pagename+".html"}, user]
	else
	  user_link = user
	end
----------------------------------------------------------------------
      #ar = @site["RingInvitedMember"].wikidb.hash.to_a
----------------------------------------------------------------------
	#str << ":[[#{user}|#{pagename}]] #{_r(:RIGHT_ARROW)} #{guest_name} (#{gueat_mail}) #{ymd}:#{message}\n"
      #return c_res(str)
----------------------------------------------------------------------
	w = c_res("** #{_r(:INVITE_NOSEND)}
#{goback}
")
      qp guest_mails
      #goback = _r(:GOBACK)
      w = c_res("** #{_r(:INVITE_MAIL_IS_SENT)}
:#{_r(:MESSAGE)}:#{message}
#{_r(:THANKYOU)}
")
      pp w
----------------------------------------------------------------------
#      xml = @res.body.get_path("//div[@class='section']/form")
#      assert_equal([], xml)
----------------------------------------------------------------------
    def nu_plg_ring_invite_go(arg=nil)
      tomails = @req.query["tomail"]
      message = @req.query["message"]
      goback = "
#{_r(:GOBACK)}
"
      if tomails.nil? || tomails.empty? || message.nil?
	return c_res("** #{_r(:INVITE_NOSEND)}#{goback}")
      end

      tomailar = []
      tomails.each {|line|
	tomail = line.chomp.sub(/^\s+/, "").sub(/\s+$/, "").sub(/,$/, "")
	next unless MailAddress.new(tomail).valid?
	tomailar << tomail
      }

      if tomailar.length == 0
	return c_res("** #{_r(:INVITE_INPUT_MAIL)}#{goback}")
      end

      tomailar.each {|tomail|
	next if @site.member.exist_qwik_members?(tomail)

	mail = @req.user
	res = @site.member.invite(tomail, mail)
	page = c_get_superpage(RING_INVITE_MEMBER)
	page = @site.create(RING_INVITE_MEMBER) if page.nil?
	now = @req.start_time
	page.wikidb.add(tomail, "", mail, message, now.to_i)
	plg_ring_invite_sendmail(mail, tomail, "", message)
      }

      return c_res("** #{_r(:INVITE_MAIL_IS_SENT)}
:#{_r(:MESSAGE)}:#{message}
#{_r(:THANKYOU)}
")
    end
----------------------------------------------------------------------
#	:MSG_FROM_PAGE => "̃y[W",
#	:MSG_GOBACK_TO => "ɖ߂B",
----------------------------------------------------------------------
#      user = plg_ring_user(mail, "user")
#      user_pagename = plg_ring_user(mail, "pagename")
#      ymdx = @req.start_time.ymdx
      datenum = @req.start_time.to_i.to_s
----------------------------------------------------------------------
      #content = ":[[#{user}|#{user_pagename}]] (#{ymdx}):#{message}\n"
----------------------------------------------------------------------
      #page = @site["1"]
      #page.store("{{ring_message_go}}")
      #res = session("/test/1.html?page=1")
      # send message.
----------------------------------------------------------------------
require "qwik/act-tableform"
     #w = plg_tableform(dest){ _r(:INVITE_FORM) }
----------------------------------------------------------------------
     #ymdx = Time.now.ymdx
      goback = "[[#{frompagename}]]#{_r(:MSG_GOBACK_TO)}"
     #frompagename = @req.query["page"]
#      qp mail
----------------------------------------------------------------------
#require "qwik/act-tableform"
#require "qwik/act-ring-common"

    def nu_plg_ring_message_go(arg=nil)
      mail = @req.user
      user = plg_ring_user(mail, "user")
      message = @req.query["message"]
      frompagename = @req.query["page"]
      goback = "
[[#{_r(:MSG_FROM_PAGE)}|#{frompagename}]]#{_r(:MSG_GOBACK_TO)}
"
      if !message || message == "" || message == _r(:MSG_INPUT_HERE)
	return c_res("** #{_r(:MSG_INPUT_MESSAGE)}#{goback}")
      end

      pagename = plg_ring_user(mail, "pagename")
     #ymdx = Time.now.ymdx
      ymdx = @req.start_time.ymdx
      content = ":[[#{user}|#{pagename}]] (#{ymdx}):#{message}
"
      @site[frompagename].add(content)

      return c_res("** #{_r(:MSG_MESSAGE_IS_ADDED)}#{goback}#{_r(:THANKYOU)}
")
    end
----------------------------------------------------------------------
     #username = plg_ring_show("user")
----------------------------------------------------------------------
/*
  border: 1px solid #933;
  border: 1px solid #000;
  background: #eee;
  color: #e60;
*/
/*
  border: 1px solid #999;
*/
----------------------------------------------------------------------
      #destpage = "RingMessageWrite"
      destpage = destpage+".html"
      pagename = 
	  [:input, {:type=>"hidden", :name=>"page", :value=>pagename}],

=======================================================2005-08-06(Sat)

----------------------------------------------------------------------
    def nu_ring_get_userinfo(mail, type)
      # Get member database.
      page = c_get_superpage(RING_MEMBER)
      return nil if page.nil?

      # Get the array.
      ar = page.wikidb[mail]
      return nil if ar.nil? # I can't find by the primary key.

      # Primary key is the mail address of the user.
      return mail if type == "mail"

      # You can select the values from these types.
      types = %w(user name faculty year pagename time)
      typenum = types.index(type)
      return nil if typenum.nil?
      return ar[typenum]
    end
----------------------------------------------------------------------
      m      = plg_ring_user(mail, "mail")
      page = c_get_superpage(RING_MEMBER)
      return "error" if page.nil?
      ar =    page.wikidb[mail]
----------------------------------------------------------------------
      user = nil if user == ""
      pagename = nil if pagename == ""
      if user
      key = "[[#{user}|#{pagename}]]" if pagename
----------------------------------------------------------------------
     #page.store(",user@e.com,Test User,ei,1970,1,0")
----------------------------------------------------------------------
    def ring_get_memberpage
      c_get_superpage(RING_MEMBER)
    end
----------------------------------------------------------------------
    def nuring_catalog
      @ring_catalog = ring_generate_catalog if ! defined?(@ring_catalog)
      return @ring_catalog
    end
----------------------------------------------------------------------
      # @catalog = Catalog.new(@config) unless defined? @catalog
      # @catalog
	#qp @config.qwiklib_dir
----------------------------------------------------------------------
    #page = @site["RingMember"]
    #page.add(",user@e.com,Test User,Alan Smithy,ei,1990,1,0")
#    pw("//table/tr")
#    pw("//table/tr/td[2]/span")
----------------------------------------------------------------------
    def nu_plg_ring_message_form(arg=nil)
      plg_tableform("RingMessageWrite"){ RING_MSG_FORM }
    end
      #username = [:span, ""]
------------------------------
    RING_MSG_FORM =
"|#{RING_MSG_USER}|{{ring_show(user)}}|
|#{RING_MSG_MESSAGE}|{{textarea(message,40,7,ɃbZ[W͂ĂB)}}|
||{{submit( POST! )}}|"
------------------------------
    #page.store(":open:true")

=======================================================2005-08-05(Fri)

----------------------------------------------------------------------
#    PRE_ACTION = %w()
#    PRE_EXT = ["", "xml", "rss", "rdf", "mdlbrss"]
#    PRE_EXT = [""]
#	  if PRE_ACTION.include?(@req.plugin)
#	    return do_action(@req.plugin)
#	  end
#	  if PRE_EXT.include?(@req.ext)
#	    return do_ext(@req.ext)
#	  end
----------------------------------------------------------------------
	#return c_notice("redirect : #{url}", url){}
----------------------------------------------------------------------
#require "getopts"
    def numain(argv)
      @opt = parse_options(argv)

      if $OPT_v
	make_version
      elsif $OPT_m
	make_manifest
      elsif $OPT_d
	make_dist
      elsif $OPT_u
	upload
      else
	show_usage
      end
    end

    def nuparse_options(argv)
      getopts("nvmdu") # getopts uses ARGV
      opt = {}
      opt.update({:noop => true, :verbose => true}) if $OPT_n
      return opt
    end

    # ==============================
    def show_usage
      puts "usage:"
      puts "./make.rb -m -> make manifest"
      puts "-n to see the work without execution"
    end

     #open(@config.base_dir+"/lib/qwik/version.rb", "wb"){|out|

=======================================================2005-08-03(Wed)

----------------------------------------------------------------------
      ok_wi([[:dl, [:dt, ""], [:dd, [:input, {:name=>"key"}]]],
	      [:p, "L[[h͂ĂB"],
	      [:dl, [:dd,
		  [:input, {:value=>"Search", :type=>"submit"}]]]],
	    "{{text
::{{input(key)}}
L[[h͂ĂB
::{{submit( Search )}}
}}")
      ok_wi([:form, {:action=>"_SiteSearch.html"},
	      [[:dl, [:dt, ""], [:dd, [:input, {:name=>"key"}]]],
		[:p, "L[[h͂ĂB"],
		[:dl, [:dd,
		    [:input, {:value=>"Search", :type=>"submit"}]]]]],
	    "{{form(_SiteSearch)
::{{input(key)}}
L[[h͂ĂB
::{{submit( Search )}}
}}")
----------------------------------------------------------------------
      str.each do |line|
----------------------------------------------------------------------
      #action, arg, str, pagename = action, arg, str, pagename
----------------------------------------------------------------------
      #lines = str.split(/\n/)
      #lines.each {|line|
------------------------------
bench:
	$(RUBY) -rrbprof -I../../compat bench-session.rb 2> rbprof-bench.txt
----------------------------------------------------------------------
      #return /\A_/ =~ pagename
----------------------------------------------------------------------
    def nuschedule_make_html(pages)
      ul = [:ul]
      pages.each {|page, year, month, mday|
	ul << [:li, [:a, {:href=>page.key+".html"}, page.get_title]]
      }
      return [:div, {:class=>"schedule"}, ul]
    end
----------------------------------------------------------------------
#    def self.tag_date(tag)
#      /\A\d\d\d\d-\d\d-\d\d\z/ =~ tag
#    end
----------------------------------------------------------------------
      #return nil unless /\A\*(.+)\z/s =~ line
      #title = $1
      #return nil if /\A\*/s =~ title
----------------------------------------------------------------------
#	title = title.strip
#	return title if title.length == 0
#	return [title, tag]

=======================================================2005-08-02(Tue)

----------------------------------------------------------------------
#	  when /\A(\\|\s)/
#	  when /\A([^,'\\\s]*)/ # anything else

=======================================================2005-08-01(Mon)

----------------------------------------------------------------------
#      assert_raise(RuntimeError){
#	assert_wiki("", "{{trackfeed(z)}}")
#      }
#      assert_raise(ArgumentError){
#	assert_wiki("", "{{trackfeed}}")
#      }
#      assert_raise(RuntimeError){
#	assert_wiki("", "{{sub_bloglines(http://e.com/,-)}}")
#      }
      #px("//div[@class='section']", 0)

----------------------------------------------------------------------
    def nu_setup
      hash = QuickML::Config.load_config_file
      h = {
	:domain => "example.com",
	:postmaster => "info@example.com",
	:info_url => "http://example.com/",
	:data_dir => ".",
	:pid_file => "quickml.pid",
	:log_file => "quickml-log",
	:verbose_mode => true,
	:max_members => 2,
       #:max_mail_length => 100 * 1024,		# 100KBytes
	:max_mail_length => 10 * 1024,		# 10KBytes
	:ml_life_time => 170,
	:ml_alert_time => 160,
	:allowable_error_interval => 3,
	:auto_unsubscribe_count => 3,
	:sweep_interval => 10,
	:confirm_ml_creation => false, # for confirming ML creation.
      }
      hash.update(h)
      @config = QuickML::Config.new(hash)
      @config.instance_eval {
	@logger = QuickML::MockLogger.new
      }
      @dir = "./test/".path
      @dir.teardown
      @dir.rmtree if @dir.directory?
      @dir.rmdir  if @dir.directory?
    end


----------------------------------------------------------------------
    #attr_reader :log, :vlog

----------------------------------------------------------------------
     #parts = @body.split(/^--#{Regexp.escape(self.boundary)}\n/)
      #qp boundary

----------------------------------------------------------------------
    RE_MULTIPART = %r!^multipart/mixed;\s*boundary=("?)(.*)\1!i
      #if RE_MULTIPART =~ self["Content-Type"]
     #if %r!\Amultipart/mixed;\s*boundary=("?)(.*)\1!i =~ self["Content-Type"]
     #if /\Amultipart\/mixed;\s*boundary=("?)(.*)\1/i =~ self["Content-Type"]
     #if /\Amultipart\/\w+;\s*boundary=("?)(.*)\1/i =~ self["Content-Type"]
----------------------------------------------------------------------
  def test_submit_3
    qml = QuickML::QuickML.new(@ml_config, "test@example.com")
    qml.setup_test_config
    mail = post_mail(qml) {
'Date: Mon, 4 Feb 2001 12:34:56 +0900
From: user@e.com
To: test@example.com
Subject: i
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-2022-JP"
Content-Transfer-Encoding: 7bit

eB
' }
    assert_equal("i", @site["1"].get_title)
    assert_equal("* i\n{{mail(user@e.com,0)\neB\n}}\n", @site["1"].load)
  end

  def test_submit_4
    qml = QuickML::QuickML.new(@ml_config, "test@example.com")
    qml.setup_test_config
    mail = post_mail(qml) {
'Date: Thu, 15 Apr 2004 21:00:11 +0900
From: user@e.com
To: test@example.com
Subject: R


' }
    assert_equal("R", @site["1"].get_title)
    assert_equal("* R\n{{mail(user@e.com,0)\n\n}}\n", @site["1"].load)
  end
----------------------------------------------------------------------
#    mail = QuickML::Mail.new
#    mail.mail_from = "user@e.com"
#    mail.add_recipient("test@example.com")
----------------------------------------------------------------------
#require "socket"
#require "net/smtp"
#require "socket"
#require "net/smtp"
----------------------------------------------------------------------
  def nunew_mail(mail_from, add_recipient, body)
    return QuickML::Mail.generate { body }
  end
----------------------------------------------------------------------
  def old_new_mail(mail_from, add_recipient, body)
    return QuickML::Mail.create(mail_from, add_recipient, body)
  end

    def nu_new_mail(mail_from, add_recipient, body)
      return QuickML::Mail.create(mail_from, add_recipient, body)
    end

    def self.nu_create(mail_from, add_recipient, body) # For test.
      mail = self.new
      mail.read(body.sjistojis)
      mail.mail_from = mail_from
      mail.add_recipient(add_recipient)
      return mail
    end
----------------------------------------------------------------------
#require "qwik/ml-util-safeio"
# $KCODE = "e"
----------------------------------------------------------------------
    #qp max_length
    #qp self.eof?
      #qp c
      #qp s.length, max_length
    #qp s
----------------------------------------------------------------------
  # @pages.close if @pages
    #page = @pages.create_new
    #page.store("*t")
#	puts dummy_str
#	puts dummy_str.length

=======================================================2005-07-31

----------------------------------------------------------------------
#      div << [:div, {:id=>"message", :style=>"margin: 0 0 1em 0;"},
#        "message"]
      #elements = c_res(content)
----------------------------------------------------------------------
      //alert(parent);
      //g_debug.p(parent);
      //alert(g_debug.inspect(parent));
      //alert(typeof g_debug);
      //alert(g_debug.inspect(g_debug));
      //alert(typeof parent);
      //alert(g_debug.inspect(parent));
      //alert(g_debug.inspect(parent.message));
      //parent.getElementById("message").innerHTML = latLngStr;
      //alert(g_debug.inspect(window.top.message));
      //for (i=0; i<window.parent.frames.length; i++)
      //    alert("The title of frame #" + i + " is: " + window.parent.frames(i).document.title);
      //alert(g_debug.inspect(window.parent.frames));
      //alert(g_debug.inspect(window.parent.frames));
----------------------------------------------------------------------
#      assert_equal([:script, {:type=>"text/javascript"}, "\n//"], w[4][0..2])

=======================================================2005-07-29

----------------------------------------------------------------------
      #assert_xpath([:title, "error"], "//title")
      assert_not_equal(
[[:"?xml", "1.0", "utf-8"],
 [:rss,
  {:version=>"2.0",
   :"xmlns:creativeCommons"=>
    "http://backend.userland.com/creativeCommonsRssModule"},
  [:channel,
   [:title, "Modulobe model gallery"],
   [:link, "http://wiki.modulobe.com/"],
   [:description, "The model list of Modulobe Wiki site."],
   [:language, "ja"],
   [:managingEditor, "modulobe@qwik.jp"],
   [:webMaster, "modulobe@qwik.jp"],
   [:lastBuildDate, "Thu, 01 Jan 1970 09:00:00 GMT"],
   [:ttl, "60"],
   [:item,
    [:title, "t1 model"],
    [:link, "http://example.com:9190/test/a.files/test1.mdlb"],
    [:description,
     "<p><img src=\"http://example.com:9190/test/a.files/.thumb/test1.gif\" alt=\"t1 model\" width=\"100\" height=\"75\"/></p><p>This is a comment.\n</p>"],   
    [:author, "Alice"],
    [:pubDate, "Thu, 01 Jan 1970 09:00:00 GMT"],
    [:enclosure,
     {:length=>564,
      :type=>"application/xml",
      :url=>"http://example.com:9190/test/a.files/test1.mdlb"}],
    [:"creativeCommons:license",
     "http://creativecommons.org/licenses/by/2.1/jp/"]]]]], res.body)

=======================================================2005-07-27(Wed)

=======================================================2005-07-26(Tue)
----------------------------------------------------------------------
#    PRE_EXT = [] if ! defined?(PRE_EXT)
#    PRE_EXT << "mdlbrss"
    #      http://colinux:9190/modulobecom/model.mdlbrss
      #item << [:description, comment]
      #qp img, name, comment
      #qp src
      #qp html

=======================================================2005-07-26(Tue)

----------------------------------------------------------------------
    def initialize
#(config, site, action)
#      @config = config
#      @site = site
#      @action = action
    end

#    def self.resolve(site, action, wabisabi)
#      #return self.new(config, site, action).resolve(wabisabi)
#      return self.resolve(site, action, wabisabi)
#    end

=======================================================2005-07-25(Mon)
=======================================================2005-07-24(Sun)
=======================================================2005-07-22(Fri)
----------------------------------------------------------------------
      #return [:a, {:href=>".login"}, _("Login")] if @req.user.nil?
----------------------------------------------------------------------
    def nu_check_user(user, pass)
      raise InvalidUserError if user.nil? || user == ""
      raise InvalidUserError unless MailAddress.new(user).valid?
      gen = @memory.passgen
      raise InvalidUserError if !gen.match?(user, pass)
    end
	   #[:dd, [:input, {:name=>"user", :istyle=>"3"}]],
----------------------------------------------------------------------
    def nu_login_form_div
      [:div, {:class=>"login"},
	[:form, {:method=>"POST", :action=>".login"},
	  [:table,
	    [:tr, [:th, _("ID"), "(E-mail)", ": "],
	      #[:td, [:input, {:name=>"user", :istyle=>"3"}]]],
	      [:td, [:input, {:name=>"user", :istyle=>"3", :class=>"focus"}]]],
	    [:tr, [:th, _("Password"), ": "],
	      [:td, [:input, {:type=>"password", :name=>"pass"}]]]],
	  [:p, {:class=>"button"},
	    [:input, {:type=>"submit", :value=>_("Login")}]]]]
    end
----------------------------------------------------------------------
	  # FIXME: Take care about lang when making cache html file.
	  #" (", [:a, {:href=>".logout"}, _("Logout")], ")"]
----------------------------------------------------------------------
   #DEFAULT_EXPIRE_TIME = 60 * 60 * 2 # 2 hours

=======================================================2005-07-20(Wed)
----------------------------------------------------------------------
      #feed = [:feed, {:version=>"0.3", :xmlns=>"http://purl.org/atom/ns#"},
----------------------------------------------------------------------
      # @res.body = RSS091Generator.generate(@site)
      @res.body = RSS10Generator.generate(@site)
	@res.body = AtomGenerator.generate(@site)
	@res.body = RSS20Generator.generate(@config, @site)
----------------------------------------------------------------------
	#entry << [:id, "tag:diveintomark.org,2003:3.2397"]
	#entry << [:issued, str]
----------------------------------------------------------------------
	#[:width, "88"],
	#[:height, "31"],

=======================================================2005-07-19(Tue)
----------------------------------------------------------------------
#     feed << [:modified, @site.get_pages.last_page_time.rfc_date+"Z"]
----------------------------------------------------------------------
#require "qwik/htree-format-xml"
#require "qwik/htree-generator"
----------------------------------------------------------------------
      #channel << [:generator, generator]
	#[:guid, site.url(page.key)]
----------------------------------------------------------------------
#      session("/test/test.rss") {|req|
#	req.cookies.clear	# without login.
#      }
#      assert_equal("application/xml", res["Content-Type"])
----------------------------------------------------------------------
#    PRE_ACTION = [] if ! defined?(PRE_ACTION)
#    pre_action = %w(getpass login basicauth typekey logout theme css redirect map)
#    PRE_ACTION.insert(PRE_ACTION.length, pre_action)
#    PRE_EXT = [] if ! defined?(PRE_EXT)
#    pre_ext = ["xml", "rss", ""] # "" is important to treat with redirect
#    PRE_EXT.insert(PRE_EXT.length, pre_ext)
#    PRE_EXT = ["xml", "rss", ""]
----------------------------------------------------------------------
#      @ymd = @mtime.ymd
#    attr_reader :ymd
----------------------------------------------------------------------
	//printf("<%d> ", i);
	//printf("<%d> ", rb_type(a[i]));
	//printf("<%d> ", rb_type(T_HASH));
----------------------------------------------------------------------
      test1 = MODULOBE_TEST_MODEL1
      @site.files("c").put("t1.mdlb", test1, nil, 0)
      test2 = MODULOBE_TEST_MODEL2
      @site.files("c").put("t2.mdlb", test2, nil, 1)
      list = @action.modulobe_files_list("c")
----------------------------------------------------------------------
    def test_modulobe_model_list
      # Prepare model files.
      page = @site.create("c")
      page.store("t")

      session("/test/c.html")

      test1 = MODULOBE_TEST_MODEL1
      @site.files("c").put("t1.mdlb", test1, nil, 0)

      test2 = MODULOBE_TEST_MODEL2
      @site.files("c").put("t2.mdlb", test2, nil, 1)

      list = @action.modulobe_files_list("c")
    end
----------------------------------------------------------------------
    def test_modulobe_img
      assert_wiki([:img, {:style=>"float:left;margin-right:16px;", :src=>"t"}],
		  "{{modulobe_img(t)}}")
      assert_wiki([], "{{modulobe_img(javascript:alert)}}")
    end

    def nu_plg_modulobe_img(src)
      return  if /\Ajavascript/i =~ src
      return [:img, {:src=>src, :style=>"float:left;margin-right:16px;"}]
    end
----------------------------------------------------------------------
    def nu_plg_modulobe_files_form(pagename=nil)
      base = @req.base
      base = pagename if pagename
      form = plg_files_form
      form[1][:action] = "#{base}.modulobe_files_upload"
      return form
    end

    def nu2_plg_modulobe_files_form(pagename=nil)
      base = @req.base
      base = pagename if pagename
      form = [:form, {:action=>base+".modulobe_files_upload",
	  :method=>"POST", :enctype=>"multipart/form-data"}]
      form << "ft@C"
      form << [:input, {:type=>"file", :name=>"content", :size=>"30"}]
      form << [:br]
      form << "摜"
      form << [:input, {:type=>"file", :name=>"content", :size=>"30"}]
      form << [:br]
      form << [:input, {:type=>"submit", :value=>_("Attach")}]
      return form
    end
	    #qp img_filename
#require "qwik/act-license"

=======================================================2005-07-18(Mon)
----------------------------------------------------------------------
#        qp h2
      #pp markers
      #pp ms
	#s = marker.format_xml
	#s = ""
      #puts marker_script
#    #{marker_script}
#      puts script
    //qwikSetMark(35.41, 139.46, '<s>a</s>');
    //qwikSetMark(35.41, 139.46, '<h2>[35.41,139.46] Tonkatsu marugo</h2><p>comment1</p>');
      #assert_equal([:script, {:src=>"http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAHhZgGAuMqbbMS0D2D4oXpRTiaeAmNLI3oUNn33befpPWyxVfgRRS4olgpPIpw0jeuhmHMru_U8PEdw", :type=>"text/javascript"}, ""], w[2])
      #pp w
----------------------------------------------------------------------
#      parser = TextParser.new
#      w = parser.make_tree(tokens).get_single
      #qp wabisabi
	  #qp w
#	set_attr(w, {:title=>"hoge"})
#	set_attr(w, {:"ap:banner"=>"hoge"})
	#edithref = "#{newpagename}.new"
#	    [:img, {:src=>"/.theme/i/new.png", :alt=>"create", :class=>"new"}]]]

=======================================================2005-07-17(Sun)
----------------------------------------------------------------------
      #res = session("/test/1.html")
      #qp res.body.
      #pw "//title"
      #pw "//body"
      #pw "//div[@class='body']"
      #assert_wiki([:div, "a"], "{{map\na\n}}")
      #qp res.body.
      #pw "//title"
      #pw "//body"
      #pw "//div[@class='body']"
      #print w.format_xml
      #assert_xpath([:title, "1"], "//div[@class='maparea']")
----------------------------------------------------------------------
      # wget "http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAHhZgGAuMqbbMS0D2D4oXpRSbc2HDnbTbajc_zGKJNTMS6HbhrRRIykR3u6FqOz3bmX5JOQGjbwmdrA"
      # Key for http://qwik.jp/etoeto/
      key = "ABQIAAAAHhZgGAuMqbbMS0D2D4oXpRSbc2HDnbTbajc_zGKJNTMS6HbhrRRIykR3u6FqOz3bmX5JOQGjbwmdrA"
      # Key for http://qwik.jp/
      key = "ABQIAAAAHhZgGAuMqbbMS0D2D4oXpRTiaeAmNLI3oUNn33befpPWyxVfgRRS4olgpPIpw0jeuhmHMru_U8PEdw"
----------------------------------------------------------------------
  class NuMarker
    def initialize(lat, lng, body)
      @lat, @lng, @body = lat, lng, body
    end
    attr_reader :lat, :lng, :body
  end
----------------------------------------------------------------------
    MAP_DEFAULT_LAT = 35.6878
    MAP_DEFAULT_LNG = 139.7523
    MAP_DEFAULT_MAG = 4
    def plg_map(clat=MAP_DEFAULT_LAT,
		clng=MAP_DEFAULT_LNG,
		mag=MAP_DEFAULT_MAG)
----------------------------------------------------------------------
    def nutest_all4
      session

      # test_qwik_text
      assert_wiki("<p><del>b</del></p>", "==b==")
      assert_wiki("<hr/>", "====")

      # test_apos
      assert_wiki("<p>'</p>", "'")
      assert_wiki("<p>a</p>", "a")
      assert_wiki("<p>&lt;</p>", "<")

      # test_plugin
      assert_wiki("", "{{null}}")
      assert_wiki("<p>a </p>", "a {{null}}")
      assert_wiki("<p>a  b</p>", "a {{null}} b")
      assert_wiki("<p>a <h2>From: a</h2> b</p>", "a {{mail(a)}} b")
      assert_wiki("<p>a <span class=\"date\">Jan 1, 1970</span> b</p>",
		  "a {{date(0)}} b")
      assert_wiki("<p>a <h2><span class=\"date\">Jan 1, 1970</span> From: a</h2> b</p>", "a {{mail(a,0)}} b")
    end
----------------------------------------------------------------------
      #qp accept_languages
	#qp lang
	  #qp catalog

=======================================================2005-07-15(Fri)
----------------------------------------------------------------------
    //printf("%d ", size);
  //printf("o1 ");
    //printf("%d ", BLOCK_SIZE);
  //printf("o2 ");
    //printf("o2a %d ", c);
  //printf("o3 ");
  //printf("<-%d-> ", rb_type(xml));
  /*
  */
      //printf("<%s> ", rb_id2name(SYM2ID(tag)));
      /*
	rb_p(xml);
      if (strcmp(rb_id2name(SYM2ID(tag)), "plugin") == 0) {
      }
      */

      /*
      rb_p("hoge1");
      */
      //printf("<%s>1 ", rb_id2name(SYM2ID(tag)));
	/*
	  printf("%d", len);
	*/
      //printf("<%s>2 ", rb_id2name(SYM2ID(tag)));
      //printf("<%s>3 ", rb_id2name(SYM2ID(tag)));
      //printf("%s4 ", rb_id2name(SYM2ID(tag)));
	//printf("%s4a ", rb_id2name(SYM2ID(tag)));
	//printf("%s4b ", rb_id2name(SYM2ID(tag)));
	  //printf("%d ", i);
	  //rb_p(a[i]);
	//printf("%s4c ", rb_id2name(SYM2ID(tag)));
	//printf("%s4d ", rb_id2name(SYM2ID(tag)));
      //printf("%s5 ", rb_id2name(SYM2ID(tag)));
----------------------------------------------------------------------
      # http://maps.google.com/maps?ll=35.695174,139.776194&spn=0.005269,0.007318&t=k&hl=en

#      clat  =  35.695174
#      clong = 139.776194
#      mag = 4
#      qp clat, clon, mag
      mag = 1
----------------------------------------------------------------------
    # MAPS_DEFAULT_WIDTH  = 400
    # MAPS_DEFAULT_HEIGHT = 300
#		 width=MAPS_DEFAULT_WIDTH,
#		 height=MAPS_DEFAULT_HEIGHT)
      #width  = width.to_i
      #height = height.to_i
----------------------------------------------------------------------
#      tokenizer = TextTokenizer.new
#      tokens = tokenizer.tokenize(str)
#      qp file.to_s
#	[:p, [:a, {:href=>@req.base+".files/"+file}, file]]]
#     session("/test/1.files/1.1.smil") # get the file
----------------------------------------------------------------------
      #    px
      #    px("//div[@class='msg']", 0)
      #    assert_text("encode file: sample.avi", "title")
----------------------------------------------------------------------
#      @cmd = "c:/usr/RealProducer/producer.exe"
#      @cmd = "/usr/local/bin/producer"
#      @real_server_content_dir = "c:/usr/HelixServer/Content"
#      @real_server_content_dir = "/usr/local/HelixServer/Content/qwik"
#      @real_server_content_dir = "/usr/local/HelixServer/Content"
#      qp inf, outf
#	  url = "rtsp://"+@req.org_host+":554/"+@site.sitename+"/"+outbase
#	  url = "rtsp://"+@config.default_hostname+":554/qwik/"+@site.sitename+"/"+outbase
----------------------------------------------------------------------
#     tokenizer = TextTokenizer.new
#     tokens = tokenizer.tokenize(str)
#      parser = TextParser.new
#      tree = parser.make_tree(tokens)
#      last_tr[2..-1].each {|td|
#	td[0] = :th if td[0] == :td
#      }
	#qp sum_str
      #qp sum
----------------------------------------------------------------------
#require "qwik/emode-parser"
     #tokens = TextTokenizer.new.tokenize(str)
      #return EmodePreProcessor.new.preprocess(str)
      #return InlineParser.new.parse(str)
----------------------------------------------------------------------
	    #qp $1

=======================================================2005-07-12(Tue)

----------------------------------------------------------------------
  /*font-size: small;*/
  /*border: 1px solid #f00;*/
  background-color: transparent;
  background-color: transparent;
  /*border: 1px solid #f51;*/
/*
div.adminmenu a {
  text-decoration: underline;
}
*/
  /*display: inline;*/
  border: 1px solid #f00;
----------------------------------------------------------------------
cdel 1-eto-triple-rolling.gif 1-eto-triple-rolling.mdlb 1-kwsk_car.gif 1-kwsk_car.mdlb

=======================================================2005-07-11(Mon)
----------------------------------------------------------------------
tr.model td .ref {
  float: left;
  margin: 0;
  padding: 0;
  background-color: transparent;
  border: 0;
  text-align: center;
  font-size: xx-small;
}
----------------------------------------------------------------------
	#thumb = action.thumb_check(f)
	#src = base+"/"+f
	#return file_html(src, "thumb", thumb, alt, alt)
	#img = action.plg_file(filebase+".gif")
	#img = [:img, {:width=>"100", :height=>"75", :src=>".theme/icons/small/generic.gif"}]
	img = [:img, {:width=>"100", :height=>"75", :src=>".theme/icons/small/batten.gif"}]
      tr << [:td, [:div, {:style=>""}, img]]
#require "qwik/act-file"
----------------------------------------------------------------------
	#img = [:img, {:src=>".theme/icons/small/generic.gif"}]
	#img = [:img, {:width=>"100", :height=>"75", :src=>imgsrc}]
----------------------------------------------------------------------
width:  100px;
height: 75px;
border: 1px solid #f00;
----------------------------------------------------------------------
    # ============================== file thumb
    def file_thumb_generate(f)
      return thumb_generate(f)
    end
----------------------------------------------------------------------
   #def plg_file(f=nil, alt=f)
     #src = @req.base+".files/"+f
     #if ! @site.files(@req.base).exist?(f)
----------------------------------------------------------------------
      # http://colinux:9190/qtest/
----------------------------------------------------------------------
#require "test/unit"
     #date = Time.now.strftime("%Y-%m-%d")
      #date = Time.now.strftime("%Y-%m-%d")

=======================================================2005-07-07(Thu)
----------------------------------------------------------------------
      #tr << [:td, {:colspan=>"3"}, ymd]
      #ymd     = model.mtime.ymd
      #tr << [:td, ymd]
      #tr << [:td, [:a, {:href=>base+"/"+file}, name]]
      #qp base
      #qp @days
----------------------------------------------------------------------
      all_models.each {|model|
      }
      all_models = @models.values.sort_by {|model|
	model.mtime
      }.reverse
----------------------------------------------------------------------
      #qp files
      #qp page.cache
      #qp modellist
----------------------------------------------------------------------
    def nuget_table
      files = @site.files(@pagename)

      # Get all files.
      all_files = []
      files.each {|basename|
	next unless /\.mdlb\z/ =~ basename
	file = files.path(basename)
	all_files << [file, file.mtime]
      }
      return nil if all_files.empty?

      # Sort by time.
      all_files = all_files.sort_by {|file, mtime|
        mtime
      }.reverse

      # Select by date.
      # not yet.

      # Extract name, author and comment.
      models = []
      all_files.each {|file, mtime|
	#qp file, mtime
      }
      #qp models

      base = c_relative_to_absolute(pagename+".files")
      trs = []
      models.each {|file, mtime, name, author, comment|
	ymd = mtime.ymd
	file = file.basename.to_s
	name = file if name.empty?
	author = "anonymous" if author.empty?
	tr = [:tr]
	tr << [:td, ymd]
	tr << [:td, [:a, {:href=>base+"/"+file}, name]]
	tr << [:td, author]
	tr << [:td, [:pre, comment]]
	trs << tr
      }
      table = [:table, *trs]
      #qp table
      return table
    end
----------------------------------------------------------------------
	#[:li, [:a, {:href=>base+"/"+file}, file]]
----------------------------------------------------------------------
  def parse_a_path(path)
    if /\A(.*)\[(.+)\]\z/ =~ path
      tag = $1
      attr_selector = $2
      attr, value = parse_attr_selector(attr_selector)
    end
    return get_tag(path)
  end
----------------------------------------------------------------------
      # test_attributes
      assert_equal({:href=>"t1", :alt=>"t2"}, e.attributes)

=======================================================2005-07-07(Thu)
----------------------------------------------------------------------
    def test_modulobe_model_list
      # Prepare model files.
      page = @site.create("c")
      page.store("t")

      session("/test/c.html")

      test1 = '<?xml version="1.0" encoding="utf-8"?>
<modulobe version="0">
<world><speed>0</speed></world>
<model>
<info>
<name>model test1</name>
<author>Alice</author>
<comment>This is a test.
</comment>
</info>
<core ref="m0"><angle><x>0</x><y>0</y><z>0</z></angle></core>
<body><module id="m0"><tie dir="0"><angle><x>0</x><y>0</y><z>180</z></angle></tie>
<tie dir="1"><angle><x>0</x><y>0</y><z>0</z></angle></tie>
<tie dir="2"><angle><x>0</x><y>0</y><z>-90</z></angle></tie>
<tie dir="3"><angle><x>0</x><y>0</y><z>90</z></angle></tie>
</module></body>
</model>
</modulobe>'
      @site.files("c").put("t1.mdlb", test1, nil, 0)

      test2 = '<?xml version="1.0" encoding="utf-8"?>
<modulobe version="0">
<world><speed>0</speed></world>
<model>
<info>
<name>model test2</name>
<author>Bob</author>
<comment>This is a test too.
</comment>
</info>
<core ref="m0"><angle><x>0</x><y>0</y><z>0</z></angle></core>
<body><module id="m0"><tie dir="0"><angle><x>0</x><y>0</y><z>180</z></angle></tie>
<tie ref="m1" dir="1"><angle><x>0</x><y>0</y><z>0</z></angle></tie>
<tie dir="2"><angle><x>0</x><y>0</y><z>-90</z></angle></tie>
<tie dir="3"><angle><x>0</x><y>0</y><z>90</z></angle></tie>
</module><module id="m1"><tie ref="m0" dir="0"><angle><x>0</x><y>0</y><z>180</z></angle></tie>
<tie ref="m2" dir="1"><angle><x>0</x><y>0</y><z>0</z></angle></tie>
<link type="8" cycle="1"><cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="90" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
</link>
</module><module id="m2"><tie ref="m1" dir="0"><angle><x>0</x><y>0</y><z>180</z></angle></tie>
<tie dir="1"><angle><x>0</x><y>0</y><z>0</z></angle></tie>
<tie dir="2"><angle><x>0</x><y>0</y><z>-90</z></angle></tie>
<tie dir="3"><angle><x>0</x><y>0</y><z>90</z></angle></tie>
</module></body>
</model>
</modulobe>'
      @site.files("c").put("t2.mdlb", test2, nil, 1)

      list = @action.modulobe_files_list("c")
      #qp list
    end

#
# Copyright (C) 2003-2005 Kouichirou Eto
#     All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of 
# the GNU General Public License version 2.
#

# special mode for modulobe.com

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/act-files"

module Modulobe
  class Model
    def initialize(str)
    end

    def parse(str)
    end
  end
end

module Qwik
  class Action
    def plg_modulobe_img(src)
      return if /\Ajavascript:/i =~ src
      return [:img, {:src=>src, :style=>"float:left;margin-right:16px;"}]
    end

    # ============================== model llist
    def plg_modulobe_model_list
      div = [:div, {:class=>"files"}]
      list = modulobe_files_list
      div << list if list
      return div
    end

    def modulobe_files_list(pagename=nil)
      pagename = @req.base if pagename.nil?
      files = @site.files(pagename)
      files_path = files.path("")
      all_files = []
      files.each {|file|
	#qp file
	next unless /\.mdlb\z/ =~ file
	f = files_path + file
	mtime = f.mtime
	all_files << [f, mtime]
      }
      return if all_files.empty?

      all_files.each {|file, mtime|
	#qp file
      }

      base = c_relative_to_absolute(pagename+".files")
      list = all_files.map {|file, mtime|
	file = file.basename.to_s
	[:li, [:a, {:href=>base+"/"+file}, file]]
      }
      ul = [:ul, *list]
      return ul
    end
    private :files_list

    # ============================== upload
    def plg_modulobe_files_form(pagename=nil)
      @req.base = pagename if pagename
      form = plg_files_form
      form[1][:action] = "#{@req.base}.modulobe_files_upload"
      return form
    end

    def ext_modulobe_files_upload
      content = @req.query["content"]
      return modulobe_files_put(content) if content
      return modulobe_files_error
    end

    def modulobe_files_error
      return c_surface(_("Error")){
	[[:h2, {:style=>"margin:2em;text-align:center;"},
	    _("Please specify file.")],
	  [:p, {:style=>"margin:2em;text-align:center;"},
	    [:a, {:href=>"uploader.html"}, _("Go back")]]]
      }
    end

    def modulobe_files_put(content)
      c_require_post

      list = []

      success = true
      content.each_data {|data|
	fullfilename = data.filename
	next if fullfilename.empty?

	filename = fullfilename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 }

	result_filename = @site.files(@req.base).force_put(filename, data)

	if filename == result_filename
	  list << [:p, [:strong, filename], " : ", _("The file is saved.")]
	else
	  list << [:p, [:strong, filename], " -> ", [:strong, result_filename],
	    " : ", _("The file is saved as this filename.")]
	end

	c_make_log("modulobe file attach") # FILE ATTACH

	#files_update_page(filename)
	# t@Cꗗɂ킦B
      }

      if list.empty?
	return modulobe_files_error
      end

      url = @req.base+".html"

      ar = list+[
	[:hr],
	[:p,_("Go next")," : ",[:a,{:href=>url},url]],
      ]
      return c_surface(_("Attach file done")){ar}
    end
  end
end

if $0 == __FILE__
  require "qwik/test-common"
  $debug = true
end

if defined?($debug) && $debug
  class TC_ActModulobe < Test::Unit::TestCase
    include TestSession

    def test_all
      # test_modulobe_img
      assert_wiki([:img, {:style=>"float:left;margin-right:16px;", :src=>"t"}],
		  "{{modulobe_img(t)}}")
      assert_wiki([], "{{modulobe_img(javascript:alert)}}")

      # test_modulobe_files
      t_add_user

      page = @site.create("c")
      page.store("{{modulobe_files_form}}")

      # See the form.
      session("/test/c.html")
      form = @res.body.get_path("//div[@class='section']/form")
      assert_equal({:method=>"POST", :action=>"c.modulobe_files_upload",
		     :enctype=>"multipart/form-data"}, form[1])
      assert_equal([:form, {:method=>"POST", :enctype=>"multipart/form-data",
		       :action=>"c.modulobe_files_upload"},
		     [:input, {:size=>"40", :type=>"file", :name=>"content"}],
		     [:br],
		     [:input, {:value=>"Attach", :type=>"submit"}]],
		   form)

      # Put a file.
      mdlb = '<?xml version="1.0" encoding="utf-8"?>
<modulobe version="0">
<world><speed>0</speed></world>

<model>
<core ref="m0">
<angle><x>0</x><y>0</y><z>0</z></angle>
</core>

<body><module id="m0"><tie dir="0">
<angle><x>0</x><y>0</y><z>180</z></angle>
</tie>
<tie ref="m1" dir="1">
<angle><x>0</x><y>0</y><z>0</z></angle>
</tie>
<tie dir="2">
<angle><x>0</x><y>0</y><z>-90</z></angle>
</tie>
<tie dir="3">
<angle><x>0</x><y>0</y><z>90</z></angle>
</tie>
</module><module id="m1"><tie ref="m0" dir="0">
<angle><x>0</x><y>0</y><z>180</z></angle>
</tie>
<tie ref="m2" dir="1">
<angle><x>0</x><y>0</y><z>0</z></angle>
</tie>
<tie dir="2">
<angle><x>0</x><y>0</y><z>-90</z></angle>
</tie>
<tie dir="3">
<angle><x>0</x><y>0</y><z>90</z></angle>
</tie>
</module><module id="m2"><tie ref="m1" dir="0">
<angle><x>0</x><y>0</y><z>180</z></angle>
</tie>
<tie ref="m3" dir="1">
<angle><x>0</x><y>0</y><z>0</z></angle>
</tie>
<link type="8" cycle="1"><cycle angle="0" power="1"/>
<cycle angle="90" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
<cycle angle="0" power="1"/>
</link>
</module><module id="m3"><tie ref="m2" dir="0">
<angle><x>0</x><y>0</y><z>180</z></angle>
</tie>
<tie dir="1">
<angle><x>0</x><y>0</y><z>0</z></angle>
</tie>
<tie dir="2">
<angle><x>0</x><y>0</y><z>-90</z></angle>
</tie>
<tie dir="3">
<angle><x>0</x><y>0</y><z>90</z></angle>
</tie>
</module></body>
</model>
</modulobe>
'
      content = WEBrick::HTTPUtils::FormData.new(mdlb)
      content.filename = "test1.mdlb"
      session("POST /test/c.modulobe_files_upload") {|req|
	req.query.update({"content"=>content})
      }
      assert_text("Attach file done", "title")

      # Check log.
      sitelog = @site.sitelog
      assert_match(/,user@e.com,modulobe file attach,c\n\z/,
		   @site["_SiteLog"].load)

      # The reference is not added.
      assert_equal("{{modulobe_files_form}}", page.load)

      # Get the file.
      session("/test/c.files/test1.mdlb")
      str = @res.body.read
      @res.body.close # important
      assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, str)
      assert_equal("application/x-modulobe", @res["Content-Type"])
    end
  end
end

=======================================================2005-07-05(Tue)

----------------------------------------------------------------------
      #path = dir.path.expand_path
	  #fullpath = dir.path + file
	  #qp fullpath
----------------------------------------------------------------------
      #"You can specify pagekey." => "Ήy[WL[w肷邱Ƃł܂B",
      #"You can use alphabet and numbers for pagekey." => "y[WL[ɂ͑啶̃At@xbgAg܂B",
      #"Invalid characters" => "gȂ܂ł܂",
      #"You can only use alphabet and numbers for pagekey." => "y[WL[ɂ͑啶̃At@xbgAg܂B",
      #"PageKey is already exist." => "y[WL[̏d",
      #" is already exist." => "͂łɑ݂Ă܂B",
      #"Please specify another PageKey." => "ʂ̃y[WL[w肵ĂB",
      #"Title is already exist." => "^Cg̏d",
      #"Please specify another title." => "ʂ̃^Cgw肵ĂB",
      #"New page is created." => "VKy[W쐬܂",
      # "Confirm" => "mF", # duplicate entry
      #"Save" => "",
      #"You need login to access this site." => "̃TCgɃANZXɂ̓OCKv܂B",
      #"Are you a member of this group?" => "̃O[ṽo[ł?",
      #": You are not a member of this group." => " ͂̃O[ṽo[XgɊ܂܂Ă܂B",
      #"You need a member of this group." => "̃TCg̃o[łKv܂B",
      #" <- first" => "  ",
      #"Please input password." => "pX[h͂ĂB",
      # nu "The password will be mailed to you." => "[ɂăpX[h܂B",
      # nu "You will get the password soon." => "ΉpX[h𑗕t܂B",
      #"Show history" => "ߋ̗",
      #"Set cookie" => "cookieZbg܂",
      #": Login" => "ɃOC܂",
      #"Experimental" => "",
----------------------------------------------------------------------
      #c_require_member
      #form[1][:action] = "#{@req.base}.modulobe_files"
      #qp form
----------------------------------------------------------------------
      session("/test/1.html")
      assert_xpath([:div, {:class=>"files"},
		     [:h5, [:a, {:href=>"1.files"}, "Files"]],
		     [:ul, [:li, [:a, {:href=>"/test/1.files/t.txt"}, "t.txt"],
			   [:span, {:class=>"delete"},
			     " (", [:a, {:href=>"/test/1.files?c=del&f=t.txt"},
			     "del"], ")"]]]],
		   "//div[@class='files']")
----------------------------------------------------------------------
      #upload_number = 20
     #ar << [:input, {:type=>"submit", :value=>"attach"}]

=======================================================2005-07-01(Fri)
----------------------------------------------------------------------
    def old_get_first_line
      load.each_line {|line|
	next if /\A#/ =~ line
	return line.chomp
      }
      ""
    end
    alias get_first_line old_get_first_line
#   alias get_first_line new_get_first_line
----------------------------------------------------------------------
#require "test/unit"
----------------------------------------------------------------------
#require "webrick"
----------------------------------------------------------------------
      #ss = SimpleSender.new(@config, @req, @res)
      #return ss.simple_send(file.to_s, type)
      #ss = SimpleSender.new(@config, @req, @res)
      #return ss.simple_send(file.to_s, type)
      #ss = SimpleSender.new
      #ss.send(@config, @req, @res, path.to_s, type)
     #raise WEBrick::HTTPStatus::NotFoundError if !local_path.path.exist?
    def initialize
    end
      @config, @req, @res = config, req, res
----------------------------------------------------------------------
      #qp @req.base+".monitor"
	#qp ev
	  #qp "save event!", ev
	  #qp "save event!", @site, @req.base
	  #qp page
	  #qp str
	  #w = c_parse(str) # without resolve
	  #qp w
	  #qp "monitor return ", w
	  #qp "monitor return"
      #puts script
      #pp w
----------------------------------------------------------------------
      #qp index
	  #qp @empty_cond.count_waiters
	  #qp "new event", ev

=======================================================2005-07-01(Fri)
----------------------------------------------------------------------
    def nutest_backup
      @pages = @site

      page = @pages.create("1")
      page.store("t")
      assert_equal("t", str = page.load)

      bdb = @pages.backupdb
#      assert_instance_of(Qwik::BackupDB, bdb)
      bdb.each_by_key("1") {|v, time|
#	assert_instance_of(Pathname, f)
	assert_instance_of(String, v)
	assert_instance_of(Time, time)
#	str = f.read
#	assert_equal("t", str)
	assert_equal("t", v)
	qp v
      }

      return if $0 != __FILE__ # just for UNIT TEST

      sleep 1
      page.store("t2")

      bdb.each_by_key("1") {|v, time|
	assert_match(/\At/, v)
      }
    end
----------------------------------------------------------------------
    def test_recent_list
      @pages = @site

      # Since this test takes long time, ignore this if under test suite.
      return if $0 != __FILE__

      @pages.create("t1").store("t");	sleep 1
#      @pages.create("t2").store("t");	sleep 1
      @pages.create("1").store("t3")
#;	sleep 1
#      @pages.create("2").store("t4")
      dlist = @pages.date_list
      assert_equal("t1", dlist[0].key)
#      assert_equal("t2", dlist[1].key)
#      assert_equal("1",  dlist[2].key)
      assert_equal("1",  dlist[1].key)
#      assert_equal("2",  dlist[3].key)
      dlist.each {|page|
	assert_instance_of(Time, page.mtime)
      }
    end

----------------------------------------------------------------------
     # assert_equal("t2t3", page.load)
----------------------------------------------------------------------
      # test_not_exist_page
      assert_equal(false, @pagedb.exist?("1"))

      @pagedb.put("1", "t")
      assert_equal(true, @pagedb.exist?("1"))

      @pagedb.touch("1")
      assert_equal(true, @pagedb.exist?("1"))

      @pagedb.delete("1")
      assert_equal(false, @pagedb.exist?("1"))

=======================================================2005-06-28(Tue)
----------------------------------------------------------------------
     #return c_notice(_("Attach file"), @req.base+".html"){[ # why?
----------------------------------------------------------------------
      #filename+"."+num.to_s
     #if @site.attach.exist?(filename)
       #while @site.attach.exist?(file_with_num(filename, num))
	#return "Site attach failed because the same filename is already used.\n"
    # @site.attach.put(filename, content)
     #"\n{{ref(#{filename})}}\n\n"
----------------------------------------------------------------------
	  #body << mail.body.chomp.chomp+"\n" # This is too ad hoc.
----------------------------------------------------------------------
      @times = {}
      @page_min = {} # page_min should be cached.
      @page_max = {}
      @site.each {|page|
	key = page.key
	@times[key] = []
	@page_min[key] = nil
	@page_max[key] = nil
      }
----------------------------------------------------------------------
/* only for modulobe.com */

/* ========== general */
* {
  margin: 0;
  padding: 0;
}
body {
  background-image:url("modulobe_bg01.png");
  font-family: Helvetica,Arial,Verdana,"lr oSVbN",sans-serif;
  font-size: small;
}
p, ul {
  margin-top: 1em;
  margin-bottom: 1em;
  font-size: small;
}
h1, h2, h3, h4, h5, h6 {
  font-size: small;
}

h1 {
  color: #f51;
  font-size: medium;
  margin: 8px 16px 0px 16px;
}

h2 {
  background-image:url("modulobe_bg-navi.png");
  font-size: medium;
}

/* ========== link */
a:link {
  background-color: transparent;
  color: #f51;
  text-decoration: none;
}
a:visited {
  background-color: transparent;
  color: #f51;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ========== img */
img {
  border: none;
}
img.right {
  float:right; 
}
div.left {
  float: left;
  margin-right: 16px;
}

/* ========== container */
.container {
  width: 784px;
  margin-left: auto;
  margin-right: auto;
  background-color: #fff;
  border: 1px solid #f51; 
}

/* ==================== main adminmenu */
.adminmenu {
  width: 784px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 24px;
  margin-bottom: 4px;
  padding: 2px 0;
}
.adminmenu {
/*
  background-image:url("modulobe_bg-navi.png");
*/
  background-image:url("modulobe_bg01.png");
  padding: 0.2em 16px;
  text-align: right;
  font-size: small;
}
.adminmenu p {
  margin: 0 0;
}

/* ==================== main adminmenu toc */
.toc {
  display: none;
}

/* ==================== day */
.day, div.info{
  padding: 32px 16px 0 16px;
}

/* ==================== sidebar */
.sidebar {
/*background-image:url("modulobe_bg01.png");*/
  padding: 1em;
  margin: 16px;
  font-size: smaller;
  text-align: center;
}

/* ==================== footer */
.footer {
  display: none;
}

/*  not yet */
/**********/
div.download {
  background-image:url("modulobe_bg-gray.png");
  /* margin-left: 32px; */
  padding: 16px;
  width: 416px; /* 448px - (16px * 2) */
  height: 96px; /* 128px - (16px * 2) */
  float: right;
  display: block;
}

div.download li {
  list-style-type: none;
}

/******************** COLUMN SETTINGS **********************/
.column_title {
  width: 288px; /* 288px - 8x2px */
  float: left;
  /*  border-top: 1px solid #F75110; */
}

.column_title h2 {
  background-image:url("modulobe_bg_header.png");
  background-repeat: repeat-x;
  padding: 14px 0px 0px 0px;
}

.column_body {
  width: 448px;
  float: right;
  padding: 0px 0px 0px 16px;
  margin-bottom: 16px;
  margin-top: 0px;
}

.column_body p{
  margin-top: 0;
  margin-bottom: 1em;
}

hr.sep {
  display: none;
  clear: both;
}

=======================================================2005-06-27(Mon)
----------------------------------------------------------------------
      #c_nerror(_("Page not found."), "FrontPage.html", 404){
----------------------------------------------------------------------
=begin
      handle = [:div, {:class=>"wema", :id=>"curosr",
	  :style=>"left:0px;top:0px;"},
	[:div, {:class=>"menubar"},
	  [:span, {:class=>"handle"}, "handle"],
	  [:span, {:class=>"close"}, [:a, {:href=>"#"}, " X "]]], # noop
	[:div, {:class=>"cont"},
	  [:span, {:id=>"indicator"}, _("Move this")]]]
      ar << handle
=end

=begin
      @site.each {|page|
	key = page.key
	@site.backupdb.each_by_key(key) {|v, time|
	  times[key] << time
	  site_min = time if site_min.nil? || time < site_min
	  site_max = time if site_max.nil? || site_max < time

	  page_min[key] = time if page_min[key].nil? || time < page_min[key]
	  page_max[key] = time if page_max[key].nil? || page_max[key] < time
	}
      }
=end

=======================================================2005-06-24(Fri)
----------------------------------------------------------------------
      #w = c_get("TextFormatSimple")
      #w = login_page("http://example.com/HelloQwik/")
----------------------------------------------------------------------
    def view_page_generate(pagename)
      gen = ViewPageGenerator.new(@config, @memory, self)
      gen.generate(@site, pagename, @site.theme)
    end

      # @res.body = view_page_generate(@req.base)
      #w = view_page_generate(pagename)
----------------------------------------------------------------------
      # test_theme_path
      org_site = @site
      @site = @memory.farm.get_site("www")

      page = @site.create_new
      page.store("* h2\ntext")
      gen = Qwik::ViewPageGenerator.new(@config, @memory, @action)

      d = @dir+".attach"
      d.erase_all_for_test if d.exist?

      page = @site["_SiteConfig"]
      page.store(":theme:q")
      assert_equal("q", @site.theme)
      assert_equal(".theme/q/q.css", @site.theme_path)

      assert_equal("* h2\ntext", @site["1"].load)
      assert_match(/\A\* menu/, @site["_SideMenu"].load)
      assert_match(/qrcode/, @site["_PageAttribute"].load)

      @res.body = gen.generate(@site, "1", @site.theme)
      assert_xpath([:link,
		   {:rel=>"stylesheet",
		     :href=>".theme/css/base.css",
		     :media=>"screen,tv,print",
		     :type=>"text/css"}],
		 "//link")

      page.store(":theme:http://e.com/q.css")
      assert_equal("http://e.com/q.css", @site.theme)
      assert_equal("/.css/http://e.com/q.css", @site.theme_path)
      @res.body = gen.generate(@site, "1", @site.theme)
      assert_xpath([:link,
		     {:media=>"screen,tv,print",
		       :type=>"text/css",
		       :rel=>"stylesheet",
		       :href=>"/.css/http://e.com/q.css"}],
		   "//link[2]")

      @site.attach.delete("test.css") if @site.attach.exist?("test.css")
      @site.attach.put("test.css", "q")
      assert_equal(true, @site.attach.exist?("test.css"))
      assert_equal("/.css/http://e.com/q.css", @site.theme_path)
      @res.body = gen.generate(@site, "1", @site.theme)
      assert_rattr({"href"=>".theme/css/base.css", "rel"=>"stylesheet",
		     "type"=>"text/css", "media"=>"screen,tv,print"}, "//link")
      assert_xpath([:link,
		     {:media=>"screen,tv,print",
		       :type=>"text/css",
		       :rel=>"stylesheet",
		       :href=>"/.css/http://e.com/q.css"}],
		   "//link[2]")

      @site = org_site
----------------------------------------------------------------------
#
# Copyright (C) 2003-2005 Kouichirou Eto
#     All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of 
# the GNU General Public License version 2.
#

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/template"
require "qwik/wabisabi-template"
require "qwik/generator-module"

module Qwik
  class ViewPageGenerator
    include GeneratorModule

    def initialize(config, memory, action)
      @config = config
      @memory = memory
      @action = action
    end

    def generate(site, pagename, theme=nil)
      data = {}

      page = site[pagename]
      title = page.get_title
      str = page.get_body
      generate_by_str(data, site, title, str)

      data[:adminmenu] = get_super(site, "AdminMenu")

      data[:toc] = @action.toc_inside

      pageattribute = get_super(site, "PageAttribute")

      data[:body_leave] = [
	[:div, {:class=>"day"},
	  [:div, {:class=>"comment"},
	    [:div, {:class=>"caption"},
	      [:div, {:class=>"page_attribute"},
		pageattribute,
		[:br, {:style=>"clear:both;"}]],
	      [:"!--", "page_attribute"]],
	    [:"!--", "caption"]],
	  [:"!--", "comment"],
	  [:div, {:class=>"body_leave"}, ""],
	  [:"!--", "body_leave"]],
	[:"!--", "day"]
      ]

      apply_template(data, "view")
    end

    def set_view_meesage_page_adminmenu(data, site)
      data[:adminmenu]  = @action.c_res("{{login_status}}\n- .")
    end

    def apply_template(data, template)
      xml = @memory.template.get(template)
      xml.apply(data)
    end

    def generate_by_str(data, site, title, str)
      w = @action.c_res(str)
      tres = TDiaryResolver.new(@config, site, @action)
      w = tres.resolve(w)
      generate_by_wabisabi(data, site, title, w)
    end

    def get_window_title(site, title)
      site_title = site.title
      if site_title != ""
	#window_title = title+" - "+site_title
	window_title = site_title+" - "+title
      else
	window_title = title
      end
      return window_title
    end

    def generate_by_wabisabi(data, site, title, wabisabi)
      #window_title = get_window_title(site, title)
      window_title = title
      
      theme_path = site.theme_path

      data[:body] = wabisabi

      head = []
#     head << [:title, page_title]
#     head << [:title, title]
      head << [:title, window_title]
      m = "screen,tv,print"
      head << [:link, {:rel=>"stylesheet", :type=>"text/css",
	  :href=>".theme/css/base.css", :media=>m}]
      head << [:link, {:rel=>"stylesheet", :type=>"text/css",
	  :href=>theme_path, :media=>m}]
#      head << [:link, {:rel=>"stylesheet", :type=>"text/css",
#	  :href=>".theme/ap/ArekorePopup.css", :media=>m}]

      head += generate_js

      data[:view_title] = title
      data[:body_enter] = nil
      data[:header] = head
      data[:sidemenu]   = get_super(site, "SideMenu")
      data[:footer]     = get_super(site, "SiteFooter")
    end

    def get_super(site, k)
      return @action.c_get(k) if site.exist?(k)
      k = "_"+k
      return @action.c_get(k) if site.exist?(k)
      raise "no such super file" # assert
    end
  end
end

if $0 == __FILE__
  require "qwik/test-common"
  $debug = true
end

if defined?($debug) && $debug
  class TC_ViewPageGenerator < Test::Unit::TestCase
    include TestSession

    def test_all
      session

      # test_view_page_generator
      page = @site.create_new
      page.store("* h2\ntext")
      gen = Qwik::ViewPageGenerator.new(@config, @memory, @action)
      @res.body = gen.generate(@site, page.key, "qwikgreen")
      assert_text("h2", "title")
      assert_text("h2", "h1")
      assert_xml("text", "//div[@class='section']//p")
#      assert_xml("menu", "//div[@class='sidebar']//h2")

      # test_basic_structure
      t_add_user
      page = @site.create_new
      page.store("* test\ntestbody\n** h3\nh3body\n* h2\nh2body\n")
      side = @site["_SideMenu"]
      side.store("* side\nsidebody [[1]]")

      # See the basic structure of the page
      session("/test/#{page.key}.html")
      assert_text("test", "title")
      assert_xml('test', "//div[@class='main']/h1")
      assert_text("h2", "h2")

      assert_xml("h3", "//div[@class='body']//h3")
      x = @res.body.get_path("//div[@class='body']//h3")
      assert_equal("h3", x.extract_text.to_s)
      assert_xml("h3", "//div[@class='day']/h3")
      assert_xml("testbody", "//div[@class='day']//p")
      assert_xml("side", "//div[@class='sidebar']//h2")
      assert_xml("h2", "//div[@class='sidebar']//a")
    end
  end
end

=======================================================2005-06-21(Tue)
=======================================================2005-06-02(Thu)
----------------------------------------------------------------------
	  #if line.include?(key) # do not use Regexp for now by security reason.
=======================================================2005-05-28(Sat)
----------------------------------------------------------------------
      }
      times.each {|k, ar|
----------------------------------------------------------------------
      var o = document.createElement("v:line");
      o.id = "vl"+this.divlist[i].id;
      ar.push(o);
      divlines.appendChild(o);
      var x = this.eraWidth * i;
      o.style.visibility = "visible";
      o.setAttribute("strokeweight", "1");
      o.setAttribute("strokecolor",   "#009");
      o.style.position = "absolute";
      o.style.left = "0px";
      o.style.top  = "0px";
      o.setAttribute("from", ""+x+","+40);
      o.setAttribute("to",   ""+x+","+48);

=======================================================2005-05-25(Wed)
----------------------------------------------------------------------
	#qp @config.max_mail_length, len
----------------------------------------------------------------------
      # @inputs.empty?
      #flag = @inputs.size <= @inputs.pos
      #flag = @inputs.closed?
      #qp flag
      #qp @inputs.size, @inputs.pos, flag
      #qp @inputs.closed?
      flag = @inputs.eof?
      flag
      #qp str
      #qp str

    def nu_safe_gets
      #return "" if @inputs.empty?
      #return "" if @inputs.eof?
      #return "" if closed?
      #return nil if closed?
      return nil if eof?
      #input = @inputs.shift
      line = @inputs.gets
      line = line.xchomp+"\r\n"
      #qp input
      return line
    end

=======================================================2005-05-20(Fri)

=======================================================2005-05-19(Thu)
----------------------------------------------------------------------
#!/usr/bin/env ruby -w
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH.unshift("../../compat") unless $LOAD_PATH.include?("../../compat")
$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
$debug = true

#require "test/unit"
#require "pp"
#require "qwik/qp"
#require "qwik/server"
require "qwik/test-module-session"

def make_clean
  "example.com".path.remove_directory
  "test".path.remove_directory
  "www".path.remove_directory
end

def load_test_files
end

def load_act_files2
  loadlib = Qwik::LoadLibrary.new("../../lib")
  loadlib.glob("qwik/act-theme.rb")
end

def load_act_files
  require "qwik/loadlib"
  loadlib = Qwik::LoadLibrary.new("../../lib")
#  loadlib.glob("qwik/act-aa.rb")
end

def load_unit_tests
  require "qwik/loadlib"
  loadlib = Qwik::LoadLibrary.new("../../lib")
end

def load_qwik_files
  require "qwik/loadlib"
  loadlib = Qwik::LoadLibrary.new("../../lib")
end

def load_bench_files
end

def load_check_files
end

if $0 == __FILE__
  make_clean
  load_test_files
  #load_usecase_files
  load_act_files
  load_act_files2
  load_qwik_files
  #load_check_files
  #load_bench_files
end

=======================================================2005-05-18(Wed)
----------------------------------------------------------------------
      qp "done"
      #trap(:TERM) { server.shutdown; }
      #trap(:INT)  { server.shutdown; }
      #wreq = wreq.dup

      qp wres.body.class
      if wres.body.is_a? String
      elsif wres.body.is_a? Array
	assert_match(%r|^<|, wres.body)

      if wres.body.is_a? String
      else
	assert_instance_of(File, wres.body)
	assert_equal(?<, wres.body.read[0])
	wres.body.close
      end

      if wres.body.is_a? String
      else
	assert_instance_of(File, wres.body)
	wres.body.close
      end
----------------------------------------------------------------------
#      server = Qwik::Server.new(config)
#      memory = server.memory
      #wreq = Test::WEBrickRequest.new(server.config)
      #wreq = Test::WEBrickRequest.new(server.config)

=======================================================2005-05-17(Tue)
----------------------------------------------------------------------
      # Do not test for base_dir.
      #base_dir = File.expand_path(File.dirname(__FILE__)+"/../../")
      #assert_equal(base_dir+"/bin", @config.bin_dir)

=======================================================2005-05-13
=======================================================2005-05-10(Tue)
=======================================================2005-05-09(Mon)
----------------------------------------------------------------------
      if inputs.is_a?(String)
	inputs = inputs.split("\n")
	qp "create inputs"
	inputs.map! {|line| line+"\r\n" }
	qp "create inputs done"
      end
      @inputs = inputs
----------------------------------------------------------------------
#require "qwik/ml-catalog-factory"
#require "qwik/ml-utils"
#require "qwik/qp"
      #qp !@gettext_catalog.nil?, @gettext_charset
      #qp @gettext_catalog.length if @gettext_catalog
      #qp cf.catalog_re
      #qp catalog_ja.length
----------------------------------------------------------------------
	 #catalogs[lang] = send("catalog_"+lang)
	 #catalogs[lang] = klass.send("catalog_"+lang)

=======================================================2005-05-08(Sun)
----------------------------------------------------------------------
 #qp type, fdesc
 #if /\Aattachment;\s+filename=\"(.*)\"\Z/ =~ disp # should use \z ?

=======================================================2005-05-07
=======================================================2005-05-06(Fri)
=======================================================2005-05-03(Tue)
=======================================================2005-05-02(Mon)

----------------------------------------------------------------------
      #config_file = argv.first if argv.length == 1
     #config = QuickML::Config.load(config_file)
      #server  = QuickML::Server.new(config)
    # not used
    def nu_error (msg)
      STDERR.puts "#{$0}: #{msg}"
      exit(1)
    end

    def nu_show_usage
      puts "Usage: quickml <data directory> <smtp server> <domain name>"
    end

    def nu_touch (filename)
      File.safe_open(filename, "a").close
    end

      sweeper = QuickML::Sweeper.new(config)

=======================================================2005-04-20(Wed)
=======================================================2005-04-19(Tue)

----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/template"
require "qwik/wabisabi-get"
require "qwik/generator-module"

module Qwik
  class NoticePageGenerator
    include GeneratorModule

    def self.generate(template, title, msg, url=nil, redirectflag=false)
      w = template.get_tag("head")

      # insert title
      w.insert(1, [:title, title])

      # insert JavaScript
      js = GeneratorModule.generate_js("/")
      w.insert(w.length, *js)

      # insert meta
      w << [:meta, {:name=>"ROBOTS", :content=>"NOINDEX,NOFOLLOW"}]
      if url && !redirectflag # redirect
	w << [:meta, {"http-equiv"=>"Refresh", :content=>"0; url=#{url}"}]
      end

      # insert h1
      w = template.get_tag("h1")
      w << title

      # insert section
      w = template.get_by_class("section")
      w << msg

      template
    end
  end
end

if $0 == __FILE__
  require "pp"
  require "test/unit"
  require "qwik/config"
  require "qwik/memory"
  $debug = true
end

if $debug
  class TC_NoticePageGenerator < Test::Unit::TestCase
    def test_all
      # setup config and memory
      @config = defined?($test_config) ? $test_config : Qwik::Config.new(true)
      @memory = defined?($test_memory) ? $test_memory :
	Qwik::ServerMemory.new(@config)

      template = @memory.template.get("notice")
      assert_equal([:h1], template.get_tag("h1"))
      assert_equal([:div, {:class=>"section"}],
		   template.get_by_class("section"))

      res = Qwik::NoticePageGenerator.generate(template, "title", "msg")
      assert_equal([:title, "title"], res.get_tag("title"))
      assert_equal([:script, {:src=>"/.theme/js/base.js",
		       :type=>"text/javascript"}, ""], res.get_tag("script"))
      assert_equal([:meta, {:content=>"NOINDEX,NOFOLLOW", :name=>"ROBOTS"}],
		   res.get_tag("meta"))
      assert_equal([:h1, "title"], res.get_tag("h1"))
      assert_equal([:div, {:class=>"section"}, "msg"],
		   res.get_path("//div[@class='section']"))
      assert_equal(nil, res.get_tag("meta[2]")) # not redirected

      template = @memory.template.get("notice")
      res = Qwik::NoticePageGenerator.generate(template, "title", "msg", "url")
      #pp res
      assert_equal([:meta, {:content=>"0; url=url", "http-equiv"=>"Refresh"}],
		   res.get_tag("meta[2]")) # redirected
    end
  end
end

----------------------------------------------------------------------
#require "qwik/generator-notice"
      #w = c_get("TextFormatSimple")
      #w = c_get("TextFormat")
    # @res.body = NoticePageGenerator.generate(template, title, msg, url)
      # setup config and memory
#      @config = defined?($test_config) ? $test_config : Qwik::Config.new(true)
#      @memory = defined?($test_memory) ? $test_memory :
#	Qwik::ServerMemory.new(@config)
     #res = Qwik::NoticePageGenerator.generate(template, "title", "msg")
     #res = Qwik::NoticePageGenerator.generate(template, "title", "msg", "url")
      #pp res
----------------------------------------------------------------------
=begin
      assert_wiki("<form action=\"1.html\"><p>t</p></form>",
		  "{{form\nt\n}}")
      assert_wiki([:form, {:action=>"1.html"}, [[:p, "t"]]],
		  "{{form\nt\n}}")
      assert_wiki([:form, {:action=>"1.html"},
		    [[:p, "VKo[ǉ܂B"],
		      [:dl, [:dt, "Ȃ̃["], [:dd, "user@e.com"],
			[:dt, "ǉ["],[:dd, [:input, {:name=>"tomail"}]]],
		      [:p, "ǉl̃[AhX͂ĂB"],
		      [:dl, [:dd,
			  [:input, {:value=>"ǉ", :type=>"submit"}]]]]],
		  "{{form
VKo[ǉ܂B
:Ȃ̃[:{{member_user(mail)}}
:ǉ[:{{input(tomail)}}
ǉl̃[AhX͂ĂB
::{{submit(ǉ)}}
}}")
      assert_wiki([:form, {:action=>"1.html"},
		    [[:p, "VKo[ǉ܂B"],
		      [:dl, [:dt, "Ȃ̃["], [:dd, "user@e.com"],
			[:dt, "ǉ["],[:dd, [:input, {:name=>"tomail"}]]],
		      [:p, "ǉl̃[AhX͂ĂB"],
		      [:dl, [:dd,
			  [:input, {:value=>"ǉ", :type=>"submit"}]]]]],
		  "{{member_add}}")
=end

    def nu_plg_member_add_form(dest="")
      c_res("{{form
VKo[ǉ܂B
:Ȃ̃[:{{member_user(mail)}}
:ǉ[:{{input(tomail)}}
ǉl̃[AhX͂ĂB
::{{submit(ǉ)}}
}}")
    end


----------------------------------------------------------------------
#require "qwik/generator"
      #c_view(msg){str}
      #c_view(msg){str}
----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/template"
require "qwik/wabisabi-get"
require "qwik/generator-module"

module Qwik
  class NuEditorPageGenerator
    include GeneratorModule

    def self.generate(template, title, message, main, sidebar)
      w = template.get_tag("head")

      # insert title
      w.insert(1, [:title, title])

      # insert JavaScript
      js = GeneratorModule.generate_js("/")
      w.insert(w.length, *js)

      # insert meta
      w << [:meta, {:name=>"ROBOTS", :content=>"NOINDEX,NOFOLLOW"}]

      # insert h1
      w = template.get_tag("h1")
      w << title

      # insert message
      w = template.get_by_class("message")
      w << message

      # insert main
      w = template.get_by_class("main")
      w.insert(2, *main)

      # insert sidebar
      w = template.get_by_class("sidebar")
      w.insert(2, *sidebar)

      template
    end
  end
end

if $0 == __FILE__
  require "pp"
  require "test/unit"
  require "qwik/config"
  require "qwik/memory"
  $debug = true
end

if $debug
  class TC_EditorPageGenerator < Test::Unit::TestCase
    def test_all
      # setup config and memory
      @config = defined?($test_config) ? $test_config : Qwik::Config.new(true)
      @memory = defined?($test_memory) ? $test_memory :
	Qwik::ServerMemory.new(@config)

      template = @memory.template.get("editor")
      assert_equal([:h1], template.get_tag("h1"))
      assert_equal([:div, {:class=>"main"}],
		   template.get_by_class("main"))

      res = Qwik::EditorPageGenerator.generate(template, "title",
					       "msg", ["m"], ["s"])
      assert_equal([:title, "title"], res.get_tag("title"))
      assert_equal([:script, {:src=>"/.theme/js/base.js",
		       :type=>"text/javascript"}, ""], res.get_tag("script"))
      assert_equal([:link, {:href=>"/.theme/css/base.css", :rel=>"stylesheet",
		       :media=>"screen,tv", :type=>"text/css"}],
		   res.get_tag("link"))
      assert_equal([:link, {:media=>"screen,tv", :type=>"text/css",
		       :href=>"/.theme/qwikeditor/qwikeditor.css",
		       :rel=>"stylesheet"}],
		   res.get_tag("link[2]"))
      assert_equal([:meta, {:content=>"NOINDEX,NOFOLLOW", :name=>"ROBOTS"}],
		   res.get_tag("meta"))
      assert_equal([:h1, "title"], res.get_tag("h1"))
      assert_equal([:div, {:class=>"message"}, "msg"],
		   res.get_path("//div[@class='message']"))
      assert_equal([:div, {:class=>"main"}, "m"],
		   res.get_path("//div[@class='main']"))
      assert_equal([:div, {:class=>"sidebar"}, "s"],
		   res.get_path("//div[@class='sidebar']"))
    end
  end
end

----------------------------------------------------------------------
#require "qwik/generator-edit"

----------------------------------------------------------------------
#require "qwik/generator-editor"
#	  [:h2, ""],
#      @res.body = EditorPageGenerator.generate(template, title,
#					       message, main, sidebar)
#      @res.body = self.class..generate(template, title,
#				       message, main, sidebar)
#    def self.generate(template, title, message, main, sidebar)


=======================================================2005-04-13(Wed)

----------------------------------------------------------------------
=begin
    class Catalog
      def initialize (filename)
	load(filename)
	@messages = Messages
	@codeconv_method = CodeconvMethod
	@charset = Charset
      end
      attr_reader :messages
      attr_reader :codeconv_method
      attr_reader :charset
    end
=end
  module GetText
  end

#require "qwik/ml-message-validator"

----------------------------------------------------------------------

    def nutest_all
      @catalog_file_name = "test-catalog.ja"
      catalog_str = <<'EOT'
Messages = {
  "hello" =>"ɂ"
}
Charset = "iso-2022-jp"
CodeconvMethod = :tojis
EOT
      File.open(@catalog_file_name, "w") {|f|
	f.puts catalog_str
      }
      catalog = QuickML::GetText::Catalog.new(@catalog_file_name)

      assert_equal("hello", _("hello"))
      @catalog = catalog
      @gettext_charset = "iso-2022-jp"
      assert_equal("ɂ".tojis, _("hello"))
    end

    #include QuickML::GetText
      #qp catalog_ja


----------------------------------------------------------------------
      #qp dir
	  #qp fullpath, lang
	  #cat = Catalog.new
      #qp catalogs
  class NuCatalogFactory
    def initialize
      @catalogs = {}
    end

    def get_catalog(lang)
      @catalogs[lang]
    end

    private
=begin
    def load_all_catalogs_impl(dir, re)
      #qp dir
      catalogs = Hash.new
      dir.path.each_entry {|file|
	# lang has just two letters length.
	if re =~ file.to_s
	  lang = $1
	  fullpath = dir.path + file
	  require fullpath
	  #qp fullpath, lang
	  cat = Catalog.new
	  catalogs[lang] = cat.send("catalog_"+lang)
	end
      }
      catalogs["en"] = Hash.new {|h, k| k }
      #qp catalogs
      return catalogs
    end
=end
  end

----------------------------------------------------------------------
    def load_all_catalogs(dir)
      catalogs = Hash.new
      dir.path.each_entry {|file|
	if /\Acatalog-(.+)\.rb\z/ =~ file.to_s
	  lang = $1
	  require dir.path + file
	  #qp dir.path + file, lang
	  catalogs[lang] = Catalog.send("catalog_"+lang)
	end
      }
      catalogs["en"] = Hash.new {|h, k| k }
      #qp catalogs
      return catalogs
    end

    module_function :load_all_catalogs

  module NuGetText
    def gettext (text)
      return text if !defined?(@gettext_catalog) || @gettext_catalog.nil?
      return (@gettext_catalog[text] or text)
    end
    alias :_ :gettext

    def load_catalog (file_name)
      return eval(File.read(file_name))
    end

    def load_catalogs (directory)
      catalogs = Hash.new
      Dir.entries(directory).each {|entry|
        file_name = File.join(directory, entry)
        if m = /^catalog\.([\w.-]+)$/.match(File.basename(file_name))
          lang = m[1]
          catalog = load_catalog(file_name)
          catalogs[lang] = catalog
        end
      }
      catalogs["en"] = Hash.new {|h, k| k }
      return catalogs
    end

    def set_catalog (catalog)
      @gettext_catalog = catalog
    end
  end

    def nu
      @catalog_table = @memory.catalog.catalogs
      assert_equal("hello", _("hello"))
      set_catalog(catalog)
      assert_equal("ɂ", _("hello"))
      set_catalog({})
      assert_equal("hello", _("hello"))
      catalogs = load_catalogs(".")
      set_catalog(catalogs["ja"])
      assert_equal("ɂ", _("hello"))
      remove_catalog
    end

    def nu_setup
      @catalog_file_name = "catalog.ja"
      @catalog = {
	"hello" => "ɂ"
      }
    end

    def nu_make_catalog
      File.open(@catalog_file_name, "w") {|f|
	f.puts "{"
	@catalog.each {|key, value|
	  f.printf('  "%s" => "%s",', key, value)
	  f.puts
	}
	f.puts "}"
      }
    end

    def nu_remove_catalog
      File.unlink(@catalog_file_name)
    end

      #make_catalog
      #catalog = load_catalog(@catalog_file_name)
      #assert_equal(catalog, @catalog)

----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/catalog-factory"
require "qwik/gettext"

module Qwik
  class Catalog
    #include GetText

    def initialize(config)
      # @config = config
      lib_dir = config.lib_dir
      # @catalogs = load_catalogs(@config.catalog_dir)
      # @catalogs = load_all_catalogs(@config.catalog_dir)
      # @catalogs = load_all_catalogs(@config.lib_dir)
      # @catalogs = CatalogFactory.load_all_catalogs(@config.lib_dir)
      @catalogs = CatalogFactory.load_all_catalogs(lib_dir+"/qwik")
      #qp @catalogs
    end
    attr_reader :catalogs
  end
end

if $0 == __FILE__
  require "qwik/test-common"
  $KCODE = "s"
  $debug = true
end

if $debug
  class TestCatalog < Test::Unit::TestCase
    include TestSession

    def test_all
      catalog = Qwik::Catalog.new(@config)
    end
  end
end


=======================================================2005-04-12(Tue)
 8:59	back

----------------------------------------------------------------------
      str = <<'EOT'
config = {
  :data_dir => '.',
  :smtp_host => '127.0.0.1',
  :domain => 'example.com',
}
EOT
      #config = QuickML::Config.new_by_str(str)
      #config = @ml_config
      #pro = QuickML::Processor.new(config, mail)

----------------------------------------------------------------------
=begin
    # Make private methods to public.
    methods = %w(
qwik_post
)
#encoded_subject
    methods.each {|m|
      t_make_public(QuickML::QuickML, m)
    }

    # Make instance variables to readable.
    vars = %w(
)
    vars.each {|v|
      t_make_readable(QuickML::QuickML, v)
    }
=end

----------------------------------------------------------------------
# by eto
module QuickML
  class Processor
  end
end

=======================================================2005-04-11(Mon)
 9:35	back.
20:35	back.

----------------------------------------------------------------------
̃eXg̐B
ruby test-all.rb
Finished in 32.667 seconds.
188 tests, 1992 assertions, 0 failures, 0 errors
----------------------------------------------------------------------
#require "qwik/act-form"
=begin
	return c_res("{{form
:"+_("User")+":{{login_user}}
:"+_("Message")+":{{textarea(message,40,7)}}
::{{submit(POST)}}
}}")
=end
    def nu_comment_form
      return c_res("{{form
:"+_("User")+":{{login_user}}
:"+_("Message")+":{{textarea(message,40,7)}}
::{{submit(POST)}}
}}")
    end

----------------------------------------------------------------------
    def plg_search
      key = @req.query["key"]
      if key.nil? || key == ""
	return search_form
      end

      ar = []
      @site.each {|page|
	str = page.load
	str.each_with_index {|line, i|
	  if line.include?(key) # do not use Regexp for now by security reason.
	    ar << [page, line, i]
	  end
	}
      }

      message = ""
      if 0 < ar.length
	message << "** \n"
	ar.each {|page, line, i|
	  k = page.key
	  message << "- [[#{k}]] : #{i} : #{line}\n"
	}
      else
	message << "** ܂ł\ns܂Au'''#{key}'''v܂ރy[W͌܂łB\n"
      end
      return c_res(message)
    end

    def nu_search_form
      return c_res("{{form(_SiteSearch)
L[[h͂ĂB
:: {{input(key)}}
{{submit()}}
}}")
    end

    def search_form
      [:form, {:action=>"_SiteSearch.html"},
	[:p, "L[[h͂ĂB"],
	[:dl,
	  [:dt, ""],
	  [:dd, [:input, {:name=>"key"}]],
	  [:dd, [:input, {:value=>"", :type=>"submit"}]]]]
    end

----------------------------------------------------------------------
      # test search_form
      assert_equal("", @action.search_form)

----------------------------------------------------------------------
    def nu_search_form_page
      c_notice(_("Search")){
	[:div, {:class=>"form"},
	  [:form, {:action=>".search"},
	    [:input, {:name=>"q"}],
	    [:input, {:type=>"submit", :value=>_("Search")}]]]
      }
    end


----------------------------------------------------------------------
      # check_obsolete_page
      session("/test/_SiteSearch.html")
      assert_xml([:p, [:a, {:href=>".search"}, ".search"], "Ɉړ܂B"],
		 "//div[@class='section']")


----------------------------------------------------------------------
	# :max_mail_length => 100 * 1024,
	# :max_mail_length => 500 * 1024,
	# :max_mail_length => 1024 * 1024,
	# :message_catalog => nil  # for English messages

      #confstr = File.safe_open("../../bin/quickmlrc").read
      #confhash = eval(confstr)
      #confhash[:data_dir] = "."
      # $quickml_config  = QuickML::Config.new(confhash)


----------------------------------------------------------------------
      # @postmaster = (config[:postmaster] or "postmaster@#{domain}")
----------------------------------------------------------------------
      set_catalog({})
      assert_equal("hello", _("hello"))
      catalogs = load_catalogs(".")
      set_catalog(catalogs["ja"])
      assert_equal("ɂ", _("hello"))
      #assert_equal(catalog, @catalog)
      #assert_equal("hello", QuickML::GetText::gettext("hello"))
      #set_catalog(catalog)
	#qp @catalog, @message_charset, text
    def nutest_all
      @catalog_file_name = "test-catalog.ja"
      @catalog = {
	"hello" => "ɂ"
      }
      File.open(@catalog_file_name, "w") {|f|
	f.puts "{"
	@catalog.each {|key, value|
	  f.printf('  "%s" => "%s",', key, value)
	  f.puts
	}
	f.puts "}"
      }

      #make_catalog

      catalog = QuickML::GetText::Catalog.new(@catalog_file_name)
#      catalog = load_catalog(@catalog_file_name)
      assert_equal(catalog, @catalog)

      assert_equal("hello", _("hello"))
      set_catalog(catalog)
      assert_equal("ɂ", _("hello"))

      set_catalog({})
      assert_equal("hello", _("hello"))
      catalogs = load_catalogs(".")
      set_catalog(catalogs["ja"])
      assert_equal("ɂ", _("hello"))

      #remove_catalog

      File.unlink(@catalog_file_name)

    end
----------------------------------------------------------------------
qwik@gem%
qwik@gem%
qwik@gem% ./quickml-ctl start
Starting QuickML services: /usr/local/qwik/lib/qwik/ml-quickml-server.rb:28:in `main': uninitialized constant QuickML::QuickML::Config (NameError)
        from /usr/local/qwik/bin/quickml-server:22:in `main'
        from /usr/local/qwik/bin/quickml-server:24

qwik@gem% 2005-04-11T14:38:25 219.109.86.161 kamataki@m1.people.or.jp "GET /qwik-users/HelloQwik.html" 200 6166


----------------------------------------------------------------------
#require "qwik/qp"
----------------------------------------------------------------------
#require "qwik/ml-utils"
#require "qwik/ml-logger"
#require "qwik/ml-gettext"

require "qwik/ml-quickml"
require "qwik/ml-processor"

----------------------------------------------------------------------
if $0 == __FILE__
  $debug = true
end

if $debug
end

----------------------------------------------------------------------
  #require "t/test"
----------------------------------------------------------------------
module QuickML
  # why?
  class Config
  end
end
----------------------------------------------------------------------
     #server_software = "qwikWeb/#{@qconfig.version}+#{@qconfig.release_date}"
     #server_software = "qwikWeb/"+@qconfig.version+"+"+@qconfig.release_date

----------------------------------------------------------------------
      @port = @qconfig.port.to_i
      if @qconfig.ssl
	require "webrick/https"
	@logfile  += "-ssl"
	@alogfile += "-ssl"
	@qlogfile += "-ssl"
	@pidfile  += "-ssl"
	@port = 443 if @port == 80
      end

----------------------------------------------------------------------
	#loglevel = WEBrick::Log::DEBUG
	#format = "%l %u \"%r\" %s %b"
#	  @alogfile = $stdout
#	  @qlogfile = $stdout

----------------------------------------------------------------------
      if @qconfig.ssl
	sslconfig = {
	  :SSLEnable       => true,
	  :SSLVerifyClient => ::OpenSSL::SSL::VERIFY_NONE,
	  :SSLCertName => [ ["C","JP"], ["O","example.com"], ["CN", "WWW"] ]
	}
	webrick_config.update(sslconfig)
      end


----------------------------------------------------------------------
#      pp req
#      pp req.header
#      pp request

=======================================================2005-04-10(Sun)
21:45	back.

----------------------------------------------------------------------
    #------------------------------------------------------------ view
    def c_view(title, &block)
      gen = ViewPageGenerator.new(@config, @memory, self)
      s = ""
      s = block.call if block_given?
      @res.body = gen.generate_mes(@site, title, s)
      c_set_html
      c_set_no_cache
      nil
    end

    def generate_mes(site, title, str)
      data = {}
      generate_by_str(data, site, title, str)
      set_view_meesage_page_adminmenu(data, site)
      apply_template(data, "view")
    end


----------------------------------------------------------------------
    def generate_wmes(site, title, wabisabi)
      data = {}
      generate_by_wabisabi(data, site, title, wabisabi)
      set_view_meesage_page_adminmenu(data, site)
      apply_template(data, "view")
    end

----------------------------------------------------------------------
    def c_wview(title, &block)
      gen = ViewPageGenerator.new(@config, @memory, self)
      s = ""
      s = block.call if block_given?
      @res.body = gen.generate_wmes(@site, title, s)
      c_set_html
      c_set_no_cache
      nil
    end

----------------------------------------------------------------------
http://127.0.0.1:9190/HelloQwik/
http://127.0.0.1:9190/HelloQwik/.test_surface

----------------------------------------------------------------------
        <div class="body_top">
        </div><!--adminmenu-->
        <div class="toc">
        </div><!--toc-->
        <div class="body_enter">
        </div><!--body_enter-->
        <div class="body_leave">
        </div><!--body_leave-->

----------------------------------------------------------------------
    def c_get_super(site, k)
      return c_get(k) if site.exist?(k)
      k = "_"+k
      return c_get(k) if site.exist?(k)
      raise "no such super file" # assert
    end


----------------------------------------------------------------------
\
\
adverse sidefacefirst surfaceforegroundfront facfront faceobverseperipherysuperficiessurfacetop




----------------------------------------------------------------------
sitetitleǂł̂͂ǂł[?

test_all(TC_ActAtom): site.rb:115:title [""]
test_all(TC_ActRss): site.rb:115:title  [""]
site.rb:115:title       [""]
site.rb:115:title       [""]
site.rb:115:title       [""]
test_get_rss(TC_AtomGenerator): site.rb:115:title       [""]
test_rss091(TC_RssGenerator): site.rb:115:title [""]
site.rb:115:title       [""]
test_rss10(TC_RssGenerator): site.rb:115:title  [""]
site.rb:115:title       [""]

test_siteconfig(TC_SiteConfig): site.rb:115:title       ["TestSite"]

----------------------------------------------------------------------


----------------------------------------------------------------------
      @logger = @memory[:logger]


=======================================================2005-04-10(Sun)
 0:07	back.



----------------------------------------------------------------------
#{{show_sitemenu}}
#{{show_presen}}
# {{edit_wysiwyg}} 
#{{monitor}}

----------------------------------------------------------------------

      title = "Edit | 1"

      pagename = "1"
      str = "t"
      md5hex = str.md5hex

      message = [
	[:div, {:class=>"day"},
	  [:h2, "XVՓ˂܂"],
	  [:div, {:class=>"section"},
	    [:p, "ꂪdiffłB"]
	  ]
	]
      ]
      message = [""]
      require "qwik/act-edit"
      message = save_edit_conflict("1", "differ", "contents")

      edit_form = editor_edit_form(pagename, str, md5hex)

      attach_form = editor_attach_form(pagename)

      main = editor_main(edit_form, attach_form, pagename)

      edit_help = editor_edit_help

      edit_history = editor_edit_history(pagename)

      sidebar = editor_sidebar(edit_help, edit_history)

      generate_editor_page(title, message, main, sidebar)




=======================================================2005-04-05(Tue)
19:31	back.
21:37	back.


----------------------------------------------------------------------
Mac pkg
http://www.remus.dti.ne.jp/~sugiyama/newt_macosx.html
Ruby Mac pkg
http://rubycocoa.sourceforge.net/doc/build.ja.html
http://rubycocoa.sourceforge.net/doc/build.ja.html
ls -dF /Library/Receipts/BSD*.pkg   # mF
/Library/Receipts/BSD.pkg/   /Library/Receipts/BSDSDK.pkg/
http://www.entropy.ch/software/macosx/welcome.html Mac OS X Packages
------------------------------
PackageMaker
http://advweb.seesaa.net/article/214284.html
ruby PackageMaker
http://www.digital-genes.com/~yatsu/macuim/hiki.cgi?PackageMaker%BB%C8%CD%D1%CA%FD%CB%A1
R}hCgp
/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
PackageMaker -build
             -p <destination pkg path>
             -f <root dir>
             -r <resources dir>
             -i <info filepath>
             -d <description file path>
Automatic building script
Here is a automatic packaging script we use to build OpenVanilla?.Please edit FileList? and two .plist files, and feel happy by typing
./mkpackage.sh
Please visit http://svn.openfoundry.org/openvanilla/trunk/PackageMaking/OSX/
http://www.tech-arts.co.jp/macosx/macosx-dev-jp/htdocs/2300/2309.html
PackageMaker -build
http://macwiki.sourceforge.jp/cgi-bin/wiki.cgi?PackageMaker
http://www.bach-phys.ritsumei.ac.jp/OSXWS/node28.html
http://www.bach-phys.ritsumei.ac.jp/OSXWS/
http://www.bach-phys.ritsumei.ac.jp/OSXWS/node34.html
http://www.bach-phys.ritsumei.ac.jp/OSXWS/node35.html
http://www.airmac.org/package/page1.html
http://khdd.net/kanou/fonts/pfaedit.html
http://www.airmac.org/package/index.html
http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/Concepts/sd_install_quick_look.html
http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/Concepts/sd_install_process.html
http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/Concepts/sd_pre_post_processing.html
http://s.sudre.free.fr/Stuff/PackageMaker_Howto.html
http://www.asari.jp/diary/archives/000098.html
http://www.0-i-0.com/tips/34-meta-pkg/mpkg.html

=======================================================2005-04-04(Mon)
 1:07	back

----------------------------------------------------------------------
ruby tmail
http://www.loveruby.net/ja/prog/tmail.html
http://www.loveruby.net/archive/tmail/tmail-0.10.8.tar.gz
http://www.loveruby.net/archive/tmail/
http://www.loveruby.net/ja/man/tmail/
Ruby Quoted Printable
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-list/10835
Ruby Quoted Printable
http://jarp.does.notwork.org/diary/
http://tmtm.org/ja/ruby/mailparser/
http://tmtm.org/ja/ruby/mailparser/mailparser-0.3.2.tar.gz
----------------------------------------------------------------------
#require "qwik/site"
#require "qwik/site-attach"
#require "qwik/wikidb"
----------------------------------------------------------------------
#require "qwik/parser"
#require "qwik/resolve"
#require "qwik/generator-view"
----------------------------------------------------------------------
    def get_or_create(k)
      page = self[k]
      page = self.create(k) if page.nil?
      page
    end
----------------------------------------------------------------------
      #return Base64.decode64(@body) if encoding == "base64"
----------------------------------------------------------------------
RCS file: /cvsroot/qwik/qwik/lib/qwik/quickml.rb,v
retrieving revision 1.17
diff -r1.17 quickml.rb
92a93
>       num = 0
94c95,102
<       return "Site attach failed because the same filename is already used.\n"
---
>       num = 1
>       while @site.attach.exist?(filename+"."+num.to_s)
>         num += 1
>       end
>       #return "Site attach failed because the same filename is already used.\n
"
>       end
>       if num != 0
>       filename = filename+"."+num.to_s

=======================================================2005-03-29(Tue)

----------------------------------------------------------------------
#      w << [:div, {:class=>"day"},
#	[:div, {:class=>"section"},
#	  msg]]
----------------------------------------------------------------------
#      if 0 < @req.path_args.length
#	return c_nerror("Path args are not acceptable."){}
#      end
----------------------------------------------------------------------
      #gen = EditPageGenerator.new(@config, @memory, self)
      # @res.body = gen.generate(@site, @req.base, contents, msg, differ)
      #c_editor(@site, @req.base, contents, message, differ)
----------------------------------------------------------------------
.message {
  margin: 8px;
  padding: 8px;
  width: 99%;
  background-color: #aaa;
  background: transparent url("./edit_form_bg.jpg") repeat 0 0;
  border: 1px solid #666;
}
.message h2 {
  margin: 0;
  padding: 0;
  border-top: 6px solid #0aa;
}

=======================================================2005-03-28(Mon)

----------------------------------------------------------------------
      #gen = Qwik::EditPageGenerator.new(@config, @memory, @action)
      # @res.body = gen.generate(@site, "1", "contents", "msg", "differ")
      # @res.body = @action.c_editor(@site, "1", "contents", "msg", "differ")
      #pp @res.body
      #assert_xml("msg", "//div[@class='msg']")
      #assert_xml("differ", "//div[@class='differ']")
#      assert_xpath({"href"=>"TextFormatSimple.html"},
#		   "//div[@class='edit_help']")
#      assert_rattr({"href"=>"TextFormatSimple.html"},
#		   "//div[@class='edit_help']//a")
    #def c_editor(site, pagename, contents=nil, msg=nil, differ=nil)
#:class=>"update", 
----------------------------------------------------------------------
#  require "t/test"
    def self.generate_pp(template, site, pagename,
		      contents=nil, msg=nil, differ=nil)
      EditorPageGenerator.generate(template, )
    end
#    def self.generate(template, site, pagename,
#		      contents=nil, msg=nil, differ=nil)
----------------------------------------------------------------------
require "qwik/generator-msg"
----------------------------------------------------------------------
      #title = page.get_title
      #head << [:title, "EDIT: "+site.title(pagename)]
      #data[:view_title]   = site.title(pagename)
      #xml = @memory.template.get("edit")
      # deep copy?
----------------------------------------------------------------------
      # insert differ
      w = template.get_by_class("differ")
      w << differ
----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/template"
require "qwik/wabisabi-template"
require "qwik/generator-module"

module Qwik
  class MessagePageGenerator
    include GeneratorModule

    def initialize(config, memory, action)
      @config = config
      @memory = memory
      @action = action
    end

    def generate(site, title, msg, url=nil, redirectflag=false)
      head = []
      head << [:title, title]
      m = "screen,tv"
      head << [:link, {:rel=>"stylesheet", :type=>"text/css",
	  :href=>"/.theme/css/base.css", :media=>m}]
      head << [:link, {:rel=>"stylesheet", :type=>"text/css",
	  :href=>"/.theme/qwiksystem/qwiksystem.css", :media=>m}]
      head += generate_js("/")
      head << [:meta, {:name=>"ROBOTS", :content=>"NOINDEX,NOFOLLOW"}]
      if url && !redirectflag # redirect
	head << [:meta, {"http-equiv"=>"Refresh", :content=>"0; url=#{url}"}]
      end
      data = {}
      data[:view_title] = title
      data[:msg]        = msg
      data[:differ]     = nil
      data[:editor]     = nil
      data[:header] = head
      xml = @memory.template.get("system")
      xml.apply(data)
    end
  end
end

if $0 == __FILE__
  require "t/test"
  $debug = true
end

if $debug
  class TC_MessagePageGenerator < Test::Unit::TestCase
    include TestSession

    def test_all
      session

      # test_message_page_generator
      gen = Qwik::MessagePageGenerator.new(@config, @memory, @action)
      @res.body = gen.generate(@site, "title", "msg")
      assert_text("title", "title")
      assert_attr({"name"=>"ROBOTS", "content"=>"NOINDEX,NOFOLLOW"}, "meta")
      assert_text("title", "h1")
      assert_xml("msg", "//div[@class='msg']")
      assert_text(nil, "meta[2]")

      gen = Qwik::MessagePageGenerator.new(@config, @memory, @action)
      @res.body = gen.generate(@site, "title", "msg", "url")
      assert_attr({"content"=>"0; url=url", "http-equiv"=>"Refresh"}, "meta[2]")
    end
  end
end

----------------------------------------------------------------------
    def c_ok(title)
      status = 200
      gen = MessagePageGenerator.new(@config, @memory, self)
      msg = yield
      @res.status = status
      @res.body = gen.generate(@site, title, msg)
      c_set_html
      c_set_no_cache
      nil
    end
    def test_all
      session
      @action.c_ok("t"){""}
      #pw("//html")
      assert_text("t", "title")
      assert_xpath([:div, {:id=>"msg", :class=>"msg"}, ""],
		   "//div[@class='msg']")
    end
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")

module Qwik
  class Action
  end
end

if $0 == __FILE__
  require "t/test"
  $debug = true
end

if $debug
  class TC_ActMessage < Test::Unit::TestCase
    include TestSession

  end
end
----------------------------------------------------------------------
  width: 70%;/* 70% - (2% * 2) */
----------------------------------------------------------------------
/* ========== comman */
a.command {
  padding: 4px 0 0 18px;
  margin: 0 0 0 0;
  background: url("./command.gif") no-repeat 0% 100%;
}
----------------------------------------------------------------------
/* ========== sidebar */
.sidebar {
  float: left;
  width: 27%;/* 30% - (1% * 2) (// - 1% //)*/
  font-size: small;
  text-align: left;
  margin-right: 1%;
  margin-left: 1%;
  padding: 0;
}
.sidebar li{
  padding-left: 16px;
  padding-right: 16px;
}

.sidebar h2{
 font-size: medium;
 margin: 0;
 margin-bottom: 4px;
 padding-left: 16px;
 padding-top: 4px;
 padding-bottom: 4px;
 border-top: 6px solid #0AA;
}
.sidebar .edit_help,.sidebar .edit_history{
 margin-bottom:1em;
 padding: 0 0px 16px 0px;
 background-image: url("./sidebar_bg.gif");
 border: 1px solid #555;

}
/********************** form-part *******************/
/* ========== form */
form.update {
  width: 100%;
  margin-left: 0;
}
form.update textarea {
  margin: 0;
  padding: 0;
  width: 97%;
  height: 350px; 
}

form.update input {
  margin: 0.2em 0;
  padding: 0 2em;
  font-weight: bold;
  font-family: Verdana,Helvetica,Arial,'MS UI Gothic',sans-serif;
}

p.right{
 text-align: right;
}

.sidebar p.right{
   padding-right: 16px;
}

/********************** for accessibility tweaks **********************/
	hr.hide {
		display: none;
	}
.main p,.sidebar p {
 margin-top: 1em;
 margin-bottom: 1em;
}
----------------------------------------------------------------------
http://127.0.0.1:9190/HelloQwik/.test_plain
----------------------------------------------------------------------
    def c_ok(title, url=nil, status=nil, &b)
      msg = ""
      msg = yield if block_given?
      ar = msg
      if url
	ar = []
	ar << msg
	ar << [:hr] if 0 < msg.length
	ar << go_url(url, _("Go back"))
      end
      status = 200 if status.nil?
      generate_message_page(status, title){
	ar
      }
    end
----------------------------------------------------------------------
      if url
	ar = []
	ar << msg
	ar << [:hr] if 0 < msg.length
	ar << go_url(url, _("Go back"))
      end
----------------------------------------------------------------------
, dummy=nil, dummy=nil
      msg = ""
 if block_given?
      msg = 
msg
{
	ar
      }
      ar = yield
      status = 200 if status.nil?
----------------------------------------------------------------------
    def generate_message_page(status, title, url=nil, &b)
      gen = MessagePageGenerator.new(@config, @memory, self)
      msg = ""
      msg = yield if block_given?
      msg = add_jump_url(msg, url) if url
      @res.status = status
      @res.body = gen.generate(@site, title, msg, url)
      c_set_html
      c_set_no_cache
      nil
    end
----------------------------------------------------------------------
, url=nil
      msg = add_jump_url(msg, url) if url
, url
      msg = ""
 if block_given?
    def add_jump_url(msg, url)
      add_go_url(msg, url, _("Jump to next page"))
    end

    def add_goback_url(msg, url)
      add_go_url(msg, url, _("Go back"))
    end

    def add_go_url(msg, url, comment=nil)
      ar = []
      ar << msg
      ar << [:hr]
      ar << go_url(url, comment)
      ar
    end

    def go_url(url, comment=nil)
      comment = comment+" : " if comment
      [:p, comment, [:a, {:href=>url}, url]]
    end
, &b
----------------------------------------------------------------------
      # insert h2
      if nil
	w = template.get_by_class("day")
	w.insert(1, [:h2, h2])
      end
----------------------------------------------------------------------
      if nil # has h2
	w = template.get_by_class("day")
	w.insert(1, [:h2, h2])
      end
----------------------------------------------------------------------
    def c_error(title, url=nil, &b)
      msg = ""
      msg = yield if block_given?
      ar = []
      ar << msg
      ar << [:hr] if 0 < msg.length
      url = "FrontPage.html" if url.nil?
      ar << go_url(url, _("Go back"))
      generate_message_page(500, title){
	ar
      }
    end
----------------------------------------------------------------------
      @action.c_error("t")
      assert_text("t", "title")
      assert_xpath([:div, {:id=>"msg", :class=>"msg"},
		     ["",
		       [:p, "Go back : ",
			 [:a, {:href=>"FrontPage.html"},
			   "FrontPage.html"]]]],
		   "//div[@class='msg']")
----------------------------------------------------------------------
    def c_redirect(title, url, &b)
      generate_message_page(302, title, url, &b)
      @res["Location"] =  c_relative_to_full(url)
    end
----------------------------------------------------------------------
       #return c_go_top(200, _("Page is deleted."))
       #return c_jump_top(200, _("Page is deleted."))
    def c_jump_top(status, title)
      c_go_top(status, title, "FrontPage.html")
    end
----------------------------------------------------------------------
    def c_go_top(status, title, url=nil)
      generate_message_page(status, title, url){
	go_url("FrontPage.html", _("Go back"))
      }
    end
      #return c_error("pagename is nil.") if @req.base.nil?
----------------------------------------------------------------------
#    include Enumerable
#      assert_instance_of(Array, farm.to_a)
#      assert_equal(true, farm.include?("test"))
----------------------------------------------------------------------
      assert_instance_of(Qwik::Site, site)
      assert_instance_of(Qwik::Page, page)
----------------------------------------------------------------------
      assert_equal(site.object_id, @site.object_id) # what?
----------------------------------------------------------------------
      # use url as sitetitle.
      return url.sub(%r|^http://|, "").sub(%r|/$|, "")
      end
      return nil
----------------------------------------------------------------------
site_
----------------------------------------------------------------------
    def title(pagename=nil)
      sitetitle = site_title

      return sitetitle if pagename.nil?

      pagetitle = page_title(pagename)

      t = pagetitle+" - "+t if pt
      t
    end

    def page_title(pagename=nil)
      return nil if pagename.nil?
      page = self[pagename]
      return nil if page.nil?
      page.get_title
    end

----------------------------------------------------------------------
      #assert_equal(true, @config.windows?) # change this if not windows...

----------------------------------------------------------------------
    def load_library
      loadlib = LoadLibrary.new(lib_dir)
      loadlib.glob("qwik/act-*.rb")
    end
----------------------------------------------------------------------
    def nu_parse_argv(argv)
#      getopts("ds", "p:", "h:", "m:", "t:")
#      @debug = true if $OPT_d
#      @port = $OPT_p.to_i if $OPT_p
#      @default_hostname = $OPT_h.to_s if $OPT_h
#      @ssl = true if $OPT_s
    end
----------------------------------------------------------------------
      #assert_rattr({"href"=>"FirstPage.edit"}, "//div[@class='section']//a")
      assert_attr({"action"=>".new", "method"=>"post"}, "form")
      assert_attr({"name"=>"t", "value"=>"ŏ̃y[W"}, "input")
     #assert_attr({"name"=>"k", "value"=>"1"}, "input[2]")
     #assert_attr({"type"=>"submit", "value"=>"New page"}, "input[3]")
      assert_attr({"type"=>"submit", "value"=>"New page"}, "input[2]")

     #assert_equal("* ŏ̃y[W\n", @site["FirstPage"].load)
      assert_equal(",ŏ̃y[W,FirstPage\n", @site["_PageTitle"].load)

      # Ouch! the page key is already exist.
      session("POST /test/.new?t=&k=FirstPage")
      assert_text("PageKey is already exist.", "h2")
      assert_attr({"action"=>".new", "method"=>"post"}, "form")
      assert_attr({"name"=>"t", "value"=>""}, "input")
      assert_attr({"name"=>"k", "value"=>"FirstPage"}, "input[2]")
      assert_attr({"type"=>"submit", "value"=>"New page"}, "input[3]")
      assert_text("FirstPage", "strong")
#      assert_text("FirstPage is already exist.Please specify another PageKey.",
#		  "p")
      assert_in([[:strong, "FirstPage"], " is already exist.", [:br],
		  "Please specify another PageKey."], "//p")
&k=SecondPage

=======================================================2005-03-27(Sun)

----------------------------------------------------------------------
      #pw("//div[@class='section']")
      #assert_xpath("FirstPage", "//a[@class='new']")

----------------------------------------------------------------------
      # Ouch! page key contains not alphabet character.
      session("/test/.new?t=ŏ̃y[W&k=First")
      assert_text("Invalid characters", "h2")
      assert_attr({"action"=>".new", "method"=>"post"}, "form")
      assert_attr({"name"=>"t", "value"=>"ŏ̃y[W"}, "input")
      assert_attr({"name"=>"k", "value"=>"First"}, "input[2]")
      assert_attr({"type"=>"submit", "value"=>"New page"}, "input[3]")

      # confirm again
      session("/test/.new?t=ŏ̃y[W&k=FirstPage")
      assert_text("Confirm", "h2")
      assert_attr({"action"=>".new", "method"=>"post"}, "form")
      assert_attr({"name"=>"t", "value"=>"ŏ̃y[W"}, "input")
      assert_attr({"name"=>"k", "value"=>"FirstPage"}, "input[2]")

      # create a new page.
      session("POST /test/.new?t=ŏ̃y[W&k=FirstPage")
      assert_xml("Edit new page", "//div[@class='section']//a")
      assert_rattr({"href"=>"FirstPage.edit"}, "//div[@class='section']//a")


----------------------------------------------------------------------

----------------------------------------------------------------------
	#return newpage_form(){}
	#return newpage_page(title, _("Title is already exist.")){

----------------------------------------------------------------------
   #def newpage_page(t=nil, k=nil, msg=nil)
    def newpage_page(t=nil, msg=nil)
      com = yield

      url = "FrontPage.html"

      ar = []
      ar << [:h2, msg] if msg

      form = [:form, {:action=>".new", :method=>"post"},
	[:dl,
	  [:dt, _("Title")],
	  [:dd, [:input, {:name=>"t", :value=>t}]]]]
      form << com if com
      form << [:div, [:input, {:type=>"submit", :value=>_("New page")}]]

      ar << [:div, {:class=>"form"}, form]

      ar << [:hr]
      ar << [:p, _("Go back"), " : ", [:a, {:href=>url}, url]]

      return c_notice(_("New page")){ar}
    end


----------------------------------------------------------------------
class NuArray
  def del(a)
    self.delete_if {|x| x == a }
  end
end

----------------------------------------------------------------------
#    def ext_new
#      t = @req.base
#      newpage_make(t, nil)
#    end
      newpage_make(t, k)
    end
    def newpage_make(t, k)

	#c_require_post

----------------------------------------------------------------------
      k = @req.query["k"]
      k = nil if k == ""
      if k.nil?
	newpagekey = @site.get_new_id
	return newpage_form(t, newpagekey, nil){[
	    [:p, [:em, _("Push create.")]],
	    [:p, _("You can specify pagekey."), [:br],
	      _("You can use alphabet and numbers for pagekey.")],
	  ]}
      end

      if !valid_as_pagekey?(k) # key is valid as pagekey?
	return newpage_form(t, k, _("Invalid characters")){
	  [:p, _("You can only use alphabet and numbers for pagekey.")]
	}
      end

      if !@req.is_post?
	return newpage_form(t, k, _("Confirm")){
	  [:p, _("Push create.")]
	}
      end

----------------------------------------------------------------------
	if title && key
	else
	  return newpage_form(key, nil, _("Title is already exist.")){
	    [:p, [:strong, key],_(" is already exist."), [:br],
	      _("Please specify another title.")]
	  }
	end
	#return newpage_create(nil, t){} # CREATE
	#return newpage_create(t, newpagekey){} # CREATE

----------------------------------------------------------------------
      if title && key != title
	# @site.pagetitle.add(title, key)
      else
	page.store("* #{key}\n")
      end
 # at the first, make the page with the title.

----------------------------------------------------------------------
      return newpage_create(title, key) # CREATE
    end

    def newpage_create(title, key)

----------------------------------------------------------------------
      if k
	dl << [:dt, _("PageKey")]
	dl << [:dd, [:input, {:name=>"k", :value=>k}]]
      end





----------------------------------------------------------------------
    def nu_plg_ring_user(mail, arg) # see information of the user specified by arg
      return mail if arg == "mail"
      num = %w(user name faculty year pagename time).index(arg)
      return "" if !num
      page = ring_get_memberpage
      if page
	ar = page.wikidb[mail]
	return "" if ar.nil?
	return ar[num] if ar[num]
      end
      ""
    end

=======================================================2005-03-26(Sat)

----------------------------------------------------------------------
#      assert_equal("http://127.0.0.1:9190/test/FrontPage.html",
#		   @action.c_relative_to_full("FrontPage.html"))


----------------------------------------------------------------------
#      px("//div[@id='body']", 0)
#      px("//div[@class='body']", 0)
#      px("//div[@class='day']", 0)
#      px("//div[@class='day']/ul", 0)
#      assert_xml([], "//div[@class='day']")
#      px("//div[@class='session']", 0)
#      assert_xml("", "//div[@class='section']")

      session("/test/")
      assert_xml([[:h5, "contents"],
		   [:div, {:id=>"tocinside"},
		     [:ol,
		       [:li, [:a, {:href=>"#8438c4ae8c24c80a465ed130009b673c"},
			   "g"]],
		       [:li, [:a, {:href=>"#b513ecfa8a65080fb8d3a7638608ca5c"},
			   "Lq@"]],
		       [:li, [:a, {:href=>"#qwikWeb"}, "qwikWeb"]]]]],
		 "//div[@class='toc']")

----------------------------------------------------------------------
      #qp pagename
	#qp k, ar
      #qp user
----------------------------------------------------------------------
require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'

class OptparseExample

  CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
  CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }

  # Return a structure describing the options.

  def self.parse(args)
    # The options specified on the command line will be collected in *options*.
    # We set default values here.
    options = OpenStruct.new
    options.library = []
    options.inplace = false
    options.encoding = "utf8"
    options.transfer_type = :auto
    options.verbose = false
    
    opts = OptionParser.new do |opts|
      opts.banner = "Usage: example.rb [options]"
    
      opts.separator ""
      opts.separator "Specific options:"
    
      # Mandatory argument.
      opts.on("-r", "--require LIBRARY",
              "Require the LIBRARY before executing your script") do |lib|
        options.library << lib
      end
    
      # Optional argument; multi-line description.
      opts.on("-i", "--inplace [EXTENSION]",
              "Edit ARGV files in place",
              "  (make backup if EXTENSION supplied)") do |ext|
        options.inplace = true
        options.extension = ext || ''
        options.extension.sub!(/\A\.?(?=.)/, ".")  # Ensure extension begins with dot.
      end
    
      # Cast 'delay' argument to a Float.
      opts.on("--delay N", Float, "Delay N seconds before executing") do |n|
        options.delay = n
      end
    
      # Cast 'time' argument to a Time object.
      opts.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
        options.time = time
      end
    
      # Cast to octal integer.
      opts.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
              "Specify record separator (default \\0)") do |rs|
        options.record_separator = rs
      end
    
      # List of arguments.
      opts.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
        options.list = list
      end
    
      # Keyword completion.  We are specifying a specific set of arguments (CODES
      # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
      # the shortest unambiguous text.
      code_list = (CODE_ALIASES.keys + CODES).join(',')
      opts.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
              "  (#{code_list})") do |encoding|
        options.encoding = encoding
      end
    
      # Optional argument with keyword completion.
      opts.on("--type [TYPE]", [:text, :binary, :auto],
              "Select transfer type (text, binary, auto)") do |t|
        options.transfer_type = t
      end
    
      # Boolean switch.
      opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
        options.verbose = v
      end
    
      opts.separator ""
      opts.separator "Common options:"
    
      # No argument, shows at tail.  This will print an options summary.
      # Try it and see!
      opts.on_tail("-h", "--help", "Show this message") do
        puts opts
        exit
      end
    
      # Another typical switch to print the version.
      opts.on_tail("--version", "Show version") do
        puts OptionParser::Version.join('.')
        exit
      end
    end
    
    opts.parse!(args)
    options
  end  # parse()

end  # class OptparseExample

options = OptparseExample.parse(ARGV)
pp options

----------------------------------------------------------------------
require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'
require "../qwik/version"

module Qwik
  class Config
    def parse_args(args)
      options = OpenStruct.new
      options.debug = false
      options.port = 9190
      options.host = ""

      optionparser = OptionParser.new {|opts|
	opts.banner = "Usage: qwikweb.rb [options]"

	opts.separator ""
	opts.separator "Specific options:"

	opts.on("-d", "--[no-]debug", "Run in debug mode") {|a|
	  options.debug = a
	}

	opts.on("-p", "--port n", OptionParser::DecimalInteger,
		"Port to open.") {|a|
	  options.port = a
	}

	opts.on("-h", "--host expample.com", "Default hostname.") {|a|
	  options.host = a
	}

	# ssl

	opts.separator ""
	opts.separator "Common options:"

	# "-h" is used in --host
	opts.on_tail("--help", "Show this message") {
	  puts opts
	  exit
	}

	opts.on_tail("--version", "Show version") {
	  puts Config::VERSION
	  exit
	}
      }
      
      optionparser.parse!(args)
      options
    end
  end
end

config = Qwik::Config.new
options = config.parse_args(ARGV)
pp options

=======================================================2005-03-25(Fri)
=======================================================2005-03-24(Thu)

----------------------------------------------------------------------
      #if self.respond_to?(method)
	#w = self.send(method)
----------------------------------------------------------------------
#require "base64"
	#check_user(user, pass) # at act-login
----------------------------------------------------------------------
#	[:p, [:em, url], " ", _(": Login"), [:br],
	#login_form_div,
----------------------------------------------------------------------
      #pw("//div[@class='section']")
----------------------------------------------------------------------
#      w[0] = nil
#      w[2] = login_page_form
----------------------------------------------------------------------
      #qp basename
----------------------------------------------------------------------
      data = {}
      data[:header] = "t"
      w = apply_template(data, "system")
      assert_equal([:head, {:id=>"header"}, "t"], w.get_tag("head"))
      id1 = w.object_id

      data = {}
      data[:header] = "t2"
      w2 = apply_template(data, "system")
      id2 = w2.object_id
      assert_not_equal(id1, id2)
      assert_equal([:head, {:id=>"header"}, "t2"], w2.get_tag("head"))
      assert_equal([:head, {:id=>"header"}, "t"], w.get_tag("head"))
----------------------------------------------------------------------
  #require "qwik/wabisabi-template"
  #require "qwik/qp"
----------------------------------------------------------------------
    def require_templates
      path = @config.template_dir.path
      path.each_entry {|file|
	f = file.to_s
	next unless /\.rb\z/ =~ f
	require "template/#{f}"
      }
    end
      #require_templates

=======================================================2005-03-23(Wed)

----------------------------------------------------------------------

----------------------------------------------------------------------
  def each_in_class(klass)
    klass, knum = split_name_num(klass)
    k = 1
    klass_path = nil
    traverse_element {|l|
      if klass_path.nil?
	if l.get_attr(:class) == klass
	  if k == knum
	    klass_path = l.to_s
	  else
	    k += 1
	  end
	end
      elsif l.path.include?(klass_path)
	yield l
      end
    }
  end


----------------------------------------------------------------------
onload="qwik_onload();" ondblclick="wema_dblClick(this);" ondragdrop="qwik_dragdrop(this);"

----------------------------------------------------------------------
import JavaScript

----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")

module Qwik
end

if $0 == __FILE__
  require "t/test"
  $debug = true
end

if $debug
  class TC_Generator < Test::Unit::TestCase
    include TestSession

    def test_all
      session

    end
  end
end
----------------------------------------------------------------------
      #classname = basename.capitalize+"Template"
----------------------------------------------------------------------
      # @templates = init_templates_from_template_dir

    private

    def init_templates_from_template_dir
      path = @config.template_dir.path
      h = {}
      Pathname.glob(path+"*.rb") {|file|
	basename = file.basename(".rb").to_s
	str = file.open {|f| f.read }
	w = eval(str) # EVAL is used!!!!!
	h[basename] = w
      }

      h.each {|k, w|
	html = w.get_path("//html")
	html.insert(1, {:"xmlns:v"=>"urn:schemas-microsoft-com:vml"})
	#qp k, w
      }

      h
    end

    def nu_init_templates
      @templates["view"] = [
	[:"!DOCTYPE", "html", "PUBLIC",
	  "-//W3C//DTD HTML 4.01 Transitional//EN",
	  "http://www.w3.org/TR/html4/loose.dtd"],
	[:html, {:"xmlns:v"=>"urn:schemas-microsoft-com:vml"},
	  [:head, {:id=>"header"}],
	  [:body,
	    {:onload=>"qwik_onload();",
	      :ondblclick=>"wema_dblClick(this);",
	      :ondragdrop=>"qwik_dragdrop(this);",
	    },
	    [:div, {:class=>"container"},
	      [:div, {:class=>"main"},
		[:div, {:id=>"adminmenu", :class=>"adminmenu"}],
		[:"!--", "adminmenu"],
		[:div, {:id=>"toc", :class=>"toc"}],
		[:"!--", "toc"],
		[:h1, {:id=>"view_title"}],
		[:div, {:id=>"body_enter"}],
		[:"!--", "id:body_enter"],
		[:div, {:id=>"body"}],
		[:"!--", "id:body"],
		[:div, {:id=>"body_leave"}],
		[:"!--", "id:body_leave"]],
	      [:"!--", "main"],
	      [:div, {:id=>"sidemenu", :class=>"sidebar"}],
	      [:"!--", "sidebar"],
	      [:div, {:id=>"footer", :class=>"footer"}],
	      [:"!--", "footer"]],
	    [:"!--", "container"]]]]

      @templates["system"] = [
	[:"!DOCTYPE", "html", "PUBLIC",
	  "-//W3C//DTD HTML 4.01 Transitional//EN",
	  "http://www.w3.org/TR/html4/loose.dtd"],
	[:html, {:"xmlns:v"=>"urn:schemas-microsoft-com:vml"},
	  [:head, {:id=>"header"}],
	  [:body, {:onload=>"qwik_onload();"},
	    [:div, {:class=>"container"},
	      [:div, {:class=>"header"},
		[:div,
		  [:div,
		    [:h1, {:id=>"view_title"}]]]],
	      [:"!--", "header"],
	      [:div, {:class=>"update day"},
		[:div, {:class=>"form"},
		  [:div, {:id=>"msg", :class=>"msg"}],
		  [:div, {:id=>"differ", :class=>"differ"}],
		  [:"!--", "differ"],
		  [:div, {:id=>"editor", :class=>"editor"}],
		  [:"!--", "editor"]],
		[:"!--", "form"]],
	      [:"!--", "update day"],
	      [:div, {:class=>"update day"},
		[:div, {:class=>"comment"},
		  [:div, {:id=>"editorfooter", :class=>"commentbody"}],
		  [:"!--", "commentbody"]],
		[:"!--", "comment"]],
	      [:"!--", "update day"],
	      [:div, {:id=>"footer", :class=>"footer"}],
	      [:"!--", "footer"]],
	    [:"!--", "container"]]]]
    end

=======================================================2005-03-22(Tue)

----------------------------------------------------------------------
  def set_text(str)
    name = self[0]
    nar = [name]
    offset = 1
    while self[offset].is_a?(Hash)
      nar << self[offset]
      offset += 1
    end
    nar << str # add it here
    nar += self[offset...self.length].dup
    nar
  end

      xml = org.each_tag(:b){|e| e.set_text("test2") }
      assert_equal([:a, [:b, "test2", [:c], [:d], [:c]]], xml)



----------------------------------------------------------------------
      str = "<a>'</a>"
      org = HTree(str)
      assert("<a>'</a>", org)
#      xml = org.root.set_text("a")
#      assert("<a>a</a>", xml)
#      xml = org.root.set_text("'")
#      assert("<a>'</a>", xml)


----------------------------------------------------------------------
      # @templates = {}
      #init_templates
----------------------------------------------------------------------
  class PageGenerator # only for test
    include PageGeneratorModule

    def generate(data)
      data[:header] = []
      apply_template(data, "view")
    end
  end

----------------------------------------------------------------------
      # test_page_generator
      gen = Qwik::PageGenerator.new(@config, @memory, @action)
      @res.body = gen.generate({})
      assert_text(nil, "h1")
      @res.body = gen.generate({:view_title => "t"})
      assert_text("t", "h1")
      @res.body = gen.generate({:view_title => [:b, "t"]})
      assert_text("t", "h1")
      assert_text("t", "b")


----------------------------------------------------------------------
    def test_text0
      @g = HTree::Generator.new

      e = @g.a{"t"}
      assert("<a>t</a>", e)
      assert_equal("t", e.text)
      assert("<a>s</a>", e.set_text("s"))

      e = @g.a{["t", @g.b{"b"}, "t"]}
      assert("<a>t<b>b</b>t</a>", e)
      assert_equal("tbt", e.text)
    end

  require "qwik/htree-generator"

----------------------------------------------------------------------

----------------------------------------------------------------------
module Wabisabi
  def to_wabisabi_ar(a)
    case a
    when String, Symbol, Hash
      return [a]
    when Array
      if a[0].is_a?(Symbol) # already wabisabi
	return [a]
      else
	nar = []
	a.each {|aa|
	  nar += to_wabisabi_ar(aa) # recursive
	}
	return nar
      end
    when HTree::Elem
      return [a.to_wabisabi]
    when HTree::Doc
      return to_wabisabi_ar(a.children) # recursive
    when HTree::DocType
      return [[:"!DOCTYPE",
	  a.root_element_name,
	  "PUBLIC",
	  a.public_identifier,
	  a.system_identifier]]
    when HTree::Text
      return [a.to_s]
    when nil
      return []
    else
      qp a, a.class
      raise "what?"
    end
  end
  module_function :to_wabisabi_ar
end

  class TC_Wabisabi_to_wabisabi_ar < Test::Unit::TestCase
    def assert(w, any)
      assert_equal(w, Wabisabi.to_wabisabi_ar(any))
    end

    def test_all
      # test_from_wabisabi
      assert(["t"], "t")
      assert([[:a]], [:a])
      assert([[:a]], [[:a]])

      # test_from_htree_elem
      @g = HTree::Generator.new
      assert([[:a]], [@g.a])
      assert([[:a, "t"]], [@g.a{"t"}])
      assert([[:a, [:b, ""]]], [@g.a{@g.b{""}}])

      # test_from_htree_doc
      doc = HTree::Doc.new(@g.a)
      assert_equal("#<HTree::Doc {emptyelem <a>}>", doc.inspect)
      assert([[:a]], [doc])

      str = <<"EOT"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>t</title></head><body><p>b</p></body></html>
EOT
      doc = HTree(str)
      assert([[:"!DOCTYPE", "html", "PUBLIC",
		 "-//W3C//DTD html 4.01 Transitional//EN",
		 "http://www.w3.org/TR/html4/loose.dtd"], "\n",
	       [:html, [:head, [:title, "t"]], [:body, [:p, "b"]]], "\n"], doc)
    end
  end


----------------------------------------------------------------------
      # test_from_generator
      @g = HTree::Generator.new
      assert_equal("<a/>", @g.a.format_xml)
      # test_get_name
      assert_equal("a", @g.a.get_name)
      # test_htree_elem_to_wabisabi
      assert([:a], @g.a)
      assert([:a, [:b]], @g.a{@g.b})
      assert([:a, {:href=>"foo.html"}], @g.a(:href=>"foo.html"))
      assert([:html, [:body, [:p, [:a, {:href => "foo.html"}, "foo"]]]],
	     @g.html{@g.body{@g.p{@g.a(:href=>"foo.html"){"foo"}}}})
----------------------------------------------------------------------
      #init_templates_by_htree
    def init_templates_by_htree
      doctype = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
      path = @config.template_dir.path
      path.each_entry {|pa|
	file = path+pa
	next unless file.file?
	cmd = pa.to_s.sub(".html", "")
	str = file.read
	str = str.map {|line| line.strip }.join
	h = HTree(doctype + str)
	@templates[cmd] = to_wabisabi_ar(h)
      }
    end

----------------------------------------------------------------------

----------------------------------------------------------------------
#require "qwik/wabisabi-generator"

----------------------------------------------------------------------
#require "qwik/parser"
#require "qwik/site"
    #include Wabisabi
      #result = "" if result.nil?
    #include Wabisabi

=======================================================2005-03-21(Mon)

----------------------------------------------------------------------
      #c_error(_("Are you a member of this group?")){[
#	  [:p, _("You need a member of this group.")],
#	  [:p,[:a,{:href=>".login"},_("Login")]," : "+_("Access here.")],
#	  [:hr],
#	  [:p,_("Go back")," : ",[:a,{:href=>"FrontPage.html"},"FrontPage"]]

----------------------------------------------------------------------
	  #return c_error(_("Are you a member of this group?")){[
#	      [:p, [:strong, @req.user],
#		_(": You are not a member of this group.")],
#	      [:p, [:a, {:href=>"/.logout"}, _("Logout")],
#		_(": access here, and login again.")]



=======================================================2005-03-19(Sat)

----------------------------------------------------------------------
#	    [:a, {:href=>"javascript:wema_editor_hide()"}, "~"]]],
#	      [:input, {:type=>"submit", :value=>" "+_("Save")}]],
----------------------------------------------------------------------
    # ============================== help window
=begin
    def help_html
      [:div, {:id=>"help", :class=>"wema"},
	[:div, {:class=>"menubar"},
	  [:span, {:class=>"handle"}, "help"],
	  [:span, {:class=>"close"},
	    [:a, {:href=>"javascript:wema_help_hide()"}, "~"]]],
	[:div, {:class=>"cont"}, help_html_cont]]
    end

    def help_html_cont
      [
	[:h2, 'tⳋ@\wv'],
	[:h3, "j["],
	[:table,
	  [:tr, [:td, "new"], [:td, "VKtⳂ쐬"]],
	  [:tr, [:td, "help"], [:td, '̃EBhE\']]],
	[:p, "É~NbNĕ܂"],
	[:h3, "tⳃRg["],
	[:table,
	  [:tr, [:td, "set"], [:td, "tⳂʏœĂ", [:br],
	      "usetvāC̏ꏊɌŒ"]],
	  [:tr, [:td, "edit"], [:td, "tⳂ̓eҏW"]],
	  [:tr, [:td, "link"], [:td, "̕tⳂɐŌqVKtⳂ쐬"]]],
	[:h3, "ҏW"],
	[:p, "eLXgGAɕtⳂ͂̕C", [:br],
	  "u݁v{^ĂD"],
	[:p, "tⳂɂ́CeLXgGA", [:br],
	  "SĂۑĂD"],
      ]
    end
=end

=======================================================2005-03-16(Wed)

----------------------------------------------------------------------
    def nuform_info(wema)
      k = wema.get_id
      [hidden("tc"+k, wema.fg),
	hidden("bg"+k, wema.bg),
	hidden("ln"+k, wema.connected),
	hidden("d"+k, wema.text)]
    end


----------------------------------------------------------------------
#	  [:p, _("Please access again.")],
      #pp @req.cookies
	#check_user(user, pass)
	#raise InvalidUserError if user.nil? || user == ""
	#raise InvalidUserError unless MailAddress.new(user).valid?
	#raise InvalidUserError if !gen.match?(user, pass)

      #c_error(_("Invalid ID(E-mail) or Password.")){
      #c_ok(_("Login Error")){

#	  [:p, _("Please confirm the mail again.")],
#	  [:p, _("(Please do not use copy & paste.  Please input the password from keryboard again.)")],
#	  [:p,[:a,{:href=>".login"},_("Login")]," : "+_("Access here.")],
	#return c_ok(_("Login")+" : "+@site.url){
	#check_user(user, pass)
#	  [:p, {:style=>"width: 90%; text-align: right;"},

----------------------------------------------------------------------
# require "qwik/monitor"
----------------------------------------------------------------------
	#qp @buf
----------------------------------------------------------------------

    def listen
      index = @buf.length
      qp index

      @waiters.push(Thread.current)

      loop {
	if @buf[index].nil?
	  sleep 1
	else
	  ev = @buf[index]
	  qp "new event", ev
	  index += 1
	  yield(ev)
	end
      }
    end

=======================================================2005-03-15(Tue)

----------------------------------------------------------------------
      #qp ev
      #qp "start monitor"
	#qp ev, @req.base
	#qp "next pass", ev, @req.base
	  #qp "cmd is save", ev, @req.base
	  #qp str
	  #w = c_res(str)
	  #qp w
#	  qp "return!", ev
      #qp w
----------------------------------------------------------------------
    def nudb_page
      @site[@key]
    end
      # page = @site.create(@key) if page.nil?
      # @key = @config.sitemember

=======================================================2005-03-14(Mon)

----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

=begin
$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/escape"
require "qwik/iconv"
require "qwik/kconv"
require "qwik/qp"
require "qwik/util-string"
require "qwik/util-path"
require "qwik/util-time"
=end


----------------------------------------------------------------------
# copied from [ruby-list:40087], by Tietew <tietew-ml-ruby-list@tietew.net>

require 'rbconfig'

module TietewAutoReload
  LIBRARY_MTIMES = {}
  LIBRARY_DEPS = {}
  PROCESSING_FILE = []

  LIBRARY_PATH_CACHE = {}
  SYSLIB = /^(#{Regexp.quote(Config::CONFIG['rubylibdir'])}|#{Regexp.quote(Config::CONFIG['sitelibdir'])})/o

  def TietewAutoReload.find_library(lib)
    cache = LIBRARY_PATH_CACHE
    unless (cvalue = cache[lib]).nil?
      return cvalue
    end
    case File.extname(lib)
    when ".so"
      return cache[lib] = false
    when ".rb"
      libname = lib.sub(/\.rb$/, '')
    else
      libname = lib
      solib = true
    end
    if libname[0] == ?/
      file = File.expand_path(libname).untaint
      if File.file?(rbname = file + ".rb")
        if SYSLIB =~ file
          cache[lib] = false
        else
          cache[lib] = rbname
        end
      elsif solib && File.file?(file + ".so")
        cache[lib] = false
      end
    else
      for dir in $:
        file = File.expand_path(libname, dir).untaint
        if File.file?(rbname = file + ".rb")
          if SYSLIB =~ file
            return cache[lib] = false
          else
            return cache[lib] = rbname
          end
        elsif solib && File.file?(file + ".so")
          return cache[lib] = false
        end
      end
    end
    nil
  end

  def require(lib)
    unless file = TietewAutoReload.find_library(lib)
      return super
    end

    library_deps = LIBRARY_DEPS
    library_mtimes = LIBRARY_MTIMES
    processing_file = PROCESSING_FILE

    deps = library_deps[file] ||= {}
    for f in processing_file
      return false if f == file
      fdeps = library_deps[f]
      fdeps[file] = 1
      fdeps.update(deps)
    end

    processing_file.push file
    begin
      do_load = false
      for f, in deps
        if File.mtime(f) != library_mtimes[f]
          do_load = true
          break
        end
      end
      mtime = File.mtime(file)
      if do_load || mtime != library_mtimes[file]
        load(file)
        library_mtimes[file] = mtime
        true
      else
        false
      end
    ensure
      processing_file.pop
    end
  end
end

#include TietewAutoReload              # override Kernel#require

----------------------------------------------------------------------
#      qp "load "+glob
#	qp "require "+f
      #puts org_libs
----------------------------------------------------------------------
qwik/act-login.rb:59:    def invalid_user
qwik/act-login.rb:83:   return invalid_user # password does not match
qwik/action.rb:110:     return invalid_user
qwik/act-httpauth.rb:14:        check_user(user, pass) # at act-login
qwik/act-login.rb:41:   check_user(user, pass)
qwik/act-login.rb:51:    def check_user(user, pass)
qwik/act-login.rb:80:   check_user(user, pass)

=======================================================2005-03-12(Sat)

----------------------------------------------------------------------
      #c_view("hello, world"){"hi, there."}

=======================================================2005-03-11(Fri)


----------------------------------------------------------------------
#require "qwik/config"
#require "qwik/memory"
#require "qwik/util"
#require "qwik/mail"
#require "qwik/password"
#require "qwik/util"

----------------------------------------------------------------------
#require "qwik/util"
#require "qwik/util"
#require "qwik/util"
#require "qwik/qp"
#require "qwik/util"
#require "qwik/util-string"
#require "qwik/config"
#require "qwik/memory"
#require "qwik/pagedb"

----------------------------------------------------------------------
#      qp $LOAD_PATH
#      c_require_lib("zip/zip")
#      qp $LOAD_PATH

----------------------------------------------------------------------

----------------------------------------------------------------------
#require "qwik/config"
#require "qwik/memory"
#      qp sitename
----------------------------------------------------------------------
=begin
    # session
    def serialpool
      @serialpool = SerialPool.new unless defined? @serialpool
      @serialpool
    end
    def sessionidpool
      @sessionidpool = SessionIDPool.new unless defined? @sessionidpool
      @sessionidpool
    end
=end
----------------------------------------------------------------------
    def nutest_act_live
      t_add_user
      page = @site.create_new
      page.store("*t")
      t = Thread.new {
	sleep 0.1
	res = session("/test/.live")
	pw("//div[@class='msg']", res)
	e = res.body.get_tag("title")
	p e.text
	assert_equal("", e.text)

	sleep 0.2

	pw("//div[@class='msg']", res)
	p "3"
	assert_text("event", "title")
	p "4"
      }

      sleep 0.2

      session("/test/1.save?contents=*t2")
      assert_text("Page is saved.", "title")
      #pw("//div[@class='section']")

    end

----------------------------------------------------------------------
O

----------------------------------------------------------------------
      #pw("//div[@class='msg']", res)
      #pp res.body
      #p "3"
      #pp res.body
      #p "4"
      #pw("//div[@class='msg']", res)
      #assert_text("Page is saved.", "title")
      # uum....
#      sleep 0.2

=======================================================2005-03-10(Thu)



----------------------------------------------------------------------
      if CALC_INT_RE =~ str
	return str.to_i
      elsif CALC_FLOAT_RE =~ str
	return str.to_f
      else
      end
      return nil




=======================================================2005-03-09(Wed)

----------------------------------------------------------------------
#require "qwik/response"
----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

module Qwik
  class NuAction
    # ============================== verify
    def check_sessionid
      sid = @req.query["sid"]
      if sid.nil?
	sid = @req.path_query["sid"]
	return nil if sid.nil?
      end
      sidpool = @memory.sessionidpool
      sessionid = sidpool[sid]
      return if sessionid.nil?
      user, pass = sessionid.user, sessionid.pass
      if user
	check_user(user, pass)
	@req.user = user
	@req.auth = "sessionid"
	@res.sessionid = sid
      end
    end

    # ============================== login
    def session_login?
      f = @req.query["mode"]
      mobile = @req.useragent.mobile
      return (f && f == "sessionid") || mobile == "docomo"
    end

    def session_login_ok(user, pass)
      sidpool = @memory.sessionidpool
      sessionid = sidpool.create(user, pass) # set it on SessionIDPool
      @res.sessionid = sessionid
      return c_ok(_("Login by Session")){[
	  c_res("** "+_("Session ID is registerd.")+"\n"+
		_("Go back")+" : [[FrontPage]]")
	]}
    end

    def act_slogin
      begin
	# login from query
	user = @req.query["user"]
	pass = @req.query["pass"]
	if user
	  check_user(user, pass)

	  sidpool = @memory.sessionidpool
	  sessionid = sidpool.create(user, pass) # set it on SessionIDPool
	  @res.sessionid = sessionid
	  return c_ok(_("Login by Session")){[
	      c_res("** "+_("Session ID is registerd.")+"\n"+
		    _("Go back")+" : [[FrontPage]]")
	    ]}
	end
      rescue InvalidUserError
	return invalid_user
      end

      # show login form
      return c_ok(_("Login")){
      }
    end

    # ============================== logout
    def session_logout
      # not yet
    end
  end

  class NuSessionID
    EXPIRE = 60*60 # 1hour

    def initialize(sid, user, pass)
      @sid = sid
      @user, @pass = user, pass
      renew
    end
    attr_reader :sid, :user, :pass, :time

    def renew
      @time = Time.now
    end

    def old?
      EXPIRE < Time.now.to_i - @time.to_i
    end
  end

  class NuSessionIDPool
    def initialize
      @pool = {}
    end

    def create_new_sessionid
      time = Time.now
      time.to_i.to_s
    end

    def create(user, pass)
      sid = create_new_sessionid
      @pool[sid] = SessionID.new(sid, user, pass)
      sid
    end

    def delete(sid)
      @pool.delete(sid)
    end

    def [](sid)
      sessionid = @pool[sid]
      return nil if sessionid.nil?
      if sessionid.old?
	@pool[sid] = nil 
	return nil
      end
      sessionid
    end
  end
end

if $0 == __FILE__
  $LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
  require "t/test"
  $debug = true
end

if $debug
  class TC_NuActSession < Test::Unit::TestCase
    include TestSession

    def test_all
      #session("/test/.slogin")
      #pw("//div[@class='msg']")
    end
  end
end

----------------------------------------------------------------------
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

module Qwik
  class NuAction
    # ============================== verify
    def check_serial
      serial_str = @req.useragent.serial
      return if serial_str.nil?
      serialpool = @memory.serialpool
      serial = serialpool[serial_str]
      return if serial.nil?
      user, pass = serial.user, serial.pass
      if user
	check_user(user, pass)
	@req.user = user
	@req.auth = "serial"
      end
    end

    # ============================== logout
    def serial_logout
      serialpool = @memory.serialpool
      serial = @req.useragent.serial
      serialpool.delete(serial) # delete it from SerialPool.
      return c_ok(_("Terminal Number is deleted.")){[
	  c_res("** "+_("Terminal Number is deleted.")+"\n"+
		_("Go back")+" : "+"[[FrontPage]]")
	]}
    end
  end

  class Serial
    def initialize(user, pass)
      @user, @pass = user, pass
      @time = Time.now
    end
    attr_reader :user, :pass, :time
  end

  class SerialPool
    def initialize
      @pool = {}
    end

    def set(ser, user, pass)
      @pool[ser] = Serial.new(user, pass)
    end

    def delete(ser)
      @pool.delete(ser)
    end

    def [](ser)
      serial = @pool[ser]
      return nil if serial.nil?
      if 60*60 < Time.now.to_i - serial.time.to_i # 1hour
	@pool[ser] = nil
	return nil
      end
      serial
    end
  end
end

if $0 == __FILE__
  $LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
  require "t/test"
  $debug = true
end

if $debug
  class TC_NuActSerial < Test::Unit::TestCase
    include TestSession

    def test_all
      session("/test/.slogin")
      #pw("//div[@class='msg']")
    end
  end
end


=======================================================2005-03-08(Tue)

----------------------------------------------------------------------
      #serial = @req.useragent.serial
      #return serial_logout if serial
      # @res.set_cookies(@req.query["user"], @req.query["pass"]) # set cookie
----------------------------------------------------------------------
	    #[:hr],
	    #[:h2, _("Session ID Auth")],
	    #[:p, [:a, {:href=>".slogin"}, _("Session ID Auth")],
	    #  " : "+_("or, Access here.")],
----------------------------------------------------------------------
	  #return session_login_ok(user, pass) if session_login?
      #check_sessionid # get user from session id pool
      #return if @req.user
      #check_serial # get user from user agent serial
      #return if @req.user
----------------------------------------------------------------------
=begin
require "qwik/config"
require "qwik/webrick"
require "qwik/mail"
require "qwik/request"
require "qwik/periodic"
require "qwik/report"
require "qwik/site"
require "qwik/loadlib"
require "qwik/catalog"
require "qwik/attach"
require "qwik/request"

require "qwik/act-attach"
require "qwik/act-password"
require "qwik/act-log"
require "qwik/act-log"
require "qwik/act-style"
require "qwik/act-getpass"
=end

=begin
require "qwik/act-wema"
require "qwik/act-interwiki"
require "qwik/act-presen"
require "qwik/act-wysiwyg"
require "qwik/act-history"
require "qwik/act-backup"
require "qwik/act-qrcode"
=end
----------------------------------------------------------------------
  class Session
    def initialize(config, memory, req, res)
      @config, @memory, @req, @res = config, memory, req, res
    end
    def run
      @action = Action.new(@config, @memory, @req, @res)
      @action.run
    end
  end
----------------------------------------------------------------------
	# cmd_init

=======================================================2005-03-06(Sun)
----------------------------------------------------------------------
  #formatter =   Qwik::XMLFormatter.new
#  alias format_xml rb_format_xml
#  alias format_xml c_format_xml
#  if $have_xmlformatter_so
#    class XMLFormatter < Gonzui::XMLFormatter; end
#  else
#    class XMLFormatter < RB_XMLFormatter; end
#  end
----------------------------------------------------------------------
    def test_verify
      session
      sitetoken = @action.typekey_get_sitetoken
      tk = TypeKey.new(sitetoken, '1.1')
      ts = "1110026410"
      email = "2005@eto.com"
      name = "etocom"
      nick = "eto"
      sig = "tRUcIO6haAHv/vQSguPk2EijTrc=:LCUvoHCXFLaeO8SoldCKmFr2Guo="
      begin
      result = tk.verify(email, name, nick, ts, sig)
      rescue VerifyFailed
	qp "verify failed"
      rescue TimeOutError
	qp "time out"
      end
      qp "ok!"
    end
----------------------------------------------------------------------
#      qp "dsa_verify ok!"
#      qp Time.now.to_i, ts.to_i
#      qp @login_timeout
    #qp message, sig, key
    #qp r_sig, s_sig, sign
    #qp dss1
=======================================================2005-03-05(Sat)
----------------------------------------------------------------------
	ts = cgi.params["ts"][0]
	email =cgi.params["email"][0]
	name =cgi.params["name"][0]
	nick =cgi.params["nick"][0]
	sig = cgi.params["sig"][0]
----------------------------------------------------------------------
tRUcIO6haAHv/vQSguPk2EijTrc=:LCUvoHCXFLaeO8SoldCKmFr2Guo=
=======================================================2005-03-04(Fri)
----------------------------------------------------------------------
@req.path_args
      @site.files(@req.base).put(file, smil_str, true) # override
      @req.base
      file = @site.files(@req.base).path(filename)
	filename = args.join("/")
	if !@site.files(@req.base).exist?(filename)
	  return c_not_found(_("No such file"))
	end
	return files_get(filename) # send it
----------------------------------------------------------------------
#     @time = Time.gm(1970, 1, 1, hour, min, sec, frame_to_usec(frame))
#      @time = arg
#      @time = Time.at(arg)
#  attr_reader :time
#  def -(other)
#    SmilTime.new(@time - other.time)
#  end
#  def +(other)
#    return SmilTime.new(@time + other) if other.kind_of?(Numeric)
#    return SmilTime.new(@time + other.time)
#  end
#  def to_s
#    elsif arg.is_a?(Time)
#      return arg
#    elsif arg.kind_of?(Numeric)
#      return Time.at(arg)
=======================================================2005-03-03(Thu)
----------------------------------------------------------------------
      #    assert_equal("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\"\n><head\n><layout\n><root-layout width=\"320\" height=\"240\"\n/><region id=\"v\" fit=\"meet\"\n/></layout\n></head\n><body\n><par\n></par\n></body\n></smil\n>", @res.body.read)
      #    assert_equal("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\"\n><head><layout><root_layout width=\"320\" height=\"240\"/><region id=\"v\" fit=\"meet\"/></layout></head><body><par/></body></smil\n>", str)
      #    qp str
      #    assert(str.include?("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\""))
      #    assert(str.include?("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\""))
      #   assert_equal("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\"\n><head\n><layout\n><root-layout width=\"160\" height=\"120\"\n/><region id=\"v\" left=\"0\" top=\"0\" width=\"160\" height=\"120\" z-index=\"1\"\n/></layout\n></head\n><body\n><par\n><video begin=\"0s\" region=\"v\" src=\"rtsp://stream.nhk.or.jp/news/20030914000046002.rm\" clip-begin=\"00:03\" clip-end=\"00:13\"\n/><video begin=\"10s\" region=\"v\" src=\"rtsp://stream.nhk.or.jp/news/20030914000046002.rm\" clip-begin=\"00:20\" clip-end=\"00:28\"\n/></par\n></body\n></smil\n>", )
      #    $KCODE = "n"
      #   assert_equal("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\"\n><head\n><layout\n><root-layout width=\"160\" height=\"120\"\n/><region id=\"v\" fit=\"meet\"\n/></layout\n></head\n><body\n><par\n><video region=\"v\" begin=\"0s\" src=\"rtsp://stream.nhk.or.jp/news/20030914000046002.rm\" clipBegin=\"00:03\" clipEnd=\"00:13\" title=\"\343\201\202\"\n/><video region=\"v\" begin=\"10s\" src=\"rtsp://stream.nhk.or.jp/news/20030914000046002.rm\" clipBegin=\"00:20\" clipEnd=\"00:28\"\n/></par\n></body\n></smil\n>", @res.body.read)
      #   assert_equal("<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\" xmlns:rn=\"http://features.real.com/2001/SMIL20/Extensions\"\n><head\n><layout\n><root-layout width=\"160\" height=\"120\"\n/><region id=\"v\" fit=\"meet\"\n/></layout\n></head\n><body\n><par\n><video region=\"v\" begin=\"0s\" src=\"rtsp://stream.nhk.or.jp/news/20030914000046002.rm\" clipBegin=\"00:03\" clipEnd=\"00:13\"\n/><video region=\"v\" begin=\"10s\" src=\"rtsp://stream.nhk.or.jp/news/20030914000046002.rm\" clipBegin=\"00:20\" clipEnd=\"00:28\"\n/></par\n></body\n></smil\n>", str)

=======================================================2005-03-02(Wed)

----------------------------------------------------------------------
#      px("//div[@class='section']", 0)
#      assert_attr({"name"=>"message", "rows"=>"7", "cols"=>"40"}, "textarea")
      #px("//div[@class='section']", 0)
      #px("//html", 0)
      #assert_xml("Hi", "//div[@class='section']/dl/dd")
      #assert_xpath("Hi", "//div[@class='section']/dl/dd")
      #assert_xpath([], "//div[@class='section']/dl")
      #x = @res.body.get_path("//div[@class='section']/dl")
      #px("//div[@class='section']/dl[2]/dd", 0)
----------------------------------------------------------------------
      #px("//html", 0)
      #px("//div[@class='main']", 0)
      #px("//div[@class='body']", 0)
      #px("//div[@class='day']", 0)
      #px("//div[@class='section']", 0)
----------------------------------------------------------------------
#    THUMB_SIZE = 100
#	cmd = "#{convert} -thumbnail #{geom} #{org_file.to_s} #{thumb.to_s}"
#	return plg_show_files
#	thumb = thumb_generate(f)
#	cmd = "#{convert} -thumbnail #{geom} #{org_file.to_s} #{thumb.to_s}"
----------------------------------------------------------------------
      #    px("//div[@class='section']")
      #    px("//div[@class='body']")
      #    px("//div[@class='main']")
      #    px("//div[@class='main']/div[3]")
      #    px("//div[@class='day']")
      #    px("//div[@class='day']/h2")
      #    px("//div[@class='main']/div[4]")
      #    px("//div[@class='main']/div[5]")
      #    px("//div[@class='body']")
----------------------------------------------------------------------
      #assert("<plugin param=\"1\" method=\"recent\"\n></plugin\n>", [:plugin, {:method=>"recent", :param=>"1"}, ""])
      #assert("<div id=\"weditor\" contenteditable=\"true\"\n><h2\n>t</h2\n><plugin param=\"1\" method=\"recent\"\n></plugin\n></div\n>", [:div, {:id=>"weditor", :contenteditable=>"true"}, [[:h2, "t"], [:plugin, {:method=>"recent", :param=>"1"}, ""]]])
----------------------------------------------------------------------
#    qp res.titlelink, res.emode_titlelink
#    qp res.make_title_link([:h2, "t"])
----------------------------------------------------------------------
#	tdiary_section(title, section)
#      qp e
#   assert_equal([:h2, "t"], res.make_title_link([:h2, "t"])) # no change
----------------------------------------------------------------------
=begin
#      dir.erase_for_test if dir.exist?
    dir.each_entry {|file|
      base = file.to_s
      next if base == "." || base == ".."
      f = dir+file
      if /\.db\z/ =~ base
	qp base
	if /\A__/ =~ base
	  f.unlink
	else
#	  erase_db(f)
	end
	next
      end
    }
=end


=======================================================2005-03-01(Tue)
=======================================================2005-02-27(Sun)
=======================================================2005-02-26(Sat)
=======================================================2005-02-25(Fri)
=======================================================2005-02-24(Thu)
----------------------------------------------------------------------
    def add3(v)
      if str != ""
	str = str.chomp
	str = str+"\n"
      end
      if v != ""
	v = v.chomp
	v = v+"\n"
      end
      newstr = str+v
      put(newstr)
    end

    def add2(v)
      str = get(k)
      addstr = ""
      if str.empty?
	addstr = v
      elsif str[str.length-1] != ?\n

      end

      if str.empty? 
	addstr += "\n"
      end

      str += "\n" if str != ""
      v = v.chomp+"\n" if v != ""
      put(k, str+v)
    end

----------------------------------------------------------------------
backupdb̎dlύXAĂ
#    def path(k, t) # k, t is String
#    def exist?(k, t)
#     path(k, time).read
#      path = path(k, Time.now.to_i.to_s)
#      path = path(k, time.to_i.to_s)
----------------------------------------------------------------------
    def touch(k) # ref. fileutils.rb
      begin
	t = Time.now
#	if path(k).exist?
#	  path(k).utime(t, t)
#	else
#	  add(k, "") # add null String
#	end
	add(k, "") # add null String
	# the file owner should be the same of the process
      rescue Errno::ENOENT
	qp "ENOENT", k
#        path(k).open("a") { }
      end
    end
----------------------------------------------------------------------
#	if path(k).exist?
#	  path(k).utime(t, t)
#	else
#	  add(k, "") # add null String
#	end
      t = Time.now
 # ref. fileutils.rb
      begin
	# the file owner should be the same of the process
      rescue Errno::ENOENT
	qp "ENOENT", k
#        path(k).open("a") { }
      end
------------------------------backupdb.rb
#    include Enumerable
#      @path = path
#      @key = key
#    attr_reader :key
#    def set(v)
#    def get(t)
#      path(t).read
#    def exist?(t)
#      path(t).exist?
#    def each
#    def path(t) # t is String
#      path = @backup_path+(t+"_"+@key)
#      budb = fsdb.backup_db("1")
#      assert_equal("1", budb.key)
#      budb.each {|f, time|

=======================================================2005-02-23(Wed)
=======================================================2005-02-22(Tue)
=======================================================2005-02-21(Mon)
----------------------------------------------------------------------
function qwik_dragdrop(e) {
  debug.p(e);
}

=======================================================2005-02-19(Sat)
----------------------------------------------------------------------
#    px("//div[@class='section']", 0)
#    assert_xml("backup list", "//div[@class='section']//a")
#    px("//div[@class='msg']", 0)
----------------------------------------------------------------------
#     path = @site.get_pages.db.get_path
----------------------------------------------------------------------
    def get_path
      @path
    end
      assert_equal("./test/", fsdb.get_path.to_s)
----------------------------------------------------------------------
      qp (@pages.db.get_path+f)
      qp (@dir.path+f)
      (@pages.db.get_path+f).exist?
----------------------------------------------------------------------
#     @data_path = @data_dir.path
#      @super_path   = @super_dir.path

=======================================================2005-02-18(Fri)
----------------------------------------------------------------------
      #px("//div[@class='msg']", 0)
      #px("//div[@class='msg']", 0)
----------------------------------------------------------------------
      frompagename = nil
      frompagename = @req.base if @req.base && @req.base != ""
----------------------------------------------------------------------
  def test_with_plugin
=begin
    session("/test/1.html")
#    px("//div[@class='wema']/plugin", 0)
    assert_rattr({"method"=>"recent", "param"=>""},
		 "//div[@class='wema']/plugin")
=end
  end
      #    page.store("{{wema}}")
      #    session("/test/1.html")
      #    assert_text("", "script")

      #   px("/html")
      #   px("//div[@class='section']")
      #   px("//div[@class='wema']", 0)
      #   px("//div[@class='wema']/div[@class='cont']", 0)
      #   px("//div[@class='wema']/p", 0)

      #    px("//div[@class='wema']", 0)
      #    px("//div[@class='wema']/p/a", 0)

=======================================================2005-02-17(Thu)

----------------------------------------------------------------------
/* ========== basic style */
hr {
  clear: both;
}
----------------------------------------------------------------------
#    alias list to_a
----------------------------------------------------------------------
    DefaultMimeTypes = {
      "ai"    => "application/postscript",
      "asc"   => "text/plain",
      "avi"   => "video/x-msvideo",
      "bin"   => "application/octet-stream",
      "bmp"   => "image/bmp",
      "class" => "application/octet-stream",
      "cer"   => "application/pkix-cert",
      "crl"   => "application/pkix-crl",
      "crt"   => "application/x-x509-ca-cert",
     #"crl"   => "application/x-pkcs7-crl",
      "css"   => "text/css",
      "dms"   => "application/octet-stream",
      "doc"   => "application/msword",
      "dvi"   => "application/x-dvi",
      "eps"   => "application/postscript",
      "etx"   => "text/x-setext",
      "exe"   => "application/octet-stream",
      "gif"   => "image/gif",
      "htm"   => "text/html",
      "html"  => "text/html",
      "jpe"   => "image/jpeg",
      "jpeg"  => "image/jpeg",
      "jpg"   => "image/jpeg",
      "lha"   => "application/octet-stream",
      "lzh"   => "application/octet-stream",
      "mov"   => "video/quicktime",
      "mpe"   => "video/mpeg",
      "mpeg"  => "video/mpeg",
      "mpg"   => "video/mpeg",
      "pbm"   => "image/x-portable-bitmap",
      "pdf"   => "application/pdf",
      "pgm"   => "image/x-portable-graymap",
      "png"   => "image/png",
      "pnm"   => "image/x-portable-anymap",
      "ppm"   => "image/x-portable-pixmap",
      "ppt"   => "application/vnd.ms-powerpoint",
      "ps"    => "application/postscript",
      "qt"    => "video/quicktime",
      "ras"   => "image/x-cmu-raster",
      "rb"    => "text/plain",
      "rd"    => "text/plain",
      "rtf"   => "application/rtf",
      "sgm"   => "text/sgml",
      "sgml"  => "text/sgml",
      "tif"   => "image/tiff",
      "tiff"  => "image/tiff",
      "txt"   => "text/plain",
      "xbm"   => "image/x-xbitmap",
      "xls"   => "application/vnd.ms-excel",
      "xml"   => "text/xml",
      "xpm"   => "image/x-xpixmap",
      "xwd"   => "image/x-xwindowdump",
      "zip"   => "application/zip",
    }

=======================================================2005-02-16(Wed)

----------------------------------------------------------------------
#     w = [[:h5, _("contents")], w]
  //alert("toc_init");
  //alert("after hi");
  debug.p("hi");
  //debug.p(t);
  //debug.p(h);
  //debug.p(h);
  /*
  debug.p(h.getAttribute("onmousedown"));
  h.setAttribute("onmousedown", "toc_toggle();");
  debug.p(h.getAttribute("onmousedown"));
  */
  //h.setAttribute("ondblclick", "toc_toggle();");

  debug.p("toc_toggle");
  debug.p(t.nodeName);
  //debug.p(t.nodeName);
  debug.p(i.nodeName);
  //debug.p(i);
  //debug.p(i.nodeName);
  debug.p(i.style.display);
  debug.p(i.style.display);
    //alert("start flush");
    //alert("window opened");
    //alert("flush end");
    //alert("start print "+html);
    //alert("en print "+this.html);
    //alert("inspect "+obj);
    //var delimiter = ", ";
    //alert("end inspect ");

=======================================================2005-02-15(Tue)

----------------------------------------------------------------------
t is {
clientWidth:48
offsetWidth:48
scrollWidth:48
}
ǂ낤?
----------------------------------------------------------------------
    //w = toc.style.width;
    //w = t.style.left;
    //w = div.style.display;
    //alert("w is "+w);
    //debug.print("w is "+w);
    //w = div.style.left;
  /*
  debug.print("t is "+inspect(t));
  debug.print("t.style is "+inspect(t.style));
  debug.print("div is "+inspect(div));
  debug.print("div.style is "+inspect(div.style));
  debug.refresh();
  */
  //alert("toc_toggle");
  //alert("toc is "+t);
  //alert("toc_toggle"+div.style.display);
  //alert("getById");
    //alert("document.getElementById");
    //alert("elem is "+elem);
----------------------------------------------------------------------
{{toc}}
----------------------------------------------------------------------
#	w[0, 1] = REPLACE_TOC[w[0]]
#	w.insert(2, link)
----------------------------------------------------------------------
#	url = c_page_url
#	href = "#{url}#"+label
#	m = ""
#	w.insert(2, [:a, {:class=>"label", :href=>href, :name=>label}, m])
#	w = res.make_title_link(w)
#	head = REPLACE_TOC[w[0]]
#	rest = w[1..w.length]
#	li = [head, rest]
#	li = head + rest
#	qp li
#	tokens << li
	qp w

=======================================================2005-02-14(Mon)

----------------------------------------------------------------------
all:	install
install:	xmlformatter.so
	mv xmlformatter.so ../qwik
xmlformatter.o:	xmlformatter.c
	gcc -g -O2  -I. -I/usr/local/lib/ruby/1.8/i686-linux -c xmlformatter.c
#	gcc -g -O2  -I. -I/usr/local/lib/ruby/1.8/i386-cygwin -c xmlformatter.c
xmlformatter.so:	xmlformatter.o
	gcc -shared -s -Wl -L"/usr/local/lib" -o xmlformatter.so xmlformatter.o -lruby-static -lcrypt
#	gcc -shared -s -Wl,--enable-auto-import,--export-all -L"/usr/local/lib" -o xmlformatter.so xmlformatter.o -lruby -lcrypt
clean:
	-rm xmlformatter.o
	-rm xmlformatter.so
	-rm *~

=======================================================2005-02-13(Sun)

----------------------------------------------------------------------
#	  raise if @config.test
#	  return c_error("server error"){ backtrace_html($!) }
#      begin
#      rescue
#	raise if @config.test
#	return c_error("server error"){ backtrace_html($!) }
#      end
#      begin
#      rescue => e
##	raise if @config.test
##	return c_error("server error"){ backtrace_html($!) }
#	return c_error(e.message){ backtrace_html($!) }
#      end
#      qp @req.sitename, @default_site
----------------------------------------------------------------------
#     time = Time.now.strftime("%Y-%m-%dT%H:%M:%S")
#     time = req.start_time.strftime("%Y-%m-%dT%H:%M:%S")
#      fromhost = request.peeraddr[2]
#      forwarded_from = req["x-forwarded-for"]
#      fromhost = forwarded_from if forwarded_from
#      request_line = request.request_line.sub(/\x0d?\x0a\z/o, '')
#      request_line = request_line.sub(/ HTTP\/1\..\z/o, '')
----------------------------------------------------------------------
    def c_redirect_to_top(st, title, msg=title)
      url = "FrontPage.html"
      msg = add_jump_url(msg, url)
      c_message(st, title, top){ msg }
    end
    def c_back_to_top(st, title)
      url = "FrontPage.html"
      url = c_relative_to_absolute(url)
      msg = ""
      msg = yield if block_given?
      msg = add_goback_url(msg, url)
      c_message(st, title, url){ msg }
    end
    def c_error(msg)
      return c_error(msg){
	[:p, hash(@req.query)]
      }
    end
    def c_message(st, title, url=nil, redirectflag=false, &block)
      gen = MessagePageGenerator.new(@config, @memory, self)
      msg = ""
      msg = yield if block_given?
      msg = add_go_url(msg, url) if url
      @res.status = st if st.is_a?(Numeric)
      if redirectflag
	@res.status = 302
	url = c_relative_to_full(url)
	@res["Location"] =  url
      end
#     @res.body = gen.generate(@site, title, msg, url, redirectflag)
      @res.body = gen.generate(@site, title, msg, nil, redirectflag)
      c_set_html
      c_set_no_cache
      nil
    end
----------------------------------------------------------------------
  class Plugin
    def backtrace_html(e)
      PrettyBacktrace.new.to_html(e)
    end
  end
----------------------------------------------------------------------
#	  return c_not_found(_("Page not found.")){
#	    url = "FrontPage.html"
#	    go_url(url, _("Go back"))
#	  }
#	  return c_back_to_top(404, _("Page not found."))

----------------------------------------------------------------------
#     msg << [:p, [:a, {:href=>url}, url]] if url
#     msg = add_goback_url(msg, url) if url
----------------------------------------------------------------------
# [:hr],
# [:h2, "Session IDF"],
----------------------------------------------------------------------
http://www.microsoft.com/japan/msdn/columns/webteam/webteam07022001.asp#webteam07022001_topic1
----------------------------------------------------------------------
#    alias message c_message
#     msg = [[:h2, title], s]

=======================================================2005-02-12(Sat)
----------------------------------------------------------------------
rb_type(xml)
#define T_STRING 0x07
#define T_ARRAY  0x09
----------------------------------------------------------------------
  "Back automaticaly." => "Iɖ߂܂B",
  ": automaticaly jump." => "ɎIɔт܂B",
----------------------------------------------------------------------
#      qp @req.request_line # "GET /http://www.google.com/search?hl=ja&lr=&ie=UTF-8&oe=UTF-8&q=ds&num=50 HTTP/1.1\r\n"
#      qp @req.unparsed_uri # "/http://www.google.com/search?hl=ja&lr=&ie=UTF-8&oe=UTF-8&q=ds&num=50"
#      qp @req.request_uri # #<URI::HTTP:0x840f0d0 URL:http://127.0.0.1:9190/http://www.google.com/search?hl=ja&lr=&ie=UTF-8&oe=UTF-8&q=ds&num=50>
#      qp @req.query_string # "hl=ja&lr=&ie=UTF-8&oe=UTF-8&q=ds&num=50"
----------------------------------------------------------------------
#	  [:p, [:a, {:href=>url}, _("Newest page")], _(": automaticaly jump.")]]
----------------------------------------------------------------------
----------------------------------------------------------------------
#	@pagename = @req.base
----------------------------------------------------------------------
#	    [:td, _("You need password to access.")]],
#	    [:td, [:a, {:href=>".getpass"}, _("Get Password")], " : ",
#	      _("Access here.")]],
----------------------------------------------------------------------
#	  [:h2, _("Do you have password?")],
#	  [:p, _("You need password to access.")],
#	  [:p, [:a, {:href=>".getpass"}, _("Get Password")], " : "+_("Access here.")],
    def go_getpass
      [[:h2, _("Do you have password?")],
	[:p, _("You need password to access.")],
	[:p, [:a, {:href=>".getpass"}, _("Get Password")], " : "+_("Access here.")]]
    end

#	  [:h2, _("Basic Auth")],
	  [:hr],
	  [:h2, _("Basic Auth")],
----------------------------------------------------------------------
#      str = page.load
----------------------------------------------------------------------
#	return "" if i.nil?
#	line = str[0..(i-1)]
#	p [str, line, rest]
----------------------------------------------------------------------
#  def strip_space
#    self.sub(/\A\s+/, "").sub(/\s+\z/, "")
#  end
----------------------------------------------------------------------
#	  qp last_tag
#	    qp term[last_tag], line
----------------------------------------------------------------------
#      @config = config
#     spath = @config.super_dir.path
#     @config = config
#      @config = config
----------------------------------------------------------------------
#	  return c_message(200, @site.url+" : "+_("Login")){[

=======================================================2005-02-11(Fri)
----------------------------------------------------------------------
      //      rb_str_new("", 0);
    /*
      rb_raise(rb_eArgError, "too short");
    */
----------------------------------------------------------------------
      //printf("%s", data);
      //printf(" -%d- ", i);
	/*
	data = rb_id2name(SYM2ID(tag));
	xmlformatter_write(xf, data);
	*/
      char *data;
      data = rb_id2name(SYM2ID(tag));
      if (strncmp(data, "!--", 3) == 0) {
	printf(" match! ");
----------------------------------------------------------------------
#	qp "utime", k
#	  path(k).open("a") { }

=======================================================2005-02-09(Wed)

----------------------------------------------------------------------
  def make_sure_directory
    if exist?
      if !directory?
	raise self.to_s+" is not directory. failed."
      end
    else
      mkdir
    end
  end
  alias :check_directory :make_sure_directory
----------------------------------------------------------------------
#require "pathname"
----------------------------------------------------------------------
      # init pagenames
      # @frontpage = "FrontPage"
      # @sitemember = "SiteMember"
      # @textformat = "TextFormat"
      # @interwiki = "InterWikiName"
	  #p k, v
----------------------------------------------------------------------
#	@res.body = view_page_cache_generate(@req.base)
#	@res.body = view_page_cache_generate(@req.base)
----------------------------------------------------------------------
    def view_page_cache_generate(pagename)
#      wabisabi = view_page_generate(pagename)
      str = wabisabi.format_xml # with indent
      view_page_cache_store(pagename, str)
#      wabisabi
    end
----------------------------------------------------------------------
#      ss = SimpleSender.new(@config, @req, @res)
#      return ss.simple_send(f.to_s, "text/html; charset=Shift_JIS")

=======================================================2005-02-08(Tue)

----------------------------------------------------------------------
#      str = "* "+msg+"\n"+str
      #add_day = false
#      str = "* "+msg+"\n"+recent_str(max)
      #qp @req.user
----------------------------------------------------------------------
#      qp @req.query.length
#	p html
#	contents = "{{html\n"+html+"\n}}\n" 
----------------------------------------------------------------------
#      sar = str.to_a # split it by \n
#      sar = sar.map {|line| line.chompp }
#      sar = str
#      if emode?(sar) # special mode
#    def emode?(sar)
#      f = sar.first
#      return f && /\A(=+)\z/ =~ f && 60 <= f.length
----------------------------------------------------------------------
#	  if pl
#	  else
#	    ar << ["\n"] # same as empty
#	    new_p = true
#	  end
#      case method
#      when "br"
#	return nil # block level br should be ignored -> ???
#      end
#    URL = '(?:http|https|ftp|mailto|file):[a-zA-Z0-9;/?:@&=+$,\-_.!~*\'()#%]+'
----------------------------------------------------------------------
#	when 0x20, ?\t		# pre
----------------------------------------------------------------------
#require "qwik/emode-parser.rb"
#require "qwik/wabisabi.rb"
----------------------------------------------------------------------
	  # do nothing
----------------------------------------------------------------------
#	    s = s.sub(/\A\s+/, "").sub(/\s+\z/, "")
#	      page_ar << [("h#{h.size+1}").intern, d(s)]

=======================================================2005-02-07(Mon)

----------------------------------------------------------------------
http://qwik.jp/morioka-dump-fs/1.html
$ rsync -av --delete $SOURCE $DEST/current
$ cd $DEST
$ DATE=$(date +%Y/%m/%d)                            ;; GNU
$ mkdir -p $DATE                                    ;; GNU
$ cp -al current $DATE                              ;; GNU
$ cp -au current $DATE                              ;; GNU
----------------------------------------------------------------------
	return c_message(200, @req.base+": "+_("Page saved.")) {[
	    [:p, "time is "+time],
	    [:p, "mode is "+mode],
	    [:pre, ""+wikitext],
#	    [:pre, ""+html],
	  ]}
#	time = @req.query["time"]
#	mode = @req.query["mode"]
#	wikitext = HtmlToWikiText.new.translate(html)
	wikitext = "{{html\n"+html+"\n}}\n"
----------------------------------------------------------------------
#     return message(500, "contents is nil.") if contents.nil?
----------------------------------------------------------------------
#	  [:span, {:class=>"close"}, [:a, {:href=>"#"}, " X "]]], # noop
----------------------------------------------------------------------
#      if check_valid(wabisabi_child)
#	return wabisabi_child
#      end
#      return "error"
----------------------------------------------------------------------
  class ThemeFactory
    def initialize(config)
      @config = config
    end
  end
----------------------------------------------------------------------
#      ss = SimpleSender.new(@config, @req, @res)
#      return ss.simple_send(path, type)
#    def c_simple_send(local_path, mtype)
#      ss = SimpleSender.new(@config, @req, @res)
#      return ss.simple_send(local_path, mtype)
#    end
----------------------------------------------------------------------
#      [:span, {:class=>"attribute"},
#	[:a, {:href=>@site.sitename+".zip"}, "ZIP"]]
----------------------------------------------------------------------
    def sexist?(k)
      spath(k).exist?
    end
----------------------------------------------------------------------
      #move_old_to_new
    def move_old_to_new # not use
      move_old_to_new_path(@path)
      move_old_to_new_path(@spath)
    end
    def move_old_to_new_path(path) # move to .txt
      path.each_entry {|file|
	f = path+file
	next unless f.file?
	base = file.to_s
	if /\A[_A-Za-z0-9]+\z/ =~ base
	  nf = path+(base+".txt")
	  if !nf.exist? # check dest file
	    FileUtils.mv(f.to_s, nf.to_s) # do not change time stamp.
	  end
	end
      }
    end

=======================================================2005-02-06(Sun)

----------------------------------------------------------------------
      if @req.user # user is logged in.
	# do nothing for now
	# make title readable
      end
#     @g.a(@site.sitename+".rss"){"RSS"}
      # @res.body = xml
----------------------------------------------------------------------
     # UserAgentlanglanĝƂ\邼ƁB
#      qp lang, alang
 # show if it does not match

=======================================================2005-02-03(Thu)

----------------------------------------------------------------------
  /*
  if (qwik_onmousemove) {
    qwik_onmousemove(p);
  }
  if (defined(g_history)) {
    g_history.onMouseMove(p);
  }
  */
----------------------------------------------------------------------
#     @res.body = gen.wgenerate(nil, title, msg, url, redirectflag)
----------------------------------------------------------------------
#      [:span, "test"]
#      time = time.to_i
#      else
#	t = Time.at(time.to_i)
#	ts = t.strftime("%b #{t.day}, %Y")
#	line = line+"~" unless /\A([\ \-\*\>\|])(.*)\z/s =~ line
----------------------------------------------------------------------
#      if /\A[0-9]+\z/ =~ @key # @key contains only number?
#	return @key
#      end
----------------------------------------------------------------------
#     @plugin = nil
#      @action = nil
#   attr_accessor :plugin
#    attr_accessor :action
----------------------------------------------------------------------
  def any_to_wabisabi(ar)
    nar = []
    ar.each {|a|
      case a
      when Array
	if a[0].is_a? Symbol
	  nar << a
	else
	  aa = any_to_wabisabi(a) # recursive
	  nar += aa
	end
      when String, Symbol, Hash
	nar << a
      when HTree::Elem
	nar << a.to_wabisabi
      when HTree::Doc
	nar += any_to_wabisabi(a.children) # recursive
      else
	qp a
	raise "what?"
      end
    }
    nar
  end
----------------------------------------------------------------------
#      return "" if $debug
	#qp "what?", x
#	qp y, w

======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================
======================================================================

======================================================================
t/memo.txt

=======================================================2005-04-04(Mon)
14:54	bac.k
19:31	back

----------------------------------------------------------------------
    assert_instance_of(QuickML::QuickML, qml)
    assert_equal("test", qml.name)
    assert_equal(nil, @site["1"])


----------------------------------------------------------------------
    #     assert_equal("eXg", @site["1"].get_title)
    #     assert_equal("* eXg\n{{mail(user@e.com,0)\n̓eXgłB\n}}\n", @site["1"].load)

----------------------------------------------------------------------
    undef_method :close if method_defined?(:close)
    def close
      @logger.log "[#{@name}]: ML Closed"
    end

module QuickML
  class QuickML

  end
end


----------------------------------------------------------------------
module QuickML
  class QuickML
    def test_submit_1(t)
    end
  end
end


----------------------------------------------------------------------
    # @site = @qwikmemory.farm.get_site("test")
    # @site.erase_all
    #page = @site.create_new
    #page.store("t")

----------------------------------------------------------------------
    undef_method :close if method_defined?(:close)
    def close
      @logger.log "[#{@name}]: ML Closed"
    end

----------------------------------------------------------------------
    methods = %w(qwik_post)
    methods.each {|m|
      t_make_public(QuickML::QuickML, m)
    }
    t_make_public(QuickML::QuickML, "qwik_post")
----------------------------------------------------------------------
      @site.erase_all
      @qwikconfig.db = @org_config_db

----------------------------------------------------------------------
    #qml.test_submit_3(self)
    # @site = @qwikmemory.farm.get_site("test")
    # @site = @memory.farm.get_site("test")
    # 3rd mail
    #mail = Mail.new

----------------------------------------------------------------------
    #assert_equal("", QuickML::Mail.encode_field("[test:1] Re: \245\306\245\271\245\310 "))

----------------------------------------------------------------------
# $VERBOSE = true

----------------------------------------------------------------------
# This file is in Shift-JIS character encoding.  Japanese Character -> ""
  def nusetup
    if !defined?($quickml_config) || $quickml_config.nil?
      confstr = File.safe_open("../../bin/quickmlrc").read
      confhash = eval(confstr)
      confhash[:data_dir] = "."
      $quickml_config  = QuickML::Config.new(confhash)
    end
    @config = $quickml_config
    @dir = @config.data_dir.path+"test"
    @dir.teardown
    @catalog = @config.catalog
    @message_charset = "iso-2022-jp"
  end

  def nuteardown
    @dir.teardown
  end


----------------------------------------------------------------------
	qp "hogeh"
	config = Qwik::Config.new(true)
	config.test = true	# do not send mail
	config.pass_file = "./password.txt"
	$test_org_data_dir = config.data_dir.dup
	config.data_dir = "."
	#config.cache_dir = "."
	#config.db = "bdb"
	$test_config = config
      end

      # @org_config_db = @qwikconfig.db
      # @qwikconfig.db = "fsdb"
	memory = Qwik::ServerMemory.new(@qwikconfig)
	logfile = "testlog.txt"
	loglevel = WEBrick::Log::INFO
	logger = WEBrick::Log::new(logfile, loglevel)
	memory[:logger] = logger
	$test_memory = memory
      end
      @org_data_dir = $test_org_data_dir


----------------------------------------------------------------------
    #      qp str
    #      qp str
    #      str = members_file_read
    #      qp str
    #      assert_equal("# user@e.com\n", str)
----------------------------------------------------------------------
#    public :obfuscate_address

    def test(t)
      # test private method
      t.assert_equal("test@e...", obfuscate_address("test@example.com"))
      t.assert_equal("http://qwik.jp/test/", qwik_url)
      t.assert_equal("\n-- \narchive-> http://qwik.jp/test/ \nML-> test@example.com\n", generate_footer)
      t.assert_instance_of(Time, last_article_time)

      # test member file
      t.assert_equal("./test/,members", @members_file)
      t.assert_equal("./test/,count", @count_file)
      t.assert_equal(false, File.exist?(@members_file))

      save_member_file
      t.assert_equal(true, File.exist?(@members_file))
      t.assert_equal("", members_file_read)

      add_member("user@e.com")
      str = members_file_read
#      qp str
      t.assert_equal("user@e.com\n", str)

      add_error_member("user@e.com")
      str = members_file_read
#      qp str
      t.assert_match(/\Auser@e.com\n; user@e.com 1 /, str)

      t.assert_equal(true, FileTest.exist?(@members_file))
      remove_member("user@e.com")
#      str = members_file_read
#      qp str
#      t.assert_equal("# user@e.com\n", str)
      t.assert_equal(false, FileTest.exist?(@members_file)) # why?
    end


=======================================================2005-03-30(Wed)
15:50	back.

----------------------------------------------------------------------
#     t.assert_equal("* UuencodeImage\n{{mail(user@e.com,0)\neXgłB\n\n{{ref(1x1a.png)}}\n\n}}\n", page.load)
#   undef_method :puts_log if method_defined?(:puts_log)
     #t.assert_equal("\n-- \narchive-> http://example.com/test/ \nML-> test@example.com\n", generate_footer)
      #t.assert_equal("http://example.com/test/", qwik_url)
#      t.assert_equal(" Re: eXg ", Mail.clean_subject(encoded_subject))

----------------------------------------------------------------------
  class Logger
    undef puts_log
    def puts_log(msg) # for test
      return if msg =~ /New ML/
      time = Time.now.strftime("%Y-%m-%dT%H:%M:%S")
      open("testlog.txt", "ab"){|f|
	f.puts "#{time}: #{msg}"
      }
    end
  end



=======================================================2005-03-09(Wed)
22:25	back.

----------------------------------------------------------------------
     #s = elem.inside.rb_format_xml
  def assert_tag(e, tag)
    elem = @res.body.get_tag(tag)
    return assert_equal(e, nil) if elem.nil?
    if e.is_a? String
      s = elem.inside.text
      return assert_equal_or_match(e, s)
    end
    assert_equal(e, elem)
  end

#    if e.is_a? String
#      s = elem.inside.format_xml
#      return assert_equal_or_match(e, s)
#    end



----------------------------------------------------------------------
  def nupx(xpath=nil, i=-1) # show by xpath
    w = @res.body.get_path(xpath)
    if w.nil?
      puts "nil"
      return
    end
    puts w.rb_format_xml(i)
  end


----------------------------------------------------------------------
      #query_str = query_str[1..-1] if query_str[0] == ?&

----------------------------------------------------------------------
#require "qwik/webrick"
#require "qwik/farm"
#require "qwik/memory"
#require "bdb"
----------------------------------------------------------------------
#config.cache_dir = "."




=======================================================2005-03-07(Mon)
10:49	back.
11:30	AISTB
11:48	bakc

----------------------------------------------------------------------
#	$(RUBY) -I. all.rb
#	$(RUBY) -I. all.rb 5
#	$(RUBY) -rprofile -I. all.rb 2>&1 >profile.txt
#	$(RUBY) -rrbprof -I. all.rb 2>rbprof.txt
#	$(RUBY) -rrbprof -I. test-qp.rb 2>rbprof.txt
#	$(RUBY) -rrbprof -I. test-util.rb 2>rbprof.txt
#	$(RUBY) -rrbprof -I. bench-session.rb 2> rbprof-bench.txt
#	-rm *.profile

----------------------------------------------------------------------
	      dummy1=nil, dummy2=nil, dummy3=nil, dummy4=nil

    raise "query!" if dummy1
    raise "cookie!" if dummy2
    raise "method!" if dummy3
    raise "user!" if dummy4


----------------------------------------------------------------------
#    req.cookies.update(cookies) if cookies

----------------------------------------------------------------------
	      dummy1=nil, dummy2=nil, dummy3=nil, user=nil)
----------------------------------------------------------------------
#    elsif query
#      req.query.update(query)

----------------------------------------------------------------------
  def t_lang_en
    @accept_language = ["en"]
  end
  def t_lang_ja
    @accept_language = ["ja"]
  end
#    req.accept_language = @accept_language if defined?(@accept_language)
#      raise "query!!!!!"
#    if user != DEFAULT_USER
#      raise "user!"
#    end

=======================================================2005-03-06(Sun)
22:50	back.

----------------------------------------------------------------------
xmlformatterŁAǂꂾ͂₭ȂĂ̂B
with xmlformatter.so
Finished in 30.073 seconds.
167 tests, 2160 assertions, 0 failures, 0 errors
with xmlformatter.so, without setback_body
Finished in 29.759 seconds.
167 tests, 2160 assertions, 0 failures, 0 errors
without xmlformatter.so
Finished in 33.369 seconds.
167 tests, 2133 assertions, 0 failures, 0 errors
without xmlformatter.so, without setback_body
Finished in 29.55 seconds.
167 tests, 2133 assertions, 0 failures, 0 errors
ƂƂŁA10%͂͂₭ȂĂƁBcCĂ!

=======================================================2005-03-04(Fri)
22:41	back.

----------------------------------------------------------------------
      #qp $test_org_data_dir
#      config.db = "bdb"
#    @farm = @memory.farm
#    @site = @farm.get_site("test")
#    @site = Qwik::Site.new(@config, @memory, "test")

=======================================================2005-03-02(Wed)
20:24	back.

----------------------------------------------------------------------
# $LOAD_PATH.unshift("../../compat") unless $LOAD_PATH.include?("../../compat")
#require "webrick/httputils"
#require "webrick/httprequest"
#require "webrick/httpresponse"
#   assert_equal("text/html; charset=Shift_JIS", @webrick_response["content-type"])
#    assert_equal("css", @req.ext)
#    assert_equal("text/html; charset=Shift_JIS", @webrick_response["content-type"])
#    assert_match(%r|^<|, @webrick_response.body)
#    assert_instance_of(File, @webrick_response.body)
#    @webrick_response.body.close
#    assert_equal("css", @req.ext)

#    @server.shutdown if @server

#    @server.shutdown if @server


----------------------------------------------------------------------
usecase-mobilelogin.rb
#!/usr/bin/env ruby
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

require "common"

class TC_UseCaseSession < Test::Unit::TestCase
  include TestSession

  def test_dummy
  end

  def nutest_mobilelogin

    t_add_user("test@docomo.ne.jp")

    # let's login
    session("/test/", nil, {"user"=>nil, "pass"=>nil})

    session("/test/.login", nil, {"user"=>nil, "pass"=>nil})
    #px("//[@class='form']", 0)
    assert_attr({"method"=>"POST"}, "form")
    assert_attr({"name"=>"user"}, "input")

    pw = Qwik::PasswordGenerator.new(@config)
    assert_equal("87779876", pw.generate("test@docomo.ne.jp"))

    session("/test/.login",
	    {"user"=>"test@docomo.ne.jp", "pass"=>"87779876"}){|req|
      ua = req.useragent
      ua.parse("DoCoMo/1.0/P504i/c10/TB/serNMAIA000001")
      assert_equal("docomo", ua.mobile)
      assert_equal("NMAIA000001", ua.serial)
    }
    assert_text("Set cookie", "title")

    session("/test/.logout", nil, {"user"=>nil, "pass"=>nil}){|req|
      req.useragent.parse("DoCoMo/1.0/P504i/c10/TB/serNMAIA000001")
    }
    #px("//[@class='form']", 0)
    assert_text("OAEgmF", "title")
    assert_attr({"name"=>"confirm", "type"=>"hidden", "value"=>"yes"}, "input")
    assert_attr({"type"=>"submit", "value"=>"OAEg"}, "input[2]")

    session("/test/.logout", {"confirm"=>"yes"}, {"user"=>nil, "pass"=>nil}){|req|
      req.useragent.parse("DoCoMo/1.0/P504i/c10/TB/serNMAIA000001")
    }
    assert_text("[ԍ폜܂", "title")

    serial = serialpool["NMAIA000001"]
    assert_equal(nil, serial)
  end
end


=======================================================2005-03-01(Tue)
17:24	back

----------------------------------------------------------------------
#     t.assert_match(%r|data/test/,members|, @members_file)
#     t.assert_match(%r|data/test/,count|, @count_file)

#      @site = Qwik::Site.new(@qwikconfig, @qwikmemory, "test")
#      @site.close

#  include TestSession
#     $quickml_config  = QuickML::Config.load("../../bin/quickmlrc")
#      pp confhash
#      pp confhash
#    @dir.rmtree if @dir.directory?
#    @dir.rmdir  if @dir.directory?
    #qp @dir.to_s
#    @dir.rmtree if @dir.directory?
#    @dir.rmdir  if @dir.directory?
#    pp @config



=======================================================2005-02-26(Sat)
14:44	back.

----------------------------------------------------------------------
require "test"

class TC_LoginLogic < Test::Unit::TestCase
  include TestSession

  def test_login_logic # not yet
    logic = Qwik::LoginLogic.new(@config, @req, @site)
    logic.authenticate_user # success

    @req.cookies.clear
    logic.authenticate_user # success for open site

    @req.query["user"] = "test@example"
#    assert_raise(Qwik::InvalidMailError) { logic.authenticate_user }

    @req.query["user"] = "test@example.com"
    @req.query["pass"] = "nosuchpassword"
#    assert_raise(Qwik::InvalidUserError) { logic.authenticate_user }

    @req.query["user"] = "test@example.com"
    @req.query["pass"] = "ABAB4B32"
#    assert_raise(Qwik::SetCookieRetry) { logic.authenticate_user }
  end
end

=======================================================2005-02-25(Fri)
11:47	back.

----------------------------------------------------------------------
#    begin
#      f.unlink
#      return
#    rescue
#      qp f.to_s+" could not erase."
#    end
#      qp f.to_s
#      db = BDB::Hash.open(f.to_s, nil, BDB::TRUNCATE)
#      BDB::Hash.remove(f.to_s)
#      BDB::Hash.unlink(f.to_s, nil)
      #sleep 0.1

=======================================================2005-02-24(Thu)
23:00	back.
23:48	back.

----------------------------------------------------------------------
#      next if base == ".attach"
#	qp f
#	  qp e
#    bd = dir+".backup" 
#    bd.erase_all_for_test if bd.directory?
----------------------------------------------------------------------
# $VERBOSE = true
# $DEBUG = true
# $debug = false
# $debug = true

----------------------------------------------------------------------
unless defined?($common_defined)
end
$common_defined = true

=======================================================2005-02-23(Wed)
20:45	back.

=======================================================2005-02-20(Sun)
 0:14	back

----------------------------------------------------------------------
# $LOAD_PATH.unshift("../../compat")
#require "qwik/htree"
#require "qwik/htree-generator"
#require "qwik/wabisabi"
#require "qwik/qp"
#  include Wabisabi
#  include Wabisabi



=======================================================2005-02-14(Mon)

----------------------------------------------------------------------
    # test_include
#    page2 = @site.create_new
#    page2.store("* \n")
#    assert_day("<h2></h2><div class=\"body\"><div class=\"section\"></div><!--section--></div><!--body-->", "{{include(#{key})}}")
#    assert("<div class=\"day\"><h2>eXg</h2><div class=\"body\"><div class=\"section\"></div><!--section--></div><!--body--></div><!--day--><div class=\"day\"><h2>From:</h2><div class=\"body\"><div class=\"section\"><p>eXgłB</p></div><!--section--></div><!--body--></div><!--day-->", "* eXg\n{{mail()\neXgłB\n\n}}")
#    assert("<div class=\"day\"><h2>e</h2><div class=\"body\"><div class=\"section\"></div><!--section--></div><!--body--></div><!--day--><div class=\"day\"><h2>From: t@e...</h2><div class=\"body\"><div class=\"section\"><p>X</p></div><!--section--></div><!--body--></div><!--day-->", "* e\n{{mail(t@e.com)\nX\n\n}}")
#    assert("<div class=\"day\"><h2>e</h2><div class=\"body\"><div class=\"section\"></div><!--section--></div><!--body--></div><!--day--><div class=\"day\"><h2><span class=\"date\">Jan 1, 1970</span> From: t@e...</h2><div class=\"body\"><div class=\"section\"><p>X</p></div><!--section--></div><!--body--></div><!--day-->", "* e\n{{mail(t@e.com,0)\nX\n\n}}")
#   assert("<div class=\"day\"><h2>e</h2><div class=\"body\"><div class=\"section\"></div><!--section--></div><!--body--></div><!--day--><div class=\"day\"><h2>From: t@e...</h2><div class=\"body\"><div class=\"section\"><p>t@e...</p></div><!--section--></div><!--body--></div><!--day-->", "* e\n{{mail(t@e.com)\nt@e.com\n\n}}")

=======================================================2005-02-12(Sat)

---------------------------------------------------------------------
#  include TestAssertWiki
#  include TestAssertXPath
----------------------------------------------------------------------
#require "common"
#  include TestSession
----------------------------------------------------------------------
    # TitleList page is no longer exist.
#    assert_equal(true, @pages.exist?("TitleList"))
#    page = @pages["TitleList"]
#    assert_equal("TitleList", page.get_title)
#   assert_equal("_SideMenu", page.get_title)
#   assert_equal("_SiteMenu", @pages["_SiteMenu"].get_title)
#   assert_equal(nil, @pages.last_page_time)
#    assert_equal(nil, @pages.last_page_time)

=======================================================2005-02-11(Fri)

----------------------------------------------------------------------
#    @pagename = "TestPage"
#    @g = HTree::HtmlGenerator.new
    #setup_req_res
    #setup_action
    #setup_plugin
#     @site.member.add(user) unless @site.member.exist?(user)
----------------------------------------------------------------------
#require 'gonzui/webapp/xmlformatter.so'
#require 'test-util'
----------------------------------------------------------------------
#!/usr/bin/env ruby

require "common"

class TC_BenchRun
  include TestSession

  def test_bench_session
#    repeat = 10
    repeat = 100
#    repeat = 1000

    t_add_user

    }
  end
end

t = TC_BenchRun.new
t.setup
t.test_bench_session
---------------------------------------------------------------------
#    px("//div[@class='msg']", 0)
#    px("//html", 0)
#    px("//div[@class='msg']", 0)

=======================================================2005-02-10(Thu)

=======================================================2005-02-07(Mon)

----------------------------------------------------------------------
#    assert_wiki("", "{{toc}}")
----------------------------------------------------------------------
#      assert_next(zis, "test/_PageTitle.txt")
#      assert_next(zis, "test/_PageTitle.html")

=======================================================2005-02-04(Fri)

----------------------------------------------------------------------
#      qp str
#      qp @name
#      qp encoded_subject
#     t.assert_equal("* R\n{{mail(eto@example.com,0)\n\n}}\n", page.load)
#     t.assert_equal("* R\n{{mail(eto@example.com,0)\n\n}}\n", page.load)
----------------------------------------------------------------------
    # łformat_xmlՂɒ`ႢȂ̂cB
----------------------------------------------------------------------
  def t_strip_p(str)
    s = str.dup
    s.sub!(/^<p>/, "")
    s.chomp!
    s.sub!(%r|</p>$|, "")
    s.sub!(%r|<p />$|, "")
    s.chomp!
    s
  end
#   s = t_strip_p(s)
    s = t_strip_n(s)

----------------------------------------------------------------------
  def assert_class(e, w, user=DEFAULT_USER, c="section", &b)
    assert_path(e, w, user, "//div[@class='#{c}']", &b)
  end


----------------------------------------------------------------------
common-rexml.rb

module HTree
  class NuDoc
    def get_rexml
      @rexml = make_rexml unless defined? @rexml
      @rexml
    end

    def make_rexml
      REXML::Document.new(to_s.sjistou8) # do not use to_rexml
    end
  end
end
----------------------------------------------------------------------
common-libxml.rb

module XML
  class Node
    class Set
      def first_node
	self.each {|ee|
	  return ee
	}
      end

      def text
	n = first_node
	n.to_s
      end

      def attributes
	prop = first_node.properties
	attr = {}
	while true
	  attr[prop.name] = prop.value
	  if prop.next?
	    prop = prop.next
	  else
	    break
	  end
	end
	attr
      end

    end
  end
end

module HTree
  class Doc
    def get_libxml
      @libxml = make_libxml unless defined? @libxml
      @libxml
    end

    def make_libxml
      require "xml/libxml"
      str = to_s.sjistou8
      xp = XML::Parser.new
      xp.string = str
      doc = xp.parse
      doc
    end
  end
end

module TestAssertLibXml
  def libxml(xpath=nil)
    require "xml/libxml"

    return libxml if xpath.nil?

    libxml.find(xpath){|e|
      qp e
      return e
    }
  end

  def assert_xml(expected, xpath, attr=nil)
    e = libxml(xpath)
    return assert_equal(expected, nil) if e.nil?

    result = e.text

    if attr
      attrs = e.attributes
      result = attrs[attr]
    end
#    result = e.attribute(attr).to_s if attr

    return assert_equal(expected, nil) if result.nil?
    s = result.u8tosjis
    assert_equal_or_match(expected, s)
  end

  def assert_rattr(expected, xpath)
    e = libxml(xpath)
    return assert_equal(expected, nil) if e.nil?

    attr = e.attributes

    return assert_equal(expected, nil) if attr.nil?
    attr = hash_to_str(attr)
    assert_equal(expected, attr)
  end

  def hash_to_str(src)
    h = {}
    src.each {|k, v|
      h[k.to_s] = v.to_s
    }
    h
  end

  def px(xpath=nil, i=-1)
#    puts libxml(xpath).to_s(i).u8tosjis
#    libxml(xpath).each {|ee|
#      puts ee
#    }
    puts libxml(xpath).to_s.u8tosjis
  end
end

=======================================================2005-02-03(Thu)

----------------------------------------------------------------------
    assert_wiki("a", "{{html
<UL>
<LI>ӏx1
<LI>ӏx1a
<UL>
<LI>ӏx2
</UL>
</UL>
}}")
  end
    assert_wiki("h2", "{{html
<H2>h2</H2>
}}")
#    assert_wiki("not yet", "{{html
#{html}
}}")
    assert_wiki("
  end
----------------------------------------------------------------------
