Merge pull request #228 from matrix-org/daniel/listfiles

Take list of files to edit as args
pull/977/head
Daniel Wagner-Hall 9 years ago
commit 77cfd9656c

@ -1,26 +1,27 @@
#!/bin/bash -eu #!/bin/bash -eu
if [[ $# != 1 || ! -d $1 ]]; then if [[ $# == 0 || ! -d $1 ]]; then
echo >&2 "Usage: $0 include_dir" echo >&2 "Usage: $0 include_dir file_to_replace..."
exit 1 exit 1
fi fi
HEADER="$1/head.html" include_dir="$1"
NAV_BAR="$1/nav.html" shift
FOOTER="$1/footer.html"
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 if [[ ! -e "${f}" ]]; then
echo >&2 "Need ${f} to exist" echo >&2 "Need ${f} to exist"
exit 1 exit 1
fi fi
done done
files=gen/*.html
perl -MFile::Slurp -pi -e 'BEGIN { $header = read_file("'$HEADER'") } s#<head>#<head>$header 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"> <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"> 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"> <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 id="main-content">
<div class="wrapper" id="wrapper"> <div class="wrapper" id="wrapper">
<div class="document_foo" id="document"> <div class="document_foo" id="document">
#' ${files} #' "$@"
perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s#</body># perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s#</body>#
</div> </div>
@ -41,4 +42,4 @@ perl -MFile::Slurp -pi -e 'BEGIN { $footer = read_file("'$FOOTER'") } s#</body>#
$footer $footer
</div> </div>
</div> </div>
</body>#' ${files} </body>#' "$@"

Loading…
Cancel
Save