江边闲话集

01/19/2007

将MT与FCKEditor集成

Filed under: 小站崛起 — Tags: , — 张太国 @ 22:28

MT的缺省编辑器实在是比较丑陋,只有那么一点点功能,这不,决定将之换掉,使用FckEditor,用以代替缺省的。
集成之路并不顺利,相反变得有些崎岖。我试用了2种方法。
下面我将介绍一下这2种方法。
第一种,不使用插件插件
非常简单,首先到FCKEditor下载最新的版本。然后将刚才下载的包解压缩到mt-static文件夹里。OK,这个时候编辑器已经准备好了,下一步是如何将它集成到MT中。如何实现?找到编辑的模版( /tmpl/cms/edit_entry.tmpl ).你可能就会问,你怎么知道要编辑模版呢?MT有许多模版构建而成,当然编辑模块也不例外。这是很多系统最常见的一种方式。我们遵循此规则应该是不会错的。
在代码行<TMPL_INCLUDE NAME="header.tmpl">下增加如下代码即可:
<head>
<script type="text/javascript" src="http://YOUR WEBSITE/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( ‘text’ ) ;
oFCKeditor.Height = "600" ;
oFCKeditor.Width = "577" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
</head>
简单是不是?一般来说这样就够了。但是对于我来说,感觉好像才刚开始,因为把静态文件放在了其他地方,我又不得不把这些文件考到那个地方去。稍微麻烦了一些。

第二种,使用插件
使用插件就更简单了。因为它已经将FCKEditor集成。其实据我个人经验,也并是特别容易,感觉比第一种更为烦琐一些。不过这主要表现在配置方面。
这里去下载此插件。我们运气好,作者已经详细的介绍了安装和配置方法,感谢他/她。
顺便,你需要和第一种方法一样,拷贝到mt-static.
顺便说一下,作者是韩国人,最近我发现韩国人,德国人以及俄国人都是很厉害的,强!!
同时我也参考了这篇文章
差点忘了,做完之后rebuild一下site。
参见

  1. 本文英文版本
  2. FCKEditor
  3. MT
  4. … …

–EOF–

12/08/2006

转载,署名,权利,以及对WP的修改

Filed under: 小站崛起 — Tags: — 张太国 @ 12:12

本文是阅读了2篇文章之后我才修改的,一篇是随心所欲关于 转载、署名、大度和权利,另外一篇是FengChedongChedong Copyright: 便于复制/粘贴的版权声明。 于是我自己也将我的WordPress样式修改了一下。那么就可以直接把作者,链接等信息COPY/PASTE过去。要是这样的话,仍然不见版权信息,那也太过分了. OK,看看在WP里是如何实现的。在你选择的样式下找到Single.php文件,并在合适的位置加入下面的代码即可:
<!–Add Copyright Start–>
            <hr>
        <font color=’blue’><?php _e(‘作者:’);?><a href=’http://www.36sign.com’><?php the_author()?></a>  发表于<?php the_time(‘F j, Y’) ?> <?php _e(‘at’); ?> <?php the_time() ?>
        <br><a href=’http://creativecommons.org/licenses/by/2.5/cn/’>Copyright</a>:可以任意转载, 转载时请务必以超链接形式标明文章原始出处和作者信息.
      <br><a href='<?php the_permalink();?>’><?php the_permalink();?></a></font>
            <hr>
<!–Add Copyright END–>

因为每个Theme都不一样,所以加入的地方也不一样,但是最终是在显示每个Post Detail的页面上加的。
K2:请在theloop.php加入(大约是在150行左右).

12/07/2006

MT3.3安装

Filed under: 小站崛起 — Tags: , , — 张太国 @ 19:50

MT(Movable Type)是SixPart的一个blog产品,目前是相当的流行,看见很多人都使用这个系统,我也终于忍不住装一下,不然也对不住自己。
安装MT,总的来说还是比较简单的。在这里,我只讲安装,不讲如何使用,因为使用,我也不太清楚,毕竟才刚刚使用。
下面讲述一下我的感受,安装MT需要注意一下几点,不管是在Windows还是在Linux/Unix.
安装这种东西无非就是配置好环境,MT需要的环境(以Windows为例,个人感觉在Windows比在Linux安装麻烦,我自己安装的时候就是这样):

  • MT For windows
  • MySQL
  • Perl
  • Apache

Step 1:  安装MySQL,Perl,Apache       
        安装MySQL,Perl,Apache我就不说了,Google一下你就能得到很多资料。

Step 2 安装MT
       当你下载MT之后,解压到的你的Web根目录下
       配置一下mt-config.cgi,里面需要配置的是数据库,CGIPath等。
      这些设置好之后,访问一下你的网页,顺利的话,会出现一个Movable Type的页面,并在页面的下方有一个check的链接。如果不顺利的话,你可能会遇见一下的错误:
  You don’t have permission to access /mt/cgi-bin/MT/mt-check.cgi on this server.
  可能的原因有
   1.因为MT是由perl编写的,所以有可能不是别cgi脚本,你需要在Apache配置文件里对cgi脚本设置什么。具体可以为:
         AddHandler cgi-script .cgi
         AddHandler cgi-script .pl

   2.如果上面设置之后,还是不行,那么可能的原因是不能执行cgi脚本,如果做呢?非常简单:
      还是在Apache的配置文件里,增加一个Directory section,可以为     
           <Directory "F:/Apache Software Foundation/Apache2.2/htdocs/mt/cgi-bin">

  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
  Options ExecCGI
</Directory>

  注意到Options ExecCGI,这个就用来执行cgi。
3.如果2不行,可能的原因还是找不到perl,怎么办?在Apache里设置Perl的安装目录,可以为:
      #!D:/perl/bin/perl
   如果你的perl安装在D盘的perl目录下。

4,如果以上都不行,还有一个方法就是给自己分配一个对文件的访问权利。原来MT的每个文件都是read-only,你只需要把文件变成可读可写,当然只分配给你自己。

Step 3.以上安装完之后,访问http://yoursite/mt/mt.cgi进行安装。
  不出问题的话,系统会给你安装数据库等。
 但是要是出问题怎么办呢?
  一般来说,最常见出现的错误有2种:
   Case 1:internal server error 500
 这个问题非常简单,打来你的mt.cgi,看看第一行,这个是perl的安装位置,你只需要换成你自己机器的安装目录。

   Case2: Got an error: install_driver(mysql) failed
     这个问题显而易见,就是你的mysql driver没有安装。如何安装,也很简单。跑到perl安装目录下的bin目录,用命令行哟。输入ppm命令,会弹出一个对话框叫Perl Package manager,会看到你的MySql就没有安装。点击“view all packages”,你会看到所有的包,找到DBI-mysql,右击"install DBI-mysql +“菜单,或者是在命令行里输入"ppm i DBI-mysql"即可。

  以上的2个问题解决之后,相信MT会很容易装上了。

以上就是安装MT需要注意的问题。稍微看了一下,发现MT确实很强大。

至于如何在Linux上安装MT,其原理和Windows非常类似,就不再赘述了。
   

11/11/2006

FckEditor在WordPress中的应用

Filed under: 小站崛起 — 张太国 @ 20:28

WordPress提供的Editor:TinyMCE实在是简陋,就连改变个字体非得修改HTML代码,很不方便,后来Google了一下,发现大家都在推荐WYSI-WordPress,小试了一把,发现他是基于TinyMCE的,功能虽然比默认的强多了,但是仍然不满意,更要命的是有时候一些article post出去之后居然在页面上不显示,但是在编辑器里却包含,其实就是<div>的问题,这个可能是WordPress的一个不好的毛病。
最后还是回归到默认的,个人认为用默认的,还不如直接写HTML呢。
今天,灵机一想,FCKEditor不是非常厉害么,于是Google一下,真的有,那就是ChenPress。下载,安装,一切OK。关于FCKEditor的信息,可以到其官方网站上去查找,地址为http://www.fckeditor.net

11/10/2006

Backup Your Database Hosting on DreamHost

Filed under: 小站崛起 — 张太国 @ 22:53

Since you host your site on dreamhost, a new problem will happen,that is how to backup your database automatically?

Knowledge You Should Know
To aim to this, you should be familiar with some knowledge:

  • MySQL

because WordPress is based on MySQL, and DreamHost also use it.

  • Linux Services

Since this task will run daily, and do it automatically, Linux service is required.

  • Linux Shell Script

Since Dreamhost doesn’t provide the auto-backup service, but Shell function , we can make use of it so that the task can be implemented.

  • Mutt

The database backup package should be sent the email address you specify, so we should email it, Mutt makes sense for it.

  • Package Compression and Extraction

Compress the packge

Ok,Let’s take a look at the script and explain how to implement it.

The SHELL Script

The scripts block is like below:

#!/bin/bash

# Backup your MySQL database and have it mailed to you
# requires mutt or another command line email client

# config
tmp=”/backup_db”
db_user=”user”
db_pw=”db-pws”
db_name=database_name
db_host=”dbhost”
recp=Reciept mail
today=`date +%Y%m%d`
mysqldump_opts=”–add-drop-table -acQq”


# email settings
subject=”DB Backup for WordPress”
sql_file=$tmp/$db_name.$today.sql
gzip_file=$tmp/$db_name.$today.sql.gz

# create the backup
mysqldump $mysqldump_opts -u $db_user -h $db_host -p$db_pw $db_name > $sql_file

#create the gzip’d attachment
gzip $sql_file

#send the mail
#we could also scp it offsite instead (better)
echo “Automated database backup” | mutt -a $gzip_file -s “$subject” $recp

#delete temp file
rm $gzip_file

Description

The process is very simple.Generally, there are 3 steps here.

  • Step1: Set the variables, such as the file name for the database backup file.In order to make you distinguish the attachment file name, it is renamed according to the current day. why it is current day, becuase it backups daily.

this code is written in Shell script, which is similiar with the command script on Microsoft Windows system.it also includes variables, linear structure, condition and loop flow.

  • step 2: dump the data from database.there is a command: mysqldump can do this.

mysqldump is useful, and has many options. In this case,the options string is “–add-drop-table -acQq”, –add-drop-table is to add or drop the table before the generated sql,for more information, please visit mysql website .

  • step 3:compress the data file exported from mysql

Package compression and extraction are the common function on Linux operation system, such as tar,gzip,unzip.etc. for more information ,you can use “man command ” in terminal .

  • step 4: move it to main inbox, and delete the temporary file

Mutt is used here, please notice that it is not a mail client, and it can’t send mail, what it does only is move the email to mail server, and fortunately, dreamhost supports it.

Config it

please save the script as “backup.sh”, and then enter ctrontab -e,input below code:

0 0 * * * ./backup.sh

then press Ctrl+o ,then Enter to save

finally, press Ctrl +X
All is OK!

11/04/2006

The Log of This Site On DH

Filed under: 小站崛起 — Tags: — 张太国 @ 03:12

Change log of this site ordered by date

  • 2006-11-2 

                    Submit the application, and the account is in pending

  • 2006-11-3

                    Fax the imprint to DH

  • 2006-11-4

  1. DH process my application ,and approve it.then open my account.
  2. About 5 hours,the domain is available
  3. Then Install wordpress

  • 2006-11-6

    1. Install WYSI-WordPress Plugin so that typing becomes more easy, since the one WordPress provides is pretty simple, and not friendly
    2. Transfer all articles from Microsoft Live Spaces to here.
    3. Add the plugin to have the first character of each article drop, this plugin is DropCap

  • 2006-11-10 

                    Add SHELL script to daily backup the database automatically

  • 2006-11-11

                  The default editor:tinyMCE is very simple, FCKEditor makes sense via using ChenPress. For more information on ChessPress, please check out http://groups-beta.google.com/group/ChenPress

  • 2006-11-14

                Make this site public gradually

  •  2006-12-05

                1. Move the root of blog ,and redirect
                2. Update permalinks settings

  • 2006-12-08

             Copyright setting update,click here for more information.

  •  2006-12-12

                1.Add Related Post plugins, click here for information.
                2. Add Ultimate Tag Warrior

  •  2006-12-14

             1. Update the realted posts file
             2.Add the shortcut to refer to the articles

  •  2006-12-18

                 Update the subscription form from text to image, and along with the feedburner feed counter.

  • 2006-12-19

              Stats Domain outage by SetupTime

  •  2007-02-09

            Upgrade to WP 2.1

« Newer Posts

Powered by WordPress