导航

风易博客

风萧萧兮易水寒, 壮士一去兮不复还。

« 程序人生之编程九重经营危机并不等于经济危机 »

Z-BLOG v1.8自定义首页调用

刚从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代码
  1. <%@ CODEPAGE=65001 %>   
  2. <%   
  3. '==================================   
  4. '首页调用文件 topBlog.asp   
  5. '风易博客 http://1982Y.Net.Cn   
  6. %>   
  7. <% Option Explicit %>   
  8. <% On Error Resume Next %>   
  9. <% Response.Charset="UTF-8" %>   
  10. <% Response.Buffer=True %>   
  11. <% Response.ContentType="application/x-javascript" %>   
  12. <!-- #include file="c_option.asp" -->   
  13. <!-- #include file="function/c_function.asp" -->   
  14. <!-- #include file="function/c_system_base.asp" -->   
  15. <%   
  16. Response.Clear   
  17. Response.Write "document.write(""" & LoadFileInfo("previous") & """)"  
  18. Response.End  
  19.   
  20. Function LoadFileInfo(name)   
  21.   
  22.     Dim strContent,str   
  23.     Dim objStream   
  24.   
  25.     Dim i,j   
  26.   
  27.     Dim aryTemplateTagsName   
  28.     Dim aryTemplateTagsValue   
  29.   
  30.     Application.Lock   
  31.     aryTemplateTagsName=Application(ZC_BLOG_CLSID & "TemplateTagsName")   
  32.     aryTemplateTagsValue=Application(ZC_BLOG_CLSID & "TemplateTagsValue")   
  33.     Application.UnLock   
  34.   
  35.     j=UBound(aryTemplateTagsName)   
  36.   
  37.     For i=1 to j   
  38.         If aryTemplateTagsName(i)="TEMPLATE_INCLUDE_" & UCase(name) Then  
  39.             strContent=aryTemplateTagsValue(i)   
  40.             Exit For  
  41.         ElseIf aryTemplateTagsName(i)="CACHE_INCLUDE_" & UCase(name) Then  
  42.             strContent=aryTemplateTagsValue(i)   
  43.         End If  
  44.     Next  
  45.   
  46.     Dim reg, objMatches   
  47.     Set reg = new RegExp   
  48.     reg.IgnoreCase = True  
  49.     reg.Global = True  
  50.   
  51.     '一日期,二日期,三标题   
  52.     reg.Pattern = "(http://[^\s]+)"".+?span.+?\[(.+?)\].+?>(.+?)<"  
  53.     Set objMatches = reg.Execute(strContent)   
  54.     If objMatches.Count > 0 Then  
  55.         For i = 0 To objMatches.Count - 1   
  56.             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>"  
  57.         Next  
  58.     End If  
  59.        
  60.     str= Replace(str,"\","\\")  
  61.     str= Replace(str,"/","\/")  
  62.     str= Replace(str,"""","'")   
  63.     str= Replace(str,vbCrLf,"")  
  64.     str= Replace(str,vbLf,"")   
  65.   
  66.     LoadFileInfo=str   
  67.   
  68. End Function  
  69.   
  70. function toUnicode(str) 'To Unicode   
  71.     dim i, unicodeF, getUnicode   
  72.     for i=1 to len(str)   
  73.         unicodeF=Mid(str,i,1)   
  74.         getUnicode=getUnicode & chr(38) & chr(35) & chr(120) & Hex(ascw(unicodeF)) & chr(59)   
  75.     next   
  76.     toUnicode=getUnicode   
  77. end function   
  78. %>  

 

  • 相关文章:
  • quote 1.gogogo
  • 很好,找了很久终于让我找到了,但发现为什么我套用你的代码后出错的呢?我的blog不是网站根目录下,是在根目录的/blog/下的,出现错误如下:

    Microsoft VBScript 编译器错误 错误 '800a0401'

    语句未结束

    /blog/topblog.asp,行 56

    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>"
  • 2008-11-17 8:52:41 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-Blog .Theme from Google黑板报 By Washun

Copyright © 2005 - 2008 风易博客 1982Y.Net.Cn All Rights Reserved.  由Wind88.Net提供优质主机空间
沪ICP备05006417号

Search

控制面板

最新评论及回复

最近发表