2012-01-19
I like using calepin; using markdown + dropbox is a great combination.
The below is a few tips on things that I found work well:
Needs some work:
{
"default_date_format": "%Y-%m-%d",
"google_analytics": "UA-27986535-1"
}
remember to remove the last “,” or it doesn’t work
I add a footer to my posts like this:
<footer><div class="metadata">...</div></footer>
I add ads to my site like this:
<div style="z-index: 2; position: absolute; right: 10px; top: 165px;">
...
</div>
I need to fix this so it works on mobile sites better.
My file naming convention is yyyy-mm-ddTHHMM title.md
, so I use this script to check that the title and the date matches between the file name and blog post:
Note: this is a work in progress!
:::bash
#!/bin/bash
set -e
set -u
blogdir='/home/davidmarsh/Dropbox/blog'
for post in *.md ; do
### check dates
#todo, check for valid dates
file_date="$(echo "${post}" | cut -d" " -f1)"
blog_date="$(grep '^Date:' "${post}" | cut -d: -f2- | sed -e 's/^ //' -e 's/ /T/' -e 's/://')"
if [[ "${file_date:=""}" != "${blog_date:=""}" ]] ; then
echo
echo "----------------------------------------"
echo "dates are different: ${post}"
echo
echo "1. file date: ${file_date}"
echo "2. blog date: ${blog_date}"
echo
echo -n "which one is correct [1,2]:"
read choice
case ${choice} in
1)
#file date is correct
echo "you chose 1"
#convert file date to blog format for use later
new_date="$(echo "${file_date}" | sed -e 's/T/ /')"
echo "so im gonna change ${blog_date} to ${new_date}"
;;
2)
#blog date is correct
echo "you chose 2"
#convert blog date to file date for use later
new_date="$(echo "${blog_date}" | sed -e 's/ /T/' -e 's/://')"
echo "so im gonna change ${file_date} to ${new_date}"
;;
*)
echo "skipping, doing nothing for ${post}"
;;
esac
fi
### check titles and slugs
file_title="$(echo "${post}" | cut -d" " -f2- | sed -e 's/\.md$//')"
blog_title="$(grep '^Title:' "${post}" | cut -d: -f2- | sed -e 's/^ //')"
if [[ "${file_title:=""}" != "${blog_title:=""}" ]] ; then
echo
echo "----------------------------------------"
echo "titles are different: ${post}"
echo
echo "1. file title: ${file_title}"
echo "2. blog title: ${blog_title}"
echo
echo -n "which one is correct [1,2]:"
read choice
case ${choice} in
1)
#file title is correct
echo "so im gonna change ${blog_title} to ${new_title}"
;;
2)
#blog title is correct
echo "so im gonna change ${file_title} to ${new_title}"
;;
*)
echo "skipping, doing nothing for ${post}"
;;
esac
fi
done
#find drafts
echo
echo "----------------------------------------"
echo "drafts:"
for post in "$(grep -l "^Status: " *.md)" ; do
echo "${post}"
done
I publish using this script:
:::bash
#!/bin/bash
#copies md and settings files from blog to calepin
#copies /images to /Public/images
set -e
set -u
uname="$(uname)"
if [[ "${uname}" == "Darwin" ]] ; then
homedir='/Users/davidmarsh'
else
homedir='/home/davidmarsh'
fi
blogdir="${homedir}/Dropbox/blog"
postdir="${homedir}/Dropbox/Apps/Calepin"
publicdir="${homedir}/Dropbox/Public"
adfile="${blogdir}/z_ad.txt"
footer="${blogdir}/z_footer.txt"
function publish_posts() {
rm "${postdir}"/*.md
cp "${blogdir}"/*.md "${postdir}"
cp "${blogdir}/settings.json" "${postdir}"
cp -R "${blogdir}/images" "${publicdir}"
}
function append_posts() {
for post in ${postdir}/*.md ; do
echo "${post}"
echo >> "${post}"
echo "----" >> "${post}"
for append in "${footer}" "${adfile}" ; do
echo >> "${post}"
cat "${append}" >> "${post}"
done
done
}
publish_posts
append_posts
if [[ "${uname}" == "Darwin" ]] ; then
open http://calepin.co/
fi