[REBOL] [ANN] Messages 1.0.5
From: ryan::christiansen::intellisol::com at: 23-Apr-2001 17:39
Messages is finally above the 1.0 release number and deservedly so. Using
the single %messages.cgi script, you can now do the following:
1. Display news headlines with a built-in commenting system.
2. Run an open discussion forum.
3. Run an open classifieds section.
4. Create, edit, or delete any set of messages (news, forum, classified,
other) using an encrypted login system which uses a session ID to timeout
administration functions after a specified amount of time.
How does it do this? Messages primarily accepts three variables to
determine what to do next. You pass the variables actionType, messageType,
and messageID via CGI. Following are examples of the types of values these
variables may hold:
-actionType
create-form
display a message creation form
create
create a new message
comment
create a comment, using the mother message's messageID as the
comment's messageType
display
display messages
search
search messages for a keyword
display-comments
display the comments that have been made on a message
edit-form
return the contents of a message in a form for editing the message
edit
edit a message
delete
delete a message
display-login
display the form for logging in to use administration functions
login
login to use administration functions
-messageType
news
forum
classified
other (whatever naming convention you choose)
20010420123456 (the messageID of a parent message, used for comment
messages)
-messageID
20010420123456 (a string of numbers based on the date and time of
creation, also used for naming the XML file which contains the message)
Messages also passes the sessionID variable during administration
functions. The sessionID is also a string of numbers based on the date and
time of sessionID creation or update.
Following are the improvements for this version:
1. Added subroutines which removes displaying redundant search forms and
message creation buttons after a search.
2. Added a classified advertising system, which is essentially a forum
system without the commenting system.
3. Removed some more redundant code.
Plans for future versions:
1. Slim down the code as much as possible.
2. Replace encryption system with a new one.
3. Add commenting support to administration functions.
4. Change all forms from GET to POST (currently using GET for
troubleshooting purposes.)
As always, your comments are greatly appreciated (and even heeded.) The
script follows.
-Ryan
#!rebol -cs
REBOL [
Title: "Messages"
Date: 20-Apr-2001
Version: 1.0.5
File: %messages.cgi
Home: http://www.rebolrepublic.org
Author: "Ryan C. Christiansen"
Email: [norsepower--qwest--net]
Rights: "Copyright (C) Ryan C. Christiansen 1999-2001"
Purpose: {
Create, display, edit, and delete messages using a standard XML
storage format and CSS2-reference <DIV> tags for display. The script is
dependent on the use of .css stylesheets for separate messageTypes.
}
Comment: {
This file %messages.cgi is a single engine for creating,
displaying, editing, and deleting messages. For displaying, editing, and
deleting messages, %messages.cgi must receive the following variables as
CGI input: actionType, messageType, and messageID. For creating messages,
%messages.cgi must receive a REBOL e-mail object! as input or the following
variables as CGI input: actionType, messageType, subject, author, and
content. During message creation, %messages.cgi creates the following
variables: date and messageID.
}
History: [
0.0.9 [4-Jan-2001 "Created %std_msg_func_lib.r based on previous
work." "Ryan"]
0.1.1 [5-Jan-2001 "Added 'display-markup object! functions and
changed file name to %standard-message-function-library.r" "Ryan"]
0.1.2 [8-Jan-2001 "Fixed 'read-message-directory to output file
names including path to directory defined by messageType." "Ryan"]
0.2.1 [9-Jan-2001 "Corrected target 'word in 'write-xml-message.
Added 'create-message object! functions. Corrected 'display-markup to
output string! datatype instead of block! datatype. Negated use of
'message-request-data target variable in 'read-directory-messages. Added
'get-messages-for-display object! functions." "Ryan"]
0.2.3 [10-Jan-2001 "Added 'display-messages function, the
top-level function for displaying messages. Pared down usage in 'Example
portion of header to include only top-most functions. Removed /html-output
function from 'get-messages-for-display object! and removed /html function
from 'display-markup object!" "Ryan"]
0.2.4 [11-Jan-2001 "Changed the order of values (switched 'author'
and 'subject') for the XML grammar in all functions. Changed the 'either
switch in 'display-messages from 'none to the string! datatype 'none'."
Ryan
]
0.2.5 [8-Feb-2001 "Removed incorrect class/id combinations from CSS
font designations. Changed 'display-markup and 'display-messages to markup
content using only CSS class designations instead of class/id
combinations." "Ryan"]
0.2.7 [18-Feb-2001 "Added routine to 'display-messages function
which will display all messages in a directory minus the content value. The
index option is called by sending 'index' as the 'messageID value to
'display-messages." "Ryan"]
0.3.7 [28-Mar-2001 "Changed name of script to %messages.cgi.
Changed e-mail address in header. Updated Comment and Example field in
header. Changed 'display-markup to markup messages using <div> tags instead
of <font> tags. Changed 'display-markup from a function to an object which
includes 'for-reading object including 'with-reference (display messageID
and messageType) and 'without-reference functions, and also 'for-editing
object with 'with-reference function to display a message or messages for
editing, including <FORM> and <INPUT> tags. Added 'edit-message function
for editing messages. Added 'edited-from-cgi function to 'decode-to-object
object! Added 'delete-message function. Added 'message-action-cgi
uber-function." "Ryan"]
0.5.0 [29-Mar-2001 "Added return display for delete, create, and
edit switches in 'message-action-cgi. Changed 'append to 'insert in
'read-directory-messages function, which will make newest messages display
first. Changed radio button value for edit/delete choice from 'choice' to
'actionType'. Fixed the way 'for-editing object functions display form
values and form targets. Added form for creating new messages to
'for-editing object functions. Added 'create-form' action type to switch in
'message-action-cgi function. Added 'display-create-form function to
display message creation form. Added Bohdan Lechnowsky's %encrypt.r
functions. Created 'encrypt-logins function for creating %.bin files
containing usernames and passwords. Added 'display-login-form function to
display login form. Added 'sessionID check to all administration functions
including delete, edit, display-admin, create, and create-form. Added
'sessionID variables to form output in all admin forms. Added sort/reverse
statement in 'read-dir
ectory-messages function in an attempt to make the newest messages display
first. Added if error? try statement to program section script which will
default to displaying messages in the absence of cgi input data." "Ryan"]
0.5.1 [30-Mar-2001 "Changed sort/reverse statement in
'read-directory-messages function so that it sorts the 'message-directory
block instead of the 'message-block block." "Ryan"]
0.5.6 [4-Apr-2001 "Removed HTML headers from 'display-create-form
and 'display-login-form. Removed 'without-reference function in
'display-messages/for-reading object!, making 'display-messages/for-reading
a function replacing the 'with-reference function. Made
'display-messages/for-editing a function replacing the 'with-reference
function within the 'display-messages/for-editing object! All messages will
display references. Changed 'display-admin' switch to 'edit-form' in
'message-action-cgi function. Added parse statement to display 'messageID
and 'messageType in 'display-messages/for-editing function." "Ryan"]
0.6.0 [5-Apr-2001 "Added 'display-comments' switch to
'message-action-cgi, including 'reverse-input function which will make the
messageID the messageType for comment viewing and posting. Added post/view
comments link to 'display-messages/for-editing function. Added error
correction to stylesheet loading, making it load %comments.css on error
(expecting an error when the messageType is messageID after the
'reverse-input operation. Added 'display-comment-form function." "Ryan"]
0.6.6 [6-Apr-2001 "Added 'post-comment-input object to 'comment'
switch, including 'parent-messageID value in 'comment' switch and
'display-comment-form function, allowing a comment's parent to be displayed
after commenting, eliminating an error. Made 'display-messages/for-reading
function an object! containing functions 'for-commenting and
'no-commenting. Updated 'message-action-cgi switch statements for the
change. Added 'parent-message-input object and 'post-comment-reverse-input
object to 'comment' switch for displaying original message and proper
comment input form after comment creation. Added <DIV> tag to post/view
comments link. Added post/view comments links to
'display-messages/for-editing function. Added 'display-comments-edit'
switch to 'message-action-cgi function." "Ryan"]
0.7.4 [11-Apr-2001 "Added 'message-block return statement to
'read-directory-messages function and moved 'sort/reverse statement to sort
'message-block instead of 'message-directory. Added error-checking to
'display' switch in 'message-action-cgi. Added 'make decimal! statement to
'login' switch in 'message-action-cgi. Created 'check-sessionID function to
replace redundant code in 'message-action-cgi. Added 'sessionID-timeout
value in configuration section. Changed 'Edit' and 'Delete' and 'Create
New!' options in 'display-messages/for-editing function to be more
descriptive. Added 'search-messages function. Added 'search' switch to
'message-action-cgi. Added search form to all 'display-messages object!
output." "Ryan"]
0.7.5 [12-Apr-2001 "Moved 'message-block return statement in
'search-messages function. Removed 'search' switch debugging in
'message-action-cgi." "Ryan"]
0.8.1 [18-Apr-2001 "Changed 'insert to 'append in
'read-directory-messages function. Added 'display-search-form function to
replace redundant code in 'display-messages object! Added
'display-create-button function to replace redundant code in
'display-messages/for-editing function. Added 'display-edit-message-button
function to replace redundant code in 'display-messages/for-editing
function. Added 'display-delete-message-button function to replace
redundant code in 'display-messages/for-editing function. Added
'display-comments-link function to replace redundant code in
'display-messages object!" "Ryan"]
0.8.2 [19-Apr-2001 "Added 'display-comments-edit-link function to
replace redundant code in 'display-messages/for-editing function." "Ryan"]
0.9.4 [20-Apr-2001 "Added 'return-div-text function to replace
redundant code in 'display-messages object! Added 'return-messageID
function to replace redundant code in 'display-messages object! Added
'return-messageType function to replace redundant code in 'display-messages
object! Added 'display-messages/forum-style function for using
%messages.cgi to run a forum. Added 'display-create-button-forum function
for creating new messages in 'display-messages/forum-style function. Added
'create-form-forum' switch to 'message-action-cgi function. Added
'display-create-form-forum function for displaying a message creation form
in a forum environment. Added 'create-forum' switch to 'message-action-cgi
function for creating new messages in a forum environment. Added
'display-comments-forum-link function for using the commenting system
within a forum environment. Added 'display-comments-forum' switch to
'message-action-cgi function for using the commenting system within a forum
environment. Added 'display-com
ments-form-forum function for displaying a commenting system form within a
forum environment. Added 'comment-forum' switch to 'message-action-cgi for
creating comments within a forum environment. Added
'display-search-form-forum function to allow searches within a forum
environment. Added 'search-forum' switch to 'message-action-cgi function to
return forum-style message display after a search." "Ryan"]
1.0.5 [23-Apr-2001 "Made all 'display-messages object! functions
into object! datatypes including 'with-search-form and 'without-search-form
sub-functions. Added /with-search-form and /without-search-form paths to
switch statements in 'message-action-cgi function. Removed
'display-create-button-forum function from
'display-messages/forum-style/without-search-form function and renamed
'display-messages/forum-style/without-search-form function to
'display-messages/forum-style/without-search-and-create. Renamed
'display-messages/forum-style/with-search-form function to
'display-messages/forum-style/with-search-and-create. Changed paths in
'message-action-cgi to correspond with new function naming conventions.
Added 'display-create-button-forum function to 'search-forum' switch in
'message-action-cgi. Added 'classified-style object! within
'display-messages object! which includes 'with-search-and-create and
'without-search-and-create functions. Added 'classified' switch to
'message-action-cgi function. Ad
ded 'display-create-form-classified function. Added
'display-create-button-classified and changed all references to
'display-create-button-forum in 'display-messages/classified-style object!
to 'display-create-button-classified. Added 'create-classified' switch to
'message-action-cgi. Added 'display-search-form-classified function and
changed all references to 'display-search-form-forum in
'display-messages/classified-style object! to
'display-search-form-classified. Removed redundant 'time-in-digits function
code from decode-to-object! object! Added 'create-form-classified' switch
to 'message-action-cgi." "Ryan"]
]
Example: {
Decode CGI input and create, display, edit, or delete message(s).
This is the script's uber-function for CGI.
message-action-cgi
To decode CGI input from the web server:
cgi-input: retrieve-user-data
Using decoded CGI data, write XML standard message file to
directory determined by messageType.
create-message/from-cgi cgi-input
Using an e-mail message or newsgroup message in the form of a
REBOL e-mail object!, write XML standard message file to 'email' directory.
create-message/from-email email-message
Convert decoded CGI data into the standard message object!,
overwriting a previously created message.
edit-message cgi-input
Delete a previously created message.
delete-message cgi-input
Using decoded CGI data containing messageID and messageType
variables, either display a single message (messageID specified), a
directory of messages (messageID = "none"), or an index of messages
(messageID = "index") to the browser, including displaying the messageID
and messageType to the reader.
display-messages/for-reading/with-reference cgi-input
Using decoded CGI data containing messageID and messageType
variables, either display a single message (messageID specified), a
directory of messages (messageID = "none"), or an index of messages
(messageID = "index") to the browser, not displaying the messageID nor the
messageType to the reader.
display-messages/for-reading/without-reference cgi-input
Using decoded CGI data containing messageID and messageType
variables, either display a single message (messageID specified), a
directory of messages (messageID = "none"), or an index of messages
(messageID = "index") to the browser, including displaying the messageID
and messageType to the reader, in an HTML form for editing.
display-messages/for-editing/with-refer