From 588e3a9e773588551d8ed0dba0004579761c53a4 Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Wed, 12 Jul 2023 03:19:57 -0500 Subject: [PATCH] Provide an argument for pointing to global plugins. If a pelican site uses the old-style pelicanconf.py, then we auto-insert some plugins. We also need to auto-insert a path to those plugins when running locally (the production install on buildbot is already handled). Thus: add a new --plugins cmdline argument. Then add that argument into devtest/compare.sh --- bin/buildsite.py | 10 +++++++++- devtest/compare.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/buildsite.py b/bin/buildsite.py index 4754828..a393d42 100755 --- a/bin/buildsite.py +++ b/bin/buildsite.py @@ -134,11 +134,18 @@ def start_build(args): else: # The default name, but we'll pass it explicitly. settings_path = os.path.join(sourcepath, PELICAN_CONF) + #print('SETTINGS_PATH:', settings_path) + if args.plugins: + ppaths = (f'PLUGIN_PATHS=["{args.plugins}",' + f' "{sourcepath}/theme/plugins"]') + else: + ppaths = '' # Set currently supported plugins ### this needs to be removed, as it is too indeterminate. with open(settings_path, 'a') as f: - f.write(""" + f.write(f""" +{ppaths} try: PLUGINS += ['toc'] except Exception: # TODO: narrow further to expected Exceptions @@ -458,6 +465,7 @@ def main(): parser_git.add_argument("--listen", help = "Start pelican -l after build (default: %(default)s)", action = "store_true") parser_git.add_argument("--debug", help = "Run pelican with debug flag (show full exception traces)", action = "store_true") parser_git.add_argument("--delete", help = "Delete output directory first", action = "store_true") + parser_git.add_argument("--plugins", help = "Directory for global plugins") parser_git.set_defaults(func=locked_build) parser_dir = subparsers.add_parser("dir", help = "Build source in current directory and optionally serve the result") diff --git a/devtest/compare.sh b/devtest/compare.sh index f869c02..41b61f4 100755 --- a/devtest/compare.sh +++ b/devtest/compare.sh @@ -25,7 +25,7 @@ cd "$source" git checkout "$branch" # Now build the site into /tmp/$project/ -"$bindir/buildsite.py" git --project "$project" --source "$source" --sourcebranch "$branch" || exit 1 +"$bindir/buildsite.py" git --project "$project" --source "$source" --sourcebranch "$branch" --plugins "$absdir"/plugins || exit 1 # Switch to what the current/prior website looks like git checkout asf-site