~stormdragon2976/bashtml

d16bf6154b1f939fe9d50b6f9699f4913adf7104 — Storm Dragon 1 year, 7 months ago 335ffe3
Plugins are mostly working.
1 files changed, 15 insertions(+), 9 deletions(-)

M bashtml.sh
M bashtml.sh => bashtml.sh +15 -9
@@ 285,9 285,13 @@ EOF
}

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

show_help() {


@@ 321,13 325,13 @@ cat << EOF > "$htmlFile"
<meta name="application-name" content="$scriptName" data-postnumber="$postNumber">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
  $( # Meta plugins.
  run_plugins meta $htmlFile)
  run_plugins meta $fileName)
<title>${settings[blogName]}</title>
<link rel="stylesheet" type="text/css" href="bashtml-css/${settings[css]}">
</head>
<body>
  $( # Pre header plugins.
  run_plugins preheader $htmlFile)
  run_plugins preheader $fileName)
<header>
<h1><a href="${settings[blogURL]}">${settings[blogName]}</a></h1>
<p>


@@ 335,7 339,7 @@ ${settings[blogDescription]}
</p>
</header>
  $( # Post header plugins.
  run_plugins postheader $htmlFile)
  run_plugins postheader $fileName)
<!-- END OF HEADER -->
EOF
}


@@ 357,11 361,11 @@ add_footer()
  fi
cat << EOF >> "$htmlFile"
  $( # Plugin placed just above footer.
    run_plugins prefooter $htmlFile)
    run_plugins prefooter $fileName)
<!-- START OF FOOTER -->
<footer>
  $( # Plugin placed inside footer.
    run_plugins footer $htmlFile)
    run_plugins footer $fileName)
<h3>$license $author</h3>
<p>
Powered by <a href="https://gitlab.com/stormdragon2976/bashtml">${scriptName} version ${scriptVersion}</a>


@@ 377,7 381,7 @@ echo "</p>"
fi)
</footer>
  $( # Plugin placed just below footer.
    run_plugins postfooter $htmlFile)
    run_plugins postfooter $fileName)
</body>
</html>
EOF


@@ 451,6 455,8 @@ new_post() {
  local pageName="$(echo "$title" | sed -e 's/^[[:space:]]\+//' -e 's/[[:space:]]\+$//' -e 's/[[:punct:]]//g' -e 's/[[:space:]]\+/-/g')"
  # Page names should also be completely lowercase.
  pageName="${pageName,,}"
  # Get the final file name to pass to plugins.
  fileName="${pageName}.${settings[pageExtension]}"
  # make sure the first line (title) is a heading level 2.
  sed -i -e '1s/^\([[:space:][:alnum:]]\)/## \1/' -e '1s/^#\+/##/' "$mdFile"
  # Add the header: