Attached is a script which I am able to run successfully on a local
machine, but when I configure it for my web space, it doesn't run.
Here's some info:
I upload the script and chmod 755
There is one directory which must be accessible to the script. I give
that directory "articles/" chmod 777
I use the correct shebang #!rebol -cs
My absolute path is correct.
I call the script using <!--#exec cgi="/cgi-bin/news-site.cgi"-->
I have other REBOL scripts running just fine in this web space, which
means I have the correct binary uploaded and CGI does, in fact, work.
I'm at a loss.
If you care to help me out, change the configuration settings in the
script and then upload the script along with the stylesheet.html
document to a cgi-bin. You will also need to create a readable/
writeable directory named "articles/" in the top directory within the
absolute path of your web space. Then, of course, you will have to send
a couple of e-mails to a pop account.
#!rebol -cs
REBOL [
Title: "News Site"
Date: 07-June-2000
Version: 2.0
File: %news-site.cgi
Author: "Ryan C. Christiansen"
Email: [EMAIL PROTECTED]
Rights: "Copyright (C) Ryan C. Christiansen 2000"
Purpose: {
INPUT:
A CGI executable script which checks a POP e-mail account for new mail, verifies
the e-mail is from a qualified contributor (or deletes the e-mail), converts the
contents of the e-mail object (as understood by REBOL) into a "make object!"
expression saved to a file. These "make object!" expressions are set up as news
articles, including values for headlines, subheadlines, bylines, titles, body text in
paragraphs, reference numbers, file names, and approval status.
OUTPUT:
A CGI executable script which dynamically creates the front page of a
news-oriented web site. Currently prints the following as text/html output...
-html head and meta information.
-stylesheet information.
-banner information.
-news headlines, bylines, articles, and article reference numbers.
}
Comment: {
The "make object!" expressions created by this script are used to create
text/html output which is a news-oriented Web page. The style of the text/html output
is dependent upon a cascading style sheet which is loaded upon execution. Your browser
must support cascading style sheets in order for the script to display the articles
properly by default.
}
History: [
1.0 [ 13-May-2000
{Made scoop.cgi a public release}
"Ryan"
]
2.0 [ 22-June-2000
{Renamed to News Site. New features include:
-articles are now saved as object expressions instead of as
html-formatted text files. Object expressions including the following variables:
'headline
'subheadline
'article-post-date
'byline
'title
'body (with each paragraph as a separate string in a
series of strings)
'reference-number
'obj-file-name
'approval
-the resultant text/html output is now entirely dynamic. New
features include:
-alternating <DIV> styles
-dynamic banner creation
-dynamic html and meta creation
}
"Ryan"
]
]
]
; ---------------------------------------------
; -- CUSTOMIZATION AND CONFIGURATION SECTION --
; ---------------------------------------------
pop-username: "username"
pop-password: "password"
pop-mail-server: "mail.domain.dom"
absolute-path: "absolute/path/"
number-of-headlines: 5
unapproved-article-folder: "articles/"
approved-article-folder: "articles/"
headline-stylesheet: %stylesheet.html
page-title: "The News and Mail"
meta-keywords: {REBOL Internet Messaging Language scripting Web development}
publication-name: "The News and Mail"
copyright-info: {© Ryan C. Christiansen, 2000}
page-width: 480
headlines-width: 480
;-- listing of e-mail addresses which are valid for posting news
reporters: make object! [
total-reporters: 3
reporter1: make object! [
email-address: [EMAIL PROTECTED]
full-name: "Ryan C. Christiansen"
person-title: "Editor-in-Chief"
]
reporter2: make object! [
email-address: [EMAIL PROTECTED]
full-name: "Ryan C. Christiansen"
person-title: "Editor-in-Chief"
]
reporter3: make object! [
email-address: [EMAIL PROTECTED]
full-name: "Ryan C. Christiansen"
person-title: "Editor-in-Chief"
]
]
; -----------------------------------
; -- FUNCTIONS USED IN THIS SCRIPT --
; -----------------------------------
; -- MAKE-POP-URL --
make-pop-url: func [
"build a pop account url"
pop-username [string!] "username"
pop-password [string!] "password"
pop-mail-server [string!] "mail server"
][
pop-url: rejoin [ "pop://" pop-username ":" pop-password "@" pop-mail-server ]
make url! pop-url
]
; -- BREAKDOWN-SUBJECT --
breakdown-subject: func [
"breakdown an e-mail subject field into its parts"
msg [object!] "e-mail message"
][
subject-info: msg/subject
subject-parts: copy []
foreach part parse/all subject-info ":" [
append subject-parts part
]
]
; -- BREAKDOWN-CONTENT --
breakdown-content: func [
"breakdown an e-mail content field into its parts"
msg [object!] "e-mail message"
][
article-info: msg/content
end-of-paragraph: rejoin [{.} newline]
replace/all article-info end-of-paragraph {.~}
content-parts: copy []
foreach part parse/all article-info {~} [ append content-parts trim/lines part
]
]
; -- BREAKDOWN-EMAIL --
breakdown-email: func [
"breakdown an e-mail message object and convert it to an article object"
msg [object!] "e-mail message"
][
subject-pieces: breakdown-subject msg
content-pieces: breakdown-content msg
make object! [
headline: subject-pieces/1
subheadline: subject-pieces/2
body: content-pieces
]
]
; -- TIME-IN-DIGITS --
time-in-digits: func [
"convert the date and time from 'now' into a string of digits"
sun-dial [date!] "the current date and time from 'now'"
][
year: to-string sun-dial/year
month: to-string sun-dial/month
if (length? month) < 2 [insert month "0"]
day: to-string sun-dial/day
if (length? day) < 2 [insert day "0"]
current-time: sun-dial/time
hour: to-string current-time/hour
if (length? hour) < 2 [insert hour "0"]
minutes: to-string current-time/minute
if (length? minutes) < 2 [insert minutes "0"]
seconds: to-string current-time/second
if (length? seconds) < 2 [insert seconds "0"]
rejoin [year month day hour minutes seconds]
]
; --------------------------------------------------
; -- GATHERING NEW INPUT FROM POP E-MAIL ACCOUNTS --
; --------------------------------------------------
pop-account: make-pop-url pop-username pop-password pop-mail-server
mailbox: open pop-account
while [not tail? mailbox] [
msg: import-email first mailbox
for x 1 reporters/total-reporters 1 [
email-path: reform [rejoin ["reporters/reporter" x "/email-address"] ]
reporter-email: load email-path
either find msg/from/1 reporter-email [
now-digits: time-in-digits now
article: breakdown-email msg
byline-path: reform [rejoin ["reporters/reporter" x
"/full-name"] ]
reporter-byline: load byline-path
article: make article [byline: reporter-byline]
title-path: reform [rejoin ["reporters/reporter" x
"/person-title"] ]
reporter-title: load title-path
article: make article [title: reporter-title]
article: make article [reference-number: now-digits]
name-for-object: rejoin [{%} now-digits {.r}]
article: make article [obj-file-name: name-for-object]
article: make article [approval: false]
posted-on: now
article: make article [article-post-date: posted-on]
save-object: reform ["save" rejoin [{%} absolute-path
unapproved-article-folder now-digits {.r}] "article"]
do save-object
wait 1
][
ignore: []
clear ignore
]
]
remove mailbox
]
close mailbox
; ---------------------------------------------------------------
; -- READING FILES AND SENDING TEXT/HTML OUTPUT TO THE BROWSER --
; ---------------------------------------------------------------
read-directory: reform [ "news-directory: read" rejoin [{%} absolute-path
approved-article-folder] ]
do read-directory
news-directory: tail news-directory
file-list: copy []
for file-grab 1 number-of-headlines 1 [
news-directory: back news-directory
file-name: first news-directory
append file-list file-name
]
print "Content-Type: text/html^/"
print rejoin [ {<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">} newline
newline
{<HTML>} newline newline
{<HEAD>} newline newline
{<TITLE>} page-title {</TITLE>} newline newline
{<META NAME="Keywords" CONTENT="} meta-keywords {">}
newline newline
{</HEAD>} newline newline
]
stylesheet: read headline-stylesheet
print rejoin [stylesheet newline newline]
print rejoin [{<BODY>} newline newline]
print rejoin [ {<TABLE width="} page-width {">} newline
{<TR>} newline
{<TD>} newline
]
print rejoin [ {<DIV class="banner">} newline
{<HR>} newline
{<font class="banner">} publication-name {</font>}
newline
{<HR>} newline
{<font class="copyright">} publication-name
{<small><SUP>TM</SUP></small>    } copyright-info {</font>} newline
{<HR>} newline
{</DIV>} newline newline
]
print rejoin [ {<TABLE width="} headlines-width {">} newline
{<TR>} newline
{<TD>} newline
]
div-style: 0
foreach file-name file-list [
read-article: reform ["article-content: do load" rejoin [{%} absolute-path
{articles/} file-name] ]
do read-article
article-temp: make article-content []
div-style: div-style + 1
either even? div-style [
print rejoin [{<DIV class="article2">} newline newline]
] [
print rejoin [{<DIV class="article">} newline newline]
]
print rejoin [ {<P class="headline">}
{<font class="headline">}
article-temp/headline {</font>}
{<BR>} newline
]
print rejoin [ {<font class="subheadline">} article-temp/subheadline {</font>}
{<BR>} newline
]
print rejoin [{<font class="articlepostdate">} {posted on }
article-temp/article-post-date {</font>} newline newline]
print rejoin [ {<P class="byline">}
{<font class="byline">} article-temp/byline
{</font>}
{<BR>} newline
]
print rejoin [{<font class="title">} article-temp/title {</font>} newline
newline]
pieces: length? article-temp/body
for y 1 pieces 1 [
piece-path: reform [rejoin ["article-temp/body/" y] ]
body-piece: load piece-path
print rejoin [ {<P class="body">}
{<font class="body">} body-piece
{</font>} newline newline
]
]
print rejoin [ {<P class="referencenumber">}
{<font class="referencenumber">} {REF: }
article-temp/reference-number {</font>}
{<BR>} newline
]
print rejoin [{</DIV>} newline newline]
]
print rejoin [{</TABLE>} newline newline]
print rejoin [{</TABLE>} newline newline]
print rejoin [ {</BODY>} newline newline
{</HTML>}
]
BeOS Attributes
<STYLE>
div.banner {text-align: center}
div.article {padding: .125in}
div.article2 {padding: .125in; background: "#F9F5E3"; border: outset; border-width:
thin}
p.headline {text-align: left}
p.byline {text-align: left}
p.body {text-align: justify}
p.cutline {text-align: right}
p.referencenumber {text-align: right}
font.banner {font-size: 36pt; color: black; font-family: Times New Roman, Palatino,
serif; font-weight: normal; font-style: normal}
font.copyright {font-size: 14pt; color: black; font-family: Times New Roman, Palatino,
serif; font-weight: normal; font-style: normal}
font.headline {font-size: 18pt; color: black; font-family: Times New Roman, Palatino,
serif; font-weight: bold; font-style: normal}
font.subheadline {font-size: 12pt; color: black; font-family: Times New Roman,
Palatino, serif; font-weight: normal; font-style: italic}
font.articlepostdate {font-size: 8pt; color: black; font-family: Arial, Helvetica,
sans-serif; font-weight: lighter; font-style: normal}
font.byline {font-size: 9pt; color: black; font-family: Arial, Helvetica, sans-serif;
font-weight: lighter; text-decoration: underline; font-style: normal}
font.title {font-size: 7pt; color: black; font-family: Arial, Helvetica, sans-serif;
font-weight: bold; text-transform: uppercase; font-style: normal}
font.body {font-size: 10pt; color: black; font-family: Times New Roman, Palatino,
serif; font-style: normal}
font.cutline {font-size: 7pt; color: black; font-family: Arial, Helvetica, sans-serif;
font-weight: lighter; text-transform: uppercase; font-style: normal}
font.linktomore {font-size: 7pt; font-family: Arial, Helvetica, sans-serif;
font-weight: lighter; text-transform: uppercase; font-style: normal}
font.referencenumber {font-size: 7pt; color: black; font-family: Arial, Helvetica,
sans-serif; font-weight: lighter; font-style: normal}
</STYLE>
BeOS Attributes