Hi Scott,

I briefly glanced at your html4.r script. (Briefly means that I may have
few more ideas when I take a close look).

Some observations:

You use print throughout in your functions. That will significantly slow
down your output to the webserver. Instead, have each function return a
string that contains the stuff you would have usually printed out. I.e in
this example:

Begin: func ["The <HTML> tag."][
        print [<HTML>]
]

use: 

begin: func [] [
  return "<HTML>"
]


In this example:

_head: make object! [
  http-equiv: none
  author: none
  keywords: none
  description: none
  title: none
  style: none
  out: func [][
    print [<HEAD>newline]
    if (not none? http-equiv) [print build-tag [meta http-equiv (http-equiv)]]
                if (not none? author)  [print build-tag [meta name "AUTHOR" content 
(author)]]
                if (not none? keywords)  [print build-tag [meta name "KEYWORDS" 
content 
(keywords)]]
                if (not none? description)  [print build-tag [meta name "DESCRIPTION" 
content (description)]]
                if (not none? style)  [
                        print build-tag [style type "text/css"]
                        print [style newline </STYLE>]]
                if (not none? title)  [print 
[{<TITLE>}title{</TITLE>}newline{</HEAD>}]]
        ]

        end: func [] [print [</HEAD>]]
] ; end of _head object


TRY INSTEAD:

_head: make object! [
  tags: make object! [
    http-equiv: none
    author: none
    keywords: none
    description: none
    title: none
    style: none
  ]
  out: func [/local result meta-block][
    result: make string! 1000
    foreach tag next first tags [
      if get in tags tag [ append result 
         either 
          meta-block: select [
            http-equiv [http-equiv]
            author [name "AUTHOR"]
            keywords [name "KEYWORDS"]
            description [name "DESCRIPTION"]
          ] tag
        [
          build-tag compose/deep [meta (meta-block) content (get in tags tag)]
        ][
          switch tag [
            style [
              rejoin [
                build-tag [tags/style type "text/css"]
                tags/style newline "</STYLE>"
              ]
            ]
            title [
              rejoin ["<TITLE>" tags/title " </TITLE> </HEAD>"]
            ]              
          ]
        ]
        append result newline
      ]
    ]
    return head insert result <HEAD>
  ]
]

To have a complete (albeit trivial) web page let me add the following strings:

content-type: "Content-Type: text/ ^/^/"
end-html: </HTML>
body: "<BODY></BODY"


In your CGI script you the say:


_head/tags/http-equiv: "Whatever"
_head/tags/author: "Elan" 
_head/tags/keywords: {REBOL programming consult web page design software
programs}
_head/tags/description: {Programmer and consultant web page}
_head/tags/title: {Think First Consulting}
_head/tags/style: none

print [
  content-type
  _head/out
  body
  end-html
]

If I print mold _head/out I get:

{<HEAD><meta http-equiv content="Whatever">
<meta name="AUTHOR" content="Elan">
<meta name="KEYWORDS" content="REBOL programming consult web page design
software programs">
<meta name="DESCRIPTION" content="Programmer and consultant web page">
<TITLE>Think First Consulting </TITLE> </HEAD>
}

Perhaps it would be a better idea to use html-head instead of _head? It's
more user friendly and even a novice will immediately understand what you
are talking about.



;- Elan >> [: - )]

Reply via email to