Asp Wiki Prior Version

This is the prior, simpler version of AspWiki. From Trueform. circa Jan 2000?. It uses ASP but not the RegExp engine.


Now the new version is here. The database will change to somewhat more advanced design in the near future. At the moment this code should work if you create a wiki.mdb at the c:\ and make a table called wikkipage that has a ID(autonr long), tekst(text),title(text). I think I have removed all the english words. You make link på prefixing a word with WW. I could not figure how to select words with mixed case.

-Trueform

Here is the previous version of the AspWiki code (from Trueform) :


 <% Option Explicit 

Function getWW(s) getWW = Right(s, Len(s) - 2) End Function

function removeHTML(isTeksten) removeHTML=server.htmlencode(isTeksten) end function

function makeHR(isTeksten) makeHR=replace(isTeksten,"----","<hr>") end function

function makepages(isTeksten) 'create a new page for each WW -keyword if it does not exist as a title allready dim sTemp dim oHits dim oHit dim nSted dim nHits dim i dim rsPages

gloRegl.IgnoreCase? = False gloRegl.Global = True gloRegl.Pattern = "WW" Set ohits = gloRegl.Execute(isTeksten) nHits = oHits.Count Do While i < nHits Set oHit = oHits.Item(nHits - 1) nSted = InStr?(oHit.FirstIndex? + 1, isTeksten, " ") If nSted = 0 Then nSted = Len(isTeksten) + 1 sTemp = Mid(isTeksten, oHit.FirstIndex? + 1, nSted - oHit.FirstIndex? - 1) gloRegl.Pattern = sTemp set rsPages=conWiki.execute("select title from wikkipage where title='" & getWW(sTemp) & "'") if rsPages.eof=true then sSql="insert into wikkipage(tekst,title) values('No text yet. Please fill in','" & getWW(sTEmp) & "')" conWiki.execute sSql end if nHits = nHits - 1 loop end function

function hyperlinkize(isTeksten) 'converts each WW prefixed word into an hyperlink. Dim sTemp Dim oHits Dim oHit Dim nSted Dim nHits Dim oHits2 Dim nHits2 Dim i

gloRegl.IgnoreCase? = False gloRegl.Global = True gloRegl.Pattern = "WW" Set oHits = gloRegl.Execute(isTeksten) nHits = oHits.Count Do While i < nHits Set oHit = oHits.Item(nHits - 1) nSted = InStr?(oHit.FirstIndex? + 1, isTeksten, " ") If nSted = 0 Then nSted = Len(isTeksten) + 1 sTemp = Mid(isTeksten, oHit.FirstIndex? + 1, nSted - oHit.FirstIndex? - 1) gloRegl.Pattern = sTemp Set oHits2 = gloRegl.Execute(isTeksten) nHits2 = oHits2.Count isTeksten = gloRegl.Replace(isTeksten, "<a href=""http://localhost/wiki.asp?topic=" & getWW(sTemp) & """>" & getWW(sTemp) & "</a>") nHits = nHits - nHits2 Loop hyperlinkize=isTeksten end function

'******************************************************************** 'main starts here! 'I had to put the code this way to make it work on personal web server ********************************************************************* %>

<html> <body> <% dim glsTopic dim glsMode 'red or edit mode(mode=edit/browse/save) dim gloRegl 'ms regular expression dim conWiki dim rsText dim sSql

glsMode=request("mode") glsTopic=request("topic") set gloRegl=server.createobject("vbscript.regexp") set conWiki=server.createobject("adodb.connection")

if glsMode="" then glsMode="browse" end if if glsTopic="" then glsTopic="main" end if conWiki.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Wiki.mdb;mode= Share Deny None" sSql="select tekst,title from wikkipage where title='" & glsTopic & "'"

set rsText=conWiki.execute(sSql)

if glsMode="edit" then response.write("<form><textarea name=""pagetext"" rows=18 cols=80>" & rsText("tekst") &" </textarea><p><input type=hidden name=topic value=" & rsText("title") &"><input type=hidden name=mode value=save><input type=submit></form>") elseif glsMode="browse" then if rsText.eof=true then response.write("The page you are trying to access are not available.") else response.write "<h1>" & rsText("title") & "</h1><br>" response.write hyperlinkize(makeHR(removeHTML(rsText("tekst")))) response.write "<p><a href=wiki.asp?mode=edit&topic=" & rsText("title") & ">Edit page</a>" end if elseif glsMode="save" then dim sText dim sSql sText=request("pagetext") sSql="update wikkipage set tekst='" & sText &"',copy='" & rsText("tekst") & "' where title='" & rsText("title") & "'" conWiki.execute sSql makePages(sText) response.write "The page has been saved. <a href=wiki.asp?topic=" & rsText("title") & ">look at page</a>" end if %>

</body> </html>


CategoryWikiImplementation


EditText of this page (last edited January 22, 2005) or FindPage with title or text search