Languages stored in the Content Database

A website's actual content is stored in category, node and template elements and may contain whatever the database can store, of course. Maxscape works with source code, and the Maxscape Library supports plain text, XML, HTML/CCS, Javascript, Maxscript and embedded or executed Perl scripts using the run-time objects. Media files are generally stored on the file system.

Content Database Template Example.
<--
Template main element with embedded Perl variables and object member function calls
using Maxscape's run-time system objects. Note, that category, template and page
elements are stored in the application server's content database. 
-->

<html>
<head>

$::WebServer->{'WebServer.default.content-type'}

@{[ $Page->ElementContent (Name => 'Category.Meta') ]}
@{[ $Page->ElementContent (Name => 'Page.Meta') ]}

<title>@{[ $Page->ElementContent (Name => 'Title') ]}</title>

<style type="text/css">
@{[ $Page->ElementContent (Name => 'Category.CSS') ]}
@{[ $Page->TemplateContent (Name => 'Template.CSS.Float', Type => 'parsed') ]}
@{[ $Page->ElementContent (Name => 'Page.CSS.Float') ]}
@{[ $Page->TemplateContent (Name => 'Template.CSS.PulldownMenu', Type => 'parsed') ]}
</style>

<script type="text/javascript">
@{[ $Page->ElementContent (Name => 'Category.Javascript') ]}
@{[ $Page->ElementContent (Name => 'Page.Javascript') ]}
</script>
</head>

<body>
@{[ ($Page->ElementContent (Name => 'Page.Header') ?
       $Page->ElementContent (Name => 'Page.Header')
     :
       $Page->TemplateContent (Name => 'Template.Page.Header')
     )
]}

<div class="PageRow">
  <div class="PageColumnMiddle">
    <main>

    @{[ $Page->simpleElementLoop () ]}

    </main
  </div>
</div>

@{[$Page->ElementContent (Name => 'Page.Trailor') ]}

</body>
</html>

The above text can be fetched from the content database and be evaluated by the following function:

# Perl code to parse the above template text.
...
sub parseText {
  my ($Page) = shift;
  my ($Text) = @_;

  $Text =~ s/([\%])/\\%/gs;

  $Text = eval (qq%{ return qq{$Text}; }%);
  if ($@) {
    return $Page->setError (Text => "parseText eval error: $@ in page $Page->{Category}/$Page->{Page}.");
  }
  return $Text;
}
...

The Content Database is more a place to intelligently store source code parts for structuring, reusablility, seperating content from design, to avoid redundancies and allow maintainabillity. It is not a tool for WYSIWYG HTML design, because of the multi language content (HTML, Javascript, Perl, ..). If you enjoy to write HTML source code, like me, you are fine, else get your HTML from elsewhere or implement your design with your favorite tools.

Maxscape is mostly written in Perl

Dynamic generation of web pages is mostly about text processing! Consequently, it is often better to embed program variables and function calls in an HTML text, than to write software functions, embedding the text to be generated. Fortunately, this is an intrinsic feature of Perl, thanks to the 'eval' function and Perl's sometimes 'cryptic' syntax.

Languages, which needs to be compiled and languages, which do not allow to embedded software, are out, if you do want to have this feature. Therefor and for other reasons, the server site programing and scripting language is Perl. Perl is a, if not the appropriate language for web server programming, because of many more reasons.
Perl is:

  • a very fast interpreter language written in C
  • has a powerful text processing engine and regular expressions
  • is tested and 100% stable
  • is portable, wide spread and well supported
  • has a huge number of modules at the CPAN archives
  • has a FCGI and a DBI/DBD database interface

Embedding Program Variables and Function Calls in Database Fields

Being able to embed software in a text, we'll take it a step further and store (HTML) text with the embedded software in a file or a rational database table field. Now, the runtime system can fetch the file/field, evaluate the variables within the text and execute the embedded (member) functions calls.

So, with Maxscape you can freely mix (HTML) text and embedded (application) software within files, as well as pages, elements, templates and fields stored in a rational database.

Next ∙ Previous ∙ Top ∙ Join ∙ Contact © Maxscape