変更点は
# user_css2.rb: $Revision3% lastupdate:2005-05-10 # # Append CSS fragment via Preferences Page. # add_header_proc do [@conf["user_css2..css"], @conf["user_css2.#{@conf.theme}.css"]].map{|css| next unless(css); <<-STYLE <style type="text/css"><!-- #{css.gsub(/\x0d\x0a|\x0a|\x0d/, "\n\t\t")} --></style> STYLE }.join(''); end unless @resource_loaded then def user_css2_label 'テーマの微調整' end def user_css2_desc <<-HTML <h3>CSS断片</h3> <p>下から選んだテーマに、スタイルシートを追加設定する場合、以下にCSSの断片を入力してください。</p> HTML end def user_css2_buttonlabel1 'このテーマを修正する' end def user_css2_buttonlabel2 'CSSファイルを開く' end end if(!@conf_theme_list && @mode =~ /^(conf|saveconf)$/ && @cgi.params['conf'][0] == 'user_css2') # plugin/00default.rb からのコピー @conf_theme_list = [] Dir::glob( "#{::TDiary::PATH}/theme/*" ).sort.each do |dir| theme = dir.sub( %r[.*/theme/], '') next unless FileTest::file?( "#{dir}/#{theme}.css".untaint ) name = theme.split( /_/ ).collect{|s| s.capitalize}.join( ' ' ) @conf_theme_list << [theme,name] end end add_conf_proc( 'user_css2', user_css2_label ) do if @mode == 'saveconf' then if(@cgi.params['user_css2.css'].empty? || @cgi.params['user_css2.css'][0].empty?) @conf.delete("user_css2.#{@cgi.params['user_css2.theme'][0]}.css"); else @conf["user_css2.#{@cgi.params['user_css2.theme'][0]}.css"] = @cgi.params['user_css2.css'][0]; end end theme = (@cgi.params['user_css2.theme'][0] or @conf.theme); theme_hash = Hash[* @conf.options.map{|thm,css| (thm =~ /^user_css2\.(.+)\.css$/) ? [$1, $1.split(/_/).collect{|s| s.capitalize}.join(' ')+' (deleted)'] : nil}.compact.flatten ].update( Hash[* @conf_theme_list.flatten] ); theme_hash[''] = '* All Theme *'; theme_url = theme_url(); theme_url += '/' if(theme_url[-1] != ?/); <<-HTML #{user_css2_desc} <select name="user_css2.theme"> #{theme_hash.keys.sort.map{|t| %(<option value="#{CGI::escapeHTML(t)}"#{' selected' if t == theme}>#{CGI::escapeHTML(theme_hash[t])}</option>)}.join} </select> <input type="submit" value="#{user_css2_buttonlabel1}"> <input type="button" value="#{user_css2_buttonlabel2}" onclick="window.open('#{theme_url}'+this.form['user_css2.theme'].value+'/'+this.form['user_css2.theme'].value+'.css')" > <p><textarea name="user_css2.css" cols="70" rows="15">#{CGI::escapeHTML( @conf["user_css2.#{theme}.css"].to_s )}</textarea></p> HTML end