#!/bin/sh


software_version() {

	VERSION=`cat VERSION`

}

niouzes_compil() {
	DIR_SAVE=`pwd`
	cd /home/gilles/public_html/www.linux-france.org/html/
	m4 niouzes.m4 > niouzes.xml
	python ./niouzes/getmynews.py --neuf niouzes.xml > niouzes-neuf.html
	python ./niouzes/getmynews.py --html niouzes.xml > niouzes-html.html
	cd $DIR_SAVE
}



lfo_announce() {
software_version
NEWS_FILE="/home/gilles/public_html/www.linux-france.org/html/niouzes/niouzes_imapsync.xml"
if ! newer VERSION $NEWS_FILE; then 
	echo "$VERSION already announced"
else
	cat > $NEWS_FILE << EOF

<news date="`date  '+%Y%m%d'`">
`LANG=fr_FR date  '+%A %d %B %Y'` : Synchronisez ou migrez vos boites 
aux lettres avec conomie et l'outil <A
HREF="prj/imapsync/">imapsync $VERSION</A> (Gilles LAMIRAL)
</news>
EOF
fi
niouzes_compil
}

#' nedit sucks with syntax color

fm_init() {
software_version
NEWS_FILE_FM="./freshmeat_submition"
NEWS_FILE_FM_INP=${NEWS_FILE_FM}.inp
NEWS_FILE_FM_OUT=${NEWS_FILE_FM}.out

}

fm_read_param() {
# read definitions
. $NEWS_FILE_FM_INP
}


fm_read_announce() {

  fm_init
  fm_read_param

  cat << EOF
Project: imapsync
Version: $VERSION
Release-Focus: $RELEASE_FOCUS
Hide: N
Home-Page-URL: http://www.linux-france.org/prj/imapsync/
Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/

$TEXT_BODY

EOF
}

fm_announce() {
  fm_init

  if ! newer VERSION $NEWS_FILE_FM_OUT; then 
	echo "$VERSION already submitted on freshmeat"
  else
    if newer VERSION $NEWS_FILE_FM_INP; then
	echo "Update $NEWS_FILE_FM_INP please"
	return 1
    fi

    fm_read_announce > $NEWS_FILE_FM_OUT 
    freshmeat-submit < $NEWS_FILE_FM_OUT
  fi
}


