RSS
 

Archive for the ‘11.工作事’ Category

解决 BLOG 在显示/回复贴子时的错误

21 十一

把 Dottext 的代码升级到 .NET 2.0 上以后,在显示Entry的页面上一直有JavaScript的错误,是在做 Validator 时产生的。错误部分的JavaScript代码如下:


<script type=”text/javascript”>
<!–
var PostComment.ascx_RequiredFieldValidator1 = document.all ? document.all["PostComment.ascx_RequiredFieldValidator1"] : document.getElementById(“PostComment.ascx_RequiredFieldValidator1″);
PostComment.ascx_RequiredFieldValidator1.controltovalidate = “PostComment.ascx_tbTitle”;
PostComment.ascx_RequiredFieldValidator1.errormessage = “请输入“标题””;
PostComment.ascx_RequiredFieldValidator1.evaluationfunction = “RequiredFieldValidatorEvaluateIsValid”;
PostComment.ascx_RequiredFieldValidator1.initialvalue = “”;
var PostComment.ascx_RequiredFieldValidator2 = document.all ? document.all["PostComment.ascx_RequiredFieldValidator2"] : document.getElementById(“PostComment.ascx_RequiredFieldValidator2″);
PostComment.ascx_RequiredFieldValidator2.controltovalidate = “PostComment.ascx_tbName”;
PostComment.ascx_RequiredFieldValidator2.errormessage = “请输入“署名””;
PostComment.ascx_RequiredFieldValidator2.isvalid = “False”;
PostComment.ascx_RequiredFieldValidator2.evaluationfunction = “RequiredFieldValidatorEvaluateIsValid”;
PostComment.ascx_RequiredFieldValidator2.initialvalue = “”;
var PostComment.ascx_validatorCheckCode = document.all ? document.all["PostComment.ascx_validatorCheckCode"] : document.getElementById(“PostComment.ascx_validatorCheckCode”);
PostComment.ascx_validatorCheckCode.controltovalidate = “PostComment.ascx_txtCheckCodeInput”;
PostComment.ascx_validatorCheckCode.isvalid = “False”;
PostComment.ascx_validatorCheckCode.evaluationfunction = “CustomValidatorEvaluateIsValid”;
// –>
</script>


PostComment.ascx 是一个文件名,下划线后面的是 validator 组件的名字,.NET 2.0 将组件的名字按层次方式级连起来组成了实例最终的id,但是“.”又是不能做为id出现的,至使脚本运行错误。


曾一直认为是 .NET 2.0 Beta 的问题,可是到了 .NET 2.0 正式版推出,错误依旧。今天忽然想到问题所在,原来是 Dottext 原有在 .NET 1.1 中运行正常的 UrlReWriteHandlerFactory 和 DottextMasterPage 机制产生的问题。


UrlReWriteHandlerFactory 在使用 DottextMasterPage 时,给 DottextMasterPage 安排了一个以逗号“,”分隔的.ascx组件文件列表。这些.ascx组件文件在 DottextMasterPage 组合的时候要创建若干 Control 的实例,这些实例的 id 属性又被分配为组件文件名。这就是问题所在。


在 .NET 2.0 中,是以每个parent-child关系层次的实例的id属性串联在一起的,这就使实例的id不应包含“.” 等不能在 JavaScript 当然对象名的字符。于是将代码先做以应急的修改,以后再做更妥善的处理:


DottextMasterPage.InitializeBlogPage 中:


foreach (string control in controls)
{
    Control c = LoadControl( string.Format( ControlLocation, skin, control ) );
    c.ID = strControlId;
   
CenterBodyControl.Controls.Add( c );
}


改为:


foreach (string control in controls)
{
    Control c = LoadControl( string.Format( ControlLocation, skin, control ) );
   
string strControlId = control;
    strControlId = strControlId.Replace( ‘.’, ‘_’ );
    c.ID = strControlId;

    CenterBodyControl.Controls.Add( c );
}


编辑备注:{3E933EFE-8394-4a87-97F6-1F7BA3CAA3B3}

 
 

【工作】CNDEV 论坛,树型菜单兼容问题

15

今天无意中用 win98 试看了一下论坛。


发现左边的树型菜单竟然不能用 win98 ie4 正常折叠、展开。研究得知:上次用来兼容什么什么浏览器将 document.all[theId] 改成的 document.getElementById(theId)。但是 document.getElementById 在 win98 ie4 中使用。所以加入了一个判断,暂不知那个什么什么浏览器上好使不好使:


     var objKids;
     
     if ( document.all != null )
     {
         objKids = document.all[src.id + 'u'];
     }
     else
     {
         // # 2005.0915 notemper2x, Win98 IE4.0 没有 getElementById 函数
         objKids = document.getElementById( src.id + ‘u’);
     }


更改注释:{CA87DD33-3E78-42da-B76C-4F0EEDEA8A11}


后来再用 FireFox 看论坛,树型菜单和贴子树,都有问题(与IE比起来,子级要比父级偏右很多)。研究发现是 padding-left 的原因,IE 的 ul 默认的 padding-left 是 0px; 而 FireFox 则有一定的数值。


将 padding-left 指定为 0px,FireFox 的异常消除。

 
 

【工作】CNDEV 论坛,改变数据库结构并加锁贴功能

11

forum_msgs 表中,以前以 board_name 和 MessageID 来确定一条记录。这样在生成新贴时,MessageID 是需要程序取得的,没有用的自增,很是麻烦。


最近在表中加入 MessageGlobalID 并在今天正式将数据库改了过去(包括 ParentMessageID 改成 ParentMessageGlobalID)。包含 msg.aspx、search.aspx 以及 NoxForum.Framework 的很多相关内容都被更新。


表中保留了以前的 MessageID,程序中也保留了以前的贴子获取函数。目的是为了最终保留以前贴子链接:/forum/msg.aspx?board=XXX&id=XXX


另外,这几天论坛里出现大量超级刷屏回复贴,所以又赶快做了一个锁贴功能。


本来说早睡觉的,结果又没早睡成。赶紧睡了,睡醒了还想爬香山去呢。

 
 

【工作】Dottext,将静态索引改为动态索引

09

每分钟查找一次新内容以做索引。目前没有分辩是否有新改的内容,也许每分钟一次太频繁等,还有很多细节要考虑。


在 blog_Content 表中加入两个索引有关的字段:
_search_is_indexed、_search_date_indexed

 
 

【工作】Dottext,Lucene 复合查询修正

07

刚才在google搜索 Lucene 复合查询,便得知前几天没解决的问题了。


代码注释:{D7843B04-94D9-4f08-90A5-D99DD933A947}
去掉以前的:{3F9AEDF7-F489-4760-9BDC-96A1BC2D1292}


Lucene 复合查询:


   Query query = MultiFieldQueryParser.Parse(
    text,
    new string[] { SearchConfiguration.Title, SearchConfiguration.RawPost },
    new Lucene.Net.Analysis.Cn.ChineseAnalyzer() );

 
 

【工作】用了两个多小时,把论坛的全文检索弄上来了

07

还有很多不如意的情况没有深入去做。
先用用再说吧。

 
 

【工作】Dottext 用户管理区在 .NET 2.0 Beta 中的页面代码提示问题

30

Dottext 0.95/0.96 在 Admin 管理区中使用 ANW:Page 作为页面模版的容器。


在 .NET 2.0 的页面编辑中,由于页面的框架部分已完全在 PageTemplate.ascx 中存在,通过 ANW:Page 使用模版的 aspx 文件因此便无需 html、body 等标记了。


但是,正因为这样,.NET 2.0 页面编辑器认为这是一个错误的页面(虽然运行器可以运行它),不能进行正常的代码提示。也就是说,在页面中,如果没有 html、body 等页面框架标记,将不能使用 asp:Label、asp:Literal、asp:DataList 等标记。


虽然研用以前的方法仍可运行,但还是感觉很别扭,想把它改换成以 .NET 2.0 新增的 MasterPage 为基础的模版页面。


为了降低工作量,先只将 PageTemplate.ascx 中的 html、body 等标记转移到新建的 PageTemplate.Master 文件中。


将所有 Admin 管理区的 aspx 文件设定 MasterPage 为 PageTemplate.Master,并加上 asp:Content 标记。Dottext.Web.Admin.Pages.Page 中也有一些相关改动。


因为使用了 MasterPage,造成了一些 runat=server 的标记 id 发生变化,不能使用 css 中面向 id 的 css 定义了(#tagid)。所以, body#Posts、body#Artical 等改为 body.body-tab-Posts、body.body-tab-Artical 等。


本次改动加入注释行:{44CEB56B-C600-46f1-8E46-D33F23946752}

 
 

【工作】学习 Lucene.Net,准备给org论坛加入全文检索功能,初见成效

29

预想实现的功能:



  • 动态建立索引:每个新增贴子及时的创建索引;每个新修改的贴子及时更改索引中的内容(删除后添加新的);每个新删除的贴子及时的删除索引中的内容。
    需要注意的是,虽然要及时的在索引中的增删改操作,但是还是尽量在背景线程中做索引库操作。
  • 定时优化索引库:频繁更新索引可能在索引库中产生大量的 deleteable 项,定时优化索引可以删除作废的数据,节约存储空间。
  • 定时或人工操作的重建索引库:动态的建立索引、优化索引仍可能让索引有不可预料的问题出现,定期重建索引,有助于使不可预料的问题减至最少。

在收藏中加入收集来的 Java 版 Lucene简介以供开发参考:http://notemper2x.cndev.org/articles/43373.aspx

 
 

【工作】Dottext.Search 搜索问题

27

这两天给 Dottext 上面添加 Dottext.Search 的搜索功能


搜索功能使用 Lucene.NET 的开源库进行的。
现在这个开源库的源代码还没有找到。


后来找到了 Lucene.NET 的中文词法分析源代码。
给 Dottext.Search 加上了支持中文的搜索。(2005.0825)


可是发现 Dottext.Search 中只能搜索 Post 的内容(数据库里的Text字段),标题却搜索不到。
查看代码发现 Dottext.Search.QueryIndex 的构造函数中在创建 QueryParse 实例出现的问题。
(代码注释: {3F9AEDF7-F489-4760-9BDC-96A1BC2D1292})


Lucene.Net.QueryParses.QueryParse 在构建时,似乎只能对某一个 Field 进行搜索,
大概看了一下,没有找到解决办法。


所以只好在创建索引库时,将 Post 的 Title 也加到 RawText 里去了。
(代码注释:{3F9AEDF7-F489-4760-9BDC-96A1BC2D1292})

 

test

10