[Tutor] further wikinessismlogy
Kirk Bailey
idiot1 at netzero.net
Thu Aug 7 21:24:03 EDT 2003
OK, got some stuff to toss out for fun and amusement:
BEWARE WORD WRAP!
# follows is a function/object/thingie that determines if a word
# is a WikiWord. WikiWords are to be treated as LINKS to pages, and
# are constructed as 2 words runtogether (like that was) with the First
# Letter Of Each word RUNTOGETHER. ALL CAPITAL words are NOT to be treated
# as wikiwords. Therefore, it must preserve some sense of prior state...
# I *THINK* the following is a (simple?) state machine...
def iswikiword(word): # test to see is a wikiword
caps='ABCDEFGHIJKLMNOPQRSTUVWXYZ' # define capitalletters
prior=0 # set inital state for flags
count=0 # wikiwords have 2+ transitions-count!
for letter in word: # examine each letter
if letter in caps: # if it IS a capital letter,
prior=1 # store that state
else: # and if not,
if prior==1: # but the previous one WAS,
prior=0 # reset the flag,
count=count+1 # anc count the transition!
else: # otherwise,
pass # chill out.
if count > 1: # ok, the results are in;
return 1 # if there are 2+, it is. Say so.
else: # and if not,
return 0 # say so.
#
# now we bend string.find into a tool to generate boolian logic values.
# in python, a 0 (ZERO) is a 'no', and ANY OTHER VALUE is a 'yes'
def isin(str,substr): # this thing is a general tool.
return 1+string.find(str,substr) # it returns a logical 1 or 0
#
#
# now we can use it in other tools.
def ishyperlink(word): # uses previous to detect a hyperlink
if isin(word,'http://'): # makes top level code simper to read
return 1
else:
return 0
#
#
# we use this tool to create wikilinks- html links in the wiki to
# a specific page in the wiki.
def makewikilink(word): # makes wikiwords into hyperlinks to the wiki
link='a \
href="'+webprefix+domainname+'/cgi-bin/wikinehesa.py/'+word+'">'+word+'</a>'
return link # look out, word wrap!
#
#
# But some links go elsewhere, and are structured differently.
# these already contain the web prefix needed IN THEM, so we do not add
# it. Instead, we exault it so it will work.
# oh- as a security precaution, we removed <anglebrackets> prior to this.
def makehyperlink(word): # this converts url's into working links.
link='<a href="'+word+'">'+word+'</a>'
return link
#
#
This wiki WILL see the light of day. Someday.
Giggling insanely in the family compscilab, I remain;
Kirk D Bailey
+ think +
http://www.howlermonkey.net +-----+ http://www.tinylist.org
http://www.listville.net | BOX | http://www.sacredelectron.org
Thou art free"-ERIS +-----+ 'Got a light?'-Promethieus
+ think +
Fnord.
More information about the Tutor
mailing list