|
What this is
Other links
The source code
require "nkf"
require "cgi/application"
require "simplebbs/model"
require "simplebbs/view/board"
module Simplebbs
class Application < CGI::Application
VERSION = 'simplebbs 0.0.1'
include Simplebbs::View::Board
def initialize
@model = nil
end
def setup(opt)
@name = opt[:name] || 'mwbbs'
@model = Simplebbs::Model.new(opt)
end
def teardown
@model.close
end
def board_name
h @name
end
ARG_top = Struct.new(:subject, :from, :mail, :text, :msglist, :id_from, :id_to)
def do_start(cgi, memo, chain)
arg = ARG_top.new
arg.subject = ''
arg.from = ''
arg.mail = ''
arg.text = ''
arg.id_from = get_param(cgi, 'from', :integer, false) || @model.get_max_id
arg.id_to = arg.id_from - 20
arg.msglist = @model.get_msglist(arg.id_from,arg.id_to)
out('charset'=>'euc-jp') {
top(arg)
}
end
def do_post(cgi, memo, chain)
msgdate = Time.now.localtime.strftime("%Y/%m/%d %H:%M:%S")
from = NKF.nkf('-m0 -eXd', get_param(cgi, 'from', :text).strip)
mail = get_param(cgi, 'mail', :text).strip
subject = get_param(cgi, 'subject', :text).strip
message = NKF.nkf('-m0 -eXd', get_param(cgi, 'text', :text)).strip
begin
raise if (from.empty? || subject.empty? || message.empty?)
id_from = @model.get_max_id
msglist = @model.get_msglist(id_from,id_from)
if msg=msglist.first
raise if msg.message == message
end
@model.insert(msgdate, from, mail, subject, message)
rescue
#
end
#
arg = ARG_top.new
arg.subject = ''
arg.from = from
arg.mail = mail
arg.text = ''
arg.id_from = @model.get_max_id
arg.id_to = arg.id_from - 20
if arg.id_to < 1
arg.id_to = 1
end
arg.msglist = @model.get_msglist(arg.id_from,arg.id_to)
out('charset'=>'euc-jp') {
top(arg)
}
end
def msg2html(text)
html = h(text)
html.gsub!(/\r?\n/,"
|
Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com