#!/bin/sh read -p "File name: " file_name read -p "URL alias: " url_alias read -p "Summary: " summ # Get title from the first line of the file title=$(sed -n '1s/^#\s*//p' "${file_name}") # Old way, decided to use less stuff but left it here cuz why not #title=$(cat "${file_name}" | head -1 | cut -c 3-) # Get the post header from the "head" file headerContent=$(cat blogposts/head) # Get the post abstract from the second line of the file postTitle=$(cat ${file_name} | grep --line-number \#\# | grep 2 | cut -c 6-) # Convert markdown content to HTML htmlContent=$(md2html "${file_name}") # Get the current date and time in the RFC 3339 format and regular format postDate=$(date +"%a, %d %b. %Y - %r") xmlDate=$(date --rfc-3339=seconds | sed 's/ /T/') remNums=$(cat atom.xml | wc -l) # Write the HTML file { echo "" echo "" echo "" echo "" echo "" echo "${title}" echo "${headerContent}" echo "" echo "" echo "${htmlContent}" echo "
Posted at ${postDate}

" echo "" echo "" cat "blogposts/tail" } > "blogposts/${url_alias}.html" # Add RSS entry echo " Tokhy's hub "${xmlDate}" Ahmed Gamal Eltokhy https://tokiesan.github.io ""$(sed -n 10,$(echo ${remNums}-1 | bc)p atom.xml)" > atom.xml echo " "${title}""${summ}""" "${xmlDate}" https://tokiesan.github.io/blogposts/${url_alias}.html " >> atom.xml # Add entry to blogposts/index.html newElem="\n${title}\n$(date +"%a, %d %b. %Y")\n" awk -v FOO1="${newElem}" '{ sub(//, " " FOO1); print; }' blogposts/index.html > temporary_output cat temporary_output > blogposts/index.html rm -rf temporary_output mv ${file_name} junk/ # Add new post to repo git add "blogposts/${url_alias}.html" "atom.xml" "blogposts/index.html" git commit -m "Added ${title} post" git push -u origin