The TransistoriZed logo should be here! But... curses! Your browser does not support SVG!

homelist of postsdocsγ ~> e-about & FAQ


A continuation of the content management script.

I have been fiddling a bit with my page content management script. So now except the pages I am also auto-generating the page bars too. As another field test I will just as well share the skeleton of my generator.

We first have the basic stuff:

 ############## EDIT THIS ###########################
OUTPUT="/media/05022eeb-bcac-4484-8eb0-1b41d4eae750/site-tex-res/site-sync/dilemaltd.com/public_html/deyan-levski/test/"
FILE="index.htm"

DIRECTORIES="\
/media/05022eeb-bcac-4484-8eb0-1b41d4eae750/site-tex-res/site-sync/dilemaltd.com/public_html/deyan-levski/test/post/ \
"
FILENAMES='post*.htm'

#################################################### 
I.e. I look through the "post" folder and the html files in it and then build-up the pages by concatinating a base skeleton and the posts e.g.:

DATE=`date`
echo $BASE >> $OUTPUT$FILE
#declare -i cnt
#declare -i p

cnt=0
dobase=0
p=0

for f in $FILENAMES; do
for i in `find $DIRECTORIES -type f \( -iname "*$f*" ! -iname "*~" ! -iname ".*" \) | sort -V -r `; do

#flinedate=$(head -n 1 $i) #Auto file date fetch stuff, that is currently not implemented.
#echo $date

cnt=`expr $cnt + 1`

if  [ "$cnt" -lt 5 ] && [ "$p" -eq 0 ]
	then
	CATSTR=$OUTPUT$FILE
	cat $i >> $CATSTR


elif [ "$cnt" -lt 5 ] && [ "$p" -ne 0 ]
	then
	CATSTR=$OUTPUT$p$FILE
	cat $i >> $CATSTR


else
	cnt=0
	p=`expr $p + 1`
	CATSTR=$OUTPUT$p$FILE
	dobase=0
	if [ "$dobase" -eq 0 ]
	then
	echo $BASE >> $CATSTR
	dobase=1
	fi


	cat $i >> $CATSTR

fi

done
done

Then generate the pagebar:

z=0

for k in { 0..$p }; do # Generate bottom Page bar

CATSTR=$OUTPUT$z$FILE
MAININDEX=$OUTPUT$FILE

	if [ $z -ne 0 ]
	then
	olz=0
		echo "
Page: " >> $CATSTR for r in `seq 0 $p`;do olz=`expr $olz + 1` if [ "$olz" -eq 1 ] then echo "0  " >> $CATSTR else olzt=`expr $olz - 1` echo "$olzt  " >> $CATSTR fi done echo "
" >> $CATSTR echo "

Last edited: $DATE by $USER

" >> $CATSTR echo "\n" >> $CATSTR else olz=0 echo "
Page: " >> $MAININDEX for r in `seq 0 $p`;do olz=`expr $olz + 1` if [ "$olz" -eq 1 ] then echo "0  " >> $MAININDEX else olzt=`expr $olz - 1` echo "$olzt  " >> $MAININDEX fi done echo "
" >> $MAININDEX echo "

Last edited: $DATE by $USER

" >> $MAININDEX echo "\n" >> $MAININDEX fi z=`expr $z + 1` done

The latter also completes the end of the HTML and adds Last edit tag. We can then look at all our files and upload them to the server.

 # Connect to FTP and upload htmls.
ftp -n -v www.dilemaltd.com << EOT
ascii
user xxxx
prompt off
cd public_html/deyan-levski/test/
mput *.htm
cd post
mput post/*.htm
quit
EOT 

In an ideal world I can possibly extend this in the same fashion and make it a generic piece of code. If I do so, I will for sure write a proper post about it.

Date:Sun Mar 30 15:47:00 CEST 2014

Comments

No comments yet
*Name:
Email:
Notify me about new comments on this page
Hide my email
*Text: