#!/usr/bin/env ruby # # 表題: dcmodel お絵描きサムネイル HTML 作成スクリプト # # 履歴: 2003/09/28 やまだ由 # 2004/02/18 やまだ由 ($head 付加) # # 注意: 本プログラムは, # dcphoto.pl Ver 1.02 - 写真用 HTML作成スクリプト # Mitsuda Chihiro を ruby で写経し, # やまだ由用にカスタマイズしたものである # # # # # --------------------------------------------------------- # include require 'date' $KCODE = "e" # --------------------------------------------------------- # main() def dcmodelthum_rd mkinfo ; p "mkinfo end" makethum_rd ; p "mkthum_rd end" end def dcmodelthum mkinfo ; p "mkinfo end" makethum ; p "mkthum end" makethum_rd ; p "mkthum_rd end" end def dcmodelthum_html mkinfo ; p "mkinfo end" makethum ; p "mkthum end" end # --------------------------------------------------------- # 以下サブルーチン群 # ------------------------- # 画像情報取得 (jpg ファイル名, 枚数, コメントファイル) def mkinfo # img-web から画像ファイル名一覧をとりだし, 配列 imgfiles へ代入 $imgfiles = [] Dir.foreach("../#{$figdir}") { |item| if item =~ /#{$base}$/ $imgfiles.push( (File.basename(item, $base) ).split($head) ) end } # 画像ファイル数 $file_num = $imgfiles.size $imgfiles = $imgfiles.sort # $infofile がなければ作成 unless File.exist?($infofile) then ifile = open($infofile, "w") $file_num.times{ |num| # ifile.print "%03d:\n" % num ifile.print "#{$imgfiles[num]}:\n" % num } ifile.close end # $infofile からファイル名とコメントを取り出す # $info[true][0] にはファイル名, $info[0][true] にはコメントが入る $info = [] ifile = open($infofile, "r") ifile.each { |line| $info.push(line.chomp.split(/:/)) } ifile.close # $infofile からファイル数を再定義 $file_num = $info.size # p $info end # ------------------------- # サムネイル $index の作成 def makethum # 元ファイル削除 File.delete("../" + $index + ".html") if File.exist?("../" + $index + ".html") # 初期化 $htmls = "" # ヘッダ部 $htmls = htmlhead # 本文表題部 $htmls << htmltitle # サムネイル部分作成 $file_num.times { |num| $htmls << htmlthum(num) } # table 末処理 amari = ($file_num - 1 ) % $figtable_num figtable_1 = $figtable_num -1 figtable_2 = $figtable_num -2 amari.upto(figtable_2) { |num| $htmls << <   HTMLEOF } $htmls << %| \n| unless amari == figtable_1 # フッタ処理 $htmls << htmlfoot # ファイルの書きだし ifile = open( "../" + $index + ".html", "w") ifile.print $htmls ifile.close end # ------------------------- # rd 組み込み用サムネイル $index の作成 def makethum_rd # ディレクトリ作成, 元ファイル削除 Dir.mkdir("../html",0775) unless File.exist?("../html") File.delete("../html/table_" + $index + ".rd") if File.exist?("../html/table_" + $index + ".rd") # 初期化 $htmls = "" $htmls << %|=begin html\n| $htmls << %|
\n| $htmls << %|\n| # サムネイル部分作成 $file_num.times { |num| $htmls << htmlthum(num) } # table 末処理 amari = ($file_num - 1 ) % $figtable_num figtable_1 = $figtable_num -1 figtable_2 = $figtable_num -2 amari.upto(figtable_2) { |num| $htmls << <   HTMLEOF } $htmls << %| \n| unless amari == figtable_1 $htmls << %|
\n| $htmls << %|
\n| $htmls << %|=end html\n| # ファイルの書きだし ifile = open( "../html/table_" + $index + ".rd", "w") ifile.print $htmls ifile.close end #------------------------------------------------------------- # サムネイル $index 用サブルーチン # html ヘッダ部 def htmlhead htmls = < #{$title} HTMLEOF return htmls end # html thumnail 繰り返し部 def htmlthum(num) picname = $info[num][0] amari = num % $figtable_num figtable_1 = $figtable_num -1 comment = $info[num][1] # テーブルの配置によって のつけたしをおこなう. # 左端 : 3n+1 ($amari == 0) # 右端 : 3n ($amari == 2) htmls = "" htmls = %| \n| if amari == 0 if picname == "title" then htmls << < #{comment} HTMLEOF elsif picname == nil then htmls << <   HTMLEOF else htmls << <
#{picname}
#{comment}

HTMLEOF end htmls << %| \n| if amari == figtable_1 return htmls end # フッター def htmlfoot htmls = < #{$footer} HTMLEOF return htmls end # 本文表題部 def htmltitle htmls = <
HTMLEOF return htmls end ###################################################### if $0 == __FILE__ dcmodelthum = <
 
<< #{$header1} >>
#{$header2}
 
テーブルをさらに作ってその中に書き込む.
そうするとこんな感じ.



[HOME] " # サムネイルフッタ ; $footer = "Last update: #{'#{Time.now}'}
Copyright © dcmodel 2005 (YAMADA Yukiko)" ######################################################## ## include ファイル ######################################################## require 'date' require '/GFD_Dennou_Club/ftp/arch/dcmodel/ClipBoard/dcmodel-thum/dcmodel-thum.rb' $KCODE = "e" EOF if File.exist?("#{Dir.pwd}/dcmodel-thum-make.rb") then print "dcmodel-thum-make.rd exist\n" else wfile = open("#{Dir.pwd}/dcmodel-thum-make.rb","w") wfile.print dcmodelthum wfile.close print "dcmodel-thum-make.rb create !\n" end end