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

Sammenlign med nuværende Vis sidehistorik

« Forrige Version 40 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 [ThumbSize] [eGrep]

Samples:

./updateGallery.sh.multipage "FamilieBilleder/2012" "familiebilleder" "Familiebilleder 2012" yes 200

Gives the Page - Familiebilleder 2012

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

Gives the Page - Christopher

 

ParameterDescriptionRequiredIn script
RelativeDirectory

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

Yes$Dir

SpaceName

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

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

yes|no

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

Yes$MakeToc
ThumbSizedifferent thumbsize than the one included from config.txtNo$Width

eGrep

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

No - If used, ThumbSize must be used also$GrepFor

 

Source of the Script:

#!/bin/bash

source config.txt

IFS=$(echo -en "\n\b")

# Arguments from command line

Dir=$1
Space=$2
PageTitle=$3
MakeToc=$4
Width=$5
GrepFor=$6

# Check Arguments

if [ $# -lt 4 ] 
then

	echo "There are not at least 4 Arguments: Dir Space PageTitle yes/no"
	exit 0

fi

if [ ! -d $MediaRoot ]
then

        echo "MediaRoot in config.txt: $MediaRoot does not exist"
        exit 0

fi

if [ $Dir == "" ]
then
	echo "Argument 1 is empty"
	exit 0

fi

if [ ! -d $MediaRoot/$Dir ]

then

	echo "Argument 1 Dir: $Dir does not exist under $MediaRoot"
	exit 0
fi

if [ ! -d $CLIHome ]

then
        echo "CLIHome  in config.txt: $CLIHome does not exist"
        exit 0
fi

if [ $MakeToc == "no" ]
then

	echo "{make-top}" > $WikiFile
else

	echo "{make-top}" > $WikiFile
	echo "{toc}" >> $WikiFile
fi

# Create Thumbnails for images and video

if [ ! -e makeThumbs.sh ]
then
        echo "makeThumbs.sh script not found here"
        exit 0
fi

if [ ! $Width == "" ]
then
	# Replace with from config.txt with command line argument width
	echo "Replacing config.txt ThumbSize $ThumbSize with argument $Width"
	ThumbSize=$Width

fi

./makeThumbs.sh $ThumbSize $MediaRoot/"$Dir"
./makeThumbs.sh $DisplaySize $MediaRoot/"$Dir"

cd $MediaRoot/"$Dir"

# Create / update Parent - so we are sure it exists

$CLIHome/confluence.sh --action storePage --space "$Space" --title "$PageTitle"  --content ""

for file in `find . -type d | grep -v "thumbs" | grep -v "cache" | egrep -i "$GrepFor" | sort`

do

if [ $file != "." ]

	then

    	echo "" > $WikiPageFile
        echo $file

	   NumOfPics=`ls -t "$file" | egrep -i "\.(jpg|jpeg|gif|png|avi|flv|mov)$" | wc -l`

	if [ $NumOfPics -gt 0 ]

	then

		# The Directory is not emtpy, so update and create it
		file=$(echo "$file"|sed 's/\.\///g')
		group=$file

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

		do
			# Loop all images

			file2=$(echo "$file"|sed 's/ /%20/g')
			echo "{me-image:path=$Dir/$file2|image=$image|group=$group|thumbsize=$ThumbSize|displaysize=$DisplaySize}" >> $WikiPageFile
		
        done

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

        	do
			# Loop all video

			file2=$(echo "$file"|sed 's/ /%20/g')
            echo "{me-video:path=$Dir/$file2|image=$movie|thumbsize=$ThumbSize|displaysize=$DisplaySize}" >> $WikiPageFile

            done

    		title=$(echo "$file"|sed 's/\//-/g')

        	echo "h1. ${file}" >> $WikiFile
        	echo "{go-top}" >> $WikiFile
        	echo "{include:${title}}" >> $WikiFile
        	echo "----" >> $WikiFile

        	$CLIHome/confluence.sh --action storePage --space "$Space" --title "${title}" --parent "$PageTitle" --file $WikiPageFile --labels "noshow"
	fi
	fi	

done

$CLIHome/confluence.sh --action storePage --space "$Space" --title "$PageTitle" --file $WikiFile


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

  • Ingen etiketter