#!/usr/bin/env ruby # coding: utf-8 require'sqlite3' require'cgi' c = CGI.new(:accept_charset => "UTF-8") print <<EOF Content-type: text/html; charset=utf-8 <DOCTYPE html> <head> <meta charset=utf-8> <title>ランキング</title> <link rel="stylesheet" type="text/css" href="editor.css"> <style> <!-- --> </style> </head> <body> EOF SQLite3::Database.new("../data/ranking.db") do |db| db.results_as_hash = true name = "" id = "" i = 1 a = 1 o = 1 puts("<h1>ランキング</h1>") puts("<p>※インデントは考慮していません</p>") db.execute("select * from ranking") do |f| name = f["name"] pro = f["id"] printf("<h4><span>名前:%s</span></h4> <h4>●コード</h4><div id=\"code\">%s</div>\n", name, pro.gsub(/(\r\n|\r|\n)/,"<br />")) i += 1 if i == 6 break end end end