cblog
This creates the blog. It gets the details of the blog from its creator and then sets up 3 files.
Note the use of se (sentence) to join "words" (basic logo building blocks) into longer blocks of text. The file operation commands are then used to write the file.
Make sure that you are writing to a extant directory! The easiest way to change the directory code is to open the whole blogwrit.lgo file in notepad and use find/replace in seek and destroy mode. (ie substitute N: for D:)
- blogwrap.htm This is the HTML container for the blog.
- blogtext.txt This is the text content of the blog.
- blogwrap.htm This is the blog content rendered into HTML.
to cblog
local "text
make "username questionbox [What is your Username?][What is your username?]
make "blogname questionbox :username [What is the name of your blog?]
make "blogcont questionbox :blogname [What is your blog about?]
make "title (se "<Title> :blogname ")
make "title1 (se "<h3> :blogname "</h3>)
make "title2 (se "Created "by :username "</p>)
make "blurb1 (se "<p>The "theme "of "this "blog "is :blogcont "</br>)
make "text (se :title1 :blurb1 :title2)
filewriter :text
htmlwriter :text
htmlwrapper :text
end
|
|
filewriter
This writes the basic text file that contains the updated blog. The main thing here is to put the new entries at the top of the file so that they appear at the top of the blog window. Nobody wants to scroll through th eold entries first.
to filewriter :text
openwrite "D:\\logogame\\blog\\blogtext.txt
setwrite "D:\\logogame\\blog\\blogtext.txt
print :text
setwrite[]
close "D:\\logogame\\blog\\blogtext.txt
end
|
htmlwriter
This code writes the blog in HTML format. It inserts the basic blog text into an HTML container so that it can be displayed.
to htmlwriter :text
openwrite "D:\\logogame\\blog\\blogtext.htm
setwrite "D:\\logogame\\blog\\blogtext.htm
print [<HTML>]
print [<HEAD>]
print [</HEAD>]
print [<BODY>]
print :text
print [</BODY>]
print [</HTML>]
setwrite[]
close "D:\\logogame\\blog\\blogtext.htm
end
|
joinblog
This allows subsequent users to add comments to the blog.
Note the do.until command which reads the whole of the present version of blogtext.txt into the blog behind th ecurrent entry. eofp stands for end of file pointer and it changes from false to true when the file reading software reaches the end of the file.
to joinblog
local "text
local "newname
make "newname questionbox [Hello, person adding to this blog.][What is your username?]
local "blurb
make "blurb (se "Hello :newname)
local "content
make "content questionbox :blurb [What do you want to add?]
make "text (se "<p> :content "</br>Added "by: :newname "</p> )
openread "D:\\logogame\\blog\\blogtext.txt
setread "D:\\logogame\\blog\\blogtext.txt
do.until [make "text se :text readlist ][eofp]
close "D:\\logogame\\blog\\blogtext.txt
openwrite "D:\\logogame\\blog\\blogtext.txt
setwrite "D:\\logogame\\blog\\blogtext.txt
print :text
setwrite[]
close "D:\\logogame\\blog\\blogtext.txt
htmlwriter :text
end
|