Sidehistorik
This script travles a directory structure and creates WIKI markup (suitable for Confluence versions lower that 4.0).Several Macros are neede and uses the Atlassian CLI for Confluence for updating a page
Bemærk |
---|
Several Requirements are needed for the final page to be displayed correctly |
...
: Atlassian CLI (Notice the 3.X versions are not free, last free download versions at Atlassian CLI Script for making thumbnail images (makeThumbs.sh) User Macro: me-image - Image lightbox with Flare User Macro: me-video - Linking to a Video file (User Macro) |
Executing the script:
./updateGallery.sh directory="FamilieBilleder/2014" space="familiebilleder" pagetitle="Familiebilleder 2014" maketoc="yes"
Kodeblok |
---|
./updateGallery.sh RelativeDirectory Space PageName yes|no eGrep directory=[Dir] space=[SpaceName] pagetitle=[PageTitle] maketoc="yes|no" |
Samples:
Gives the Page - Familiebilleder 2012Sample
Kodeblok |
---|
./updateGallery.sh directory="FamilieBilleder" space="familiebilleder" pagetitle="Christopher" maketoc="yes" width="20"0 grepfor="Christopher|Stoffer" |
Gives the Page - ChristopherParameters:
Parameter | Description | Required | In script |
RelativeDirectory | is the path to be traveled (this is /data/images/FamilieBilleder) for my installation, where /data/images is hardcoded in the script |
---|
PageId
Yes | $Dir | ||
SpaceName | is the Name of the Space where a page will be updated (or created) | Yes | $Space |
---|---|---|---|
PageName | is the Name of |
the Confluence page |
to be updated (or created) in the SpaceName Space | Yes | $PageTitle |
yes|no |
---|
determines if a TOC markup is inserted at the top of the page | Yes | $MakeToc | |
ThumbSize | different thumbsize than the one included from config.txt | No | $Width |
eGrep | is an optional RegEx string for fine-picking from the |
---|
Source of the Script:
Kodeblok | ||
---|---|---|
| ||
#!/bin/bash
IFS=$(echo -en "\n\b")
# Arguments
Dir=$1
Space=$2
PageTitle=$3
MakeToc=$4
GrepFor=$5
# Check Arguments
if [ $# -lt 4 ]
then
echo "There are not at least 4 Arguments: Dir Space PageTitle yes/no"
exit 0
fi
if [ Dir == "" ]
then
echo "Argument 1 is empty"
exit 0
fi
if [ ! -d /data/images/$Dir ]
then
echo "Argument 1 Dir: $Dir does not exist"
exit 0
fi
if [ $MakeToc == "no" ]
then
html="{make-top}"
else
html="{toc} \n {make-top}"
fi
cd /data/images/"$Dir"
for file in `find . -type d | grep -v "thumbs" | grep -v "cache" | egrep -i "$GrepFor" | sort`
do
NumOfPics=`ls -t "$file" | egrep -i "\.(jpg|gif|png|bmp)$" | wc -l`
if [ $NumOfPics -gt 0 ]
then
file=$(echo "$file"|sed 's/\.\///g')
html="$html \n h1. $file \n {go-top} \n "
group=$file
for image in `ls "$file" | egrep -i "\.(jpg|gif|png|bmp)$"`
do
file2=$(echo "$file"|sed 's/ /%20/g')
html="$html {me-image:path=$Dir/$file2/|image=$image|group=$group}"
done
html="$html \n "
fi
done
/opt/atlassian-cli/confluence.sh --action storePage --space "$Space" --title "$PageTitle" --content "$html" |
Line 73 and 76 can be expandede with a {include-fancybox}\\\\n or {include-lightbox}\\\\n is You want a lighbox popup of the image
This is a sample output for the script:
...
RelativeDirectory structure (blank selects all images/movies) | No - If used, ThumbSize must be used also | $GrepFor |
Source of the Script: https://bitbucket.org/moseiseydk/confluence-gallery/src/1ccb4aa93b95d321c7d5c29ea776f799819bc6d0/updateGallery.sh?at=master