<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>OHeHLium liang~ &#187; wordpress</title>
	<link>http://www.ohehlium.com/log</link>
	<description>Say something~</description>
	<pubDate>Mon, 13 Oct 2008 00:51:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>
	<language>en</language>
			<item>
		<title>Wordpress: url里的中文</title>
		<link>http://www.ohehlium.com/log/2007/04/18/wordpress-url%e9%87%8c%e7%9a%84%e4%b8%ad%e6%96%87/</link>
		<comments>http://www.ohehlium.com/log/2007/04/18/wordpress-url%e9%87%8c%e7%9a%84%e4%b8%ad%e6%96%87/#comments</comments>
		<pubDate>Wed, 18 Apr 2007 12:32:43 +0000</pubDate>
		<dc:creator>liang</dc:creator>
		
		<category><![CDATA[wordpress]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.ohehlium.com/log/2007/04/18/wordpress-url%e9%87%8c%e7%9a%84%e4%b8%ad%e6%96%87/</guid>
		<description><![CDATA[我一开始可能就做了个错误的决定，让url里包含着中文。在一亩地里，幸好一般的帖子的链接并不包含中文，可是序之类的属于页面，我没注意就设成了包含中文(当然可以通过Post Slug补救，但也只能一般页面，如果是子页面，也有情况处理不好)。于是在这种情况下，在一亩地里的序之类的地方留言，就会由于链接不对而得到错误页面。
理论上，网页留言并不是很复杂的情况，同时如果要求留言之后仍保留在同一页面，可以有以下两种方式：
1、自包含的页面处理，只要表格是这样的形式：&#60;form method=&#8221;&#8230;&#8221; action=&#8221;page_itself&#8221;&#62;
2、由别的页面处理，但在处理的末尾使用redirect的方法把页面又重指回到起始页面。Wordpress就用的是这种方式。
在第2种方式下，就需要有一些参数传递。我一开始总想不通这样简单的参数传递为何会引起错误的链接，于是用了小聪明，把404.php给改了一下，其实就是在发现错误链接的时候，试图通过其他信息把它又重定向回起始页面。但是，结果却发现这个方法在IE里又不适用，只有Firefox还行。这使得我只好不偷懒，重新阅读程序。
期间，还发现了另一个错误，那就是在编辑页面预览的地方，如果帖子的url包含中文，竟然也不能正确预览，而之前使用WP 2.0的时候决没有这样的错误。于是对比了一下，在wp 2.1里，调用iframe的地方，使用了一个新的function: clean_url，它会把一些不常见字符之类的给替换掉；而在wp 2.0里，用的是attribute_escape，但处理的只是常见符号。把clean_url改成attribute_escape也就能正常预览了(虽然我还是不明白有什么必要来调用clean_url或者attribute_escape)。
这倒也提醒了我，上面留言时可能出现的错误，于是看了一下wp_redirect，果然有部分内容和clean_url功能相同，把链接里的一些字符给处理了。 我就决定舍弃Wordpress提供的wp_redirect，自己用header(&#8221;Location: &#8220;.$url)来完成网页重定向，结果又是在IE里碰到了麻烦，一看url完全是乱码。而Firefox里则一切正常。问题其实又回到了一开始我试图用404.php来处理错误的地方。
于是就Google了一下，发现不同浏览器对url的encoding方式就是不同。一般的建议是不要依赖于浏览器来正确统一的解码。也就意味着在服务器端，我得先使用一下urlencode。 然后由于我自己想表现的厉害些，就想用array_map来做encoding，结果就是总有一些意外的情况，虽然总能处理，但却完全违背了我懒惰编程的习惯。所以最后就只是用urlencode来处理了几项会出错的地方。
一切都暂时解决了之后，我就想最当初Stone还问过我Slug是啥，我也没多加理会，还不让Stone用来着，硬是要链接里出现 %e5%92 这样的字符才高兴(当然有些浏览器还是挺好的，可以好好的看出是中文)。但最后也在奇怪，为什么Wordpress帖子(Post)的url是中文其实也没事，而页面(Page)却不行。再仔细查看了一下，原来是Wordpress把帖子的url都已经urlencode过了，而页面的url却没有。不明白Wordpress为什么不好事做到底&#8230;
]]></description>
			<content:encoded><![CDATA[<p>我一开始可能就做了个错误的决定，让url里包含着中文。在<a href="http://yimudi.org" title="一亩地">一亩地</a>里，幸好一般的帖子的链接并不包含中文，可是<a href="http://www.ohehlium.com/journal/%E5%BB%BF%E4%BA%8C%E6%9C%9F/%E5%BB%BF%E4%BA%8C%E6%9C%9F-%E5%BA%8F/" title="journal preface">序之类</a>的属于页面，我没注意就设成了包含中文(当然可以通过Post Slug补救，但也只能一般页面，如果是子页面，也有情况处理不好)。于是在这种情况下，在<a href="http://yimudi.org" title="一亩地">一亩地</a>里的<a href="http://www.ohehlium.com/journal/%E5%BB%BF%E4%BA%8C%E6%9C%9F/%E5%BB%BF%E4%BA%8C%E6%9C%9F-%E5%BA%8F/" title="journal preface">序之类</a>的地方留言，就会由于链接不对而得到错误页面。</p>
<p>理论上，网页留言并不是很复杂的情况，同时如果要求留言之后仍保留在同一页面，可以有以下两种方式：</p>
<p>1、自包含的页面处理，只要表格是这样的形式：&lt;form method=&#8221;&#8230;&#8221; action=&#8221;page_itself&#8221;&gt;</p>
<p>2、由别的页面处理，但在处理的末尾使用redirect的方法把页面又重指回到起始页面。Wordpress就用的是这种方式。</p>
<p>在第2种方式下，就需要有一些参数传递。我一开始总想不通这样简单的参数传递为何会引起错误的链接，于是用了小聪明，把404.php给改了一下，其实就是在发现错误链接的时候，试图通过其他信息把它又重定向回起始页面。但是，结果却发现这个方法在IE里又不适用，只有Firefox还行。这使得我只好不偷懒，重新阅读程序。</p>
<p>期间，还发现了另一个错误，那就是在编辑页面预览的地方，如果帖子的url包含中文，竟然也不能正确预览，而之前使用WP 2.0的时候决没有这样的错误。于是对比了一下，在wp 2.1里，调用iframe的地方，使用了一个新的function: clean_url，它会把一些不常见字符之类的给替换掉；而在wp 2.0里，用的是attribute_escape，但处理的只是常见符号。把clean_url改成attribute_escape也就能正常预览了(虽然我还是不明白有什么必要来调用clean_url或者attribute_escape)。</p>
<p>这倒也提醒了我，上面留言时可能出现的错误，于是看了一下wp_redirect，果然有部分内容和clean_url功能相同，把链接里的一些字符给处理了。 我就决定舍弃Wordpress提供的wp_redirect，自己用header(&#8221;Location: &#8220;.$url)来完成网页重定向，结果又是在IE里碰到了麻烦，一看url完全是乱码。而Firefox里则一切正常。问题其实又回到了一开始我试图用404.php来处理错误的地方。</p>
<p>于是就Google了一下，发现不同浏览器对url的encoding方式就是不同。一般的建议是不要依赖于浏览器来正确统一的解码。也就意味着在服务器端，我得先使用一下urlencode。 然后由于我自己想表现的厉害些，就想用array_map来做encoding，结果就是总有一些意外的情况，虽然总能处理，但却完全违背了我懒惰编程的习惯。所以最后就只是用urlencode来处理了几项会出错的地方。</p>
<p>一切都暂时解决了之后，我就想最当初Stone还问过我Slug是啥，我也没多加理会，还不让Stone用来着，硬是要链接里出现 %e5%92 这样的字符才高兴(当然有些浏览器还是挺好的，可以好好的看出是中文)。但最后也在奇怪，为什么Wordpress帖子(Post)的url是中文其实也没事，而页面(Page)却不行。再仔细查看了一下，原来是Wordpress把帖子的url都已经urlencode过了，而页面的url却没有。不明白Wordpress为什么不好事做到底&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ohehlium.com/log/2007/04/18/wordpress-url%e9%87%8c%e7%9a%84%e4%b8%ad%e6%96%87/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Snap preview - delayed/timeout load</title>
		<link>http://www.ohehlium.com/log/2007/01/14/snap-preview-delayedtimeout-load/</link>
		<comments>http://www.ohehlium.com/log/2007/01/14/snap-preview-delayedtimeout-load/#comments</comments>
		<pubDate>Sun, 14 Jan 2007 16:18:08 +0000</pubDate>
		<dc:creator>liang</dc:creator>
		
		<category><![CDATA[wordpress]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.ohehlium.com/log/2007/01/14/snap-preview-delayedtimeout-load/</guid>
		<description><![CDATA[I saw this function weeks ago. It pops you up a thumnail of the link:

I like this function. It is just like what the search engine, Ask.com, did to display the search results. Even the Wordpress.com started to use it. And I enabled this funtion last week.
But today, there is a serious problem fetching the [...]]]></description>
			<content:encoded><![CDATA[<p>I saw this function weeks ago. It pops you up a thumnail of the link:</p>
<p><a title="snap" href="http://www.snap.com/"><img title="snap preview" alt="snap preview" src="http://www.snap.com/images/promo_spa.gif" /></a></p>
<p>I like this function. It is just like what the search engine, <a title="ask" href="http://www.ask.com/">Ask.com</a>, did to display the search results. Even the <a title="wordpress.com snap" href="http://blog.snap.com/2007/01/13/snap-preview-anywhere%e2%84%a2-on-600k-wordpresscom-blo/">Wordpress.com</a> started to use it. And I enabled this funtion last week.</p>
<p>But today, there is a serious problem fetching the javascript from spa.snap.com. There is apparently a timeout, about 20 seconds. The preview is not functional now. I hope it won&#8217;t die as the <a title="Gravatar" href="http://www.gravatar.com/">Gravatar</a> and I still want to keep this function. I think they can solve the problem later. But I need a solution to download my page faster, at least without the 20s delay.</p>
<p>The solution seems simple, instead of putting the javascript in the header, moving the preview code to the near bottom, just before the end of body . This is just as where the Google analytics code is put.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ohehlium.com/log/2007/01/14/snap-preview-delayedtimeout-load/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
