Can you help me with a server-side include problem?

I have a REBOL .cgi script which executes from an index.shtml file. The 
script checks a POP account for new mail, converts the contents of the 
mail strings into HTML files, then prints text/html to the browser. The 
text/html it prints to the browser is a list of include statements 
intending to include the contents of the five most recent files in a 
directory, as such...

<!--#include virtual="/articles/20000510164353.html"-->
<!--#include virtual="/articles/20000510164352.html"-->
<!--#include virtual="/articles/20000510164351.html"-->
<!--#include virtual="/articles/20000510164350.html"-->
<!--#include virtual="/articles/20000510164349.html"-->

The index.shtml file is not "including" the articles mentioned in the 
include statements. They do show up fine when I view source from the 
resulting index.shtml page after the page has been rendered in the 
browser. I know "include" is working because it is including other 
files, albeit not from include statements generated by the .cgi script.

I think the problem lies in the fact I am returning include statements 
to the browser, which somehow are not executed as includes.

Obviously, I'm doing something wrong. Can you correct me?

The script follows.

Thanks.

-Ryan


#!rebol -cs

REBOL []

reporters: [
        [
                "work"
                email.address [ [EMAIL PROTECTED] ]
                full.name [ "Ryan C. Christiansen" ]
                reporter.title [ "Editor-in-Chief" ]
        ][
                "home"
                email.address [ [EMAIL PROTECTED] ]
                full.name [ "Ryan C. Christiansen" ]
                reporter.title [ "Editor-in-Chief" ]
        ][
                "work extended"
                email.address [ [EMAIL PROTECTED] ]
                full.name [ "Ryan C. Christiansen" ]
                reporter.title [ "Editor-in-Chief" ]
        ]
]

mailbox: open pop://username:[EMAIL PROTECTED] ; CHANGED FOR 
EXAMPLE

while [not tail? mailbox] [

        msg: import-email first mailbox

        foreach person reporters [
                if info: find person 'email.address [
                        either find msg/from/1 info/2 [

                                new-article: make string! 10000
                                append new-article {<DIV class="article2">}

                                subject-info: msg/subject
                                subject-parts: []
                                foreach part parse/all subject-info ":" [
                                        append subject-parts part
                                ]

                                headline: first subject-parts
                                append new-article rejoin [{<P class="headline"><font 
class="headline">} headline {</font><BR>}]

                                subheadline: second subject-parts
                                append new-article rejoin [{<font class="subhead">} 
subheadline {</font>}]

                                temp-one: find person 'full.name
                                byline: temp-one/2
                                append new-article rejoin [{<P><font class="byline">} 
byline {</font><BR>}]

                                temp-two: find person 'reporter.title
                                title: temp-two/2
                                append new-article rejoin [{<font 
class="bylinetitle">} 
title {</font>}]

                                article-info: msg/content
                                end-of-paragraph: rejoin [{.} newline]
                                replace/all article-info end-of-paragraph {.<BR><BR>}
                                end-of-paragraph2: rejoin [{.} crlf]
                                replace/all article-info end-of-paragraph2 {.<BR><BR>}
                                append new-article rejoin [{<P class="news"><font class
="bodytext">} article-info {</font>}]

                                append new-article {</DIV>}

                                current-time: now/time

                                year: to-string now/year

                                month: to-string now/month
                                if (length? month) < 2 [insert month "0"]

                                day: to-string now/day
                                if (length? day) < 2 [insert day "0"]

                                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"]

                                file-name: rejoin [year month day hour minutes seconds]

                                complete-file-name: rejoin [file-name {.html}]

                                write-file: reform ["write" rejoin [{%/absolute/path/
articles/} complete-file-name] "new-article"] ; CHANGED FOR EXAMPLE

                                do write-file

                                wait 1

                                ][
                                
                                ignore: []
                                clear ignore
                        ]
                ]
        ]

        remove mailbox

]

close mailbox



news-directory: read %/absolute/path/articles/

news-directory: tail news-directory

file-list: []
for file-grab 1 5 1 [
        news-directory: back news-directory
        file-name: first news-directory
        append file-list file-name
]

list-of-includes: []
foreach file-name file-list [
        include-statement: rejoin [{<!--#include virtual="/articles/} file-
name {"-->}]
        append list-of-includes include-statement
]

print "Content-Type: text/html^/"

foreach statement list-of-includes [print statement]

Reply via email to