Du ser en gammel version af denne side. Se den nuværende version.

Sammenlign med nuværende Vis sidehistorik

« Forrige Version 21 Næste »

This script travles a directory structure and creates WIKI markup and uses the Atlassian CLI for Confluence for updating a page 

 

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: make-top (User Macro)

User Macro: go-top (User Macro)

User Macro: me-image - Image lightbox with Slimbox2 (User Macro)

User Macro: include-lightbox - Slimbox2 including (In Custom HTML or Layout)

User Macro: me-video - Linking to a Video file (User Macro)

 

Executing the script:

./updateGallery.sh RelativeDirectory SpaceName PageName yes|no eGrep

Sample

./updateGallery.sh "FamilieBilleder" familiebilleder Christopher yes "Christopher|Stoffer"

Gives the Page - Christopher

 

ParameterDescription

RelativeDirectory

is the path to be traveled (this is /data/images/FamilieBilleder) for my installation, where /data/images is hardcoded in the script

SpaceName

is the Name of the Space where a page will be updated (or created)

PageNameis the Name of the Confluence page to be updated (or created) in the SpaceName Space

yes|no

determines if a TOC markup is inserted at the top of the page

eGrep

is an optional RegEx string for fine-picking from the RelativeDirectory structure (blank selects all images/movies)

Source of the Script:

#!/bin/bash


source config.txt

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 $ContentRoot/$Dir ]
then
	echo "Argument 1 Dir: $Dir does not exist"
	exit 0
fi
if [ ! -d $LinksRoot ]
then
        echo "LinksRoot: $LinksRoot does not exist"
        exit 0
fi
if [ $MakeToc == "no" ]
then
	echo "{make-top}" > /tmp/confluencewikimarkup.txt
else
	echo "{toc}" > /tmp/confluencewikimarkup.txt
	echo "{make-top}" >> /tmp/confluencewikimarkup.txt
fi

cd $ContentRoot/"$Dir"
for file in `find . -type d | grep -v "thumbs" | grep -v "cache" | egrep -i "$GrepFor" | sort`
do
 
 echo $file
	NumOfPics=`ls -t "$file" | egrep -i "\.(jpg|gif|png|avi|flv|mov)$" | wc -l`
	if [ $NumOfPics -gt 0 ]
	then
	
     	file=$(echo "$file"|sed 's/\.\///g')
		if [ $file != "." ]
		then
			echo "h1. ${file}" >> /tmp/confluencewikimarkup.txt
			echo "{go-top}" >> /tmp/confluencewikimarkup.txt
		fi

		group=$file


		for image in `ls "$file" | egrep -i "\.(jpg|gif|png)$"`
		do


			file2=$(echo "$file"|sed 's/ /%20/g')
			if [ $file2 == "." ]
			then
				file2=""
			else
				md5=`openssl md5 $ContentRoot/$Dir/$file/$image`
				md5=`echo $md5  | rev | cut -d ' '  -f1 | rev`
				rm $LinksRoot/$md5
				ln -s $ContentRoot/$Dir/$file/$image $LinksRoot/$md5
			fi

			echo "{me-image:path=$Dir/$file2/|image=$image|group=$group|md5=$md5}" >> /tmp/confluencewikimarkup.txt
		done


		for movie in `ls "$file" | egrep -i "\.(flv|avi|mov)$"` 
       	do


			file2=$(echo "$file"|sed 's/ /%20/g')
			md5=`openssl md5 $ContentRoot/$Dir/$file/$movie`
            md5=`echo $md5  | rev | cut -d ' '  -f1 | rev`
			rm $LinksRoot/$md5
            ln -s $ContentRoot/$Dir/$file/$movie $LinksRoot/$md5
         	echo "{me-video:path=$Dir/$file2/|image=$movie}" >> /tmp/confluencewikimarkup.txt
        done
	fi
	
done
/opt/atlassian-cli/confluence.sh --action storePage --space "$Space" --title "$PageTitle" --file /tmp/confluencewikimarkup.txt

This is a sample output for the script - screenhot of a page:

  • Ingen etiketter