Index: amazon.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/amazon.rb,v
retrieving revision 1.48.2.14
diff -u -r1.48.2.14 amazon.rb
--- amazon.rb	5 May 2007 21:48:37 -0000	1.48.2.14
+++ amazon.rb	11 Nov 2007 22:54:00 -0000
@@ -7,6 +7,7 @@
 #
 require 'open-uri'
 require 'timeout'
+require 'uri'
 require 'rexml/document'
 
 # do not change these variables
@@ -83,7 +84,15 @@
 end
 
 def amazon_url( item )
-	item.elements.to_a( 'DetailPageURL' )[0].text
+	if not @conf['amazon.preview'] then
+		item.elements.to_a( 'DetailPageURL' )[0].text
+	else
+		asin = item.elements.to_a( 'ASIN' )[0].text
+		uri = URI::parse(item.elements.to_a( 'DetailPageURL' )[0].text)
+		uri.path = '/gp/product/' + asin + '/'
+		uri.query = 'tag=' + @conf['amazon.aid']
+		uri.to_s
+	end
 end
 
 def amazon_label( item )
@@ -120,7 +129,7 @@
 	<a href="#{url}">
 		<img class="amazon-detail left" src="#{h image[:src]}"
 		height="#{h image[:height]}" width="#{h image[:width]}"
-		alt="#{h title}" title="#{h title}">
+		alt="#{h title}" title="#{h title}" />
 	</a>
 	<span class="amazon-title">#{h title}</span><br>
 	<span class="amazon-author">#{h author}</span><br>
@@ -149,7 +158,7 @@
 			img = <<-HTML
 			<img class="#{h pos}" src="#{h image[:src]}"
 			height="#{h image[:height]}" width="#{h image[:width]}"
-			alt="#{h label}" title="#{h label}">
+			alt="#{h label}" title="#{h label}" />
 			HTML
 			img.gsub!( /\t/, '' )
 		end
@@ -168,7 +177,7 @@
 		image = <<-HTML
 		<img class="#{h pos}"
 		src="#{h @conf['amazon.secure-cgi']}?asin=#{u asin};size=#{u @conf['amazon.imgsize']}"
-		alt="#{h label}" title="#{h label}">
+		alt="#{h label}" title="#{h label}" />
 		HTML
 	end
 	image.gsub!( /\t/, '' )
@@ -248,6 +257,8 @@
 					end
 				end
 			end
+
+			@conf['amazon.preview'] = (@cgi.params['amazon.preview'][0] == 'true')
 		end
 		unless @conf['amazon.hideconf'] then
 			@conf['amazon.aid'] = @cgi.params['amazon.aid'][0]
@@ -278,6 +289,8 @@
 				</select></p>
 				<h3>#{@amazon_label_clearcache}</h3>
 				<p><label for="amazon.clearcache"><input type="checkbox" id="amazon.clearcache" name="amazon.clearcache" value="true">#{@amazon_label_clearcache_desc}</label></p>
+				<h3>#{@amazon_label_preview}</h3>
+				<p><label for="amazon.preview"><input type="checkbox" id="amazon.preview" name="amazon.preview" value="true"#{" checked" if @conf['amazon.preview']}>#{@amazon_label_preview_desc}</label></p>
 			HTML
 		end
 	end
@@ -316,3 +329,18 @@
 alias isbnImgRight isbn_image_right
 alias isbnImg isbn_image
 alias amazon isbn_image
+
+# Imported from http://different-view.jp/~vette/108/amazon_preview.rb.html
+add_footer_proc do
+	aid =  @conf['amazon.aid'] || ''
+	if @conf['amazon.preview'] and not aid.empty? and not @cgi.mobile_agent? then
+		<<-SCRIPT
+<!-- ********** Amazon Item Preview ******************** -->
+<script type="text/javascript" src="http://www.assoc-amazon.jp/s/link-enhancer?tag=#{aid}&amp;o=9"></script>
+<noscript><div><img src="http://www.assoc-amazon.jp/s/noscript?tag=#{aid}" alt="" /></div></noscript>
+<!-- ********** Amazon Item Preview ******************** -->
+		SCRIPT
+	else
+		''
+	end
+end
Index: bq.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/bq.rb,v
retrieving revision 1.4.2.2
diff -u -r1.4.2.2 bq.rb
--- bq.rb	17 Jan 2007 00:39:55 -0000	1.4.2.2
+++ bq.rb	11 Nov 2007 22:54:00 -0000
@@ -26,7 +26,7 @@
 	else
 		result = %Q[<blockquote>\n]
 	end
-	result << %Q[<p>#{src.gsub( /\n/, "</p>\n<p>" )}</p>\n].sub( %r[<p></p>], '' )
+	result << %Q[<p>#{src.gsub( /\n\n/, "</p>\n<p>" ).gsub( /\n/, "<br/>\n" )}</p>\n].sub( %r[<p></p>], '' )
 	result << %Q[</blockquote>\n]
 	if url then
 		cite = %Q[<cite><a href="#{h url}" title="#{h bq_cite_from( title )}">#{title}</a></cite>]
@@ -35,6 +35,6 @@
 		cite = %Q[<cite>#{title}</cite>]
 		result << %Q[<p class="source">[#{bq_cite_from( cite )}]</p>\n]
 	end
-	result
+	%Q[</p>\n] + result + %Q[<p>]
 end
 
Index: category.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/category.rb,v
retrieving revision 1.34.2.9
diff -u -r1.34.2.9 category.rb
--- category.rb	28 Sep 2007 09:23:00 -0000	1.34.2.9
+++ category.rb	11 Nov 2007 22:54:01 -0000
@@ -183,8 +183,8 @@
 	end
 
 	params = ''
-	params << %Q[<input type="hidden" name="year" value="#{h info.year}">] if info.year
-	params << %Q[<input type="hidden" name="month" value="#{h info.month}">] if info.month
+	params << %Q[<input type="hidden" name="year" value="#{h info.year}" />] if info.year
+	params << %Q[<input type="hidden" name="month" value="#{h info.month}" />] if info.month
 
 	<<HTML
 <form method="get" action="#{h @index}"><div>
@@ -192,7 +192,7 @@
 #{options}
 	</select>
 	#{params}
-	<input type="submit" value="#{label}">
+	<input type="submit" value="#{label}" />
 </div></form>
 HTML
 end
@@ -621,9 +621,9 @@
 		ret << '<div class="field title">'
 		ret << "#{@category_conf_label}:\n"
 		@categories.each do |c|
-			ret << %Q!| <a href="javascript:inj_c(&quot;[#{h c}]&quot;)">#{h c}</a>\n!
+			ret << %Q!| <a href="javascript:inj_c(&quot;[#{u c}]&quot;)">#{h c}</a>\n!
 		end
-		ret << "|\n</div>\n<br>\n"
+		ret << "|\n</div>\n<br />\n"
 	end
 end
 
Index: edit_today.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/edit_today.rb,v
retrieving revision 1.2.2.5
diff -u -r1.2.2.5 edit_today.rb
--- edit_today.rb	22 Jul 2007 19:52:39 -0000	1.2.2.5
+++ edit_today.rb	11 Nov 2007 22:54:01 -0000
@@ -19,7 +19,7 @@
 		unless @conf.mobile_agent?
 			r = <<-HTML
 			#{title}\n<span class="edit-today">
-			<a href="#{@update}?edit=true;#{date.strftime( 'year=%Y;month=%m;day=%d' )}" title="#{edit_today_edit_label( date )}" rel="nofollow">#{caption}</a>
+			[<a href="#{@update}?edit=true;#{date.strftime( 'year=%Y;month=%m;day=%d' )}" title="#{edit_today_edit_label( date )}" rel="nofollow">#{caption}</a>]
 			</span>
 			HTML
 		else
Index: footnote.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/footnote.rb,v
retrieving revision 1.9.2.5
diff -u -r1.9.2.5 footnote.rb
--- footnote.rb	21 Feb 2007 03:55:38 -0000	1.9.2.5
+++ footnote.rb	11 Nov 2007 22:54:01 -0000
@@ -36,7 +36,7 @@
 		r << %Q|#{mark}#{idx}|
 	else
 		r << %Q|<a |
-		r << %Q|name="#{@fn_fragment_fm % idx}" |
+		r << %Q|id="#{@fn_fragment_fm % idx}" |
 		r << %Q|href="##{@fn_fragment_f % idx}" |
 		r << %Q|title="#{h text}">|
 		r << %Q|#{mark}#{idx}|
@@ -63,7 +63,7 @@
 				r << %Q|#{h @fn_marks[idx]}#{idx+1}|
 			else
 				r << %Q|<a |
-				r << %Q|name="#{@fn_fragment_f % (idx+1)}" |
+				r << %Q|id="#{@fn_fragment_f % (idx+1)}" |
 				r << %Q|href="##{@fn_fragment_fm % (idx+1)}">|
 				r << %Q|#{h @fn_marks[idx]}#{idx+1}|
 				r << %Q|</a>|
Index: highlight.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/highlight.rb,v
retrieving revision 1.9.2.3
diff -u -r1.9.2.3 highlight.rb
--- highlight.rb	15 Jul 2007 18:41:09 -0000	1.9.2.3
+++ highlight.rb	11 Nov 2007 22:54:01 -0000
@@ -7,9 +7,15 @@
 # You can redistribute it and/or modify it under GPL2.
 #
 if @mode == 'day' and not bot? then
+	is_xhtml = (/application\/xhtml\+xml/ =~ ENV['HTTP_ACCEPT'])
+	is_xhtml = false # for SnapShots (TM)
 	add_footer_proc do
-		<<-SCRIPT
-			<script type="text/javascript"><!--
+		html = <<-SCRIPT
+<script type="text/javascript">
+		SCRIPT
+		html << "<![CDATA[\n" if is_xhtml
+		html <<<<-SCRIPT
+			<!--
 			var highlightElem = null;
 			var saveClass = null;
 	
@@ -34,19 +40,16 @@
 			}
 					
 			function getHighlightElement(name) {
-				for (var i=0; i<document.anchors.length; ++i) {
-					var anchor = document.anchors[i];
-					if (anchor.name == name) {
-						var elem;
-						if (anchor.parentElement) {
-							elem = anchor.parentElement;
-						} else if (anchor.parentNode) {
-							elem = anchor.parentNode;
-						}
-						return elem;
+				var anchor = document.getElementById(name);
+				if (anchor) {
+					if (anchor.parentElement) {
+						elem = anchor.parentElement;
+					} else if (anchor.parentNode) {
+						elem = anchor.parentNode;
 					}
+					return elem;
 				}
-				return null;
+				return elem;
 			}
 			
 			if (document.location.hash) {
@@ -61,10 +64,15 @@
 			}
 			
 			function handleLinkClick() {
-				highlightElement(this.hash.substr(1));
+				highlightElement(this.location.hash.substr(1));
 			}
-			// --></script>
+			// -->
+		SCRIPT
+		html << "]]>\n" if is_xhtml
+		html <<<<-SCRIPT
+			</script>
 		SCRIPT
+		html
 	end
 end
 
Index: makerss.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/makerss.rb,v
retrieving revision 1.46.2.10
diff -u -r1.46.2.10 makerss.rb
--- makerss.rb	23 Sep 2007 08:31:48 -0000	1.46.2.10
+++ makerss.rb	11 Nov 2007 22:54:01 -0000
@@ -389,7 +389,7 @@
 		text = rdfsec.section.body
 		rdf << %Q|<description>#{h makerss_desc_shorten( text )}</description>\n|
 		unless @conf['makerss.hidecontent']
-			rdf << %Q|<content:encoded><![CDATA[#{text.make_link.gsub( /\n/, '<br>' ).gsub( /<br><br>\Z/, '' ).gsub( /\]\]>/, ']]]]><![CDATA[>' )}]]></content:encoded>\n|
+			rdf << %Q|<content:encoded><![CDATA[#{text.make_link.gsub( /\n/, '<br />' ).gsub( /<br \/><br \/>\Z/, '' ).gsub( /\]\]>/, ']]]]><![CDATA[>' )}]]></content:encoded>\n|
 		end
 		rdf << "</item>\n"
 	end
@@ -408,7 +408,7 @@
 	html = ''
 	@makerss_rsses.each do |rss|
 		next unless rss.url
-		html << %Q|\t<link rel="alternate" type="application/rss+xml" title="RSS#{h rss.title}" href="#{h rss.url}">\n|
+		html << %Q|\t<link rel="alternate" type="application/rss+xml" title="RSS#{h rss.title}" href="#{h rss.url}" />\n|
 	end
 	html
 }
@@ -432,10 +432,10 @@
 end
 
 add_edit_proc do
-	checked = @cgi.params['makerss_update'][0] == 'false' ? ' checked' : ''
+	checked = @cgi.params['makerss_update'][0] == 'false' ? ' checked="checked"' : ''
 	r = <<-HTML
 	<div class="makerss"><label for="makerss_update">
-	<input type="checkbox" id="makerss_update" name="makerss_update" value="false"#{checked} tabindex="390">
+	<input type="checkbox" id="makerss_update" name="makerss_update" value="false"#{checked} tabindex="390" />
 	#{@makerss_edit_label}
 	</label></div>
 	HTML
Index: search_control.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/search_control.rb,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 search_control.rb
--- search_control.rb	4 May 2007 04:02:24 -0000	1.8.2.2
+++ search_control.rb	11 Nov 2007 22:54:01 -0000
@@ -212,7 +212,7 @@
 	# output
 	sw = @conf[_sc_vkey( view, number )]
 	if sw then
-		%Q|\t<meta name="robots" content="#{'f' == sw ? 'noindex' : 'index' },#{follow}">\n|
+		%Q|\t<meta name="robots" content="#{'f' == sw ? 'noindex' : 'index' },#{follow}" />\n|
 	else
 		''
 	end
Index: en/amazon.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/en/amazon.rb,v
retrieving revision 1.11.2.2
diff -u -r1.11.2.2 amazon.rb
--- en/amazon.rb	9 Feb 2007 16:13:01 -0000	1.11.2.2
+++ en/amazon.rb	11 Nov 2007 22:54:01 -0000
@@ -61,3 +61,5 @@
 @amazon_label_usedefault = 'Use default image'
 @amazon_label_clearcache = 'Clear Cache'
 @amazon_label_clearcache_desc = 'Delete local cache file about book images'
+@amazon_label_preview = 'Use Preview'
+@amazon_label_preview_desc = 'Check if preview is used'
Index: ja/amazon.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/ja/amazon.rb,v
retrieving revision 1.11.2.3
diff -u -r1.11.2.3 amazon.rb
--- ja/amazon.rb	9 Feb 2007 16:13:01 -0000	1.11.2.3
+++ ja/amazon.rb	11 Nov 2007 22:54:01 -0000
@@ -77,3 +77,5 @@
 @amazon_label_usedefault = 'デフォルトのイメージを使う'
 @amazon_label_clearcache = 'キャッシュの削除'
 @amazon_label_clearcache_desc = 'イメージ関連情報のキャッシュを削除する(Amazon上の表示と矛盾がある場合に試して下さい)'
+@amazon_label_preview = '商品プレビューを使う'
+@amazon_label_preview_desc = '商品プレビュー機能を使う場合はチェックして下さい'
Index: zh/amazon.rb
===================================================================
RCS file: /cvsroot/tdiary/plugin/zh/amazon.rb,v
retrieving revision 1.6.2.2
diff -u -r1.6.2.2 amazon.rb
--- zh/amazon.rb	9 Feb 2007 16:13:01 -0000	1.6.2.2
+++ zh/amazon.rb	11 Nov 2007 22:54:02 -0000
@@ -61,3 +61,5 @@
 @amazon_label_usedefault = 'Use default image'
 @amazon_label_clearcache = 'Clear Cache'
 @amazon_label_clearcache_desc = 'Delete local cache file about book images'
+@amazon_label_preview = 'Use Preview'
+@amazon_label_preview_desc = 'Check if preview is used'

