<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rock Sun's Blog &#187; program</title>
	<atom:link href="http://rocksun.cn/category/program/feed/" rel="self" type="application/rss+xml" />
	<link>http://rocksun.cn</link>
	<description>Blogger's Blog</description>
	<lastBuildDate>Wed, 16 May 2012 13:01:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>一个测试Google Ajax API的网站</title>
		<link>http://rocksun.cn/website-for-google-ajax-api/</link>
		<comments>http://rocksun.cn/website-for-google-ajax-api/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 03:32:46 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=454</guid>
		<description><![CDATA[


包含了所有Google AJAX API范例的网站，也可以修改范例，测试运行自己的代码，是使用Google API开发的好帮手。



No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>包含了所有<a href="http://code.google.com/apis/ajax/playground/">Google AJAX API范例的网站</a>，也可以修改范例，测试运行自己的代码，是使用Google API开发的好帮手。</p>
<p><a href="http://code.google.com/apis/ajax/playground/" target="_blank"><img src="http://www.webresourcesdepot.com/wp-content/uploads/image/ajax-apis-playground.gif" alt="AJAX APIs Playground" width="480" height="153" /></a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/website-for-google-ajax-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django 1.0之后的文件上传</title>
		<link>http://rocksun.cn/django-upload-and-new-tran-tools/</link>
		<comments>http://rocksun.cn/django-upload-and-new-tran-tools/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 16:51:24 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[enocoding]]></category>
		<category><![CDATA[gbk]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=442</guid>
		<description><![CDATA[今天实现了另一个RockSun在线工具，按照指定编码和换行格式保存文件，能够将数据按照GBK或者UTF编码、以及Windows和Linux换行保存并直接让用户下载，也可以由用户上传的文件转化后直接下载。可能会有bug，有点累，先不多想了。
首先说一下直接提示用户下载文件的功能，没有多说的，就是往http的response头里增加两句话，用django的语法写就是：

        response = HttpResponse(text, mimetype='application/octet-stream')
        response['Content-Disposition'] = 'attachment; filename=%s' %filename.encode('utf8')
        return response

此外，网上说django上传文件的介绍似乎都是1.o之前的方法，最后还是直接看官方文档比较准确，文档在这里：http://docs.djangoproject.com/en/dev/topics/http/file-uploads/，这里简单说一下，首先是form，没有什么特别的：
&#60;form enctype=&#8221;multipart/form-data&#8221; action=&#8221;/someurl&#8221; method=&#8221;post&#8221;&#62;
&#60;input type=&#8221;file&#8221; name=&#8221;file&#8221;/&#62;
&#8230;
&#60;/form&#62;
然后，在views中可以直接读文件内容和文件名：

        text = file_obj.read()
        [...]


Related posts:<ol><li><a href='http://rocksun.cn/flash-zoom/' rel='bookmark' title='Permanent Link: Flash Zoom'>Flash Zoom</a></li><li><a href='http://rocksun.cn/write-my-first-wordpress-plugin/' rel='bookmark' title='Permanent Link: My first wordpress plugin'>My first wordpress plugin</a></li><li><a href='http://rocksun.cn/resize-image-in-context-menu/' rel='bookmark' title='Permanent Link: Resize Image In Context Menu'>Resize Image In Context Menu</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>今天实现了另一个RockSun在线工具，按照<a href="http://rocksun.cn/rstools/transform/saveas/">指定编码和换行格式保存文件</a>，能够将数据按照GBK或者UTF编码、以及Windows和Linux换行保存并直接让用户下载，也可以由用户上传的文件转化后直接下载。可能会有bug，有点累，先不多想了。</p>
<p>首先说一下直接提示用户下载文件的功能，没有多说的，就是往http的response头里增加两句话，用django的语法写就是：</p>
<blockquote>
<pre lang="python">        response = HttpResponse(text, mimetype='application/octet-stream')
        response['Content-Disposition'] = 'attachment; filename=%s' %filename.encode('utf8')
        return response</pre>
</blockquote>
<p>此外，网上说django上传文件的介绍似乎都是1.o之前的方法，最后还是直接看官方文档比较准确，文档在这里：<a href="http://docs.djangoproject.com/en/dev/topics/http/file-uploads/">http://docs.djangoproject.com/en/dev/topics/http/file-uploads/</a>，这里简单说一下，首先是form，没有什么特别的：</p>
<blockquote><p>&lt;form enctype=&#8221;multipart/form-data&#8221; action=&#8221;/someurl&#8221; method=&#8221;post&#8221;&gt;<br />
&lt;input type=&#8221;file&#8221; name=&#8221;file&#8221;/&gt;<br />
&#8230;<br />
&lt;/form&gt;</p></blockquote>
<p>然后，在views中可以直接读文件内容和文件名：</p>
<blockquote>
<pre lang="python">        text = file_obj.read()
        filename = file_obj.name</pre>
</blockquote>
<p>在默认情况下，小于2.5M的文件会存放到内存里，如果文件比较大则会存放为临时文件，对大文件最好不要直接read，而是用chunks方式读取，详细还是要读文档。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/flash-zoom/' rel='bookmark' title='Permanent Link: Flash Zoom'>Flash Zoom</a></li><li><a href='http://rocksun.cn/write-my-first-wordpress-plugin/' rel='bookmark' title='Permanent Link: My first wordpress plugin'>My first wordpress plugin</a></li><li><a href='http://rocksun.cn/resize-image-in-context-menu/' rel='bookmark' title='Permanent Link: Resize Image In Context Menu'>Resize Image In Context Menu</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/django-upload-and-new-tran-tools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>测试简繁体转换工具</title>
		<link>http://rocksun.cn/try-trad-2-sim/</link>
		<comments>http://rocksun.cn/try-trad-2-sim/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 04:08:44 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[在线]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=436</guid>
		<description><![CDATA[这是我前几天用到的一段繁体原文：
雖然 TortoiseSVN 有提供 Create Patch 與 Apply Patch 等功能，不過客戶端的正式主機幾乎都沒有安裝 TortoiseSVN 軟體，所以可說是英雄無用武之地。所以長久以來，我一直苦苦追尋這樣的功能：「如何才能讓 TortoiseSVN 僅匯出新增或修改過的檔案呢？」這個功能我已經找了一年多了，好幾次有股衝動想寫這樣的軟體出來，因為每次要匯出差異的檔案真的很麻煩。
用繁体转简体工具转换后：
虽然 TortoiseSVN 有提供 Create Patch 与 Apply Patch 等功能，不过客户端的正式主机几乎都没有安装 TortoiseSVN 软件，所以可说是英雄无用武之地。所以长久以来，我一直苦苦追寻这样的功能：「如何才能让 TortoiseSVN 仅导出新增或修改过的文件呢？」这个功能我已经找了一年多了，好几次有股冲动想写这样的软件出来，因为每次要导出差异的文件真的很麻烦。
感觉很不错，结果比较满意。


Related posts:《使用Subversion进行版本控制》中文版1.4发布完成三个在线转化功能我的Wordpress又升级了



Related posts:<ol><li><a href='http://rocksun.cn/svnbook-release-chinese-14/' rel='bookmark' title='Permanent Link: 《使用Subversion进行版本控制》中文版1.4发布'>《使用Subversion进行版本控制》中文版1.4发布</a></li><li><a href='http://rocksun.cn/complete-three-online-tools/' rel='bookmark' title='Permanent Link: 完成三个在线转化功能'>完成三个在线转化功能</a></li><li><a href='http://rocksun.cn/upgrade-wordpress-to-265/' rel='bookmark' title='Permanent Link: 我的Wordpress又升级了'>我的Wordpress又升级了</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>这是我前几天用到的一段繁体原文：</p>
<blockquote><p>雖然 TortoiseSVN 有提供 Create Patch 與 Apply Patch 等功能，不過客戶端的正式主機幾乎都沒有安裝 TortoiseSVN 軟體，所以可說是英雄無用武之地。所以長久以來，我一直苦苦追尋這樣的功能：「如何才能讓 TortoiseSVN 僅匯出新增或修改過的檔案呢？」這個功能我已經找了一年多了，好幾次有股衝動想寫這樣的軟體出來，因為每次要匯出差異的檔案真的很麻煩。</p></blockquote>
<p>用<a href="http://rocksun.cn/rstools/transform/trad2sim/">繁体转简体工具</a>转换后：</p>
<blockquote><p>虽然 TortoiseSVN 有提供 Create Patch 与 Apply Patch 等功能，不过客户端的正式主机几乎都没有安装 TortoiseSVN 软件，所以可说是英雄无用武之地。所以长久以来，我一直苦苦追寻这样的功能：「如何才能让 TortoiseSVN 仅导出新增或修改过的文件呢？」这个功能我已经找了一年多了，好几次有股冲动想写这样的软件出来，因为每次要导出差异的文件真的很麻烦。</p></blockquote>
<p>感觉很不错，结果比较满意。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/svnbook-release-chinese-14/' rel='bookmark' title='Permanent Link: 《使用Subversion进行版本控制》中文版1.4发布'>《使用Subversion进行版本控制》中文版1.4发布</a></li><li><a href='http://rocksun.cn/complete-three-online-tools/' rel='bookmark' title='Permanent Link: 完成三个在线转化功能'>完成三个在线转化功能</a></li><li><a href='http://rocksun.cn/upgrade-wordpress-to-265/' rel='bookmark' title='Permanent Link: 我的Wordpress又升级了'>我的Wordpress又升级了</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/try-trad-2-sim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>简繁体转化工具</title>
		<link>http://rocksun.cn/sim-2-trad/</link>
		<comments>http://rocksun.cn/sim-2-trad/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 17:57:53 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[术语]]></category>
		<category><![CDATA[转化]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=433</guid>
		<description><![CDATA[今天完善了简繁体转化工具，增加了保存术语的替换功能。术语信息可以由大家随意修改，不必担心破坏数据，因为每次提交的数据都存放到了Subversion库中。欢迎大家维护一起术语，将这个工具完善起来。


Related posts:开发Django时引用CSS和JSDjango 1.0之后的文件上传Subversion导出修订版本范围中修改过的文件



Related posts:<ol><li><a href='http://rocksun.cn/develop-django-with-css-js/' rel='bookmark' title='Permanent Link: 开发Django时引用CSS和JS'>开发Django时引用CSS和JS</a></li><li><a href='http://rocksun.cn/django-upload-and-new-tran-tools/' rel='bookmark' title='Permanent Link: Django 1.0之后的文件上传'>Django 1.0之后的文件上传</a></li><li><a href='http://rocksun.cn/export-subversion-files-in-a-range/' rel='bookmark' title='Permanent Link: Subversion导出修订版本范围中修改过的文件'>Subversion导出修订版本范围中修改过的文件</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>今天完善了<a href="http://rocksun.cn/rstools/transform/sim2trad/">简繁体转化工具</a>，增加了保存术语的替换功能。术语信息可以由大家随意修改，不必担心破坏数据，因为每次提交的数据都存放到了Subversion库中。欢迎大家维护一起术语，将这个工具完善起来。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/develop-django-with-css-js/' rel='bookmark' title='Permanent Link: 开发Django时引用CSS和JS'>开发Django时引用CSS和JS</a></li><li><a href='http://rocksun.cn/django-upload-and-new-tran-tools/' rel='bookmark' title='Permanent Link: Django 1.0之后的文件上传'>Django 1.0之后的文件上传</a></li><li><a href='http://rocksun.cn/export-subversion-files-in-a-range/' rel='bookmark' title='Permanent Link: Subversion导出修订版本范围中修改过的文件'>Subversion导出修订版本范围中修改过的文件</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/sim-2-trad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>完成三个在线转化功能</title>
		<link>http://rocksun.cn/complete-three-online-tools/</link>
		<comments>http://rocksun.cn/complete-three-online-tools/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 16:37:52 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=418</guid>
		<description><![CDATA[三个转化包括简体转繁体、繁体转简体以及GBK或UTF-8字符转化为16进制的字符串。
感觉用Django开发还真的蛮简洁的，代码量极少。部署稍微有点罗嗦，因为模板文件和应用都不在一个目录里，前几天写的上传工作拷贝修改的文件起了作用，一个命令就能全部部署上去。


Related posts:测试简繁体转换工具



Related posts:<ol><li><a href='http://rocksun.cn/try-trad-2-sim/' rel='bookmark' title='Permanent Link: 测试简繁体转换工具'>测试简繁体转换工具</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>三个转化包括<a href="http://rocksun.cn/rstools/transform/sim2trad/">简体转繁体</a>、<a href="http://rocksun.cn/rstools/transform/trad2sim/">繁体转简体</a>以及<a href="http://rocksun.cn/rstools/transform/str2hex/">GBK或UTF-8字符转化为16进制的字符串</a>。</p>
<p>感觉用Django开发还真的蛮简洁的，代码量极少。部署稍微有点罗嗦，因为模板文件和应用都不在一个目录里，前几天写的<a href="http://rocksun.cn/upload-file-changed/">上传工作拷贝修改的文件</a>起了作用，一个命令就能全部部署上去。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/try-trad-2-sim/' rel='bookmark' title='Permanent Link: 测试简繁体转换工具'>测试简繁体转换工具</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/complete-three-online-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>开发Django时引用CSS和JS</title>
		<link>http://rocksun.cn/develop-django-with-css-js/</link>
		<comments>http://rocksun.cn/develop-django-with-css-js/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 06:35:58 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=403</guid>
		<description><![CDATA[开始照着Django的教程做的应用，没有用到css和js，没有讲到这个问题。所以在实际用到css和js时，才发现这个问题，我发现最方便的方法是在应用的urls.py的映射当中，增加这两行：
(r&#8217;^css/(?P&#60;path&#62;.*)$&#8217;, &#8216;django.views.static.serve&#8217;,{&#8216;document_root&#8217;: &#8216;F:/rocksun/rstools/template/css&#8217;}),
(r&#8217;^images/(?P&#60;path&#62;.*)$&#8217;, &#8216;django.views.static.serve&#8217;,{&#8216;document_root&#8217;: &#8216;F:/rocksun/rstools/template/images&#8217;}),
这样设置之后，模板中对于/css的请求就会进入我设置的F:/rocksun/rstools/template/css目录下，同理images，不需要设置media目录了。


Related posts:完成三个在线转化功能简繁体转化工具在我的Blog网站上运行Django



Related posts:<ol><li><a href='http://rocksun.cn/complete-three-online-tools/' rel='bookmark' title='Permanent Link: 完成三个在线转化功能'>完成三个在线转化功能</a></li><li><a href='http://rocksun.cn/sim-2-trad/' rel='bookmark' title='Permanent Link: 简繁体转化工具'>简繁体转化工具</a></li><li><a href='http://rocksun.cn/run-django-on-mysite/' rel='bookmark' title='Permanent Link: 在我的Blog网站上运行Django'>在我的Blog网站上运行Django</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>开始照着Django的教程做的应用，没有用到css和js，没有讲到这个问题。所以在实际用到css和js时，才发现这个问题，我发现最方便的方法是在应用的urls.py的映射当中，增加这两行：</p>
<blockquote><p>(r&#8217;^css/(?P&lt;path&gt;.*)$&#8217;, &#8216;django.views.static.serve&#8217;,{&#8216;document_root&#8217;: &#8216;F:/rocksun/rstools/template/css&#8217;}),<br />
(r&#8217;^images/(?P&lt;path&gt;.*)$&#8217;, &#8216;django.views.static.serve&#8217;,{&#8216;document_root&#8217;: &#8216;F:/rocksun/rstools/template/images&#8217;}),</p></blockquote>
<p>这样设置之后，模板中对于/css的请求就会进入我设置的F:/rocksun/rstools/template/css目录下，同理images，不需要设置media目录了。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/complete-three-online-tools/' rel='bookmark' title='Permanent Link: 完成三个在线转化功能'>完成三个在线转化功能</a></li><li><a href='http://rocksun.cn/sim-2-trad/' rel='bookmark' title='Permanent Link: 简繁体转化工具'>简繁体转化工具</a></li><li><a href='http://rocksun.cn/run-django-on-mysite/' rel='bookmark' title='Permanent Link: 在我的Blog网站上运行Django'>在我的Blog网站上运行Django</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/develop-django-with-css-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在我的Blog网站上运行Django</title>
		<link>http://rocksun.cn/run-django-on-mysite/</link>
		<comments>http://rocksun.cn/run-django-on-mysite/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 06:21:35 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[rstools]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=399</guid>
		<description><![CDATA[我的Blog在Dreamhost上，听说可以运行Django程序，所以想在上面跑一个Django应用，一边学习Django，一边做一些互联网的小应用，目前只作了一个页面，没有任何功能。
这里是一个很好的教程，我说一下我遇到的一些问题，因为我的应用不是存放在根下面的，而是在rstools目录下，所以我的rstools目录下的.htaccess文件内容如下：
RewriteEngine On
RewriteBase /rstools/
RewriteRule ^(dispatch\.fcgi/.*)$ &#8211; [L]
RewriteRule ^(.*)$ /rstools/dispatch.fcgi/$1 [L]
然后因为我的FastCGI没有开启，所以会报告如下错误：
mod_rewrite: maximum
number of internal redirects reached. Assuming configuration error. Use &#8216;Rewrite
Options MaxRedirects&#8217; to increase the limit if neccessary.
FastCGI没有开启时另一个症状是直接访问dispach.fcgi则会返回其文件内容，而不是执行的结果。在DreamHost的控制面板中打开FastCGI就可以解决这个问题。


Related posts:开发Django时引用CSS和JS完成三个在线转化功能简繁体转化工具



Related posts:<ol><li><a href='http://rocksun.cn/develop-django-with-css-js/' rel='bookmark' title='Permanent Link: 开发Django时引用CSS和JS'>开发Django时引用CSS和JS</a></li><li><a href='http://rocksun.cn/complete-three-online-tools/' rel='bookmark' title='Permanent Link: 完成三个在线转化功能'>完成三个在线转化功能</a></li><li><a href='http://rocksun.cn/sim-2-trad/' rel='bookmark' title='Permanent Link: 简繁体转化工具'>简繁体转化工具</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>我的Blog在Dreamhost上，听说可以运行Django程序，所以想在上面跑一个Django应用，一边学习Django，一边做一些互联网的小应用，目前<a href="http://rocksun.cn/rstools/transform/sim2trad/">只作了一个页面</a>，没有任何功能。</p>
<p><a href="http://www.lostk.com/blog/configure_python_and_django_on_dreamhost/">这里</a>是一个很好的教程，我说一下我遇到的一些问题，因为我的应用不是存放在根下面的，而是在rstools目录下，所以我的rstools目录下的.htaccess文件内容如下：</p>
<blockquote><p>RewriteEngine On<br />
RewriteBase /rstools/<br />
RewriteRule ^(dispatch\.fcgi/.*)$ &#8211; [L]<br />
RewriteRule ^(.*)$ /rstools/dispatch.fcgi/$1 [L]</p></blockquote>
<p>然后因为我的FastCGI没有开启，所以会报告如下错误：</p>
<blockquote><p>mod_rewrite: maximum<br />
number of internal redirects reached. Assuming configuration error. Use &#8216;Rewrite<br />
Options MaxRedirects&#8217; to increase the limit if neccessary.</p></blockquote>
<p>FastCGI没有开启时另一个症状是直接访问dispach.fcgi则会返回其文件内容，而不是执行的结果。在DreamHost的控制面板中打开FastCGI就可以解决这个问题。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/develop-django-with-css-js/' rel='bookmark' title='Permanent Link: 开发Django时引用CSS和JS'>开发Django时引用CSS和JS</a></li><li><a href='http://rocksun.cn/complete-three-online-tools/' rel='bookmark' title='Permanent Link: 完成三个在线转化功能'>完成三个在线转化功能</a></li><li><a href='http://rocksun.cn/sim-2-trad/' rel='bookmark' title='Permanent Link: 简繁体转化工具'>简繁体转化工具</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/run-django-on-mysite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first wordpress plugin</title>
		<link>http://rocksun.cn/write-my-first-wordpress-plugin/</link>
		<comments>http://rocksun.cn/write-my-first-wordpress-plugin/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 03:26:14 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[recommend]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=200</guid>
		<description><![CDATA[I choose a new wordpress template some days ago, it looks good. But have some problems like this. I spent about four hours to do this, because I know little about php and had never written wordpress plugins. Now I think it is very interesting to write the plugin. So I want to introduce it.
Where [...]


Related posts:<ol><li><a href='http://rocksun.cn/flash-zoom/' rel='bookmark' title='Permanent Link: Flash Zoom'>Flash Zoom</a></li><li><a href='http://rocksun.cn/ftp-image-with-conext-menu/' rel='bookmark' title='Permanent Link: FTP image with Conext Menu'>FTP image with Conext Menu</a></li><li><a href='http://rocksun.cn/write-plugin-for-flow/' rel='bookmark' title='Permanent Link: 要想热 写插件'>要想热 写插件</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>I choose a new wordpress template some days ago, it looks good. But have some problems like <a title="Flash Zoom" href="http://rocksun.cn/flash-zoom/">this</a>. I spent about four hours to do this, because I know little about php and had never written wordpress plugins. Now I think it is very interesting to write the plugin. So I want to introduce it.</p>
<h3>Where to get start?</h3>
<p>First, I know I will filter the source, so I regist the filter with this function:</p>
<pre lang="php">add_filter('the_content','filter_shrink');</pre>
<p>The &#8220;the_content&#8221; is the filter&#8217;s name, and filter_shrink is my filter function, I will write it later. Then I should could change the width and height from option page, so I write:</p>
<pre lang="php">add_action('admin_menu', 'flash_zoom_options_page');</pre>
<p>This function told wordpress I will regist a menu in &#8220;admin_menu&#8221; with the flash_zoom_options_page function.</p>
<h3>implements the functions</h3>
<p>Now let&#8217;s see the filter_shrink:</p>
<pre lang="php">function replaceSize($matches)
{
  global $flashzoom_settings;
  $replaceStr = ' width="'.$flashzoom_settings['target_width'].'" height="'.$flashzoom_settings['target_height'].'" ';
  return $matches[1].$replaceStr.$matches[3].$replaceStr.$matches[5];
}

function filter_shrink($content) {
    global $flashzoom_settings;
    if(is_home()){
      $content = preg_replace_callback(
           '|(&lt;'.'object.*)(width="d*"s*height="d*")(.*)(width="d*"s*height="d*")(.*&lt;/object&gt;)|',
            "replaceSize",
            $content);
    }

    return $content;
}</pre>
<p>Look at the &#8220;$flashzoom_settings&#8221;, it is the length and height that stored in wordpress. I just use preg_replace_callback function to replace the origin width and height. The php regexp is strange, especially the usage of &#8220;|&#8221;.</p>
<p>Then we can see the flash_zoom_options_page function:</p>
<pre lang="php" colla="-">function isInteger($input){
  return preg_match('@^[-]?[0-9]+$@',trim($input)) === 1;
}

function flash_zoom_options_page() {
		add_options_page('FlashZoom', 'FlashZoom', 8, basename(__FILE__), 'flash_zoom_options_subpanel');
}

function flash_zoom_options_subpanel() {
	global $ol_flash, $flashzoom_settings, $_POST, $wp_rewrite;

	if (current_user_can('activate_plugins')) {
		// Easiest test to see if we have been submitted to
		if(isset($_POST['target_width']) || isset($_POST['target_height'])) {
		  if(!isInteger($_POST['target_width'])||!isInteger($_POST['target_height'])){
		    $ol_flash = "Please input the number!";
		  }else{
			// Now we check the hash, to make sure we are not getting CSRF
			  if(fb_is_hash_valid($_POST['token'])) {
				  if (isset($_POST['target_width'])) {
					  $flashzoom_settings['target_width'] = $_POST['target_width'];
					  update_option('flashzoom_settings',$flashzoom_settings);
					  $ol_flash = "Your settings have been saved.";
				  }
				  if (isset($_POST['target_height'])) {
					  $flashzoom_settings['target_height'] = $_POST['target_height'];
					  update_option('flashzoom_settings',$flashzoom_settings);
					  $ol_flash = "Your settings have been saved.";
				  }
			  } else {
				  // Invalid form hash, possible CSRF attempt
				  $ol_flash = "Security hash missing.";
			  } // endif fb_is_hash_valid
			} //endif isInteger
		} // endif isset(feedburner_url)
	} else {
		$ol_flash = "You don't have enough access rights.";
	}
	if ($ol_flash != '') echo '
<div id="message" class="updated fade">

' . $ol_flash . '</div>

';

	if (current_user_can('activate_plugins')) {
	  $temp_hash = fb_generate_hash();
		fb_store_hash($temp_hash);
		echo '
<div class="wrap">';
		echo '
<h2>Set Up Flash Zoom Size</h2>

';
		echo '
<form method="post">
<input name="redirect" type="hidden" value="true" />
<input name="token" type="hidden" value="' . fb_retrieve_hash() . '" />
<table class="form-table" border="0">
<tbody>
<tr valign="top">
<th scope="row"><label for="target_width">Target Width</label></th>
<td>
<input id="target_width" maxlength="4" name="target_width" size="4" type="text" value="' . htmlentities($flashzoom_settings['target_width']) . '" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="target_height">Target Height</label></th>
<td>
<input id="target_height" maxlength="4" name="target_height" size="4" type="text" value="' . htmlentities($flashzoom_settings['target_height']) . '" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Save" />
</form>

';
		echo '</div>

';
	} else {
		echo '
<div class="wrap">

Sorry, you are not allowed to access this page.</div>

';
	}

}</pre>
<p>The flash_zoom_options_page function create an panel flash_zoom_options_subpanel, and the first part of flash_zoom_options_subpanel will check the parameters and store it into database, the other part will display the form.</p>
<p>We have not use the install step, so we add these two lines .</p>
<pre lang="php"  colla="-">add_option('flashzoom_settings',$data,'FlashZoom Options');
$flashzoom_settings = get_option('flashzoom_settings');</pre>
<p>Last, don&#8217;t forget the plugin header,  so the wordpress can recognize the plugin. The full plugin is:</p>
<pre lang="php"  colla="-">/*
Plugin Name: Flash Zoom
Plugin URI: http://rocksun.cn/flash-zoom/
Description: zoom the flash in homepage.
Version: 0.8
Author: Rock Sun
Author URI: http://rocksun.cn/
*/

add_option('flashzoom_settings',$data,'FlashZoom Options');
$flashzoom_settings = get_option('flashzoom_settings');

function isInteger($input){
  return preg_match('@^[-]?[0-9]+$@',trim($input)) === 1;
}

function flash_zoom_options_page() {
		add_options_page('FlashZoom', 'FlashZoom', 8, basename(__FILE__), 'flash_zoom_options_subpanel');
}

function flash_zoom_options_subpanel() {
	global $ol_flash, $flashzoom_settings, $_POST, $wp_rewrite;

	if (current_user_can('activate_plugins')) {
		// Easiest test to see if we have been submitted to
		if(isset($_POST['target_width']) || isset($_POST['target_height'])) {
		  if(!isInteger($_POST['target_width'])||!isInteger($_POST['target_height'])){
		    $ol_flash = "Please input the number!";
		  }else{
			// Now we check the hash, to make sure we are not getting CSRF
			  if(fb_is_hash_valid($_POST['token'])) {
				  if (isset($_POST['target_width'])) {
					  $flashzoom_settings['target_width'] = $_POST['target_width'];
					  update_option('flashzoom_settings',$flashzoom_settings);
					  $ol_flash = "Your settings have been saved.";
				  }
				  if (isset($_POST['target_height'])) {
					  $flashzoom_settings['target_height'] = $_POST['target_height'];
					  update_option('flashzoom_settings',$flashzoom_settings);
					  $ol_flash = "Your settings have been saved.";
				  }
			  } else {
				  // Invalid form hash, possible CSRF attempt
				  $ol_flash = "Security hash missing.";
			  } // endif fb_is_hash_valid
			} //endif isInteger
		} // endif isset(feedburner_url)
	} else {
		$ol_flash = "You don't have enough access rights.";
	}
	if ($ol_flash != '') echo '
<div id="message" class="updated fade">

' . $ol_flash . '</div>

';

	if (current_user_can('activate_plugins')) {
	  $temp_hash = fb_generate_hash();
		fb_store_hash($temp_hash);
		echo '
<div class="wrap">';
		echo '
<h2>Set Up Flash Zoom Size</h2>

';
		echo '
<form method="post">
<input name="redirect" type="hidden" value="true" />
<input name="token" type="hidden" value="' . fb_retrieve_hash() . '" />
<table class="form-table" border="0">
<tbody>
<tr valign="top">
<th scope="row"><label for="target_width">Target Width</label></th>
<td>
<input id="target_width" maxlength="4" name="target_width" size="4" type="text" value="' . htmlentities($flashzoom_settings['target_width']) . '" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="target_height">Target Height</label></th>
<td>
<input id="target_height" maxlength="4" name="target_height" size="4" type="text" value="' . htmlentities($flashzoom_settings['target_height']) . '" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Save" />
</form>

';
		echo '</div>

';
	} else {
		echo '
<div class="wrap">

Sorry, you are not allowed to access this page.</div>

';
	}

}

function replaceSize($matches)
{
  global $flashzoom_settings;
  $replaceStr = ' width="'.$flashzoom_settings['target_width'].'" height="'.$flashzoom_settings['target_height'].'" ';
  return $matches[1].$replaceStr.$matches[3].$replaceStr.$matches[5];
}

function filter_shrink($content) {
    global $flashzoom_settings;
    if(is_home()){
      $content = preg_replace_callback(
           '|('.'<object width="100" height="100" type="application/x-shockwave-flash"></object></pre>


<p>Related posts:<ol><li><a href='http://rocksun.cn/flash-zoom/' rel='bookmark' title='Permanent Link: Flash Zoom'>Flash Zoom</a></li><li><a href='http://rocksun.cn/ftp-image-with-conext-menu/' rel='bookmark' title='Permanent Link: FTP image with Conext Menu'>FTP image with Conext Menu</a></li><li><a href='http://rocksun.cn/write-plugin-for-flow/' rel='bookmark' title='Permanent Link: 要想热 写插件'>要想热 写插件</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/write-my-first-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的Wordpress又升级了</title>
		<link>http://rocksun.cn/upgrade-wordpress-to-265/</link>
		<comments>http://rocksun.cn/upgrade-wordpress-to-265/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 11:52:22 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[recommend]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=122</guid>
		<description><![CDATA[感觉升级的次数比写blog的次数还要多，不过这一次我要好好写写升级的过程，也算给和我同样遭遇的wordpress用户一个提示。
因为从2.0就开始使用wordpress了，那时使用的数据库编码经常不是utf8的，所以创建表的语句就象这样：
CREATE TABLE `rs_comments` (
`comment_ID` bigint(20) unsigned NOT NULL auto_increment,
`comment_post_ID` int(11) NOT NULL default '0',
`comment_author` tinytext collate latin1_general_ci NOT NULL,
`comment_author_email` varchar(100) collate latin1_general_ci NOT NULL default '',
`comment_author_url` varchar(200) collate latin1_general_ci NOT NULL default '',
`comment_author_IP` varchar(100) collate latin1_general_ci NOT NULL default '',
`comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_content` text collate latin1_general_ci [...]


Related posts:<ol><li><a href='http://rocksun.cn/write-my-first-wordpress-plugin/' rel='bookmark' title='Permanent Link: My first wordpress plugin'>My first wordpress plugin</a></li><li><a href='http://rocksun.cn/flash-zoom/' rel='bookmark' title='Permanent Link: Flash Zoom'>Flash Zoom</a></li><li><a href='http://rocksun.cn/watermark-with-gimp-script/' rel='bookmark' title='Permanent Link: Watermark: With GIMP Script'>Watermark: With GIMP Script</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>感觉升级的次数比写blog的次数还要多，不过这一次我要好好写写升级的过程，也算给和我同样遭遇的wordpress用户一个提示。</p>
<p>因为从2.0就开始使用wordpress了，那时使用的数据库编码经常不是utf8的，所以创建表的语句就象这样：</p>
<pre lang="sql">CREATE TABLE `rs_comments` (
`comment_ID` bigint(20) unsigned NOT NULL auto_increment,
`comment_post_ID` int(11) NOT NULL default '0',
`comment_author` tinytext collate latin1_general_ci NOT NULL,
`comment_author_email` varchar(100) collate latin1_general_ci NOT NULL default '',
`comment_author_url` varchar(200) collate latin1_general_ci NOT NULL default '',
`comment_author_IP` varchar(100) collate latin1_general_ci NOT NULL default '',
`comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_content` text collate latin1_general_ci NOT NULL,
`comment_karma` int(11) NOT NULL default '0',
`comment_approved` enum('0','1','spam') collate latin1_general_ci NOT NULL default '1',
`comment_agent` varchar(255) collate latin1_general_ci NOT NULL default '',
`comment_type` varchar(20) collate latin1_general_ci NOT NULL default '',
`comment_parent` bigint(20) NOT NULL default '0',
`user_id` bigint(20) NOT NULL default '0',
PRIMARY KEY  (`comment_ID`),
KEY `comment_approved` (`comment_approved`),
KEY `comment_post_ID` (`comment_post_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=40397 ;</pre>
<p>而最新的wordpress，导出来的表对应的都是utf8编码的，所以应该把上述语句替换为：</p>
<pre lang="sql">CREATE TABLE `rs_comments` (
`comment_ID` bigint(20) unsigned NOT NULL auto_increment,
`comment_post_ID` int(11) NOT NULL default '0',
`comment_author` tinytext  NOT NULL,
`comment_author_email` varchar(100)  NOT NULL default '',
`comment_author_url` varchar(200)  NOT NULL default '',
`comment_author_IP` varchar(100)  NOT NULL default '',
`comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_content` text  NOT NULL,
`comment_karma` int(11) NOT NULL default '0',
`comment_approved` enum('0','1','spam')  NOT NULL default '1',
`comment_agent` varchar(255)  NOT NULL default '',
`comment_type` varchar(20)  NOT NULL default '',
`comment_parent` bigint(20) NOT NULL default '0',
`user_id` bigint(20) NOT NULL default '0',
PRIMARY KEY  (`comment_ID`),
KEY `comment_approved` (`comment_approved`),
KEY `comment_post_ID` (`comment_post_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=40397 ;</pre>
<p>注意我的单个字段也有编码设置，应该都清除掉。然后我们就把这些数据用phpmyadmin导入到数据库里，如果顺利地话通过phpmyadmin 看到的都是正常的汉字。然后升级文件，网上提到要修改wp-config的设置，我觉得那都不是长远之计，最好不修改。把最新版本的wp-config- sample.php，改名为wp-config.php，然后修改其中的数据库连接信息，上传到服务器上就好了。跑到wp-admin下就会自动提示需要升级结构，点确定就可以了，然后我们就有了完全utf8环境的wordpress了。</p>


<p>Related posts:<ol><li><a href='http://rocksun.cn/write-my-first-wordpress-plugin/' rel='bookmark' title='Permanent Link: My first wordpress plugin'>My first wordpress plugin</a></li><li><a href='http://rocksun.cn/flash-zoom/' rel='bookmark' title='Permanent Link: Flash Zoom'>Flash Zoom</a></li><li><a href='http://rocksun.cn/watermark-with-gimp-script/' rel='bookmark' title='Permanent Link: Watermark: With GIMP Script'>Watermark: With GIMP Script</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/upgrade-wordpress-to-265/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>编译OpenSSL</title>
		<link>http://rocksun.cn/compile-openssl/</link>
		<comments>http://rocksun.cn/compile-openssl/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 15:52:15 +0000</pubDate>
		<dc:creator>rocksun</dc:creator>
				<category><![CDATA[program]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[compile]]></category>

		<guid isPermaLink="false">http://rocksun.cn/?p=113</guid>
		<description><![CDATA[今天编译Cyrus SASL，需要依赖OpenSSL，看看安装说明好像很简单，可是换了方式跑了好几次，最后nmake的时候一直报错：

.cryptocversion.c(105) : warning C4129: &#8216;o&#8217; : unrecognized characterescape sequenceNMAKE : fatal error U1077: &#8216;cl&#8217; : return code &#8216;0&#215;2&#8242;

我感到自己好像没有错啊，就去google，倒是有人也发现这个问题了，不过似乎没有答案。无法，回来再看，无奈之间打开了那个出错的文件cversion.c，发现了一段问题，里面似乎要一个路径，但是那段宏的引用感觉有些蹊跷，突然想起来了，那个路径？起初我的路径是这么写的：
perl Configure VC-WIN32 &#8211;prefix=F:toolssvnopenssl-0.9.8hbin

&#160;
然后修改了一下：

perl Configure VC-WIN32 &#8211;prefix=F:/tools/svn/openssl-0.9.8h/bin

&#160;

再编译，没有问题了，唉，那个脚本对“”的处理有问题。
&#160;
Technorati 标签: compile,openssl


Related posts:Windows编译Subversion简要说明Dreamhost上编译Subversion上传工作拷贝中改变的文件



Related posts:<ol><li><a href='http://rocksun.cn/windows%e7%bc%96%e8%af%91subversion%e7%ae%80%e8%a6%81%e8%af%b4%e6%98%8e/' rel='bookmark' title='Permanent Link: Windows编译Subversion简要说明'>Windows编译Subversion简要说明</a></li><li><a href='http://rocksun.cn/install-subversion-on-dreamhost/' rel='bookmark' title='Permanent Link: Dreamhost上编译Subversion'>Dreamhost上编译Subversion</a></li><li><a href='http://rocksun.cn/upload-file-changed/' rel='bookmark' title='Permanent Link: 上传工作拷贝中改变的文件'>上传工作拷贝中改变的文件</a></li></ol>

]]></description>
			<content:encoded><![CDATA[<p>今天编译Cyrus SASL，需要依赖OpenSSL，看看安装说明好像很简单，可是换了方式跑了好几次，最后nmake的时候一直报错：<br />
<blockquote>
<p>.cryptocversion.c(105) : warning C4129: &#8216;o&#8217; : unrecognized character<br />escape sequence<br />NMAKE : fatal error U1077: &#8216;cl&#8217; : return code &#8216;0&#215;2&#8242;</p>
</blockquote>
<p>我感到自己好像没有错啊，就去google，倒是有人也发现这个问题了，不过似乎没有答案。无法，回来再看，无奈之间打开了那个出错的文件cversion.c，发现了一段问题，里面似乎要一个路径，但是那段宏的引用感觉有些蹊跷，突然想起来了，那个路径？起初我的路径是这么写的：</p>
<blockquote><p>perl Configure VC-WIN32 &#8211;prefix=F:toolssvnopenssl-0.9.8hbin</p>
</blockquote>
<p>&nbsp;
<p>然后修改了一下：<br />
<blockquote>
<p>perl Configure VC-WIN32 &#8211;prefix=F:/tools/svn/openssl-0.9.8h/bin</p>
</blockquote>
<pre>&nbsp;</pre>
<p><font face="Courier New"></font>
<pre>再编译，没有问题了，唉，那个脚本对“”的处理有问题。</pre>
<pre>&nbsp;</pre>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:66842a7c-6e04-42f3-9a41-8943e0ced04b" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati 标签: <a href="http://technorati.com/tags/compile" rel="tag">compile</a>,<a href="http://technorati.com/tags/openssl" rel="tag">openssl</a></div>


<p>Related posts:<ol><li><a href='http://rocksun.cn/windows%e7%bc%96%e8%af%91subversion%e7%ae%80%e8%a6%81%e8%af%b4%e6%98%8e/' rel='bookmark' title='Permanent Link: Windows编译Subversion简要说明'>Windows编译Subversion简要说明</a></li><li><a href='http://rocksun.cn/install-subversion-on-dreamhost/' rel='bookmark' title='Permanent Link: Dreamhost上编译Subversion'>Dreamhost上编译Subversion</a></li><li><a href='http://rocksun.cn/upload-file-changed/' rel='bookmark' title='Permanent Link: 上传工作拷贝中改变的文件'>上传工作拷贝中改变的文件</a></li></ol></p>
<p></p>]]></content:encoded>
			<wfw:commentRss>http://rocksun.cn/compile-openssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

