on the Curl Web Content Markup Language

on the Curl Web Content Markup and Programming Language from www.curl.com and www.curlap.com

Sunday, June 26, 2011

Curl page from Ruby CGI

Over at Aule-Browser I have Ruby CGI generating a page with the following:

This web page is Curl web content (no HTML5 or CSS or JavaScript.)


For information about Curl web markup, programming in Curl and Curl open-source: www.Curl.com


Here is the code and markup used:
{curl 7.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{document-style DefaultDocument}
{set-document-properties background={Background.from-string "linen"}, margin=0.75in}
{text This web page is {bold Curl web content} (no HTML5 or CSS or JavaScript.)}
{paragraph

  For information about Curl web markup, programming in Curl and Curl open-source:
  {link target="_blank", href={url "http://www.curl.com"}, www.Curl.com}
}
 \u0000  {br}  || but note that in a Ruby heredoc I must escape my unicode escape
{paragraph Here is the code and markup used:}
{pre
{curl 7.0 applet} ... etc etc ...  }
                                                                                               


but what that does not show is the simplicity of the CGI:
#!/usr/bin/ruby
# curl_01.cgi

puts "Content-Type: text/vnd.curl"
puts

puts "{curl 7.0 applet}",
<<eos
{curl-file-attributes character-encoding = "utf8"}
{applet
    {compiler-directives careful? = true}
}
{document-style DefaultDocument}

{set-document-properties background={Background.from-string "linen"}, margin=0.75in}

{text This web page is {bold Curl web content} (no HTML5 or CSS or JavaScript.)}

{paragraph

  For information about Curl web markup, programming in Curl and Curl open-source:
  {link target="_blank", href={url "http://www.curl.com"}, www.Curl.com}
}
 \\u0000  {br}  || but note that in a Ruby heredoc I must escape my unicode escape

{paragraph
  Here is the code and markup used:}

{pre |"
{curl 7.0 applet}
etc etc
}
eos

Tuesday, June 21, 2011

Curl top-level code and the doc's live code example macro

Curl neophytes are sometimes confused by the use of {value } macros in the examples in the Curl doc's.

I have placed an alternative example style below.

Curl at the top-level is rather like minimalist HTML: if you place a value in a page then the value gets displayed.

But usually a Curl applet is not a {value } expression at the top-level in a .curl file and this adds to unfamiliarity.

The example does include one use of a {value } expression - the macro is used in a {paragraph } text‑proc.

{value } is used in the live code doc's because we are passing our example value into a macro such as {example }.

In my variant example, a {do } expression is used with a top-level global public var instead. The macro {value } is used in {paragraph } as it might be used in a typical applet.

My revision:

The Curl docs on String Files for the scheme curl://some‑text‑resource has a live code {example } using {string-url }

Here is a variant of that example which uses the Curl macro {with-open-streams   do }

The example is not wrapped in a {value } macro as neophytes find this confusing and it is not required for this example at the 'price' of a public global var in the example code.  The text‑proc paragraph preserves our whitespace for our lines as read.

|| Note: we do not need to {set } myinput in this variant of the example.

{def result:StringBuf = {StringBuf}}
{do
    || create a string to be read as a stream
    def mystring:String = "This is some string data I want to read as a stream \nin order to test a macro"

    || Construct a Url under the curl://string directory, using the
    || string we want to read as the filename.
    def myurl:Url = {string-url mystring}

    || Now, read from it as if it were a normal file.
    let myinput:#TextInputStream

    {with-open-streams myinput = {read-open myurl} do

        {until myinput.end-of-stream? do
            {result.concat {myinput.read-one-line}}}

    }
}  

{paragraph text-preserve-whitespace?=true, {value result}}

Wednesday, June 8, 2011

OpenCurl Curl

While I see the expression OpenCurl only twice at http://www.curl.com/, I am seeing it in the readme.txt files of Curl projects at sourceforge.net and have noted the variant OPENCURL at code.google.com/p/zuzu-curl

The failure to protect Curl as a trademark of the M.I.T. spin-off corp has had the sad consequence of confusion with cURL.

The latest Curl library in beta as sourceforge bears the identifier COM.CURL.EXT and not OPENCURL.EXT.

Perhaps when that library goes to a 1.x release we will be closer to Curl 8.0 aka curl9.