rougail-tutorials_builder/build.sh
2025-11-10 08:20:56 +01:00

188 lines
6.2 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash -e
#-----------------------
VERSION=1.1
#-----------------------
set -x
DEST=../rougail-tutorials
if [ -d $DEST ]; then
echo "déjà fait"
exit 1
fi
export LC_ALL=C.UTF-8
BUILDER="$(pwd)"
mkdir -p $DEST/firefox
rm -f summary.md previous.yml
touch summary.md
rm -f summary_total.md
touch summary_total.md
cd "$DEST"
DEST="$(pwd)"
TUTO_ROOT=https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit
cp "$BUILDER"/firefox.png .
cp "$BUILDER"/foxyproxy.png .
cp "$BUILDER"/summary.md .
cp "$BUILDER"/install.txt .
touch README.md
"$BUILDER"/build.py "$BUILDER" "$VERSION"
rm -rf summary.md
rm -rf summary_total.md
rm -rf jinja_caches
git init -b "$VERSION"
git add .
git commit -am"$(cat $BUILDER/TITLE)"
#old_commit_id="$(git rev-parse HEAD)"
cd - > /dev/null
for i in $(ls -d "examples"/* | sort); do
num=$(echo $(basename "$i"))
echo "$num"
commit_id="v${VERSION}_$num"
title="$(head -n 1 $i/README.md)"
summary="[tutorial $commit_id] $title"
echo "- [$summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/$commit_id/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/${commit_id}~1..$commit_id))" >> summary_total.md
done
for i in $(ls -d "examples"/* | sort); do
if [ -f "$i/TITLE.md" ]; then
echo "- $(head -n 1 $i/TITLE.md)" >> summary.md
fi
if [ -f "$i/SUBTITLE.md" ]; then
echo " - $(head -n 1 $i/SUBTITLE.md)" >> summary.md
fi
if [ -f "$i/README.md" ]; then
rm -rf "$DEST/config" "$DEST/tree.html"
num=$(echo $(basename "$i"))
echo "$num"
commit_id="v${VERSION}_$num"
title=$(head -n 1 $i/README.md)
summary="[tutorial $commit_id)] $title"
if [ -f $i/URL ]; then
base_url_doc=$(cat $i/URL)
fi
url_doc="$base_url_doc#$(echo $title | tr A-Z a-z | sed 's/ /-/g' | sed 's//-/g')"
diff_url="https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/${commit_id}~1..$commit_id"
echo " - [$summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/$commit_id/README.md) ([doc]($url_doc) - [diff]($diff_url))" >> summary.md
cp "summary_total.md" "$DEST"
BEFORE=$PWD
cd "$i/structural_files"
if [ -d firefox ]; then
for j in $(ls firefox/*.yml 2>/dev/null); do
cp -v "$j" "$DEST/$j"
done
fi
if [ -d foxyproxy ]; then
mkdir -p $DEST/foxyproxy
for j in $(ls foxyproxy/*.yml 2>/dev/null); do
cp -v "$j" "$DEST/$j"
done
fi
cd $DEST
tree -H $TUTO_ROOT/$commit_id/ -P "*.yml" > tree.html
cd - > /dev/null
cp -v DISPLAY_* "$DEST/" 2> /dev/null || true
cp -f ../README.md "$DEST"
if [ -d ../config ]; then
cp -aL ../config "$DEST"
fi
msg="[tutorial $commit_id] $(cat ../README.md)"
[ -e ../firefox.png ] && cp ../firefox.png "$DEST"
[ -e ../foxyproxy.png ] && cp ../foxyproxy.png "$DEST"
cd $BEFORE
cd "$DEST"
#
before=$(grep "commit/$commit_id/README.md" summary_total.md -B1 | wc -l)
echo "- [Summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/$VERSION/README.md)" > summary_before.md
if [ "$before" = "2" ]; then
echo $(grep "commit/$commit_id/README.md" summary_total.md -B1 | head -n 1) >> summary_before.md
fi
echo "" >> summary_before.md
echo "# $summary" >> summary_before.md
echo "" >> summary_before.md
echo "[View the diff]($diff_url)" >> summary_before.md
echo "" >> summary_before.md
echo "[Read the documentation]($url_doc)" >> summary_before.md
after=$(grep "commit/$commit_id/README.md" summary_total.md -A1 | wc -l)
if [ "$after" = "2" ]; then
echo $(grep "commit/$commit_id/README.md" summary_total.md -A1 | tail -n 1) > summary_after.md
fi
#
if [ -f config/mode ]; then
mv config/mode mode
fi
"$BUILDER"/build.py "$BUILDER" "$commit_id"
rm -rf config/*/README.md config/*/read_write config/namespace config/*/invalid DISPLAY_*
rm -rf jinja_caches summary.md summary_before.md summary_after.md summary_total.md
if [ -f mode ]; then
MODE=1
rm -f mode
else
MODE=0
fi
git add *.png README.md install.txt tree.html
if [ -d config ]; then
git add config
else
git status |grep -q config && git add config
fi
git commit -m"$summary (config and doc)"
git add .
git commit -am"$msg"
git tag -a "$commit_id" -m"format version $VERSION: $num"
if [ "$MODE" = 1 ]; then
touch mode
fi
cd - > /dev/null
# old_commit_id="$commit_id"
fi
done
cd "$DEST"
echo "# Description
This tutorial shows to you an example of Rougail use on how to set a proxy in the Mozilla Firefox browser.
More precisely, this tutorial aims at reproducing this [Mozilla Firefox](https://www.mozilla.org/firefox/new/) settings page:
![Firefox Proxy setting](firefox.png)
And the integration of part of the [Firefox FoxyProxy plugin](https://addons.mozilla.org/firefox/addon/foxyproxy-standard/).
The idea is to have a namespace specific to FoxyProxy and to find in it part of the settings that we will have made in the main namespace.
This is what the page looks like:
![Foxyproxy Proxy setting](foxyproxy.png)
" > README.md
echo '# Installation
To test this tutorial, you need to download this repository and install Rougail:
```bash' >> README.md
cat install.txt >> README.md
echo '```
' >> README.md
echo "# Summary
Each step is a separerate commit. You can navigate to history to discover different aspect to the Rougail format.
" >> README.md
cp "$BUILDER"/firefox.png .
cp "$BUILDER"/foxyproxy.png .
cat "$BUILDER"/summary.md >> README.md
echo >> README.md
rm -rf firefox foxyproxy mode install.txt tree.html
git add .
git commit -am"Summary"
#
git remote add origin ssh://git@forge.cloud.silique.fr:2222/stove/rougail-tutorials.git
git push --set-upstream origin $VERSION --force
git push --tag --force
rm -f summary.md summary_total.md
echo "FAIT"
exit 0