Take list of files to edit as args

pull/228/head
Daniel Wagner-Hall 9 years ago
parent 7b63c042fb
commit 60127de1e3

@ -1,26 +1,27 @@
#!/bin/bash -eu
if [[ $# != 1 || ! -d $1 ]]; then
echo >&2 "Usage: $0 include_dir"
if [[ $# == 0 || ! -d $1 ]]; then
echo >&2 "Usage: $0 include_dir file_to_replace..."
exit 1
fi
HEADER="$1/head.html"
NAV_BAR="$1/nav.html"
FOOTER="$1/footer.html"
include_dir="$1"
shift
for f in "$1"/{head,nav,footer}.html; do
HEADER="${include_dir}/head.html"
NAV_BAR="${include_dir}/nav.html"
FOOTER="${include_dir}/footer.html"
for f in "${include_dir}"/{head,nav,footer}.html; do
if [[ ! -e "${f}" ]]; then
echo >&2 "Need ${f} to exist"
exit 1
fi
done
files=gen/*.html
perl -MFile::Slurp -pi -e 'BEGIN { $header = read_file("'$HEADER'") } s#<head>#<head>$header
<link rel="stylesheet" href="//matrix.org/docs/guides/css/docs_overrides.css">
#' ${files}
#' "$@"
perl -MFile::Slurp -pi -e 'BEGIN { $nav = read_file("'$NAV_BAR'") } s#<body># <body class="blog et_fixed_nav et_cover_background et_right_sidebar">
<div id="page-wrapper">
@ -29,7 +30,7 @@ perl -MFile::Slurp -pi -e 'BEGIN { $nav = read_file("'$NAV_BAR'") } s#<body># <
<div id="main-content">
<div class="wrapper" id="wrapper">
<div class="document_foo" id="document">
#' ${files}
#' "$@"
perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s#</body>#
</div>
@ -41,4 +42,4 @@ perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s#</body>#
$footer
</div>
</div>
</body>#' ${files}
</body>#' "$@"

Loading…
Cancel
Save