最新修改:03/02/2009,配合 列表插件,可以达到更好的效果。无缝继承了19种列表,提供了包括(文章排行,随机文章)等多种文章列表等。
刚从PJBLOG转到Z-BLOG,还不是很习惯,Z-BLOG内置的首页调用不错,但是不太适合我的需要,为此,特改造一个自定义的最新日志调用。只显示日志标题,并自动用CSS截取多余的字符长度,超链接在新窗口打开。用法很简单,把以下代码保存为一个新文件,然后上传到z-blog根目录,并在外部调用之,调用条数可以在z-blog后台修改,调用代码如下: <script type="text/javascript" charset="utf-8" src="http://1982y.net.cn/topblog.asp"></script>,可根据需要改成自己的z-blog地址。
预览:http://www.wind88.net

源代码如下:
ASP/Visual Basic代码
- <%@ CODEPAGE=65001 %>
- <%
- '==================================
- '首页调用文件 topBlog.asp
- '风易博客 http://1982Y.Net.Cn
- %>
- <% Option Explicit %>
- <% On Error Resume Next %>
- <% Response.Charset="UTF-8" %>
- <% Response.Buffer=True %>
- <% Response.ContentType="application/x-javascript" %>
- <!-- #include file="c_option.asp" -->
- <!-- #include file="function/c_function.asp" -->
- <!-- #include file="function/c_system_base.asp" -->
- <%
- '新增代码
- Dim actKey : actKey = Request.QueryString("act")
- If actKey = "" Then actKey = "previous"
- Response.Clear
- Response.Write "document.write(""" & LoadFileInfo("previous") & """)"
- Response.End
- Function LoadFileInfo(name)
- Dim strContent,str
- Dim objStream
- Dim i,j
- Dim aryTemplateTagsName
- Dim aryTemplateTagsValue
- Application.Lock
- aryTemplateTagsName=Application(ZC_BLOG_CLSID & "TemplateTagsName")
- aryTemplateTagsValue=Application(ZC_BLOG_CLSID & "TemplateTagsValue")
- Application.UnLock
- j=UBound(aryTemplateTagsName)
- For i=1 to j
- If aryTemplateTagsName(i)="TEMPLATE_INCLUDE_" & UCase(name) Then
- strContent=aryTemplateTagsValue(i)
- Exit For
- ElseIf aryTemplateTagsName(i)="CACHE_INCLUDE_" & UCase(name) Then
- strContent=aryTemplateTagsValue(i)
- End If
- Next
- Dim reg, objMatches
- Set reg = new RegExp
- reg.IgnoreCase = True
- reg.Global = True
- '一日期,二日期,三标题
- reg.Pattern = "(http://[^\s]+)"".+?span.+?\[(.+?)\].+?>(.+?)<"
- Set objMatches = reg.Execute(strContent)
- If objMatches.Count > 0 Then
- For i = 0 To objMatches.Count - 1
- str = str & "<div style='width:145px;overflow:hidden;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;'><a href="""&objMatches(i).SubMatches(0)""" target=""_blank"" title="""&toUnicode(objMatches(i).SubMatches(2))""" style=""color:#0469C4;TEXT-DECORATION: none"">"&toUnicode(objMatches(i).SubMatches(2))"</a></div>"
- Next
- End If
- str= Replace(str,"\","\\")
- str= Replace(str,"/","\/")
- str= Replace(str,"""","'")
- str= Replace(str,vbCrLf,"")
- str= Replace(str,vbLf,"")
- LoadFileInfo=str
- End Function
- function toUnicode(str) 'To Unicode
- dim i, unicodeF, getUnicode
- for i=1 to len(str)
- unicodeF=Mid(str,i,1)
- getUnicode=getUnicode & chr(38) & chr(35) & chr(120) & Hex(ascw(unicodeF)) & chr(59)
- next
- toUnicode=getUnicode
- end function
- %>
最后,我们还需要改动列表插件的一个函数,如下:PLUGIN\busfly_randomsort\index.asp,在约219行至250行的位置,替换为如下函数
ASP/Visual Basic代码
- '*********************************************************
- ' 目的: 列表记录的数据
- ' 参数说明:
- ' b_objRS => 数据集合
- ' strOutName => 保存到include时的名字(不带后缀名)
- ' out_count => 多少条记录
- '*********************************************************
- Function busfly_randomsort_outArticleHtml(ByVal b_objRS,ByVal strOutName,ByVal out_count)
- dim i
- dim strOut
- strOut=" "
- If (Not b_objRS.bof) And (Not b_objRS.eof) Then
- For i=1 to out_count
- Set busfly_randomsort_objArticle=New TArticle
- If busfly_randomsort_objArticle.LoadInfoByID(b_objRS("log_ID")) Then
- strOut=strOut & "<li><a href="""& busfly_randomsort_objArticle.Url & """ title=""" & busfly_randomsort_strReplace(busfly_randomsort_objArticle.Title,busfly_randomsort_chReplace) & """><span class=""article-date"">["&Right("0"&Month(busfly_randomsort_objArticle.PostTime),2)"/"&Right("0"&Day(busfly_randomsort_objArticle.PostTime),2)"]</span>" & busfly_randomsort_cutTitle(busfly_randomsort_objArticle.Title,busfly_randomsort_INTCUTLEN) & "</a></li>"
- End If
- Set busfly_randomsort_objArticle=Nothing
- b_objRS.MoveNext
- If b_objRS.eof Then Exit For
- Next
- End If
- b_objRS.close
- strOut=TransferHTML(strOut,"[no-asp]")
- Call SaveToFile(BlogPath & "/include/"&strOutName".asp",strOut,"utf-8",True)
- strOut=""
- End Function
- '*********************************************************