#!/usr/bin/ruby
# coding: euc-jp
require 'date'
day = Date.today
STDERR.print "タイトル:"
title = gets.chomp
comment = ""
STDERR.puts "コメントをどうぞ(ピリオドのみの行でおしまい)"
while true
com1 = gets
if com1 == ".\n" || com1 == nil then # nilはC-dで入力終了したとき
break
end
comment += com1
end
STDERR.print "写真をアップロード(画像ファイル指定、ないときはReturn):"
photo = gets.chomp
if photo != "" then
photo = '<img src="'+photo+'" width="640" height="480">'
end
STDERR.print "書いた人:"
writer = gets.chomp
open("template.txt", "r") do |cm|
while x = cm.gets
x.gsub!("%day%", day.to_s)
x.gsub!("%title%", title)
x.gsub!("%comment%", "<p>"+comment.chomp+"</p>")
x.gsub!("%photo%", photo)
x.gsub!("%writer%", writer)
print x
end
end