Technorati是一家国外的公司提供的一个搜索引擎,用来搜索blog内容。它主要提供的功能有三项,关键字搜索,tags搜索和引用链接搜索。在Windows Live Writer里可以直接添加Technorati标签,可是用起来很麻烦,不够原生态。
目标:给BlogEngine添加Technorati标签。
实施:
打开Web\Control\PostViewBase.cs源代码,修改TagLinks()方法。修改后代码为
protected virtual string TagLinks(string separator,string path)
{
if (Post.Tags.Count == 0)
return null;
string[] tags = new string[Post.Tags.Count];
string link = "{2}";
for (int i = 0; i < Post.Tags.Count; i++)
{
string tag = Post.Tags[i];
tags[i] = string.Format(CultureInfo.InvariantCulture, link, path, HttpUtility.UrlEncode(tag), HttpUtility.HtmlEncode(tag));
}
return string.Join(separator, tags);
}
重新编译下核心。打开对应模板的\themes\Standard\PostView.ascx文件,直接在调用TagLinks()时增加一个网址即可。比如Technorati的为http://technorati.com/tag,修改后代码为:
Tags: <%=TagLinks(", ","/?tag=") %>
Tags: <%=TagLinks(", ","http://technorati.com/tag") %>
<%=CategoryLinks(" | ") %>
更新的时候记得要更新Dll文件。