#This code (c) Josh Kopin 2008. You can do whatever you want with it, but you have to tell me about what you use it for! #See the About page for artistic details. #Also, I'm sorry for the mess. I'm no python guru, but this gets the job done (slowly) so I'm just thrilled. #class to hold each word and the words that come after it class Word: "holds a word of revelation and the words that follow it." def __init__(self, word, doors = []): self.word = word self.doors = doors def connect(self, nextword = ""): for d in self.doors: if d == nextword: #weight the word more heavily someday return 0 self.doors = self.doors + [nextword] #search an array of words for a particular word. used to build the doorways between words def indexOf(word, wordList): for i in range(0, len(wordList)): if wordList[i].word == word: return i return -1 #should make an array out of bounds error happen #open the book of revelations (have it in this file) f = open('./revelations.txt', 'r'); #read it into a string text = f.read(); #convert the string to uppercase text = text.upper(); #strip all the non-alphabetic, non-whitespace characters acc = "" for i in range(0, len(text)): if(text[i].isalpha() | ( text[i] == ' ' )): acc = acc+text[i] #chop up the book of revelations into individual words array = acc.split() #build an array that contains each word of revelation only once words = [] for i in range(0, len(array)): done = False for w in words: if array[i] == w.word: done = True break if done == False: words = words + [Word(array[i])] #build the doorways between words for i in range(1, len(array)): words[indexOf(array[i-1], words)].connect(words[indexOf(array[i],words)].word) #make a webpage for each word and its doors (make a folder called revelation wherever you run this script) #also, have an about.html and a lens.css to see everything properly. for w in words: out = open('./revelation/'+w.word+'.html', 'w') out.write(""" """+w.word+"""



Start again from home...

""") out.close() #write index index = open("./index.html", 'w') index.write(""" REVELATIONS

Begin to traverse your revelation...


About the Hypertext Revelation


Keep following the links to trace out a luminous yellow revelation. Be sure to enable javascript and cookies, and try not to use the back button...
Click any word that grabs your fancy.

""") index.close()