diff options
author | Nicolas BERNSTEIN <alexis211@gmail.com> | 2012-04-13 19:17:17 +0200 |
---|---|---|
committer | Nicolas BERNSTEIN <alexis211@gmail.com> | 2012-04-13 19:17:17 +0200 |
commit | a535a9e7e017629178b45acc2e96e1d674a0d6fc (patch) | |
tree | b983c468aa37422bb58ff560b91eed067ca1a96e /tpl/blog/atom_feed.php | |
parent | ccff9ce8d8a2818699ce4e20a310986fc95ea022 (diff) | |
download | Bits-a535a9e7e017629178b45acc2e96e1d674a0d6fc.tar.gz Bits-a535a9e7e017629178b45acc2e96e1d674a0d6fc.zip |
Added : ATOM feed for blog ; abilty to comment posts.
Diffstat (limited to 'tpl/blog/atom_feed.php')
-rw-r--r-- | tpl/blog/atom_feed.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tpl/blog/atom_feed.php b/tpl/blog/atom_feed.php new file mode 100644 index 0000000..20dc0ea --- /dev/null +++ b/tpl/blog/atom_feed.php @@ -0,0 +1,37 @@ +<?php +header("Content-Type: application/xml"); + +echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; +echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n"; +echo '<title>' . $blog_title . '</title>'."\n"; +echo '<id>' . $blog_base_url . "blog". "</id>\n"; +echo '<link href="' . $blog_base_url . "blog". '" rel="self" />' . "\n"; + + +function beginning($text, $len = 500) { + $text = preg_replace('#<.+>#isU', ' ', $text); + if (strlen($text) > $len) { + $text = substr($text, 0, $len)."..."; + } + return $text; +} + +foreach ($posts as $post) { + echo "\n<entry>\n"; + echo '<title>' . $post['title'] . "</title>\n"; + echo '<published>' . @date("c", $post['date_ts']) . "</published>\n"; + echo '<id>' . $blog_base_url . "view-blog-" . $post['id'] . "</id>\n"; + foreach (explode(', ', $post['tags']) as $tag) { + echo '<category term="' . $tag . '" />' . "\n"; + } + echo '<link href="' . $blog_base_url . "view-blog-" . $post['id'] . '" />' . "\n"; + echo '<summary type="html"><![CDATA['. beginning($post['text_html']) .']]></summary>' . "\n"; + echo '<content type="html"><![CDATA['. $post['text_html'] ."]]></content>\n"; + echo "<author><name>".$post['owner']."</name></author>\n"; + echo "</entry>\n"; +} + +echo '</feed>'; + +die(); + |