#!/usr/local/bin/ruby
#  encoding: utf-8
#  daybook_print.rb
#
#  Created by midori on 2006-09-24.
#  Copyright (c) 2006. All rights reserved.
#  You can distribute/modify

module PrintMessage
  def m_daybook_print(title, message)
    print "Content-Type: text/html\n\n"
    erb_text =<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="author" content="midore"/>
  <link rel="stylesheet" type="text/css" media="screen,tv" href="/css/daybook_index.css" title="indexcss"/>
  <title>#{title}</title>
  </head>
  <!-- BODY -->
  <body>
    <h1>#{message} </h1>
    <h2><a href="/daybook/daybook_index.html">Index</a></h2>
  <hr/>
  <p>#{Time.now.to_s}</p>
  </body>
</html>
EOF
    print erb_text
  end
end

class DaybookPrint
include PrintMessage
  def error_print
   title = "Error"
   message = "Error_0"
   m_daybook_print(title, message)
  end
  def end_print
   title = "OK"
   message = "Complete"
   m_daybook_print(title, message)
  end
  def custom_print(str)
   title = "custom messag"
   message = str
   m_daybook_print(title, message)
  end
  def search_print(str_xhtml)
   print "Content-Type: text/html\n\n"
   print str_xhtml
  end
  def error_out
    print "Content-Type: text/html\n\n"
    print "<p>#{
    CGI.escapeHTML($!.inspect)}<br>\n"
    $@.each {|x| print CGI.escapeHTML(x), "<br>\n"
      }
  end
end