| 1 | # tdiarytimes_flashstyle.rb $Revision: 1.2 $ |
|---|
| 2 | # |
|---|
| 3 | # Copyright (c) 2004 phonondrive <tdiary@phonondrive.com> |
|---|
| 4 | # Distributed under the GPL |
|---|
| 5 | # |
|---|
| 6 | # プラグイン配布ページ: |
|---|
| 7 | # http://phonondrive.com/trd/ |
|---|
| 8 | # -------------------------------------------------------------------- |
|---|
| 9 | # |
|---|
| 10 | # |
|---|
| 11 | # |
|---|
| 12 | # Abstract: |
|---|
| 13 | # -------------------------------------------------------------------- |
|---|
| 14 | # 日記を登録した時間帯をタイムライン上に記録します。記録されたエントリは |
|---|
| 15 | # 日時の経過と共にフェードアウトしていきます。このような MTBlogTimes や |
|---|
| 16 | # tdiarytimes.rb と同等の機能を FLASH で実現します。 |
|---|
| 17 | # ruby-gd のインストール作業も必要ないため、すぐに使用出来ます。 |
|---|
| 18 | # |
|---|
| 19 | # |
|---|
| 20 | # Usage: |
|---|
| 21 | # -------------------------------------------------------------------- |
|---|
| 22 | # プラグインは、プラグインフォルダに入れて下さい。 |
|---|
| 23 | # |
|---|
| 24 | # プラグインは、プラグインフォルダに入れてください。 |
|---|
| 25 | # tdiarytimes*.swf を tdiary.rb と同じフォルダにアップロードします。 |
|---|
| 26 | # ヘッダ、フッタ部に記述した <%= tdiarytimes_flashstyle %> の部分に、 |
|---|
| 27 | # FLASH アプレットが表示されます。 |
|---|
| 28 | # tdiarytimes.log は日記登録時に .swf と同じフォルダに作成されます。 |
|---|
| 29 | # |
|---|
| 30 | # ※ tdiarytimes_textstyle.rb との互換性はありません。 |
|---|
| 31 | # |
|---|
| 32 | # |
|---|
| 33 | # Options: |
|---|
| 34 | # -------------------------------------------------------------------- |
|---|
| 35 | # タイムラインの色、透明度、サイズなどは、プリファレンス画面で設定できます。 |
|---|
| 36 | # |
|---|
| 37 | # |
|---|
| 38 | # In secure mode: |
|---|
| 39 | # -------------------------------------------------------------------- |
|---|
| 40 | # たぶん動作しません。 |
|---|
| 41 | # |
|---|
| 42 | # |
|---|
| 43 | =begin ChangeLog |
|---|
| 44 | 2004.05.02 phonondrive <tdiary@phonondrive.com> |
|---|
| 45 | * version 1.1.2 |
|---|
| 46 | タイムラインが曜日別の FLASH を追加 |
|---|
| 47 | 2004.05.02 phonondrive <tdiary@phonondrive.com> |
|---|
| 48 | * version 1.1.1 |
|---|
| 49 | タイムラインが円形で、時刻盤が曜日表示の FLASH を追加 |
|---|
| 50 | ログファイルが存在しない時にエラーが出る不具合を修正 |
|---|
| 51 | 2004.04.28 phonondrive <tdiary@phonondrive.com> |
|---|
| 52 | * version 1.1.0 |
|---|
| 53 | タイムラインが円形の FLASH を追加 |
|---|
| 54 | 2004.04.27 phonondrive <tdiary@phonondrive.com> |
|---|
| 55 | * version 1.0.1 |
|---|
| 56 | 時刻目盛テキストの色が変更されない不具合を修正 |
|---|
| 57 | 2004.04.25 phonondrive <tdiary@phonondrive.com> |
|---|
| 58 | * version 1.0.0 |
|---|
| 59 | =end |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | # -------------------------------------------------------------------- |
|---|
| 63 | # プラグインの動作 |
|---|
| 64 | # -------------------------------------------------------------------- |
|---|
| 65 | |
|---|
| 66 | def tdiarytimes_flashstyle |
|---|
| 67 | if @conf['tdiarytimes_f.templete'] == nil or @conf['tdiarytimes_f.templete'] == "" |
|---|
| 68 | r = %Q|使用を開始するには、<a href="./#{@update}?conf=tdiarytimes_f">プリファレンス画面</a>にて一度設定を完了して下さい。(tdiarytimes-flashstyle)| |
|---|
| 69 | else |
|---|
| 70 | logname = ((@conf['tdiarytimes_f.log_path'] != "" and @conf['tdiarytimes_f.log_path'] != nil) ? @conf['tdiarytimes_f.log_path'] : "tdiarytimes.log") |
|---|
| 71 | r = @conf['tdiarytimes_f.templete'].gsub(/\&uid/,"\&uid=#{File.mtime(logname.untaint).to_i}") |
|---|
| 72 | end |
|---|
| 73 | end |
|---|
| 74 | |
|---|
| 75 | # -------------------------------------------------------------------- |
|---|
| 76 | # 日記登録時の処理 |
|---|
| 77 | # -------------------------------------------------------------------- |
|---|
| 78 | |
|---|
| 79 | if /^(append|replace)$/ =~ @mode and @cgi.params['hide'][0] != 'true' then |
|---|
| 80 | |
|---|
| 81 | logname = ((@conf['tdiarytimes_f.log_path'] != "" and @conf['tdiarytimes_f.log_path'] != nil) ? @conf['tdiarytimes_f.log_path'] : "tdiarytimes.log") |
|---|
| 82 | entr_lifetime = ((@conf['tdiarytimes_f.entr_lifetime'] != "" and @conf['tdiarytimes_f.entr_lifetime'] != nil) ? @conf['tdiarytimes_f.entr_lifetime'].to_i * 60 * 60 * 24 : 30 * 24 * 60 * 60) |
|---|
| 83 | entr_interval = ((@conf['tdiarytimes_f.entr_interval'] != "" and @conf['tdiarytimes_f.entr_interval'] != nil) ? @conf['tdiarytimes_f.entr_interval'] : 2 * 60 * 60) |
|---|
| 84 | |
|---|
| 85 | begin |
|---|
| 86 | logs = open(logname){|io| io.read }.chomp.split(',') |
|---|
| 87 | rescue |
|---|
| 88 | logs = "" |
|---|
| 89 | end |
|---|
| 90 | |
|---|
| 91 | if (Time.now.to_i - logs.max.to_i) > entr_interval.to_i |
|---|
| 92 | logs << "#{Time.now.to_i}" |
|---|
| 93 | open(logname,"w"){|io| |
|---|
| 94 | io.write(logs.find_all{|item| (Time.now.to_i - item.to_i) < entr_lifetime.to_i }.join(',')) |
|---|
| 95 | } |
|---|
| 96 | end |
|---|
| 97 | |
|---|
| 98 | end |
|---|
| 99 | |
|---|
| 100 | # -------------------------------------------------------------------- |
|---|
| 101 | # プリファレンス画面での設定 |
|---|
| 102 | # -------------------------------------------------------------------- |
|---|
| 103 | |
|---|
| 104 | add_conf_proc( 'tdiarytimes_f', 'tdiarytimes-flashstyle の設定' ) do |
|---|
| 105 | |
|---|
| 106 | if @mode == 'saveconf' then |
|---|
| 107 | |
|---|
| 108 | filename = "tdiarytimes234x30.swf" |
|---|
| 109 | width = "234" |
|---|
| 110 | height = "30" |
|---|
| 111 | argvs = "" |
|---|
| 112 | |
|---|
| 113 | argv = Array.new |
|---|
| 114 | |
|---|
| 115 | @conf['tdiarytimes_f.uid'] = @cgi.params['uid'][0] |
|---|
| 116 | argv << "#{Time.now.to_i}&uid" if @conf['tdiarytimes_f.uid'] == "1" |
|---|
| 117 | |
|---|
| 118 | @conf['tdiarytimes_f.type'] = @cgi.params['type'][0] |
|---|
| 119 | @conf['tdiarytimes_f.filename'] = @cgi.params['filename'][0] |
|---|
| 120 | @conf['tdiarytimes_f.width'] = @cgi.params['width'][0] |
|---|
| 121 | @conf['tdiarytimes_f.height'] = @cgi.params['height'][0] |
|---|
| 122 | |
|---|
| 123 | @conf['tdiarytimes_f.log_path'] = @cgi.params['log_path'][0] |
|---|
| 124 | argv << "log_path=#{@cgi.params['log_path'][0]}" if @cgi.params['log_path'][0] != "" |
|---|
| 125 | |
|---|
| 126 | @conf['tdiarytimes_f.text_visible'] = @cgi.params['text_visible'][0] |
|---|
| 127 | argv << "text_visible=#{@cgi.params['text_visible'][0]}" if @cgi.params['text_visible'][0] == "0" |
|---|
| 128 | @conf['tdiarytimes_f.text_text'] = @cgi.params['text_text'][0] |
|---|
| 129 | argv << "text_text=#{CGI::escape @cgi.params['text_text'][0].upcase}" if @cgi.params['text_text'][0] != "" |
|---|
| 130 | @conf['tdiarytimes_f.text_rgb'] = @cgi.params['text_rgb'][0] |
|---|
| 131 | argv << "text_rgb=0x#{@cgi.params['text_rgb'][0]}" if @cgi.params['text_rgb'][0] != "" |
|---|
| 132 | |
|---|
| 133 | @conf['tdiarytimes_f.face_visible'] = @cgi.params['face_visible'][0] |
|---|
| 134 | argv << "face_visible=#{@cgi.params['face_visible'][0]}" if @cgi.params['face_visible'][0] == "0" |
|---|
| 135 | @conf['tdiarytimes_f.face_rgb'] = @cgi.params['face_rgb'][0] |
|---|
| 136 | argv << "face_rgb=0x#{@cgi.params['face_rgb'][0]}" if @cgi.params['face_rgb'][0] != "" |
|---|
| 137 | |
|---|
| 138 | @conf['tdiarytimes_f.stage_rgb'] = @cgi.params['stage_rgb'][0] |
|---|
| 139 | argv << "stage_rgb=0x#{@cgi.params['stage_rgb'][0]}" if @cgi.params['stage_rgb'][0] != "" |
|---|
| 140 | @conf['tdiarytimes_f.stage_alpha'] = @cgi.params['stage_alpha'][0] |
|---|
| 141 | argv << "stage_alpha=#{@cgi.params['stage_alpha'][0]}" if @cgi.params['stage_alpha'][0] != "" |
|---|
| 142 | @conf['tdiarytimes_f.bg_rgb'] = @cgi.params['bg_rgb'][0] |
|---|
| 143 | argv << "bg_rgb=0x#{@cgi.params['bg_rgb'][0]}" if @cgi.params['bg_rgb'][0] != "" |
|---|
| 144 | @conf['tdiarytimes_f.bg_alpha'] = @cgi.params['bg_alpha'][0] |
|---|
| 145 | argv << "bg_alpha=#{@cgi.params['bg_alpha'][0]}" if @cgi.params['bg_alpha'][0] != "" |
|---|
| 146 | @conf['tdiarytimes_f.bar_rgb'] = @cgi.params['bar_rgb'][0] |
|---|
| 147 | argv << "bar_rgb=0x#{@cgi.params['bar_rgb'][0]}" if @cgi.params['bar_rgb'][0] != "" |
|---|
| 148 | @conf['tdiarytimes_f.bar_width'] = @cgi.params['bar_width'][0] |
|---|
| 149 | argv << "bar_width=#{@cgi.params['bar_width'][0]}" if @cgi.params['bar_width'][0] != "" |
|---|
| 150 | |
|---|
| 151 | @conf['tdiarytimes_f.entr_interval'] = @cgi.params['entr_interval'][0] |
|---|
| 152 | @conf['tdiarytimes_f.entr_lifetime'] = @cgi.params['entr_lifetime'][0] |
|---|
| 153 | @conf['tdiarytimes_f.fade_time'] = @cgi.params['fade_time'][0] |
|---|
| 154 | argv << "fade_time=#{@cgi.params['fade_time'][0]}" if @cgi.params['fade_time'][0] != "" |
|---|
| 155 | |
|---|
| 156 | @conf['tdiarytimes_f.preview'] = @cgi.params['preview'][0] |
|---|
| 157 | |
|---|
| 158 | if @cgi.params['type'][0] == "0" |
|---|
| 159 | filename = @cgi.params['filename'][0] |
|---|
| 160 | width = @cgi.params['width'][0] |
|---|
| 161 | height = @cgi.params['height'][0] |
|---|
| 162 | elsif @cgi.params['type'][0] |
|---|
| 163 | filename = "tdiarytimes#{@cgi.params['type'][0].gsub('-','')}.swf" |
|---|
| 164 | width = @cgi.params['type'][0].split('-').first.split('x')[0] |
|---|
| 165 | height = @cgi.params['type'][0].split('-').first.split('x')[1] |
|---|
| 166 | end |
|---|
| 167 | |
|---|
| 168 | if argv.size > 0 then argvs = "?#{argv.join('&')}" end |
|---|
| 169 | |
|---|
| 170 | @conf['tdiarytimes_f.templete'] = tdiarytimes_flashstyle_templete(filename, argvs, width, height) |
|---|
| 171 | end |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | <<-HTML |
|---|
| 175 | <h3 class="subtitle">設定の概要</h3> |
|---|
| 176 | <p>() 内は初期値です。初期値を使用する場合は、空欄のままで構いません。色は RRGGBB 形式で指定して下さい。不透明度は 0 (透明) 〜 100 (不透明) です。線幅はピクセルで指定します。</p> |
|---|
| 177 | <hr> |
|---|
| 178 | <h3 class="subtitle">プレビュー</h3> |
|---|
| 179 | #{tdiarytimes_flashstyle_preview} |
|---|
| 180 | <hr> |
|---|
| 181 | <h3 class="subtitle">表示する FLASH アプレットの選択</h3> |
|---|
| 182 | <p><select name="type"> |
|---|
| 183 | <option value="0"#{if @conf['tdiarytimes_f.type'] == "0" then " selected" end}>プリセットを使用しない</option> |
|---|
| 184 | <option value="125x30"#{if @conf['tdiarytimes_f.type'] == "125x30" then " selected" end}>tdiarytimes125x30.swf, 125x30</option> |
|---|
| 185 | <option value="234x30"#{if @conf['tdiarytimes_f.type'] == "234x30" or @conf['tdiarytimes_f.type'] == nil or @conf['tdiarytimes_f.type'] == "" then " selected" end}>tdiarytimes234x30.swf, 234x30</option> |
|---|
| 186 | <option value="468x30"#{if @conf['tdiarytimes_f.type'] == "468x30" then " selected" end}>tdiarytimes468x30.swf, 468x30</option> |
|---|
| 187 | <option value="125x125-r"#{if @conf['tdiarytimes_f.type'] == "125x125-r" then " selected" end}>tdiarytimes125x125r.swf, 125x125 (円形)</option> |
|---|
| 188 | <option value="125x125-r7"#{if @conf['tdiarytimes_f.type'] == "125x125-r7" then " selected" end}>tdiarytimes125x125r7.swf, 125x125 (円形, 曜日)</option> |
|---|
| 189 | <option value="125x125-s"#{if @conf['tdiarytimes_f.type'] == "125x125-s" then " selected" end}>tdiarytimes125x125s.swf, 125x125 (曜日別)</option> |
|---|
| 190 | </select></p> |
|---|
| 191 | <h3 class="subtitle">プリセットを使用しない場合は、以下で指定して下さい。</h3> |
|---|
| 192 | <p>FLASH のファイル名<br><input name="filename" value="#{@conf['tdiarytimes_f.filename'].to_s}" size="40"></p> |
|---|
| 193 | <p>FLASH の表示幅<br><input name="width" value="#{@conf['tdiarytimes_f.width'].to_s}" size="20"></p> |
|---|
| 194 | <p>FLASH の表示高さ<br><input name="height" value="#{@conf['tdiarytimes_f.height'].to_s}" size="20"></p> |
|---|
| 195 | <hr> |
|---|
| 196 | <h3 class="subtitle">タイトルテキスト</h3> |
|---|
| 197 | <p>タイトルテキストの表示有無 (表示)<br><select name="text_visible"> |
|---|
| 198 | <option value="1"#{if @conf['tdiarytimes_f.text_visible'] != "0" then " selected" end}>表示</option> |
|---|
| 199 | <option value="0"#{if @conf['tdiarytimes_f.text_visible'] == "0" then " selected" end}>非表示</option> |
|---|
| 200 | </select></p> |
|---|
| 201 | <p>タイトルテキスト (TDIARYTIMES-FLASHSTYLE)<br>使用出来る文字は、英大文字 (A-Z) と数字 (0-9)、および記号のみです。<br><input name="text_text" value="#{@conf['tdiarytimes_f.text_text'].to_s}" size="20"></p> |
|---|
| 202 | <p>タイトルテキストの色 (333333)<br><input name="text_rgb" value="#{@conf['tdiarytimes_f.text_rgb'].to_s}" size="20"></p> |
|---|
| 203 | <h3 class="subtitle">時刻目盛テキスト</h3> |
|---|
| 204 | <p>時刻目盛テキストの表示有無 (表示)<br><select name="face_visible"> |
|---|
| 205 | <option value="1"#{if @conf['tdiarytimes_f.face_visible'] != "0" then " selected" end}>表示</option> |
|---|
| 206 | <option value="0"#{if @conf['tdiarytimes_f.face_visible'] == "0" then " selected" end}>非表示</option> |
|---|
| 207 | </select></p> |
|---|
| 208 | <p>時刻目盛テキストの色 (333333)<br><input name="face_rgb" value="#{@conf['tdiarytimes_f.face_rgb'].to_s}" size="20"></p> |
|---|
| 209 | <hr> |
|---|
| 210 | <h3 class="subtitle">背景や棒グラフの色</h3> |
|---|
| 211 | <p>背景の色 (FFFFFF)<br><input name="stage_rgb" value="#{@conf['tdiarytimes_f.stage_rgb'].to_s}" size="20"></p> |
|---|
| 212 | <p>背景の不透明度 (0)<br><input name="stage_alpha" value="#{@conf['tdiarytimes_f.stage_alpha'].to_s}" size="20"></p> |
|---|
| 213 | <p>タイムラインの背景の色 (333333)<br><input name="bg_rgb" value="#{@conf['tdiarytimes_f.bg_rgb'].to_s}" size="20"></p> |
|---|
| 214 | <p>タイムラインの背景の不透明度 (100)<br><input name="bg_alpha" value="#{@conf['tdiarytimes_f.bg_alpha'].to_s}" size="20"></p> |
|---|
| 215 | <p>タイムラインに記録される棒グラフの色 (EEEEEE)<br><input name="bar_rgb" value="#{@conf['tdiarytimes_f.bar_rgb'].to_s}" size="20"></p> |
|---|
| 216 | <p>タイムラインに記録される棒グラフの線幅 (1)<br><input name="bar_width" value="#{@conf['tdiarytimes_f.bar_width'].to_s}" size="20"></p> |
|---|
| 217 | <p>タイムラインに記録される棒グラフの寿命日数 (30)<br><input name="fade_time" value="#{@conf['tdiarytimes_f.fade_time'].to_s}" size="20"></p> |
|---|
| 218 | <hr> |
|---|
| 219 | <h3 class="subtitle">ログ管理</h3> |
|---|
| 220 | <p>前回の日記登録から設定時間内はエントリを新規登録しない (2)<br><input name="entr_interval" value="#{@conf['tdiarytimes_f.entr_interval'].to_s}" size="20"></p> |
|---|
| 221 | <p>設定日数後にログファイルからエントリを削除する (30)<br><input name="entr_lifetime" value="#{@conf['tdiarytimes_f.entr_lifetime'].to_s}" size="20"></p> |
|---|
| 222 | <p>本プラグインが作成するログファイル名 (tdiarytimes.log)<br><input name="log_path" value="#{@conf['tdiarytimes_f.log_path'].to_s}" size="20"></p> |
|---|
| 223 | <hr> |
|---|
| 224 | <h3 class="subtitle">ユニークID を使用したファイル取得</h3> |
|---|
| 225 | <p>ファイル取得のリクエストにユニークID (例えば ?#{Time.now.to_i}) を含めることにより、古いファイルがブラウザにキャッシュされたままになるのを防ぎます。FLASH のユニークID はプリファレンス設定時に、ログファイルのユニークID はエントリ登録時に更新されます。</p> |
|---|
| 226 | <p>ユニークID の付加 (付加する)<br><select name="uid"> |
|---|
| 227 | <option value="1"#{if @conf['tdiarytimes_f.uid'] != "0" then " selected" end}>付加する</option> |
|---|
| 228 | <option value="0"#{if @conf['tdiarytimes_f.uid'] == "0" then " selected" end}>付加しない</option> |
|---|
| 229 | </select></p> |
|---|
| 230 | <hr> |
|---|
| 231 | <h3 class="subtitle">プレビュー</h3> |
|---|
| 232 | <p>表示したい FLASH ファイル (.swf) が tdiary.rb と同じフォルダにアップロードされている必要があります。また、ログファイルが FLASH ファイルと同じフォルダに作成されていない場合にはグラフが表示されません。</p> |
|---|
| 233 | <p>プレビュー (非表示)<br><select name="preview"> |
|---|
| 234 | <option value="0"#{if @conf['tdiarytimes_f.preview'] != "1" then " selected" end}>非表示</option> |
|---|
| 235 | <option value="1"#{if @conf['tdiarytimes_f.preview'] == "1" then " selected" end}>表示</option> |
|---|
| 236 | </select></p> |
|---|
| 237 | HTML |
|---|
| 238 | |
|---|
| 239 | end |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | def tdiarytimes_flashstyle_preview |
|---|
| 243 | unless @conf.mobile_agent? |
|---|
| 244 | <<-r |
|---|
| 245 | <p>#{if @conf['tdiarytimes_f.preview'] == "1" then "#{tdiarytimes_flashstyle}" else "プレビュー表示を有効にすると、ここに FLASH が表示されます。" end}</p> |
|---|
| 246 | r |
|---|
| 247 | end |
|---|
| 248 | end |
|---|
| 249 | |
|---|
| 250 | def tdiarytimes_flashstyle_templete( filename="tdiarytimes234x30.swf", argvs="", width="234", height="30" ) |
|---|
| 251 | <<-r |
|---|
| 252 | <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="#{width}" height="#{height}" id="tdiarytimes" align="middle"> |
|---|
| 253 | <param name="allowScriptAccess" value="sameDomain" /> |
|---|
| 254 | <param name="movie" value="#{filename}#{argvs}" /> |
|---|
| 255 | <param name="play" value="false" /> |
|---|
| 256 | <param name="loop" value="false" /> |
|---|
| 257 | <param name="quality" value="high" /> |
|---|
| 258 | <param name="wmode" value="transparent" /> |
|---|
| 259 | <param name="bgcolor" value="#ffffff" /> |
|---|
| 260 | <embed src="#{filename}#{argvs}" play="false" loop="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="#{width}" height="#{height}" name="tdiarytimes" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> |
|---|
| 261 | </object> |
|---|
| 262 | r |
|---|
| 263 | end |
|---|