Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 26 lines (21 sloc) 1.37 KB
#! /bin/bash
FILES=`find /home/bala/blog/posts -maxdepth 1 -mindepth 1 -name "*.html"| sort -r`;
cat /home/bala/blog/data/html-templates/index-template-header.html > /home/bala/blog/index.html
for POST in $FILES;
TITLE="$(grep -o '<h1>.*</h1>' $POST | sed 's/<h1>\|<\/h1>//g')"
LINK="./posts/$(echo $POST | awk -F'/' '{print $NF}')"
DESC="$(grep -oP '(?<=<meta name="description" content=").+?(?=">)' $POST)"
DATE="$(grep -oP '(?<=<meta name="pubDate" content=").+?(?=">)' $POST)"
IMAGE="$(grep -oP '(?<=<meta name="image" content=").+?(?=">)' $POST | cut -c2- )"
printf "\t<div class='blogcontainer'>\n" >> /home/bala/blog/index.html
printf "\t\t<a style=\"background-image: url('$IMAGE-thumb');\" class='blogimage' href='$LINK'></a>\n" >> /home/bala/blog/index.html
printf "\t\t<div class='blogdetails'>\n" >> /home/bala/blog/index.html
printf "\t\t\t<h2><a href='$LINK'>$TITLE</a></h2>\n" >> /home/bala/blog/index.html
printf "\t\t\t<div class='date'>$DATE</div>\n" >> /home/bala/blog/index.html
printf "\t\t\t<div class='description'>$DESC</div>\n" >> /home/bala/blog/index.html
printf "\t\t</div>\n" >> /home/bala/blog/index.html
printf "\t</div>\n" >> /home/bala/blog/index.html
printf "\t<hr>\n" >> /home/bala/blog/index.html
cat /home/bala/blog/data/html-templates/index-template-footer.html >> /home/bala/blog/index.html
You can’t perform that action at this time.