Introduction
Overview
Installation
•Initiating the Process
Small Site Tutorial
Elements In Depth...
Script Examples...
Platform Specific...
Glossary
History
Support
Downloads
Support the good work:

support email
|
Initiating the Process.
A Sample Script | Additional Parameters | Using sys.path and os.path | Windows Issues
-
A Sample Script
Here is a sample script to initiate the Elements process on a source directory called "htmlSrc". This script lives in the parent directory of the htmlSrc, so the htmlSrc and script are both in the same parent.
import Elements, os, sys
siteSrc = os.path.join(sys.path[0], 'htmlSrc')
siteDest = os.path.join(sys.path[0], "elements")
Elements.process (siteSrc, siteDest)
siteDest can be either an absolute path or a string which will be used as the name of a directory at the same level as the siteSrc directory.
- Additional Parameters
Elements optionally accepts two additional parameters when calling Elements.process(). If the third parameter is present, it is expected to be an html-style path to a directory or page of the site to process. Elements will use all the elements defined in the site (in the siteSrc), but will only build pages within the specified directory.
Also, if the third parameter is present, copyAssets (see Glossary) is automatically set to false—when using the third parameter, if there is already a siteDest present, it will not be deleted, and images will not be copied to the siteDest. (With copyAssets == true, if the siteDest exists, it is deleted and re-built each time Elements.process() is called.)
If the fourth parameter is present, it is expected to an html-style path to the page which should be displayed when processing it finished. It can be a path relative to the top of the site or an absolute url.
import Elements, os, sys
siteSrc = os.path.join(sys.path[0], 'htmlSrc')
siteDest = os.path.join(sys.path[0], "elements")
process = '/platform/windows.html'
display = '/platform/index.html'
Elements.process (siteSrc, siteDest, process, display)
- Using sys.path and os.path
In these examples, the site source files are in the same parent folder as the ElementProcess script. See the Python documentation for info on sys.path and os.path.
- Windows Issues
If you're on Windows, see the Windows page for important issues when building the siteSrc string. There are other ways to build the siteSrc and siteDest strings in the ElementsProcess.py file. Whatever works for you is best. If you hard code the path in a PC, be sure to escape the backslashes in the path with a second backslash.
top
|