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

Sammenlign med nuværende Vis sidehistorik

« Forrige Version 7 Næste »

This script travles a directory structure and creates WIKI markup (suitable for Confluence versions lower that 4.0).

Several Macros are neede for the final page to be displayed correctly. See User Macros

Executing the script:

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

Sample

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

Gives the Page - Christopher

Parameters:

RelativeDirectory

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

PageId

is Id for the Confluence page needed to be updated

yes|no

is if a TOC markup is inserted

eGrep

is an optional RegEx string for fine-picking from the Directory structure

Source of the Script:

#!/bin/bash


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


# 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
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')
                html="$html \n h1. $file \n {go-top} \n "
                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
                                file2="$file2/"
                        fi
                        html="$html {me-image:path=$Dir/$file2/|image=$image|group=$group}"
                done
                for movie in `ls "$file" | egrep -i "\.(flv|avi|mov)$"`
                do
                        file2=$(echo "$file"|sed 's/ /%20/g')
                        html="$html {me-video:path=$Dir/$file2/|image=$movie}"
                done
                html="$html \n "
        fi

done
/opt/atlassian-cli/confluence.sh --action storePage --space "$Space" --title "$PageTitle" --content "$html"

This is a sample output for the script:

{make-top}
{toc}

h1. 2 x Fødselsdag 03-09-2011
{go-top}

{me-image:path=FamilieBilleder/2011/2%20x%20Fødselsdag%2003-09-2011/|image=CIMG2034.JPG|group=2 x Fødselsdag 03-09-2011}
{me-image:path=FamilieBilleder/2011/2%20x%20Fødselsdag%2003-09-2011/|image=CIMG2035.JPG|group=2 x Fødselsdag 03-09-2011}
{me-image:path=FamilieBilleder/2011/2%20x%20Fødselsdag%2003-09-2011/|image=CIMG2036.JPG|group=2 x Fødselsdag 03-09-2011}
{me-image:path=FamilieBilleder/2011/2%20x%20Fødselsdag%2003-09-2011/|image=CIMG2037.JPG|group=2 x Fødselsdag 03-09-2011}
{me-image:path=FamilieBilleder/2011/2%20x%20Fødselsdag%2003-09-2011/|image=CIMG2038.JPG|group=2 x Fødselsdag 03-09-2011}
{me-image:path=FamilieBilleder/2011/2%20x%20Fødselsdag%2003-09-2011/|image=CIMG2039.JPG|group=2 x Fødselsdag 03-09-2011}

h1. Afslapning 24-07-2011
{go-top}
  • Ingen etiketter