Added blog RSS feed

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI (W00d5t0ck) 2012-09-16 22:12:26 +02:00
parent df1a078bb9
commit 831f4ca317
4 changed files with 49 additions and 0 deletions

View File

@ -71,4 +71,20 @@ class BlogController extends Controller
'post' => $post, 'post' => $post,
); );
} }
/**
* @Route("/feed", name="GergelyPolonkaiFrontBundle_blogFeed", defaults={"_format": "xml"})
* @Template
*/
public function feedAction()
{
$query = $this->getDoctrine()->getEntityManager()->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p WHERE p.draft = FALSE ORDER BY p.createdAt DESC");
$query->setMaxResults(10);
$posts = $query->getResult();
return array(
'now' => new \DateTime('now'),
'posts' => $posts,
);
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Gergely Polonkai</title>
<description>Gergely Polonkai's Blog</description>
<link>{{ app.request.scheme }}://{{ app.request.host }}{{ app.request.basepath }}</link>
<lastBuildDate>{{ now|date('r') }}</lastBuildDate>
<pubDate>{{ now|date('r') }}</pubDate>
<ttl>7200</ttl>
<language>en</language>
<image>
<title>Gergely Polonkai</title>
<url>{{ app.request.scheme }}://{{ app.request.host }}{{ asset('bundles/gergelypolonkaifront/images/profile.png') }}</url>
<link>{{ app.request.scheme }}://{{ app.request.host }}{{ app.request.basepath }}</link>
</image>
{% for post in posts %}
<item>
<title><![CDATA[{{ post.title }}]]></title>
<link>{{ app.request.scheme }}://{{app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogViewPost', {year: post.createdAt|date('Y'), month: post.createdAt|date('m'), day: post.createdAt|date('d'), slug: post.slug }) }}</link>
<comments>{{ app.request.scheme }}://{{app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogViewPost', {year: post.createdAt|date('Y'), month: post.createdAt|date('m'), day: post.createdAt|date('d'), slug: post.slug }) }}#comments</comments>
<pubDate>{{ post.createdAt|date('r') }}</pubDate>
<description>Content lead</description>
<guid>{{ app.request.scheme }}://{{app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogViewPost', {year: post.createdAt|date('Y'), month: post.createdAt|date('m'), day: post.createdAt|date('d'), slug: post.slug }) }}</guid>
{#
<category><![CDATA[Cat1]]></category>
#}
</item>
{% endfor %}
</channel>
</rss>

View File

@ -7,6 +7,7 @@
{% stylesheets 'bundles/gergelypolonkaifront/css/*' filter='cssrewrite' output='css/gergelypolonkaiweb.css' %} {% stylesheets 'bundles/gergelypolonkaifront/css/*' filter='cssrewrite' output='css/gergelypolonkaiweb.css' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" media="screen" /> <link rel="stylesheet" type="text/css" href="{{ asset_url }}" media="screen" />
{% endstylesheets %} {% endstylesheets %}
<link rel="alternate" type="application/rss+xml" title="Gergely Polonkai's Blog - RSS Feed" href="{{ app.request.scheme }}://{{ app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogFeed') }}" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head> </head>
<body> <body>
@ -28,6 +29,7 @@
<a href="http://tumblr.w00d5t0ck.info" target="_blank"><img src="{{ asset('bundles/gergelypolonkaifront/images/tumblr_16.png') }}" alt="Tumblr" /></a> <a href="http://tumblr.w00d5t0ck.info" target="_blank"><img src="{{ asset('bundles/gergelypolonkaifront/images/tumblr_16.png') }}" alt="Tumblr" /></a>
<a href="msnim:chat?contact=polesz@w00d5t0ck.info" target="_blank"><img src="{{ asset('bundles/gergelypolonkaifront/images/windows_16.png') }}" alt="Windows Live" /></a> <a href="msnim:chat?contact=polesz@w00d5t0ck.info" target="_blank"><img src="{{ asset('bundles/gergelypolonkaifront/images/windows_16.png') }}" alt="Windows Live" /></a>
<a href="http://w00d5t0ck.deviantart.com" target="_blank"><img src="{{ asset('bundles/gergelypolonkaifront/images/deviantart_16.png') }}" alt="deviantArt" /></a> <a href="http://w00d5t0ck.deviantart.com" target="_blank"><img src="{{ asset('bundles/gergelypolonkaifront/images/deviantart_16.png') }}" alt="deviantArt" /></a>
<a href="{{ path('GergelyPolonkaiFrontBundle_blogFeed') }}"><img src="{{ asset('bundles/gergelypolonkaifront/images/rss_16.png') }}" alt="RSS Feed" /></a>
</div> </div>
</div> </div>
<div id="content"> <div id="content">