| tDisallow access to commit and file contents in robots.txt - stagit - static gi… | |
| git clone git://src.adamsgaard.dk/stagit | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit 63be26e0567dc276b45dadeae53b537bf09d7d8c | |
| parent 8e6633b64f13aba222eab8996f83366ab12dc7c7 | |
| Author: Anders Damsgaard <[email protected]> | |
| Date: Mon, 6 Jan 2020 11:49:36 +0100 | |
| Disallow access to commit and file contents in robots.txt | |
| Diffstat: | |
| M create.sh | 5 +++++ | |
| M post-receive.sh | 6 ++++++ | |
| 2 files changed, 11 insertions(+), 0 deletions(-) | |
| --- | |
| diff --git a/create.sh b/create.sh | |
| t@@ -22,6 +22,8 @@ curdir="$(pwd)" | |
| # make index. | |
| stagit-index "${reposdir}/"*/ > "${curdir}/index.html" | |
| +echo "User-agent: *" > robots.txt | |
| + | |
| # make files per repo. | |
| for dir in "${reposdir}/"*/; do | |
| # strip .git suffix. | |
| t@@ -39,5 +41,8 @@ for dir in "${reposdir}/"*/; do | |
| ln -sf ../logo.png logo.png | |
| ln -sf ../favicon.png favicon.png | |
| + printf "Disallow: /%s/file/\nDisallow: /%s/commit/\n" \ | |
| + "$r" "$r" >> "${curdir}/robots.txt" | |
| + | |
| echo "done" | |
| done | |
| diff --git a/post-receive.sh b/post-receive.sh | |
| t@@ -66,6 +66,12 @@ stagit-index "${reposdir}/"*/ > "${destdir}/index.html" | |
| # make pages. | |
| stagit -c "${cachefile}" "${reposdir}/${r}" | |
| +# disallow access to file and commit contents in parent robots.txt | |
| +if ! grep -q "Disallow: /${r}/" "${destdir}/robots.txt"; then | |
| + printf "Disallow: /%s/file/\nDisallow: /%s/commit/\n" \ | |
| + "$r" "$r" >> "${destdir}/robots.txt" | |
| +fi | |
| + | |
| ln -sf log.html index.html | |
| ln -sf ../style.css style.css | |
| ln -sf ../logo.png logo.png |