223 lines
8.1 KiB
Bash
Executable file
223 lines
8.1 KiB
Bash
Executable file
#!/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 .
|
||
EMPTY=$(echo -e "\n")
|
||
touch README.md
|
||
"$BUILDER"/build.py "$BUILDER" "$VERSION" "false"
|
||
rm -rf summary.md
|
||
rm -rf summary_total.md
|
||
rm -rf jinja_caches
|
||
git init -b "$VERSION" > /dev/null
|
||
git add .
|
||
git commit -am"$(cat $BUILDER/TITLE)" > /dev/null
|
||
#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/URL ]; then
|
||
base_url_doc=$(cat $i/URL)
|
||
fi
|
||
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) ([doc]($base_url_doc))" >> 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"
|
||
url_doc="$base_url_doc#$(echo $title | tr A-Z a-z | sed 's/ /-/g' | sed 's/’/-/g' | sed 's/\"//g' | 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
|
||
if [ -d ../types ]; then
|
||
mkdir -p $DEST/types
|
||
for j in $(ls -d ../types/* 2>/dev/null); do
|
||
cp -va "$j" "$DEST/types/"
|
||
done
|
||
has_new_type="true"
|
||
else
|
||
has_new_type="false"
|
||
fi
|
||
cd $DEST
|
||
tree -H $TUTO_ROOT/$commit_id/ -P "*.yml" > tree.html
|
||
cd - > /dev/null
|
||
cp -v NODISPLAY DISPLAY_* "$DEST/" 2> /dev/null || true
|
||
cp -f ../README.md "$DEST"
|
||
if [ -d ../config ]; then
|
||
cp -vaL ../config "$DEST"
|
||
fi
|
||
msg="[tutorial $commit_id] $(cat ../README.md)"
|
||
[ -e ../firefox.png ] && cp ../firefox.png "$DEST"
|
||
[ -e ../foxyproxy.png ] && cp ../foxyproxy.png "$DEST"
|
||
[ -e ../namespace ] && cp ../namespace "$DEST"
|
||
cd $BEFORE
|
||
cd "$DEST"
|
||
#
|
||
echo "- [List of all the tutorial steps](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/$VERSION/README.md)" > summary_before.md
|
||
if [ -n "$old_commit_id" ]; then
|
||
echo "- [$(echo $old_summary| sed 's/\[tutorial /\[Previous tutorial /')](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/$old_commit_id/README.md) ([diff]($diff_url))" >> summary_before.md
|
||
fi
|
||
echo "" >> summary_before.md
|
||
echo "# $summary" >> summary_before.md
|
||
echo "" >> summary_before.md
|
||
echo "- [Read the tutorial \"$title\" in the documentation]($url_doc)" >> summary_before.md
|
||
echo "- [View the changes in the files]($diff_url)" >> 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 | sed 's/\[tutorial /\[Next tutorial /') > summary_after.md
|
||
fi
|
||
#
|
||
ENV="ROUGAILCLI_CLI.CONFIG_FILE=$BUILDER/rougailcli_common.yml"
|
||
if [ -d types ]; then
|
||
ENV="$ENV,$BUILDER/rougailcli_types.yml"
|
||
fi
|
||
if [ -f config/mode ]; then
|
||
mv config/mode mode
|
||
fi
|
||
if [ -f mode ]; then
|
||
ENV="$ENV,$BUILDER/rougailcli_mode.yml"
|
||
fi
|
||
if [ -f namespace ] || [ -d foxyproxy ]; then
|
||
ENV="$ENV,$BUILDER/rougailcli_namespace.yml"
|
||
if [ -d foxyproxy ]; then
|
||
ENV="$ENV,$BUILDER/rougailcli_namespace_foxyproxy.yml"
|
||
fi
|
||
fi
|
||
env $ENV,$BUILDER/rougailcli_documentation.yml rougail > DOCUMENTATION.md
|
||
if [ "$(cat DOCUMENTATION.md)" = "$EMPTY" ]; then rm DOCUMENTATION.md; echo "NO DOCUMENTATION"; fi
|
||
if [ -f "$BUILDER"/previous.yml ]; then
|
||
env $ENV,$BUILDER/rougailcli_documentation.yml,$BUILDER/rougailcli_changelog.yml rougail > CHANGELOG.md
|
||
if [ "$(cat CHANGELOG.md)" = "$EMPTY" ]; then rm CHANGELOG.md; fi
|
||
fi
|
||
if [ ! -f CHANGELOG.md ]; then echo "NO CHANGELOG"; fi
|
||
"$BUILDER"/build.py "$BUILDER" "$commit_id" "$has_new_type"
|
||
rm -rf config/*/README.md config/*/read_write namespace config/*/invalid DISPLAY_* NODISPLAY
|
||
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
|
||
git add DOCUMENTATION.md &> /dev/null || true
|
||
git add CHANGELOG.md &> /dev/null || true
|
||
if [ -d config ]; then
|
||
git add config
|
||
else
|
||
git status |grep -q config && git add config
|
||
fi
|
||
git commit -m"$summary (config and doc)" > /dev/null
|
||
git add .
|
||
git commit -am"$msg" --allow-empty > /dev/null
|
||
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"
|
||
old_summary="$summary"
|
||
# echo "pouet $i"
|
||
# [ "$i" = "examples/002" ] && exit 1
|
||
if [ -f previous.yml ]; then cp -a previous.yml previous_old.yml; fi
|
||
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:
|
||
|
||

|
||
|
||
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:
|
||
|
||

|
||
" > 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
|