1
0
Fork 0

backport documentation variable configurations (#3850)

* Correct custom search IDs, sitemap and edit URLs

* deploy versions through shell script from central places

* shellcheckify

* shellcheck, indent

* move all configs into one file

* add settings

* one more char that may occur in ids

* add per book version, its not yet the right ids.

* Update VERSIONS

Created new CSE for Devel Cookbook, replaced all IDs by Devel CSE IDs, adjusted prio to 0.3
This commit is contained in:
Wilfried Goesgens 2017-12-05 14:11:21 +01:00 committed by Jan
parent 64f259aa70
commit 3fe4b2fda5
10 changed files with 395 additions and 312 deletions

View File

@ -37,8 +37,8 @@
},
"sitemap-general": {
"prefix": "https://docs.arangodb.com/devel/AQL/",
"changefreq": "daily",
"priority": 0.3
"changefreq": "@GCHANGE_FREQ@",
"priority": @GPRIORITY@
},
"ga": {
"token": "UA-81053435-2"

View File

@ -1,4 +1,7 @@
// Try to set the version number early, jQuery not available yet
var searcheable_versions = [@BROWSEABLE_VERSIONS@];
var cx = '@GSEARCH_ID@';
document.addEventListener("DOMContentLoaded", function(event) {
if (!gitbook.state.root) return;
var bookVersion = gitbook.state.root.match(/\/(\d\.\d(\.\d)?|devel)\//);
@ -16,6 +19,21 @@ window.localStorage.removeItem(":keyword");
$(document).ready(function() {
function appendHeader() {
var VERSION_SELECTOR = ""
var i = 0;
var prefix;
for (i = 0; i < searcheable_versions.length; i++ ) {
if (searcheable_versions[i] === 'devel') {
prefix = '';
} else {
prefix = 'v';
}
VERSION_SELECTOR += '<option value="' +
searcheable_versions[i] +
'">' + prefix +
searcheable_versions[i] +
'</option>\n';
}
var div = document.createElement('div');
div.innerHTML = '<div class="arangodb-header">\n' +
@ -30,11 +48,7 @@ function appendHeader() {
' </a>\n' +
' </div>\n' +
' <select class="arangodb-version-switcher">\n' +
' <option value="devel">devel</option>\n' +
' <option value="3.2">v3.2</option>\n' +
' <option value="3.1">v3.1</option>\n' +
' <option value="3.0">v3.0</option>\n' +
' <option value="2.8">v2.8</option>\n' +
VERSION_SELECTOR +
' </select>\n' +
' <div class="google-search">\n' +
' <gcse:searchbox-only></gcse:searchbox-only>\n' +
@ -93,7 +107,6 @@ function appendHeader() {
//render header
rerenderNavbar();
function addGoogleSrc() {
var cx = '010085642145132923492:6ymjhhr677k';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;

View File

@ -36,15 +36,15 @@
"css": ["styles/header.css"]
},
"sitemap-general": {
"prefix": "https://docs.arangodb.com/3.2/cookbook/",
"changefreq": "weekly",
"priority": 0.8
"prefix": "https://docs.arangodb.com/devel/cookbook/",
"changefreq": "@GCHANGE_FREQ@",
"priority": @GPRIORITY@
},
"ga": {
"token": "UA-81053435-2"
},
"edit-link": {
"base": "https://github.com/arangodb/Cookbook/edit/master/recipes",
"base": "https://github.com/arangodb/arangodb/edit/devel/Documentation/Books/Cookbook",
"label": "Edit Page"
},
"localized-footer": {

View File

@ -1,4 +1,7 @@
// Try to set the version number early, jQuery not available yet
var searcheable_versions = [@BROWSEABLE_VERSIONS@];
var cx = '@GSEARCH_ID@';
document.addEventListener("DOMContentLoaded", function(event) {
if (!gitbook.state.root) return;
var bookVersion = gitbook.state.root.match(/\/(\d\.\d(\.\d)?|devel)\//);
@ -16,6 +19,21 @@ window.localStorage.removeItem(":keyword");
$(document).ready(function() {
function appendHeader() {
var VERSION_SELECTOR = ""
var i = 0;
var prefix;
for (i = 0; i < searcheable_versions.length; i++ ) {
if (searcheable_versions[i] === 'devel') {
prefix = '';
} else {
prefix = 'v';
}
VERSION_SELECTOR += '<option value="' +
searcheable_versions[i] +
'">' + prefix +
searcheable_versions[i] +
'</option>\n';
}
var div = document.createElement('div');
div.innerHTML = '<div class="arangodb-header">\n' +
@ -30,11 +48,7 @@ function appendHeader() {
' </a>\n' +
' </div>\n' +
' <select class="arangodb-version-switcher">\n' +
' <option value="devel">devel</option>\n' +
' <option value="3.2">v3.2</option>\n' +
' <option value="3.1">v3.1</option>\n' +
' <option value="3.0">v3.0</option>\n' +
' <option value="2.8">v2.8</option>\n' +
VERSION_SELECTOR +
' </select>\n' +
' <div class="google-search">\n' +
' <gcse:searchbox-only></gcse:searchbox-only>\n' +
@ -93,7 +107,6 @@ function appendHeader() {
//render header
rerenderNavbar();
function addGoogleSrc() {
var cx = '010085642145132923492:ol7d_ppmq48';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;

View File

@ -37,8 +37,8 @@
},
"sitemap-general": {
"prefix": "https://docs.arangodb.com/devel/HTTP/",
"changefreq": "daily",
"priority": 0.3
"changefreq": "@GCHANGE_FREQ@",
"priority": @GPRIORITY@
},
"ga": {
"token": "UA-81053435-2"

View File

@ -1,4 +1,6 @@
// Try to set the version number early, jQuery not available yet
var searcheable_versions = [@BROWSEABLE_VERSIONS@];
var cx = '@GSEARCH_ID@';
document.addEventListener("DOMContentLoaded", function(event) {
if (!gitbook.state.root) return;
var bookVersion = gitbook.state.root.match(/\/(\d\.\d(\.\d)?|devel)\//);
@ -16,6 +18,21 @@ window.localStorage.removeItem(":keyword");
$(document).ready(function() {
function appendHeader() {
var VERSION_SELECTOR = ""
var i = 0;
var prefix;
for (i = 0; i < searcheable_versions.length; i++ ) {
if (searcheable_versions[i] === 'devel') {
prefix = '';
} else {
prefix = 'v';
}
VERSION_SELECTOR += '<option value="' +
searcheable_versions[i] +
'">' + prefix +
searcheable_versions[i] +
'</option>\n';
}
var div = document.createElement('div');
div.innerHTML = '<div class="arangodb-header">\n' +
@ -30,11 +47,7 @@ function appendHeader() {
' </a>\n' +
' </div>\n' +
' <select class="arangodb-version-switcher">\n' +
' <option value="devel">devel</option>\n' +
' <option value="3.2">v3.2</option>\n' +
' <option value="3.1">v3.1</option>\n' +
' <option value="3.0">v3.0</option>\n' +
' <option value="2.8">v2.8</option>\n' +
VERSION_SELECTOR +
' </select>\n' +
' <div class="google-search">\n' +
' <gcse:searchbox-only></gcse:searchbox-only>\n' +
@ -93,7 +106,6 @@ function appendHeader() {
//render header
rerenderNavbar();
function addGoogleSrc() {
var cx = '010085642145132923492:fixi4yzeiz8';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;

View File

@ -37,8 +37,8 @@
},
"sitemap-general": {
"prefix": "https://docs.arangodb.com/devel/Manual/",
"changefreq": "daily",
"priority": 0.3
"changefreq": "@GCHANGE_FREQ@",
"priority": @GPRIORITY@
},
"ga": {
"token": "UA-81053435-2"

View File

@ -1,4 +1,6 @@
// Try to set the version number early, jQuery not available yet
var searcheable_versions = [@BROWSEABLE_VERSIONS@];
var cx = '@GSEARCH_ID@';
document.addEventListener("DOMContentLoaded", function(event) {
if (!gitbook.state.root) return;
var bookVersion = gitbook.state.root.match(/\/(\d\.\d(\.\d)?|devel)\//);
@ -16,6 +18,21 @@ window.localStorage.removeItem(":keyword");
$(document).ready(function() {
function appendHeader() {
var VERSION_SELECTOR = ""
var i = 0;
var prefix;
for (i = 0; i < searcheable_versions.length; i++ ) {
if (searcheable_versions[i] === 'devel') {
prefix = '';
} else {
prefix = 'v';
}
VERSION_SELECTOR += '<option value="' +
searcheable_versions[i] +
'">' + prefix +
searcheable_versions[i] +
'</option>\n';
}
var div = document.createElement('div');
div.innerHTML = '<div class="arangodb-header">\n' +
@ -30,11 +47,7 @@ function appendHeader() {
' </a>\n' +
' </div>\n' +
' <select class="arangodb-version-switcher">\n' +
' <option value="devel">devel</option>\n' +
' <option value="3.2">v3.2</option>\n' +
' <option value="3.1">v3.1</option>\n' +
' <option value="3.0">v3.0</option>\n' +
' <option value="2.8">v2.8</option>\n' +
VERSION_SELECTOR +
' </select>\n' +
' <div class="google-search">\n' +
' <gcse:searchbox-only></gcse:searchbox-only>\n' +
@ -93,7 +106,6 @@ function appendHeader() {
//render header
rerenderNavbar();
function addGoogleSrc() {
var cx = '010085642145132923492:djexw6vlsgo';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;

View File

@ -2,32 +2,48 @@
ALLBOOKS="HTTP AQL Manual Cookbook"
OTHER_MIME="pdf epub mobi"
# shellcheck disable=SC2016
TRIPPLETICS='```'
declare -A COLORS
declare -A C
COLORS[RESET]='\033[0m'
# Regular Colors
#COLORS[Black]='\033[0;30m' # Black
# shellcheck disable=SC2154
COLORS[Red]='\033[0;31m' # Red
# shellcheck disable=SC2154
COLORS[Green]='\033[0;32m' # Green
# shellcheck disable=SC2154
COLORS[Yellow]='\033[0;33m' # Yellow
#COLORS[Blue]='\033[0;34m' # Blue
#COLORS[Purple]='\033[0;35m' # Purple
#COLORS[Cyan]='\033[0;36m' # Cyan
# shellcheck disable=SC2154
COLORS[White]='\033[0;37m' # White
for i in "${!COLORS[@]}"; do
# shellcheck disable=SC2086
C[${i}]=$(echo -e ${COLORS[$i]})
done
# shellcheck disable=SC2034
WRN_COLOR="${C[Yellow]}"
ERR_COLOR="${C[Red]}"
STD_COLOR="${C[White]}"
OK_COLOR="${C[Green]}"
RESET="${C[RESET]}"
newVersionNumber=$(cat ../../VERSION | tr -d '\r\n')
newVersionNumber=$( tr -d '\r\n' < ../../VERSION)
declare -A ALL_GSEARCH_ID
for book in ${ALLBOOKS}; do
ALL_GSEARCH_ID[$book]=$( grep "GSEARCH_ID_${book}" ../../VERSIONS |sed 's;.*"\([0-9a-zA-Z:-]*\)".*;\1;')
done
GCHANGE_FREQ=$(grep "GCHANGE_FREQ" ../../VERSIONS |sed 's;.*"\([0-9a-zA-Z:]*\)".*;\1;')
GPRIORITY=$(grep "GPRIORITY" ../../VERSIONS |sed 's;.*"\([0-9a-zA-Z.]*\)".*;\1;')
BROWSEABLE_VERSIONS=$(grep "BROWSEABLE_VERSIONS" ../../VERSIONS |sed -e 's;" *$;;' -e 's;.*";;')
function start_X11_display()
{
@ -104,10 +120,10 @@ function ppbook-precheck-bad-code-sections()
{
NAME="$1"
echo "${STD_COLOR}##### checking for bad code sections in ${NAME}${RESET}"
if grep -qR '^``` *.* ' "${NAME}"; then
if grep -qR "^${TRIPPLETICS} *.* " "${NAME}"; then
echo "${ERR_COLOR}"
echo "tripple tics with blanks afterwards found: "
grep -R '^``` *.* ' "${NAME}"
grep -R "^${TRIPPLETICS} *.* " "${NAME}"
echo "${RESET}"
exit 1
fi
@ -224,7 +240,7 @@ function book-check-markdown-leftovers()
fi
set +e
ERRORS=$(find "books/${NAME}" -name '*.html' -exec grep '```' {} \; -print)
ERRORS=$(find "books/${NAME}" -name '*.html' -exec grep "${TRIPPLETICS}" {} \; -print)
set -e
if test "$(echo -n "${ERRORS}" | wc -l)" -gt 0; then
echo "${ERR_COLOR}"
@ -262,7 +278,7 @@ function check-dangling-anchors()
echo "${STD_COLOR}##### checking for dangling anchors${RESET}"
find books/ -name '*.html' | while IFS= read -r htmlf; do
fn=$(basename "${htmlf}")
dir=$(echo "$htmlf" |sed "s;/$fn;;")
dir=$(sed "s;/$fn;;" <<< "$htmlf")
mkdir -p "/tmp/tags/${dir}"
grep '<h. ' < "${htmlf}" | \
sed -e 's;.*id=";;' -e 's;".*;;' > "/tmp/tags/${dir}/${fn}"
@ -276,6 +292,7 @@ function check-dangling-anchors()
echo "${STD_COLOR}##### cross checking anchors${RESET}"
NO=0
echo "${NO}" > /tmp/anchorlistcount.txt
# shellcheck disable=SC2002
cat /tmp/anchorlist.txt | while IFS= read -r i; do
ANCHOR=$(echo "$i" | cut '-d,' -f 3)
FN=$(echo "$i" | cut '-d,' -f 2)
@ -284,7 +301,7 @@ function check-dangling-anchors()
if test -z "$FN"; then
FN="$SFN"
else
SFNP=$(echo "$SFN" | sed 's;/[a-zA-Z0-9]*.html;;')
SFNP=$(sed 's;/[a-zA-Z0-9]*.html;;' <<< "$SFN")
FN="${SFNP}/${FN}"
fi
if test -d "$FN"; then
@ -386,15 +403,8 @@ function build-book()
cp "../../${NAME}/FOOTER.html" .
fi
)
if test -z "${RELEASE_DIRECTORY}"; then
if ! test -f "ppbooks/${NAME}/book.json" ; then
cp "${NAME}/book.json" "ppbooks/${NAME}"
fi
else
if ! test -f "ppbooks/${NAME}/book.json" ; then
sed "s;/devel;/${RELEASE_DIRECTORY};" < "${NAME}/book.json" > "ppbooks/${NAME}/book.json"
fi
fi
(
cd "ppbooks/${NAME}"
cp -a "../../${NAME}/styles/"* styles/
@ -412,21 +422,6 @@ function build-book()
ppbooks/ \
../../js/apps/system/_admin/aardvark/APP/api-docs.json \
"${FILTER}" || exit 1
if echo "${newVersionNumber}" | grep -q devel; then
VERSION="${newVersionNumber} $(date +' %d. %b %Y ')"
else
VERSION="${newVersionNumber}"
fi
export VERSION
echo "${STD_COLOR} - Building Version ${VERSION}${RESET}"
(
cd "ppbooks/${NAME}"
sed -i -e "s/VERSION_NUMBER/v${VERSION}/g" styles/header.js
sed -i -e "s/VERSION_NUMBER/v${VERSION}/g" HEADER.html
sed -i -e "s/VERSION_NUMBER/v${VERSION}/g" README.md
sed -i -e "s/VERSION_NUMBER/v${VERSION}/g" book.json
)
test -d "books/${NAME}" || mkdir -p "books/${NAME}"
@ -437,6 +432,37 @@ function build-book()
ppbook-check-directory-link "${NAME}"
book-check-images-referenced "${NAME}"
if echo "${newVersionNumber}" | grep -q devel; then
VERSION="${newVersionNumber} $(date +' %d. %b %Y ')"
RELEASE_DIRECTORY=devel
else
VERSION="${newVersionNumber}"
RELEASE_DIRECTORY=$(sed "s;\.[0-9]*$;;" <<< "${newVersionNumber}")
fi
export VERSION
if ! test -f "ppbooks/${NAME}/book.json" ; then
cp "${NAME}/book.json" "ppbooks/${NAME}"
fi
for facilityfile in book.json styles/header.js HEADER.html README.md; do
export facilityfile
export RELEASE_DIRECTORY
(
cd "ppbooks/${NAME}"
sed -e "s/VERSION_NUMBER/v${VERSION}/g" \
-e "s;/devel;/${RELEASE_DIRECTORY};" \
-e "s;@GSEARCH_ID@;${ALL_GSEARCH_ID[${NAME}]};" \
-e "s;@GCHANGE_FREQ@;${GCHANGE_FREQ};" \
-e "s;@GPRIORITY@;${GPRIORITY};" \
-e "s;@BROWSEABLE_VERSIONS@;${BROWSEABLE_VERSIONS};" \
\
-i "${facilityfile}"
)
done
echo "${STD_COLOR} - Building Version ${VERSION}${RESET}"
if test -n "${NODE_MODULES_DIR}"; then
echo "${STD_COLOR}#### Installing plugins from ${NODE_MODULES_DIR}${RESET}"
cp -a "${NODE_MODULES_DIR}" "ppbooks/${NAME}"
@ -445,7 +471,7 @@ function build-book()
(cd "ppbooks/${NAME}"; gitbook install -g)
fi
echo "${STD_COLOR} - Building Book ${NAME} ${RESET}"
(cd "ppbooks/${NAME}" && gitbook ${GITBOOK_ARGS} build "./" "./../../books/${NAME}")
(cd "ppbooks/${NAME}" && gitbook "${GITBOOK_ARGS[@]}" build "./" "./../../books/${NAME}")
rm -f "./books/${NAME}/HEADER.html"
rm -f "./books/${NAME}/FOOTER.html"
echo "${STD_COLOR} - deleting markdown files in output (gitbook 3.x bug)"
@ -463,7 +489,7 @@ function build-book-dist()
cd "ppbooks/${NAME}"
for ext in ${OTHER_MIME}; do
OUTPUT="${OUTPUT_DIR}/ArangoDB_${NAME}_${newVersionNumber}.${ext}"
if gitbook ${GITBOOK_ARGS} "${ext}" ./ "${OUTPUT}"; then
if gitbook "${GITBOOK_ARGS[@]}" "${ext}" ./ "${OUTPUT}"; then
echo "success building ${OUTPUT}"
else
exit 1
@ -640,7 +666,7 @@ function build-dist-books()
function printHelp()
{
cat <<EOF
cat <<EOF
Usage: VERB arguments
Available Verbs:
build-dist-books - build all books in all representations (HTML(+tarball)/PDF/...) - takes some time.
@ -728,7 +754,7 @@ case "$VERB" in
build-book-keep-md "$NAME"
;;
clean)
clean
clean "$@"
;;
*)
printHelp

7
VERSIONS Normal file
View File

@ -0,0 +1,7 @@
GSEARCH_ID_HTTP "010085642145132923492:fixi4yzeiz8"
GSEARCH_ID_AQL "010085642145132923492:6ymjhhr677k"
GSEARCH_ID_Manual "010085642145132923492:djexw6vlsgo"
GSEARCH_ID_Cookbook "010085642145132923492:nknyifjn7tu"
GCHANGE_FREQ "daily"
GPRIORITY "0.3"
BROWSEABLE_VERSIONS "'devel', '3.2', '3.1', '3.0', '2.8'"