无法删除MT widget 默认module的问题

升级MT3.3 以后多了不少plugin,其中包括Widgets Manager,Widget 这个词最近在Blog 出现频率很高,也不知道到底是何物,今天google了一下,才知道大部分人谈论的Widget 与我要了解的MT Widget 还不是一回事。 这里有篇文章详细介绍:使用Movable Type的Widgets,我就不废话了。只说一个奇怪的问题,Widget Manager 会在Template 的Module 中生成默认的Widget 可以利用的Module,我已经有了很多类似的Module,于是把已有的Module重命名,在名称前面加上"Widget: "...
升级MT3.3 以后多了不少plugin,其中包括Widgets Manager,Widget 这个词最近在Blog 出现频率很高,也不知道到底是何物,今天google了一下,才知道大部分人谈论的Widget 与我要了解的MT Widget 还不是一回事。 这里有篇文章详细介绍:使用Movable Type的Widgets,我就不废话了。只说一个奇怪的问题,Widget Manager 会在Template 的Module 中生成默认的Widget 可以利用的Module,我已经有了很多类似的Module,于是把已有的Module重命名,在名称前面加上"Widget: " 前缀,这样就可以被Widget Manager 识别,然后将默认的全部删除,但是下一次点击Manage my Widgets进入后,这些默认的Module 又会自动生成,没有找到解决办法,最后将我自己的Module修改成与默认的具有相同的名字(大小写敏感),才算了事。

重构MT模板结构

MT默认的模板包含大量的重复或者类似模板代码,当你需要进行一处模板修改时,也许不得不考虑得更多,并在多个模板中同时进行,已达到统一的效果。 模板重构的目的就是尽可能将多个模板之间相同的部分抽象出来,然后在多个模板中进行引用,另外还有趋向于将一组具有相同功能的模板代码放入同一个模板文件 的作用,从而减少模板修改带来的工作量。MT很早就在模板中支持Module,定义好的Module可以通过如下代码进行引用。 <$MTInclude module="Module Name"$> 我 们需要做的就是把重复的模板代码放在一个个Module中进行定义,然后在模板中去引用他们。经过一定的重构,模板的重用性得到一定的改观,但依然会有一 些冗余的代码,除非MT可以提供一些模板标签,能够让我们判断当前所在的模板而采用不同的Module或者调整细微的模板代码差别。幸运的是,我找到了一 个MT plugin,mt-varz version 0.31。 它提供了更高级的变量支持,支持以下模板标签: <$MTGetVar$>,...

MT默认的模板包含大量的重复或者类似模板代码,当你需要进行一处模板修改时,也许不得不考虑得更多,并在多个模板中同时进行,已达到统一的效果。 模板重构的目的就是尽可能将多个模板之间相同的部分抽象出来,然后在多个模板中进行引用,另外还有趋向于将一组具有相同功能的模板代码放入同一个模板文件 的作用,从而减少模板修改带来的工作量。MT很早就在模板中支持Module,定义好的Module可以通过如下代码进行引用。

<$MTInclude module="Module Name"$>

我 们需要做的就是把重复的模板代码放在一个个Module中进行定义,然后在模板中去引用他们。经过一定的重构,模板的重用性得到一定的改观,但依然会有一 些冗余的代码,除非MT可以提供一些模板标签,能够让我们判断当前所在的模板而采用不同的Module或者调整细微的模板代码差别。幸运的是,我找到了一 个MT plugin,mt-varz version 0.31。 它提供了更高级的变量支持,支持以下模板标签:

<$MTGetVar$>, <MTSetVarBlock>, <MTIf>, <MTUnless>, <MTIfOne>, <MTUnlessEmpty>, <MTUnlessZero>

其中部分标签在MT3.3中已经得到支持, mt-varz对其进行了over load,具体细节可以参考此plugin文档(在下载包内)。我们在这里需要用到MT标准标签MTSetVar,以及mt-varz 支持的MTIf 标签。我在每个模板的第一行使用MTSetVar 定义一个变量用于标识当前模板,然后在Module中需要的地方使用MTIf 判断当前模板,并注入相应模板代码。下面是一个例子:

Template: Category Archive

<$MTSetVar name="Category Archive" value="1"$> 
...
<$MTInclude module="Header"$>
...

Template Module: Header

<head>
<MTIf name="Category Archive">
<title><$MTBlogName encode_html="1"$>: <$MTArchiveTitle$> Archives</title>
</MTIf>
...
</head> 
<$MTSetVar name="Category Archive" value="1"$> 这里value 可以是其它非0值,如果值为1,那么MTIfOne 标签在上面与MTIf 标签的作用相同,加以利用可以进行更精细的控制。除了1以外,目前还不提供对变量值的详细判断。

经过重构之后,我的Main Index 模板看起来就像这个样子,其它也很类似,模板修改主要在少量的Module中进行。

<$MTSetVar name="Main Index" value="1"$>
<$MTInclude module="Template Header"$> 
<$MTInclude module="Header"$>  
<MTEntries>
<$MTInclude module="Entry"$>
</MTEntries>
<$MTInclude module="Footer"$>
<$MTInclude module="Template Footer"$>  

更新:经测试,<MTIfOne> 标签不能正确的解析内嵌的<MTElse> 标签,根据不同情况,将在模板rebuild 阶段抛出错误,或者rebuild 通过,但逻辑不符合嵌套关系。下面是一个逻辑错误示例。<MTIf>标签是否存在此问题未作测试。已经report 这个bug 给了Appnel,希望可以解决。

<MTIfOne name="Search Result Template"><MTIfTagSearch>Tag Search<MTElse>None Tag Search</MTElse></MTIfTagSearch></MTIfOne>

Refine and add new features to my web site

This site disappeared on Internet from the early of this year because of the server...

This site disappeared on Internet from the early of this year because of the server problem. Since then it's running on my thinkpad locally for 1 year. Now it's more like my personal blog. I have to have some refine work on my blog since I decided to publish it again. Also I added some new features.

Here's a work log.

upgrade MT to version 3.3 

changed to plugined tinymce


changed title appearance

There are 3 level Titles.

  1. site title
  2. category and monthly title
  3. entry title

Each pages have this title structure for search engine friendly, but only display the related title. Others are hided.

In the 2nd level pages, the site title is hided. Also in the 3rd level pages, both 1st level and 2nd level titles are hided.

Using style:

.subindex-container .index-logo,
.individual-container .index-logo,
.individual-container .subindex-logo {
display: none;
}

gave tags to each entry

Give one or more meaningful tags to each entry. The old keywords field is abandoned. 

neater monthly archive list

added keywords.js

I used keyword.js to hilight keywords which visitor used in search engine for linking in this page in my old site. I did some simple configure and add it into my blog.

I had following settings. 

// Configuration:
Keyword = {
hilite: true,
index: false,
refill1: true,
refill2: false,
element1: 'search',
element2: 'w', 
style_name: 'hilite',
style_name_suffix: true,
debug_referrer: '',
debug_meta: ''
};

added edit link to individual archive

Simply to add an edit link to individual entry view, that makes editing entries quicker without going to MT management first.

Add following code to individual template:

<a href="<$MTCGIPath$>mt.cgi?__mode=view&_type=entry&id=<$MTEntryID$>&blog_id=<$MTBlogID$>" title="edit this entry, only for admin">Edit</a> 

changed download files location 

I organized all download files by date instead of by categories. That reduces the length of the file list in a same directory.

Current directory structure rule is /ref/year/month/files, exam:

/ref/2006/12/simple.zip

fixed new line problem for entries 

recheck the broken links

I have been using Xenu to check broken site links. It's still a good solution up to now. Recently, I got another solution that could play part of role of Xenu, CheckLinks. It's a plugin for MT that only check the links they are within entries. The reason I picked it up is that It's easier to have the edit link in the bad links report by CheckLinks. Here's a report from my site.  For having this feature, I use below Template. This template is used for checking all entries(maximum 9999 here) in your blog and printing only the entries with bad links. But rebuilding this template is as slow as when you check through your blog links with other tool. So better to uncheck the "Rebuild this template automatically when rebuilding index templates" at template setting if you are using it in Indexes Template. 

<MTEntries lastn="9999">
<MTCheckLinks include_local="1">
<MTCheckLinksHere>
<$MTEntryBody$>
<$MTEntryExtended$>
</MTCheckLinksHere>
<MTIfBadLinks>
<dl class="badlinks">
<dt><a href="<$MTEntryLink$>"><$MTEntryTitle$></a> (<a href="<$MTCGIPath$>mt.cgi?__mode=view&_type=entry&id=<$MTEntryID$>&blog_id=<$MTBlogID$>" title="in <$MTCatetoryTitle$>">edit</a>) Have bad links:</dt>
<MTBadLinks load_entries="1">
<dd><$MTBadLinkStatus trim_to="3"$>: <$MTBadLinkURL$> [<a href="<$MTBadLinkURL$>"><$MTBadLinkText$></a>]</dd>
</MTBadLinks>
</dl>
</MTIfBadLinks>
</MTCheckLinks>
</MTEntries> 

A note: If you are refering any Entries Tag like "MTEntryTitle" within CheckLinks Tag <MTBadLinks>, you must specify load_entries="1" otherwise there's error raising during rebuilding this template.

 

set up category rss feeds and links

managed external links by blogroll

I downloaded a new plugin Blogroll for managing my links. 

Use Blogroll I could manage and group my links, and publish them in template.

Using following code in template: 

<MTBlogrollCategories>   
<h3><$MTBlogrollCategoryLabel$></h3> 
<ul><MTBlogrollLinks> 
<li><a href="<$MTBlogrollLinkURI$>" title="<MTBlogrollLinkDesc>"<MTIfNonEmpty tag="BlogrollLinkRel"> rel="<MTBlogrollLinkRel>"</MTIfNonEmpty> <MTIfNonEmpty tag="BlogrollLinkTarget">target="<MTBlogrollLinkTarget>"</MTIfNonEmpty>><$MTBlogrollLinkName$></a></li> 
</MTBlogrollLinks></ul> 
</MTBlogrollCategories> 

related tags on tag search 

I downloaded a new plugin TagSupplymentals that brings much features on tags. I use MTRelatedEntries and MTRelatedTags.

Using following code in template:

<ul>
<h3>Related Entries</h3>
<MTRelatedEntries lastn="5">
<li><$MTInclude module="Entry Link"$></li>
</MTRelatedEntries>
</ul> 
 
<ul>
<h3>Related Tags</h3>
<MTEntryTags>
<MTRelatedTags>
<li><a xhref="<$MTTagSearchLink$>"><$MTTagName$></a> (<$MTTagCount$>)</li>
</MTRelatedTags>
</MTEntryTags>
</ul>

 

related entries by tags

See above. 

more clear search result

On the search result list, as default only show the entry title and entry summary. So the searcher could have an overview on all search result. If he wants more info about the entry there's a link to expand the entry area to show entry body.

Template:

<MTEntriesHeader>
<!--start #top-alpha-->
<div id="top-alpha">
<label id="hidebodybar" class="hidbodybar"></label>
<!--end #top-alpha-->
</div>
</MTEntriesHeader>
<!--start #entry~-->
<div class="entry" id="entry<$MTEntryID pad="1"$>">
<a name="a<$MTEntryID pad="1"$>" />

<!--start #top-entry~-->
<div class="top-entry" id="top-entry<$MTEntryID pad="1"$>">
<label class="hidebodybar" id="hidebodybar<$MTEntryID pad="1"$>"></label>
<!--end #top-entry~-->
</div>
<h3 class="entryheader" id="a<$MTEntryID pad="1"$>"><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></h3>
<!--start #entryinfo~-->
<div class="entryinfo" id="entryinfo<$MTEntryID pad="1"$>">
<MTIfOne name="Category Archive">
<p class="subtitle"><$MTEntryDate format="%x"$></p>
<MTElse>
<p class="subtitle">In <a href="<$MTEntryLink archive_type="Category"$>"><$MTEntryCategory$></a>, <$MTEntryDate format="%x"$></p>
</MTElse>
</MTIfOne>
<!--end #entryinfo~-->
</div>
<!--start #entrysummary~-->
<div class="entrysummary" id="entrysummary<$MTEntryID pad="1"$>">
<$MTEntryBody convert_breaks="0" words="16"$>...
<!--end #entrysummary~-->
</div>
<!--start #entrybody~-->
<div class="entrybody" id="entrybody<$MTEntryID pad="1"$>">
<$MTEntryBody convert_breaks="0"$>
<MTEntryIfExtended><p>继续阅读 "<a href="<$MTEntryPermalink$>#more"><$MTEntryTitle$></a>" 的剩余内容</p></MTEntryIfExtended>
<!--end #entrybody~-->
</div>
<!--start #entryfooter~-->
<div class="entryfooter" id="entryfooter<$MTEntryID pad="1"$>">
<MTEntryIfTagged><p>标签 Tags: 其它与<MTEntryTags glue=", "><a href="<$MTTagSearchLink$>"><$MTTagName$></a> (<$MTTagCount$>)</MTEntryTags> 相关的话题</p></MTEntryIfTagged>
<p class="posted">
Posted by <$MTEntryAuthorUsername$> at <$MTEntryDate format="%X"$>
<MTEntryIfAllowComments> | <a href="<$MTEntryPermalink archive_type="Individual"$>#comments">Comments (<$MTEntryCommentCount$>)</a></MTEntryIfAllowComments>
<MTEntryIfAllowPings> | <a href="<$MTEntryPermalink archive_type="Individual"$>#trackbacks">TrackBack (<$MTEntryTrackbackCount$>)</a></MTEntryIfAllowPings>
| <a href="<$MTCGIPath$>mt.cgi?__mode=view&_type=entry&id=<$MTEntryID$>&blog_id=<$MTBlogID$>" title="edit this entry, only for admin">Edit</a>
</p>
<!--end #entryfooter~-->
</div>
<!--end #entry-->
</div>

Javascript: hide-body.js

flexible style sheet

I had this new bar on the top of page.

text bar for changing style

It makes possible to switch different style sheet on current page by one click.

For doing this, needs switch-css.js, and the defination in the head.

<link rel="stylesheet" type="text/css" href="<$MTBlogURL$>css/screen.css" media="screen" title="BlockStyle" />
<link rel="alternate stylesheet" type="text/css" href="<$MTBlogURL$>css/screen-clearstyle.css" media="screen" title="ClearStyle" />
<script type="text/javascript" language="javascript" src="<$MTBlogURL$>switch-css.js"></script>
And the label tag with ID definition in the page. The css links would be generated by the .js above dynamically.
<label id="switchcssbar"></label>

The code refer to:

tested none-css appearance 

To see what my blog is like without style sheet, click below link. If you want to change it back, choose the block Style links on the top of any page. I'm ready to change this site as None Style

tested printable view

To see how it works, select "File - Print Preview" in your Internet Browser.

The format is defined in print.css .

made the old site work

Made some neccesary changes on my old site for showing it in sub folder well.

change to mysql database

power editing basename 

I think this would be helpful, lots of people want to have this feature. 

add style to preformatted tag <pre>

I used <pre> tag for several cases:

  • programming code (exam: javascripts)
  • command (exam: unix shell commands)
  • output (exam: screen output of a command)
  • refererence (exam: a short paragraph from other blog)

But they do have different requirements for showing up. So I add several class styles for the tag.

  • .code
  • .cmd
  • .output
  • .refer (with word wrap)

For the .refer class style, I referred to pre标签自动换行方案.

Update: Read an article What are semantics?, learned that I should use <blockquote> tag to wrap the resource that I refer to. So I need to use <blockquote> tag instead of class style .refer.

upgrade to TinyMCE 2.09

Refined Page structure

Refinced CSS

I split my css file as multi-level and use import keyword to link them up. I have following structure. The base.css and extend.css is used by each style sheet. The difference is that the extend.css is also refered by TinyMCE in MT. About TinyMCE please read this article .

base.css      extend.css
          \      /
           \    /
         screen.css
         screen-linestyle.css
         screen-clearstyle.css

I reset padding and margin as 0 in my base.css that makes crossing browsers development easier. Here's a style list about Firefox 1.5 default style sheet for HTML elements for reference.

I tried to have more comfortable color for pages. Here are some links would be helpful on this. The safe 216 web colors, a list of online colour tool.

 

Disable listing directory


Create a file ".htaccess" at the root path of web site and have following line:

Options All -Indexes 

Rewrite url for old site


Add below lines to /.htaccess.

RewriteEngine On
RewriteRule ^archives/([0-9]+/[0-9]+) $1
RewriteRule ^archives/(jeet_kune_do|outdoors) $1
RewriteRule ^archives/study_notes/(web|linux) $1
RewriteRule ^hobbies/(outdoors) $1
RewriteRule ^hobbies/ham/ amateur_radio
RewriteRule ^hobbies/sbenefit/ society_benefit
RewriteRule ^notes/*(db2|linux)* $1
RewriteRule ^notes/[a-z0-9\_\-]+.htm$ db2
RewriteRule ^archives/study_notes/[a-z0-9\_\-]+.html$ db2 
A little help on expression I used. 
  • ^ is maching the begin of aline.
  • $ is mathing the end of a line. 
  • $n is a reference for the expression within (), also could have $1, $2..., as I know, $0 should be the entire of $n.
  • | is the OR relationship.
  • + match at least one time.
Had this article  for reference. 

Related entries on tags

I had a plugin that allows having a related entries list in the same category. It's...

I had a plugin that allows having a related entries list in the same category. It's not very helpfule for visitors as you have many entries in a category.

Tags is supported since MT 3.3. We may want to have a related entries list based on tags on the current entry. TagSupplementals plugin is doing that. It provides a set of features for tags supplement. We're using one of them.

Change monthly archive style

The too long monthly archive list get bad-looking.Download a new plug-in mt-archive-dateheader to have a neat...

The too long monthly archive list get bad-looking.

Download a new plug-in mt-archive-dateheader to have a neat calendar for monthly archive like this:

kalsey-dates.gif

 

Change the template to

  <h2>按月归档|By Month</h2>

<a class="skip" xhref="http://blog.alex.com/cgi-bin/mt/mt.cgi#endbymonth">Skip over by month</a>

<MTArchiveList archive_type="Monthly">
<MTArchiveDateHeader>
<p><b><MTArchiveDate format="%Y"></b></p>
</MTArchiveDateHeader>
<a xhref="<$MTArchiveLink$>"><MTArchiveDate format="%B"></a><span class="num"><$MTArchiveCount$></span>
</MTArchiveList>
<p></p>

<a class="skip" id="endbymonth"></a>

安装MT Collect 插件,实现文章内自动索引标题

安装环境 Movable Type 3.14 RedHat Linux 安装配置插件 下载插件 安装配置说明 作者网站,还有很多其它插件。 将文件Collect.pl 上传到服务器上MT 的plugins 目录,并设置权限:$ tag -zxvf...

安装环境

  • Movable Type 3.14
  • RedHat Linux

安装配置插件

下载插件

安装配置说明

作者网站,还有很多其它插件。

将文件Collect.pl 上传到服务器上MT 的plugins 目录,并设置权限:

$ tag -zxvf Collect.tar.gz
$ cp Collect/Collect.pl /var/www/cgi-bin/mt/plugins/
$ chmod 755 /var/www/cgi-bin/mt/plugins/Collect.pl

修改MT 模板

Individual Archives 模板相关部分如下:

  <MTCollect tags="h3,H3"><MTCollectThis><$MTEntryBody$></MTCollectThis>
  <MTIfCollected>
  <table align="right" width="250" class="section" bgcolor="#EEEEEE" style="padding-top: 2">
  <tr>
    <td bgcolor="#BBBBBB">目录</td>
  </tr>
  <tr>
    <td>¡¡
      <ol>
        <MTCollected><li><a xhref="http://blog.alex.com/cgi-bin/mt/mt.cgi#<$MTCollectedIndex$>" mce_href="http://blog.alex.com/cgi-bin/mt/mt.cgi#<$MTCollectedIndex$>"><$MTCollectedContent$></a></li>
        </MTCollected>
      </ol>
    </td>
  </tr>
  </table>
  </MTIfCollected>
  </MTCollect>
  <MTCollect tags="h3,H3"><MTCollectThis show="1" h3="&lt;a name=&quot;[N]&quot; \/&gt;/" H3="&lt;a name=&quot;[N]&quot; \/&gt;/"><$MTEntryBody$></MTCollectThis>
  </MTCollect>

上面的模板共使用了两次MTCollect 标签,第一次用于生成索引目录,第二次用于在索引的段落标题中加入锚链接(anchor)。MTCollect 标签的tags 属性用于指定收集的HTML 标签名称,区分大小写,如果有多个标签,用逗号隔开,这里我们收集标题标签h3 与 H3。

<MTCollect tags="h3,H3">

MTCollectThis 标签用于指定收集的对象,并对收集的标签赋以新值。需要用到tag="new value" 的格式,tag 必须是上级MTCollect 收集的标签名称。我们需要在标题中加入锚链接,并保存原标题。因此我们如下定义模板:

<MTCollectThis show="1" h3="&lt;a name=&quot;[N]&quot; \/&gt;/" H3="&lt;a name=&quot;[N]&quot; \/&gt;/"><$MTEntryBody$></MTCollectThis>

上面的模板会将原文档中的内容:

<h3>段落标题1</h3>
<h3>段落标题2</h3>

替换成如下内容:

<a name="1" /><h3>段落标题1</h3>
<a name="2 /><h3>段落标题2</h3>

新值当中的最后一个斜线 "/" 代表收集到的内容,如果需要写入一个真实的斜线,比如A 标签的结束标志 "<a />",则需要使用转义字符 "\/" 。

方括号"[]" 中的 "N" 代表收集序号,我们恰好利用这个序号来作为锚链接的值。

属性 show="1" 告诉MTCollect ,不仅显示收集并替换的新值,也显示作为收集对象的原始内容。

此插件所有标签的使用方法,请参考:

http://www.staggernation.com/mtplugins/Collect/

使用

在编写新的Blog 时,使用H3 或h3 作为文章的段落标题,上述代码将会自动识别,并生成目录索引,生成的目录索引自动编号,并可以链接到对应文章标题处。具体实例可参看本文右上部的目录。

 

安装MT Related Entries 插件,实现相关文章

安装环境 Movable Type 3.14 Redhat Linux Related Entries 2.0  配置插件 下载插件 安装和配置指南 解开压缩包,将文件RelatedEntries.pl 上传到服务器上MT 脚本文件所在的目录,例如:/cgi-bin/mt/plugins/ 如果MT...

安装环境

配置插件

下载插件

安装和配置指南

解开压缩包,将文件RelatedEntries.pl 上传到服务器上MT 脚本文件所在的目录,例如:

/cgi-bin/mt/plugins/

如果MT 根目录下plugins 目录不存在,则手动创建。

设置.pl 文件的权限为 755

chmod 755 RelatedEntries.pl

之后就可以在MT 的模板中进行调用了。

修改MT 模板

在Individual Archives 模板中定义如下:

  <MTRelatedEntries>
  <p>
  <b>相关文章</b>
  <ul>
    <MTEntries lastn="5"><li><$MTInclude module="EntryLinkWithDate"$></li></MTEntries>
  </ul>
  </p>
  </MTRelatedEntries>

Rebuild 站点即可。

Update

已改用关联性更准确的plugin TagSupplymentals,参考related entries by tags

 

mail.png


标签订阅|Tag Subscription

If you use an RSS reader, you can subscribe to a feed of all future entries tagged 'plugin'. [What is this?]

Subscribe to feed Subscribe to feed

最近更新|Recent Entries

不定期更新|Handy Entries

其它标签|Other Tags

分类栏目|Categories

按月归档|By Month

2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

站内链接|Site Links

Powered by
Movable Type 3.34