Config file elements
- Overview of building process
- Template, section and content file placeholders
- Content file structure and commands
- Config file tags
- Appendix A: Resolving target filenames
- Appendix B: Flow of commands resolution
Config file is a place where you set the parameters of assembling your site. Here you define source and target folders, template files, your entities and macros etc. When calling the osb.php script which does all the work of assembling the site you pass a link to this file from which it loads all the defined parameters.
When setting source and target folders you may specify path as absolute or relative to your config.xml file. See source, target tags.
See template tag for a way to define different templates, suffix tag to change the default .src extension and Appendix A for a primer on resolution of file names.
Here is a sample config.xml file which closely resembles the default parameters for most tags. You may use it as a reference for elements description.
<site title="Test Site">
<source>test</source>
<target>/Users/stas/Sites/test</target>
<template>base/main.html</template>
<template suffix=".help">base/help.html</template>
<template suffix=".home">base/home.html</template>
<template suffix=".0">base/empty.txt</template>
<entity name="w1">640</entity>
<entity name="w2">800</entity>
<entity name="promo-link" filename="base/promo.html" />
<macro name="tr" params="2"><![CDATA[<tr><td>$1</td><td>$2</td></tr>]]></macro>
<access-rights grant-section="grants" role-mask="osb_%s" schema="osb">roles</access-rights>
<exec suffix=".php" exclude=".nocode">d:\zend\zendenc --delete-source %s</exec>
<ver-file>ver.txt</ver-file>
<log-file>build.log</log-file>
<!-- default values follow -->
<sections>_sections.xml</sections>
<suffix action="copy">.html;.htm;.shtml;.css;.js;
.jpeg;.jpg;.gif;.png;.ico;.swf;
.php;.phtml;.php3;.pl;.java;.asp;.asx;
.zip;.gz;.tar;.bz2;
.doc;.xls;.pdf;.xml;.txt
</suffix>
<suffix action="build" default="html">.src</suffix>
</site>
- access-rights
This element contains the name of section responsible for granting different kind of SQL permissions to the role. File which name is constructed by applying this value into the
section-maskis located in each folder and scanned through for the presence of lines defining the grants. The new section file is then created with correct SQL lines used to create the corresponding SQL role and grant it the rights to the listed objects in the specified schema. Schema is specified by theschemaattribute, role name is created by applying current folder name torole-maskattribute and the new section file name is created by applyinggrant-sectionattribute tosection-maskelement.Consider the following section file
_roles.cfgwith role description:UPDATE Employees SELECT ViewTrackEmployees ViewRolesList Qualification Qualification2 ViewSubcategories Makers # track_sticker ViewTrackReceipts ViewTrackWares Employees PriceList2 WaresPayment ViewPartsUsed ViewPartsNeeded WaresList MakersOrders PartsGiven ViewServicesUsed ClientCalls EXECUTE AddNeededSupplement GetSupplement SYSTEM OSBDBA ENDThen the resulting file
_grants.cfgwill contain the following SQL (based on values from the sampleconfig.xmlfile above and supposing current folder name isstats):create role osb_stats not identified; grant CREATE SESSION to osb_stats; grant UPDATE on osb_schema.Employees to osb_stats; grant SELECT on osb_schema.ViewTrackEmployees to osb_stats; grant SELECT on osb_schema.ViewRolesList to osb_stats; grant SELECT on osb_schema.Qualification to osb_stats; grant SELECT on osb_schema.Qualification2 to osb_stats; grant SELECT on osb_schema.ViewSubcategories to osb_stats; grant SELECT on osb_schema.Makers to osb_stats; grant SELECT on osb_schema.ViewTrackReceipts to osb_stats; grant SELECT on osb_schema.ViewTrackWares to osb_stats; grant SELECT on osb_schema.Employees to osb_stats; grant SELECT on osb_schema.PriceList2 to osb_stats; grant SELECT on osb_schema.WaresPayment to osb_stats; grant SELECT on osb_schema.ViewPartsUsed to osb_stats; grant SELECT on osb_schema.ViewPartsNeeded to osb_stats; grant SELECT on osb_schema.WaresList to osb_stats; grant SELECT on osb_schema.MakersOrders to osb_stats; grant SELECT on osb_schema.PartsGiven to osb_stats; grant SELECT on osb_schema.ViewServicesUsed to osb_stats; grant SELECT on osb_schema.ClientCalls to osb_stats; grant EXECUTE on osb_schema.AddNeededSupplement to osb_stats; grant EXECUTE on osb_schema.GetSupplement to osb_stats; grant OSBDBA to osb_stats;
grant-section
section name to create and populate with SQL instructions granting rights to the current role. This name will be incorporated intosection-maskby means ofsprintffunction to get the resulting section file name. In the above example:grant-sectionisgrants,section-maskis_%s.cfg, so resulting file with SQL code is_grants.cfg.role-mask
attribute defining mask into which the name of current folder is inserted to get a role name for this folder (example above: if dir name isstatsand mask isosb_%sthen the name of the SQL role becomesosb_stats). Since element value will be processed by sprintf function with one parameter specifying section name, the value must contain one%splaceholder for it. All other%symbols must be prefixed with another%.schema
default SQL schema to whose objects the rights are granted (example above: schema isosb_schemaso each mentioned SQL object is prefixed with this name, likeosb_schema.ClientCalls).
- delimiter
defines the delimiter character that separates titles in content files or values of different lists in configuration file (default is tab character
\tfor titles and;for lists).group
identifies the list containing values to separate. The valuesuffixdefines the delimiter for a list of suffixes to build / copy (seesuffix). If omitted then the delimiter is defined for titles in content files.
- entity
definition of site-wide entities. OSB entities are used in template, section and content files just like other HTML-style entities (wrapped in
∧symbols, like©or&). Entity value may be defined directly inconfig.xmlor in external file in which case file name must be provided with thefilenameattribute. May not contain macros. If contains other entities the following apply: entities are processed in order in which they were defined inconfig.xmlfile. If entity A contains entity B in it then A must be declared before B. As a rule of thumb define complex entities first and atomic entities then.name
defines the name of the entity. The entity will be accessed by its name so that if it is namedpromoits value is retrieved in content, section and template files with&promo;.filename
sets the name of the file containing entity value. Path may be absolute or relative toconfig.xml. May be used in situations with large values.For example, we may consider to define a promotional link at the end of each page of our site (see below). We know that the text for the link will be the same on each page. At the same time we want flexibility in the sense that when we decide to change that text it must automatically change on all corresponding pages. We create file
promo.htmlin ourbasefolder with the text of the entity. Then inconfig.xmlwe include the following line which creates the entitypromoand reads its content from filebase/promo.html:<entity name="promo-link" filename="base/promo.html" />
See also:
macro.
- exec
specifies a program to execute each time a conforming file is updated/copied to the target folder. Since element value will be processed by
sprintffunction with one parameter specifying target file name, the value must contain one%splaceholder for it. All other%symbols must be prefixed with another%. Conforming files are restricted by element arguments. exec call is executed on the conforming target file. The return status of the program is analyzed to define whether it ended successfully.suffix
defines target file extension for conforming files. If extension equals tosuffixand file is not denied byexcludeargument it is considered conforming.exclude
if one of source file extensions is equal toexcludevalue this extension is stripped from target file name and the target file is considered non conforming even if its extension equals tosuffix.
- host
defines remote host parameters. Used by OSB FTP Uploader and OSB Sitemap Generator.
id
sets host identifier to use when launching FTP Uploader.user
defines username for connection.pass
defines password.path
defines base directory on host used to upload files.Example:
<host id="ftp1" user="uploader" pass="00000" path="/www">ftp.myhost.com</host>
- log-file
defines a filename for the log file which tracks the names of updated/copied files. Log is not written if no files were updated/copied. If
ver-fileelement is specified version info is also logged. Path may be absolute or relative toconfig.xml.
- macro
defines site-wide macro command. Macros are more powerful entities which may use parameters to provide changing content. Parameters for the macro are stored in curly braces and
$1,$2, ...,$nplaceholders in macro content are replaced by corresponding parameters at runtime. OSB macros are used in template, section and content files and are of the form¯o{param1}{param2}{param3};where the name of the macro and the number of parameters is defined by element arguments. Macro value may be defined directly inconfig.xmlor in external file in which case file name must be provided with thefilenameattribute. May contain entities. If contains other macro the following apply: macros are processed in order in which they were defined inconfig.xmlfile. If macro A contains macro B in it then A must be declared before B. As a rule of thumb define complex macros first and atomic macros then.name
defines the name of the macro. The macro will be accessed by its name so that if it is namedtrand hasparamsvalue set to2its value is retrieved in content, section and template files with&tr{cell 1}{cell 2};.params
defines the number of parameters available to the macro. When using macro in source files exactly the same number of parameters must be provided in curly braces. Otherwise the macro will not be recognized. The number of parameters is unlimited.$1,$2, ...,$nplaceholders are used in macro content to determine the placement of corresponding parameters.filename
sets the name of the file containing macro value. Path may be absolute or relative toconfig.xml. May be used in situations when defining large macro values.An example that demonstrates the
trmacro from above is:<macro name="tr" params="2"><![CDATA[<tr><td>$1</td><td>$2</td></tr>]]></macro>
Since our config file is an XML document we have to use the CDATA form to put HTML tags in macro content. Otherwise you'll have to use
<->pairs around all the tags. If macro content is significantly larger than the one line example or you just want to separate macros bodies from configuration instructions you may prefer to provide thefilenameargument instead of incorporating macros intoconfig.xmlfile.See also:
entity.
- section-mask
specifies the look of section files. Since element value will be processed by
sprintffunction with one parameter specifying section name, the value must contain one%splaceholder for it. All other%symbols must be prefixed with another%. Section names are thus restricted to filesystem allowed characters. For example, ifsection-maskis defined as_%s.cfgthen section namedsubmenu-level-2will reside in file_submenu-level-2.cfg.DEPRECATED See also:
sections.
- sections
specifies the name of an xml file containing sections definitions for the current directory. Default value is
_sections.xml. File structure is as follows:<sections> <section name="menu"><a href="&.root;/">Home</a> || <a href="links.html">Links</a></section> <section name="home"><![CDATA[<a href="index.html">Home</a>]]></section> <section name="home-a">Home</section> <section name="links"><![CDATA[<a href="links.html">Links</a>]]></section> <section name="links-a">Links</section> </sections>
Each section is identified by
nameattribute. In the above exampleHome :: Download :: Introduction :: Tutorial :: Reference :: Support :: Linksis placed in the template file to indicate the position of the menu for all files that will use this template. Then when OSB visits the directory containing this sections file themenusection is translated into the following:<a href="&.root;/">Home</a> || <a href="links.html">Links</a>. Sincehomeandlinksare also defined in the file this construction is resolved to the form<a href="index.html">Home</a> || <a href="links.html">Links</a>. This representation replacesHome :: Download :: Introduction :: Tutorial :: Reference :: Support :: Linksplaceholder in the template.Source file
links.srcmay contain command.replace(links,links-a). In this case the wholeHome :: Download :: Introduction :: Tutorial :: Reference :: Support :: Linksplaceholder will be replaced by<a href="index.html">Home</a> || Links. Guess why.
- site
a container element for
config.xmlfile.title
attribute contains current site title and will show in a list of config parameters while building site. Site title may be accessed through a.site-titleplaceholder in template, section and content files.
- sitemap
defines the name for a sitemap file. This file will be generated in target folder. If omitted the sitemap file will not be generated.
id
the unique id that identifies sitemap definition. This Sitemap id is provided when launching OSB.url
defines the site url as visible from the user's perspective. The address must identify the directory containing document root (whether the site root or a site subfolder).Example:
<sitemap id="sm1" url="http://www.myhost.com/">sitemap.xml</sitemap>
- source
defines the root of source structure which will be processed. May be absolute or relative to
config.xml. The files in the source tree are content and section files which are copied/built into the target. The folder structure from the source will be copied into the target. Section files in each subfolder correspond to this subfolder only.See also:
target.
- suffix
element that defines which action will be taken on file depending on file extension. Element content is a list of extensions each starting with a dot. The list of action includes
copy,buildandsitemap. If omitted, default values for corresponding actions are used (see the sampleconfig.xmlfile above). If provided, the list of specified extensions overwrites the default list for specified action. Files whose extensions do not appear insuffixelements are not processed (do not appear in target or are not included in sitemap).action
this attribute defines the action taken on source or target file if its extension is in the list. The value ofcopystates that the file will be copied from the source to the target directory as is without modification if source is newer than the target. If the value isbuildthe element defines primary extensions for content files which will be built from source to target folders if content file is newer than the target or if corresponding section or template files are newer. The valuesitemapdefines the list of target file extensions to be included into the sitemap file.Default list for
build:.src
Default list for
copy:.html;.htm;.shtml;.css;.js; .jpeg;.jpg;.gif;.png;.ico;.swf; .php;.phtml;.php3;.pl;.java;.asp;.asx; .zip;.gz;.tar;.bz2; .doc;.xls;.pdf;.xml;.txt
Default list for
sitemap:.html;.htm;.shtml; .php;.phtml;.php3;.pl;.java;.asp;.asx;.cgi; .doc;.xls;.pdf; .xml;.txt
default
used only in combination withbuildaction. Defines target file extension for content file in case it only provides a primary extension. For example, if set tohtmthen all content files of formname.srcwill be translated toname.htmin target. Default ishtml.Example:
<suffix action="build" default="php">.src;.psrc</suffix>
Here we specify that source content files may have
.srcor.psrcprimary extensions and if the content file name is in thescript.psrcform the resulting target file name will bescript.php.
- target
defines the root of target structure to be built. May be absolute or relative to
config.xml. The files in the target tree appear during the build process and directory structure is identical to the source tree. The target file is only updated if it is older than the corresponding source content file, one of the section files for the current folder or the template file used for the content file.See also:
source.
- template
element defining file name for the template holding the common page layout. In case of non-default template also provides content file secondary extension. Path may be absolute or relative to
config.xml. The default template is required. Non-default templates are optional.suffix
attribute defines content file secondary extension for non-default template. Omit when declaring the default template.See also:
suffixelement for the way to change the content file extension used for default template.
- ver-file
provides file name of a one-line text file that handles site versioning. The number at the end of the first line (before the last dot) is incremented on each build if at least one target file were updated or created. The full content of version file is available trough
.verand.versionplaceholders in template, section and content files. Path may be absolute or relative toconfig.xml.Example version file:
Version 3.1.0.371
In this case the last number in the string is considered 371 and this number will be incremented to 372 on the next build if at least one file in the target tree is updated. The new version file will be:
Version 3.1.0.372