30 lines
1.3 KiB
Bash
Executable File
30 lines
1.3 KiB
Bash
Executable File
# " --> "
|
|
# & --> &
|
|
# ' --> '
|
|
# < --> <
|
|
# > --> >
|
|
content="$(./hoedown "$1" | tail -n +2 | sed 's/</\<\;/g' | sed 's/>/\>\;/g')"
|
|
title=$(cat "$1" | head -n 1 | sed 's/# //' | sed -e 's/\r//g')
|
|
file=$(printf "$1" | sed 's/\.md$//' | sed 's/^\.\///')
|
|
|
|
config=$(cat ./config.txt)
|
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
|
|
|
#f_end="$(cat ./$prime_folder/$post/index.xml | tail -n 2)"
|
|
#f_start=$(cat ./$prime_folder/$post/index.xml | awk -v RS="$f_end" 'NR==1{printf $0} NR!=1{printf "%s", $0}')
|
|
f_start=$(head -n 6 "./static/$prime_folder$post/index.xml")
|
|
f_end=$(tail -n +7 "./static/$prime_folder$post/index.xml")
|
|
|
|
|
|
pub_date=$(date '+%a, %d %b %Y %H:%M:%S %z')
|
|
|
|
f_out=$(printf "$f_start\n<item>\n\t<title>$title</title>\n\t<pubDate>$pub_date</pubDate>\n\t<link>$url/$prime_folder$post/$file/</link>\n\t<guid>$url/$prime_folder$post/$file/</guid>\n\t<description>$content</description>\n</item>\n$f_end" | awk -v chunk="$(date '+%B %d/%d/%Y %I:%M%p')" '{gsub("<DATE_POST>",chunk)}1')
|
|
|
|
|
|
printf "$f_out"
|
|
printf "$f_out" > "static/$prime_folder$post/index.xml"
|