Skip to content

Commit

Permalink
Merge pull request #344 from lenybernard/feature/rss-feed
Browse files Browse the repository at this point in the history
add Blog RSS feed
  • Loading branch information
Leny BERNARD committed Feb 18, 2016
2 parents f7e08cf + 98d7007 commit b6ee283
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
17 changes: 17 additions & 0 deletions Bundle/BlogBundle/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ public function indexAction(Request $request, $blogId = null, $tab = 'articles')
);
}

/**
* New page.
*
* @Route("/feed/{slug}.rss", name="victoire_blog_rss", defaults={"_format" = "rss"})
*
* @param Request $request
* @Template("VictoireBlogBundle:Blog:feed.rss.twig")
*
* @return JsonResponse
*/
public function feedAction(Request $request, Blog $blog)
{
return [
'blog' => $blog,
];
}

/**
* New page.
*
Expand Down
14 changes: 14 additions & 0 deletions Bundle/BlogBundle/Resources/views/Blog/Tabs/_links.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% trans_default_domain "victoire" %}

<div class="vic-tab-content vic-modal-tab-content">
<div class="vic-tab-pane vic-active" id="links">
<ul>
<li>
<a href="{{ path('victoire_core_page_show', {'url': blog.url}) }}">URL</a>
</li>
<li>
<a href="{{ path('victoire_blog_rss', {'slug': blog.slug}) }}">Flux RSS</a>
</li>
</ul>
</div>
</div>
3 changes: 3 additions & 0 deletions Bundle/BlogBundle/Resources/views/Blog/Tabs/content.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
{{ render(controller('VictoireBlogBundle:Blog:' ~ tab, {'id' : blog.id})) }}
</div>
{% endfor %}
<div class="vic-tab-pane" id="victoire-blog-links">
{% include 'VictoireBlogBundle:Blog:Tabs/_links.html.twig' with {'id' : blog.id} %}
</div>
</div>
7 changes: 7 additions & 0 deletions Bundle/BlogBundle/Resources/views/Blog/Tabs/nav.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@
</a>
</li>
{% endfor %}
<li class="vic-pull-right">
<a href="#victoire-blog-links" role="vic-tab" data-toggle="vic-tab">
{% spaceless %}
<i class="fa fa-link"></i>
{% endspaceless %}
</a>
</li>
</ul>
27 changes: 20 additions & 7 deletions Bundle/BlogBundle/Resources/views/Blog/feed.rss.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
{% extends 'VictoireCoreBundle::_modal.html.twig' %}
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>{{ blog.name }}</title>
<link>{{ url('victoire_core_page_show', {'url': blog.url}) }}</link>
<description>{{ blog.seo|default({'description' : ''}).description }}</description>

{% block modal_header_title %}
{% if blog.seo and blog.seo.ogImage %}
<image>
<url>{{ blog.seo.ogImage.url }}</url>
<link>{{ url('victoire_core_page_show', {'url': blog.url}) }}</link>
</image>
{% endif %}

{% endblock %}

{% block modal_body_content %}

{% endblock %}
{% for article in blog.articles %}<item>
<title>{{ article.name }}</title>
<link>{{ vic_business_link(article, null, constant('\\Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_URL')) }}</link>
<description>{{ article.description }}</description>
</item>
{% endfor %}

</channel>
</rss>
4 changes: 4 additions & 0 deletions Bundle/SeoBundle/Resources/views/_meta.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content='width=device-width, initial-scale=1' name='viewport'/>

{% if view.articles is defined %}
<link rel="alternate" type="application/rss+xml" title="{{ view.name }}" href="{{ path('victoire_blog_rss', {'slug': view.slug}) }}"/>
{% endif %}

{% if view is defined and view.seo is defined and view.seo %}
<!-- Basics -->
{% if view.seo.metaTitle %}<title>{{ view.seo.metaTitle }}</title>{% endif %}
Expand Down

0 comments on commit b6ee283

Please sign in to comment.