public function testWriter()
    {
        $writer = new Atom();
        $writer->title = 'My site';
        $writer->site_url = 'http://boo/';
        $writer->feed_url = 'http://boo/feed.atom';
        $writer->author = array('name' => 'Me', 'url' => 'http://me', 'email' => 'me@here');
        $writer->items[] = array('title' => 'My article 1', 'updated' => strtotime('-2 days'), 'url' => 'http://foo/bar', 'summary' => 'Super summary', 'content' => '<p>content</p>');
        $writer->items[] = array('title' => 'My article 2', 'updated' => strtotime('-1 day'), 'url' => 'http://foo/bar2', 'summary' => 'Super summary 2', 'content' => '<p>content 2 &nbsp; &copy; 2015</p>', 'author' => array('name' => 'Me too'));
        $writer->items[] = array('title' => 'My article 3', 'url' => 'http://foo/bar3');
        $generated_output = $writer->execute();
        $expected_output = '<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator uri="https://github.com/fguillot/picoFeed">PicoFeed</generator>
  <title>My site</title>
  <id>http://boo/</id>
  <updated>' . date(DATE_ATOM) . '</updated>
  <link rel="alternate" type="text/html" href="http://boo/"/>
  <link rel="self" type="application/atom+xml" href="http://boo/feed.atom"/>
  <author>
    <name>Me</name>
    <email>me@here</email>
    <uri>http://me</uri>
  </author>
  <entry>
    <title>My article 1</title>
    <id>http://foo/bar</id>
    <updated>' . date(DATE_ATOM, strtotime('-2 days')) . '</updated>
    <link rel="alternate" type="text/html" href="http://foo/bar"/>
    <summary>Super summary</summary>
    <content type="html"><![CDATA[<p>content</p>]]></content>
  </entry>
  <entry>
    <title>My article 2</title>
    <id>http://foo/bar2</id>
    <updated>' . date(DATE_ATOM, strtotime('-1 day')) . '</updated>
    <link rel="alternate" type="text/html" href="http://foo/bar2"/>
    <summary>Super summary 2</summary>
    <content type="html"><![CDATA[<p>content 2 &nbsp; &copy; 2015</p>]]></content>
    <author>
      <name>Me too</name>
    </author>
  </entry>
  <entry>
    <title>My article 3</title>
    <id>http://foo/bar3</id>
    <updated>' . date(DATE_ATOM) . '</updated>
    <link rel="alternate" type="text/html" href="http://foo/bar3"/>
  </entry>
</feed>
';
        $this->assertEquals($expected_output, $generated_output);
    }
예제 #2
0
        Response\Redirect('?action=show&menu=' . $menu . '&id=' . $id);
    }
    Response\Redirect('?action=' . $menu . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Display bookmarks page
Router\get_action('bookmarks', function () {
    $offset = Request\int_param('offset', 0);
    $nb_items = Model\Item\count_bookmarks();
    $items = Model\Item\get_bookmarks($offset, Model\Config\get('items_per_page'));
    Response\html(Template\layout('bookmarks', array('favicons' => Model\Feed\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => '', 'direction' => '', 'display_mode' => Model\Config\get('items_display_mode'), 'items' => $items, 'nb_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'bookmarks', 'title' => t('Bookmarks') . ' (' . $nb_items . ')')));
});
// Display bookmark feeds
Router\get_action('bookmark-feed', function () {
    // Check token
    $feed_token = Model\Config\get('feed_token');
    $request_token = Request\param('token');
    if ($feed_token !== $request_token) {
        Response\text('Access Forbidden', 403);
    }
    // Build Feed
    $writer = new Atom();
    $writer->title = t('Bookmarks') . ' - Miniflux';
    $writer->site_url = Helper\get_current_base_url();
    $writer->feed_url = $writer->site_url . '?action=bookmark-feed&token=' . urlencode($feed_token);
    $bookmarks = Model\Item\get_bookmarks();
    foreach ($bookmarks as $bookmark) {
        $article = Model\Item\get($bookmark['id']);
        $writer->items[] = array('id' => $article['id'], 'title' => $article['title'], 'updated' => $article['updated'], 'url' => $article['url'], 'content' => $article['content']);
    }
    Response\xml($writer->execute());
});