diff --git a/template/antora.yml b/template/antora.yml new file mode 100644 index 0000000..d6a028a --- /dev/null +++ b/template/antora.yml @@ -0,0 +1,6 @@ + + name: swarmlab_cloud + title: swarmlab_cloud + version: docs + nav: + - modules/ROOT/nav.adoc diff --git a/template/build.sh b/template/build.sh new file mode 100755 index 0000000..9c1036c --- /dev/null +++ b/template/build.sh @@ -0,0 +1,5 @@ +docker stop swarmlab-documentation +docker container rm swarmlab-documentation +docker pull hub.swarmlab.io:5480/antora + +docker run -ti --name swarmlab-documentation -p 8080:8080 -v $PWD/:/antora -v $PWD/supplemental-ui:/antora/supplemental-ui hub.swarmlab.io:5480/antora /bin/sh -c "DOCSEARCH_ENABLED=true DOCSEARCH_ENGINE=lunr DOCSEARCH_INDEX_VERSION=latest NODE_PATH=/usr/local/lib/node_modules:\$NODE_PATH exec sh -c '/antora/run/build.sh'" diff --git a/template/config.ini b/template/config.ini new file mode 100644 index 0000000..e43b86b --- /dev/null +++ b/template/config.ini @@ -0,0 +1 @@ +SERVICE_URL=https://git.swarmlab.io:3000/docs/Documentation.git diff --git a/template/init-docs.sh b/template/init-docs.sh new file mode 100755 index 0000000..b8170e3 --- /dev/null +++ b/template/init-docs.sh @@ -0,0 +1,196 @@ +#!/bin/bash + + +#SERVICE_URL=https://git.swarmlab.io:3000/docs/Documentation.git + +#SERVICE_NAME=cloud +#SERVICE_NAME_MENOU=cloud + + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + TARGET="$(readlink "$SOURCE")" + if [[ $TARGET == /* ]]; then + SOURCE="$TARGET" + else + DIR="$( dirname "$SOURCE" )" + SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + fi +done + +SRPATH="$( dirname "$SOURCE" )" +SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ "$SFPATH" != "$SRPATH" ]; then + RDIR=$SRPATH # relativ path directory +fi + +cwdir=$PWD +wdir=$SFPATH + +#echo $cwdir + +#echo $wdir + + + + +txturl='\033[1;36m' +txturl1='\033[0;36m' +txtg='\033[0;32m' +NOCOLOR='\033[0m' + + +usage () +{ + echo "" + echo " No argument supplied" + echo "" + echo "--------------" + echo " create Swarmlab.io Doc " + echo "--------------" + echo "" + echo " USAGE: ./init-docs.sh [OPTIONS]" + echo "" + echo " Examples of [OPTIONS] can be:" + echo "" + echo -e " ${txtg}[docname]:${NOCOLOR} You can use upper and lowercase letters, numbers, “.” (dot), and “_” (underscore) symbols. " + echo "" + echo "" + echo " " +} + +if [[ $# -eq 0 ]] ; then + usage + exit 1 +fi + +if [[ -z "$1" ]] ; then + usage + exit 1 + +else + +pdir="$(dirname "$wdir")" +dname="$pdir/$1" +#echo $pdir +#echo $dname + +if [[ -d "$dname" ]] ; then + echo "" + echo "--------------" + echo -e "Directory ${txtg} ${dname} ${NOCOLOR} ${txturl} exists ${NOCOLOR}" + echo "--------------" + echo "" + exit 1 +fi + +. $wdir/config.ini + +SERVICE_NAME=$1 +SERVICE_NAME_MENOU=$1 + +echo "" +echo "Default parameters are:" +echo -e "SERVICE_URL=${txtg}${SERVICE_URL}${NOCOLOR}" +echo -e "SERVICE_NAME=${txtg}${SERVICE_NAME}${NOCOLOR}" +echo -e "SERVICE_NAME_MENOU=${txtg}${SERVICE_NAME_MENOU}${NOCOLOR}" +echo -e "You can change this setting in: ${txturl} config.ini ${NOCOLOR}" +echo "" +echo "Do you wish to create this in $dname?" +select yn in "Yes" "No"; do + case $yn in + Yes ) break;; + No ) exit;; + esac +done + +if [[ $yn == 'Yes' ]];then + + +mkdir -p $dname + +if [[ ! -d "$dname" ]] ; then + echo "" + echo "--------------" + echo -e "mkdir: cannot create directory ${txtg} ${dname} ${NOCOLOR}" + echo "--------------" + echo "" + exit 1 +fi + +cd $wdir + +cp -rf modules ${dname} +cp -rf supplemental-ui ${dname} +cp -rf run ${dname} +cp -f build.sh ${dname} +cp -f antora.yml ${dname} +cp -f site.yml ${dname} +cp -f push.sh ${dname} + +if [[ ! -d "${dname}/modules" || ! -d "${dname}/supplemental-ui" || ! -d "${dname}/run" || ! -f "${dname}/antora.yml" || ! -f "${dname}/site.yml" || ! -f "${dname}/build.sh" || ! -f "${dname}/push.sh" ]] ; then + echo "" + echo "--------------" + echo -e "cannot create template in directory ${txtg} ${dname} ${NOCOLOR}" + echo "--------------" + echo "" + exit 1 +fi + + exit 1 + +cat << EOF > $dname/antora.yml + + name: swarmlab_${SERVICE_NAME} + title: swarmlab_${SERVICE_NAME} + version: docs + nav: + - modules/ROOT/nav.adoc +EOF + +cat << EOF > $dname/site.yml +site: + title: Swarmlab ${SERVICE_NAME} + url: http://docs.swarmlab.io/SwarmLab-HowTos/swarmlab/docs + start_page: swarmlab_${SERVICE_NAME}::index.adoc +content: + sources: + - url: ${SERVICE_URL} + branches: master + start_path: docs +ui: + bundle: + url: https://git.swarmlab.io:3000/docs/docs/raw/branch/master/ui-bundle.zip + snapshot: true + supplemental_files: ./supplemental-ui +asciidoc: + attributes: + :plantuml-server-url: http://www.plantuml.com/plantuml + extensions: + - '@djencks/asciidoctor-mathjax' + - asciidoctor-plantuml +EOF + +cat << EOF > $dname/modules/ROOT/nav.adoc +* xref:index.adoc[${SERVICE_NAME_MENOU}] +EOF + +cat << EOF > $dname/modules/ROOT/pages/index.adoc + += ${SERVICE_NAME_MENOU} + +image::ROOT:swarmlab.png[swarmlab,150,float=right] + +This tutorial demonstrates: *a.* howto create a Swarmlab.io doc wit asciidoc + +== Intro + +*intro* here + +EOF + +fi + +cd $cwdir + +fi diff --git a/template/modules/ROOT/images/adhoc.png b/template/modules/ROOT/images/adhoc.png new file mode 100644 index 0000000..6256678 Binary files /dev/null and b/template/modules/ROOT/images/adhoc.png differ diff --git a/template/modules/ROOT/images/swarmlab.png b/template/modules/ROOT/images/swarmlab.png new file mode 100644 index 0000000..d94ea42 Binary files /dev/null and b/template/modules/ROOT/images/swarmlab.png differ diff --git a/template/modules/ROOT/nav.adoc b/template/modules/ROOT/nav.adoc new file mode 100644 index 0000000..4245037 --- /dev/null +++ b/template/modules/ROOT/nav.adoc @@ -0,0 +1 @@ +* xref:index.adoc[cloud] diff --git a/template/modules/ROOT/pages/index.adoc b/template/modules/ROOT/pages/index.adoc new file mode 100644 index 0000000..e44ce24 --- /dev/null +++ b/template/modules/ROOT/pages/index.adoc @@ -0,0 +1,11 @@ + += cloud + +image::ROOT:swarmlab.png[swarmlab,150,float=right] + +This tutorial demonstrates: *a.* howto create a Swarmlab.io doc wit asciidoc + +== Intro + +*intro* here + diff --git a/template/run/build-intro.sh b/template/run/build-intro.sh new file mode 100755 index 0000000..af181d8 --- /dev/null +++ b/template/run/build-intro.sh @@ -0,0 +1,4 @@ +antora --fetch /antora/site-intro.yml +antora /antora/site-intro.yml +ifconfig +http-server build/site -c-1 diff --git a/template/run/build.sh b/template/run/build.sh new file mode 100755 index 0000000..7122c21 --- /dev/null +++ b/template/run/build.sh @@ -0,0 +1,4 @@ +antora --fetch /antora/site.yml +antora /antora/site.yml +ifconfig +http-server build/site -c-1 diff --git a/template/site.yml b/template/site.yml new file mode 100644 index 0000000..4c5b613 --- /dev/null +++ b/template/site.yml @@ -0,0 +1,20 @@ +site: + title: Swarmlab cloud + url: http://docs.swarmlab.io/SwarmLab-HowTos/swarmlab/docs + start_page: swarmlab_cloud::index.adoc +content: + sources: + - url: https://git.swarmlab.io:3000/docs/Documentation.git + branches: master + start_path: docs +ui: + bundle: + url: https://git.swarmlab.io:3000/docs/docs/raw/branch/master/ui-bundle.zip + snapshot: true + supplemental_files: ./supplemental-ui +asciidoc: + attributes: + :plantuml-server-url: http://www.plantuml.com/plantuml + extensions: + - '@djencks/asciidoctor-mathjax' + - asciidoctor-plantuml