~stormdragon2976/bashtml

e9b89a21cd6ca6cc74f9dbe659d0af3c318398c6 — Storm Dragon 1 year, 7 months ago aba60d6
Improved run_plugins() function.
3 files changed, 12 insertions(+), 7 deletions(-)

A .gitmodules
A bashtml-plugins
M bashtml.sh
A .gitmodules => .gitmodules +3 -0
@@ 0,0 1,3 @@
[submodule "bashtml-plugins"]
	path = bashtml-plugins
	url = https://gitlab.com/stormdragon2976/bashtml-plugins.git

A bashtml-plugins => bashtml-plugins +1 -0
@@ 0,0 1,1 @@
Subproject commit 61f3e96f48d0bde1495729340008f26304e5e78c

M bashtml.sh => bashtml.sh +8 -7
@@ 292,12 292,13 @@ EOF
}

run_plugins() {
    # $1 is the type of plugin to run.
    # $2 is the page name the plugin is running on, e.g. index.html
    # $1 is the type of plugin to run. 
    local plugins=($(find bashtml-plugins/ -iname "*.$1" 2> /dev/null))
    # We are done with $1, so remove it 
    shift
    unset i
    for i in ${plugins[@]} ; do
        ./$i "$2"
        ./$i ${@}
    done
}



@@ 530,10 531,10 @@ new_post() {
  if [[ ! -e "${pageName}.${settings[pageExtension]}" ]]; then
    cp -- "$htmlFile" "${pageName}.${settings[pageExtension]}"
    build_pages
    echo "$title published successfully."
    # Plugins called after successful post.
    # Plugins called after article is posted.
    run_plugins post
    echo "$title created successfully."
    # Plugins called after article is created.
    # Contains file name and page title.
    run_plugins post "$fileName" "$title"
  else
    echo "A file named ${pageName}.${settings[pageExtension]} already exists."
    echo "Your file is saved at $htmlFile. Please place it manually."