<commit_before>#!/usr/bin/ruby -Ku

require 'webrick'


class TinyBBS < WEBrick::HTTPServlet::AbstractServlet
end

server = WEBrick::HTTPServer.new({
  :DocumentRoot => './public',
  :DocumentRootOptions => { :FancyIndexing => false },
  #:BindAddress => '127.0.0.1',
  :BindAddress => '192.168.3.11',
  :Port => 8080})
trap("INT") { server.shutdown }

server.mount_proc('/') {|req, res|
  res.body = <<HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <h1>Tiny BBS</h1>
    <form method="POST" action="/post">
      <textarea name="content"></textarea>
      <button type="submit">書き込む</button>
    </form>
HTML
  posts = []
  Dir.glob('./data/*').sort.each_with_index {|fp, i|
    time_str = Time.at(File.basename(fp).to_i).to_s
    content = IO.read(fp)
    posts << "<p>" + "<span>#{(i + 1).to_s}&nbsp;:&nbsp;</span><span>#{time_str}</span>" + "<p>#{content}</p>" + "</p><hr>"
  }
  res.body += posts.reverse.join
  res.body += <<HTML
  </body>
</html>
HTML
}
server.mount_proc('/post') {|req, res|
  IO.write('./data/' + Time.now.to_i.to_s, req.query['content'])
  res.set_redirect(WEBrick::HTTPStatus::Found, '/')
}
server.start<commit_msg>Change the directory structure for introducing an external CSS.<commit_after>#!/usr/bin/ruby -Ku

require 'webrick'


class TinyBBS < WEBrick::HTTPServlet::AbstractServlet
end

server = WEBrick::HTTPServer.new({
  :DocumentRoot => './public',
  :DocumentRootOptions => { :FancyIndexing => false },
  #:BindAddress => '127.0.0.1',
  :BindAddress => '192.168.3.11',
  :Port => 8080})
trap("INT") { server.shutdown }

server.mount_proc('/bbs') {|req, res|
  res.body = <<HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <h1>Tiny BBS</h1>
    <form method="POST" action="/bbs/post">
      <textarea name="content"></textarea>
      <button type="submit">書き込む</button>
    </form>
HTML
  posts = []
  Dir.glob('./data/*').sort.each_with_index {|fp, i|
    time_str = Time.at(File.basename(fp).to_i).to_s
    content = IO.read(fp)
    posts << "<p>" + "<span>#{(i + 1).to_s}&nbsp;:&nbsp;</span><span>#{time_str}</span>" + "<p>#{content}</p>" + "</p><hr>"
  }
  res.body += posts.reverse.join
  res.body += <<HTML
  </body>
</html>
HTML
}
server.mount_proc('/bbs/post') {|req, res|
  IO.write('./data/' + Time.now.to_i.to_s, req.query['content'])
  res.set_redirect(WEBrick::HTTPStatus::Found, '/bbs')
}
server.start
{'fraction_non_alphanumeric': 0.2304847986852917, 'fraction_numerical': 0.018898931799506986, 'mean_word_length': 3.87, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '42455', 'n_tokens_mistral': 991, 'n_tokens_neox': 956, 'n_words': 160}