Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (21 sloc) 850 Bytes
<?php
require '../../cheapreads/evernote.php';
$template="booknotes.markdown";
$date_format = "D, d M Y H:i:s O";
$notes = getTag('book');
foreach($notes as $note) {
if(strpos($note['title'], 'TODO') !== false) {
// Not ready yet!
continue;
}
$parts = explode(' - ', $note['title']);
$book_id = array_pop($parts);
$book_title = implode(' - ', $parts);
$book_link = strtolower(str_replace(" ", "-", preg_replace("/[^A-Za-z0-9 ]/", '', $book_title)));
$output = str_replace("[[book_notes]]", $note['body'], file_get_contents($template));
$output = str_replace("[[book_link]]", $book_link, $output);
$output = str_replace("[[book_title]]", $book_title, $output);
$filename = '2017-03-23-book-' . $book_id . '-' . $book_link . '.markdown';
file_put_contents('../_posts/' . $filename, $output);
print "Wrote data to $filename\n";
}