From bd072c48f380aaf25756c72e2d2ed2474ae9e96d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 12 Oct 2014 12:42:11 +0200 Subject: Extracted the static site generation framework into BuildXSLT module * i.e. the `detail` transformation chain of [blog.kummerlaender.eu](https://github.com/KnairdA/blog.kummerlaender.eu/) * added module defintion file `StaticXSLT.xml` * revamped documentation accordingly * added MIT license --- LICENSE | 20 ++++ README.md | 47 +++++++++ StaticXSLT.xml | 6 ++ src/steps/list.xsl | 49 +++++++++ src/steps/plan.xsl | 99 ++++++++++++++++++ src/steps/process.xsl | 250 +++++++++++++++++++++++++++++++++++++++++++++ src/steps/summarize.xsl | 75 ++++++++++++++ src/utility/datasource.xsl | 24 +++++ 8 files changed, 570 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 StaticXSLT.xml create mode 100644 src/steps/list.xsl create mode 100644 src/steps/plan.xsl create mode 100644 src/steps/process.xsl create mode 100644 src/steps/summarize.xsl create mode 100644 src/utility/datasource.xsl diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2c1c5d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Adrian Kummerländer + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..38b2e25 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# StaticXSLT + +…is a [BuildXSLT](https://github.com/KnairdA/BuildXSLT) module implementing a static site generator in XSLT using [InputXSLT](https://github.com/KnairdA/InputXSLT). + +## Overview: + +The `src/steps` directory contains a chain of transformations which are processed by the build system as specified in `StaticXSLT.xml`. + +The first of these transformations `list.xsl` traverses and lists a `source` directory containing various _levels_ depicting the different stages of the actual static site generation process as a base for all further processing. + +Based on the results of the `list.xsl` transformation the next transformation `plan.xsl` schedules a number of different tasks to be processed by `process.xsl`. Examples for these tasks are cleaning a `target` directory, linking files and folders and of course generating transformation stylesheets contained within the various levels of the `source` tree. + +After the various tasks are processed by `process.xsl` the results of all tasks are summarized by `summarize.xsl` to provide the user with a easy to read plain-text output. + +## Usage: + +The `StaticXSLT.xml` file defines a [BuildXSLT](https://github.com/KnairdA/BuildXSLT) module which may be called by _StaticXSLT_ based applications as follows: + +``` + + + + + source + target + + + + [StaticXSLT.xml] + +``` + +In this example the input tree defines both the `source` and `target` directories relative to the working directory of the `ixslt` executable which is required to make use of the external functions provided by [InputXSLT](https://github.com/KnairdA/InputXSLT). The square brackets around the `StaticXSLT.xml` filename are instructing the custom include entity resolver to resolve the given path against the include path array provided to `ixslt`. This means that _StaticXSLT_ based websites may be generated as follows: + +``` +xslt --input make.xml --transformation ../BuildXSLT/build.xsl --include ../StaticXSLT +``` + +## Levels: + +A _level_ is simply a folder within a given `source` directory which may in turn contain a arbitrary number of transformations and source documents inside subfolders. All transformations within these _levels_ are processed by the _StaticXSLT_ transformation chain which handles datasource dependency resolution and preserves the correct result path context. _Levels_ are processed according to their alphabetic order. Subfolders of _level_ directories that do not contain any XSLT stylesheets and non-stylesheet files are automatically symlinked to their appropriate target directory. + +## Data Source and target resolution: + +Every transformation contained in one of the levels contains a `meta` variable defining the required data sources and target paths. This information is read during task processing by the `process.xsl` transformation and used to provide each transformation with the data sources it requires and write the output to the path it desires. This definition of requirements and targets directly inside each transformation is an essential part of how this static site generation concept works. + +The system currently provides a couple of different data source reading modes such as `full` for reading a complete XML file as input, `iterate` for iterating the second-level elements of a given XML source and `expression` for evaluating a arbitrary XPath expression against a given XML file. Target modes include `plain` for writing a the result into a given file at the appropriate target level and `xpath` for evaluating a XPath expression to generate the target path. This XPath evaluation functionality in combination with the `iterate` data source mode is especially helpful in situations where one wants to generate multiple output files from a single transformation such as when generating article pages or the pages of the article stream. diff --git a/StaticXSLT.xml b/StaticXSLT.xml new file mode 100644 index 0000000..80fa071 --- /dev/null +++ b/StaticXSLT.xml @@ -0,0 +1,6 @@ + + src/steps/list.xsl + src/steps/plan.xsl + src/steps/process.xsl + src/steps/summarize.xsl + diff --git a/src/steps/list.xsl b/src/steps/list.xsl new file mode 100644 index 0000000..c70a6bf --- /dev/null +++ b/src/steps/list.xsl @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/steps/plan.xsl b/src/steps/plan.xsl new file mode 100644 index 0000000..653a9ca --- /dev/null +++ b/src/steps/plan.xsl @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/steps/process.xsl b/src/steps/process.xsl new file mode 100644 index 0000000..7b596b6 --- /dev/null +++ b/src/steps/process.xsl @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + success + + + error + + + + + + + + + + + + + + + + + + + + + diff --git a/src/steps/summarize.xsl b/src/steps/summarize.xsl new file mode 100644 index 0000000..0399507 --- /dev/null +++ b/src/steps/summarize.xsl @@ -0,0 +1,75 @@ + + + + + + + Error # + + : + + + + + Generation of " + + " failed. + + + + + + + + + Link from " + + " to " + + " failed. + + + Cleaning of " + + " failed. + + + + + + + + + + + + Tasks processed: + + + Tasks successful: + + + + ▶ Generation + + + successful + + + failed + + + . + + + + + diff --git a/src/utility/datasource.xsl b/src/utility/datasource.xsl new file mode 100644 index 0000000..411086a --- /dev/null +++ b/src/utility/datasource.xsl @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + -- cgit v1.2.3