% @Language="VBScript" %>
<%
'============================================================
' APP: TagCloud
' AUTHOR: © www.u229.no
' CREATED: October 2006
'============================================================
' ROUTINES:
' - Function ReadRSSTags()
' - Sub BubbleSort(byRef a)
'============================================================
Option Explicit
On Error Resume Next
With Response
.ExpiresAbsolute = #1/1/1980#
.AddHeader "cache-control", "no-cache, must-revalidate"
.AddHeader "pragma", "no-cache"
.AddHeader "Content-Type", "text/html; charset=UTF-8"
End With
%>
TagCloud
TAG CLOUD MADE FROM A BBC FEED:
<%
Dim m_sTags
Dim m_aTags
Dim m_sSmallWords
Dim m_sCurrent, m_sLast
Dim m_bMatch
Dim m_iWordCount
Dim m_sHTML
Dim i, iMax
'// READ THE RSS FILE AND REMOVE SOME COMMON CHARACTERS
m_sTags = Replace(Replace(Replace(Replace(Replace(Replace(ReadRSSTags, "?", ""), "!", ""), ".", ""), ",", ""), "-", ""), ":", "")
'// THESE ARE THE SMALL WORDS THAT WE DON'T CARE ABOUT. INCLUDE MORE WORDS IF YOU LIKE.
m_sSmallWords = " in a an and or but for to it that this those these all on off can will no not we will be more new up down over you they get one two three four five six seven eight nine ten nobody now back after yes no like "
'// STORE THE WORDS (TAGS) IN AN ARRAY
m_aTags = Split(m_sTags, " ")
m_iWordCount = 1
m_bMatch = False
'// SORT THE WORDS ALPHABETICALLY. THIS MAKES THEM EASIER TO COUNT.
Call BubbleSort(m_aTags)
m_sHTML = ""
iMax = UBound(m_aTags)
'// LOOP THE WORDS
For i = 0 To iMax
m_sCurrent = m_aTags(i)
'// WE FOUND A MATCH!
If m_sCurrent = m_sLast Then
m_bMatch = True
m_iWordCount = (m_iWordCount + 1)
Else
If m_bMatch Then
If m_iWordCount > 1 Then
If Not InStr(m_sSmallWords, LCase(m_sLast)) > 0 Then
'// THIS IS OUR SIMPLE WEIGHING ALGORITHM: WE DON'T CARE ABOUT WORDS APPEARING JUST ONE TIME.
If m_iWordCount = 2 Then m_sHTML = m_sHTML & "" & m_sLast & " "
If m_iWordCount = 3 Then m_sHTML = m_sHTML & "" & m_sLast & " "
If m_iWordCount > 3 Then m_sHTML = m_sHTML & "" & m_sLast & " "
End If
End If
End If
m_iWordCount = 1
End If
m_sLast = m_sCurrent
Next
'// OUTPUT THE TAG CLOUD
Response.Write m_sHTML & "