summaryrefslogtreecommitdiff
path: root/webgen
diff options
context:
space:
mode:
authorPhilipp Schafft <lion@lion.leolix.org>2017-05-01 10:35:12 +0000
committerPhilipp Schafft <lion@lion.leolix.org>2017-05-17 11:45:50 +0000
commitc883e27dd7d85ac35e9158d128656c97c9d6f427 (patch)
tree53414233a604957dcf840165cea2f84f9b4a8e5d /webgen
parentb797dd44c3e3f106566d4f1657d3f8b8708d260f (diff)
Feature: Added basic plugin support
This includes support to run plugins as --preprocessor and a newly added --generate.
Diffstat (limited to 'webgen')
-rwxr-xr-xwebgen43
1 files changed, 43 insertions, 0 deletions
diff --git a/webgen b/webgen
index f447734..880f9ca 100755
--- a/webgen
+++ b/webgen
@@ -47,8 +47,34 @@ PREPROCESSOR='none'
POSTPROCESSOR='none'
LANGUAGE=''
TEMPLATES=''
+PLUGINS=''
# CODE:
+call_plugin() {
+# Args: plugin, mode, input, output, args...
+ _plugin="$1"
+ _mode="$2"
+ _input="$3"
+ _output="$4"
+ shift 4
+
+ "webgenp-$_plugin" --tpl . --mode "$_mode" --input "$_input" --output "$_output" "$@"
+}
+
+generate() {
+ cd $TPLS
+ if [ -z "$PLUGINS" ]
+ then
+ PLUGINS=`cat \#plugin`
+ fi
+
+ for _p in $PLUGINS
+ do
+ echo "Calling plugin $_p"
+ call_plugin "$_p" generate . .
+ done
+}
+
setup() {
if [ -e $TPLS -o -e Makefile ]
then
@@ -216,6 +242,7 @@ list_dependencies() {
show_help() {
echo "Usage: webgen [--preprocessor PP] [--postprocessor OP] [--language LANG] [{+|~|=}][TPL]"
echo " or: webgen [--language LANG] --list-dependencies [{+|~|=}]TPL"
+ echo " or: webgen [--plugin PLUGIN] --generate"
echo " or: webgen --setup"
echo " or: webgen --list"
echo " or: webgen --help"
@@ -232,6 +259,10 @@ do
POSTPROCESSOR="$2"
shift
;;
+ '--plugin')
+ PLUGINS="$PLUGINS $2"
+ shift
+ ;;
'--language')
if [ "$2" = 'default' ]
then
@@ -248,6 +279,10 @@ do
popd > /dev/null
shift;
;;
+ '--generate')
+ generate
+ exit 0
+ ;;
'--setup')
setup
exit 0
@@ -290,6 +325,10 @@ cat_file() {
cpp)
cpp -P -o - -D__TEMPLATE__="\"$_tpl\"" -D__TEMPLATE_CLEAN__="\"$CLEANTPLNAME\"" -D __OUTPUT_FILE__="\"$OF\"" ./"$_file"
;;
+ plugin-*)
+ _plugin=`echo "$PREPROCESSOR" | sed 's/^plugin-//'`;
+ call_plugin "$_plugin" preprocessor "$_file" - --kv template "$_tpl" --kv template-clean "$CLEANTPLNAME" --kv output-file "$OF"
+ ;;
*)
echo "Error: Unknown preprocessor: $PREPROCESSOR" >&2
;;
@@ -308,6 +347,10 @@ postprocessor() {
xmllint-html)
xmllint -o "$_of" --format --html -
;;
+ plugin-*)
+ _plugin=`echo "$POSTPROCESSOR" | sed 's/^plugin-//'`;
+ call_plugin "$_plugin" postprocessor - "$_of" --kv template "$_tpl" --kv template-clean "$CLEANTPLNAME" --kv output-file "$OF"
+ ;;
*)
echo "Error: Unknown postprocessor: $POSTPROCESSOR" >&2
;;