function post_to_item(DOMDocument $dom, Array $post) {
$mime_type = $post['MIME_TYPE'];
- $post_id = $post['ID'];
+ $post_id = $post['POST_ID'];
+ $pic_id = $post['PIC_ID'];
+ $post_size = $post['SIZE'];
$post_body = $post['BODY'];
$timestamp = $post['TIMESTAMP'];
$item = $dom->createElement('item');
$link = $dom->createElement('link', "https://pics.jacobcasper.com/#post-{$post_id}");
$guid = $dom->createElement('guid', "https://pics.jacobcasper.com/#post-{$post_id}");
$pub_date = $dom->createElement('pubDate', date(DATE_RSS, $timestamp));
- // TODO write the endpoint for this
- //$enclosure = $dom->createElement('enclosure');
- //$enclosure->setAttribute('url', "https://pics.jacobcasper.com/pic/{$post_id}");
- //$enclosure->setAttribute('length', "9999");
- //$enclosure->setAttribute('type', $mime_type);
+ $enclosure = $dom->createElement('enclosure');
+ $enclosure->setAttribute('url', "https://pics.jacobcasper.com/pic/{$pic_id}");
+ $enclosure->setAttribute('length', $post_size);
+ $enclosure->setAttribute('type', $mime_type);
$item->appendChild($description);
- //$item->appendChild($enclosure);
+ $item->appendChild($enclosure);
$item->appendChild($link);
$item->appendChild($guid);
$item->appendChild($pub_date);
$channel_node = $rss_dom->firstChild->childNodes[1];
$db = get_db();
$posts = $db->query('SELECT
- p.ID, p.TIMESTAMP, pi.MIME_TYPE, c.BODY
+ p.ID as POST_ID,
+ pi.id as PIC_ID,
+ p.TIMESTAMP,
+ pi.MIME_TYPE,
+ length(pi.PIC_B64) as SIZE,
+ c.BODY
FROM posts p
JOIN pics pi on p.id = pi.post_id
JOIN comments c on p.id = c.post_id