summaryrefslogtreecommitdiff
path: root/webgen
diff options
context:
space:
mode:
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
;;