Mercurial > hgrepos > hgweb.cgi > skipweb
view blog.rb @ 417:2bd243792a79
merged
author | MURAKAMI Masaki <c112124@h.koeki-u.ac.jp> |
---|---|
date | Thu, 21 Nov 2013 00:00:19 +0900 |
parents | 45b0a081ca83 |
children |
line wrap: on
line source
#!/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