mirror of
https://github.com/kvazar-network/webapp.git
synced 2025-02-03 10:46:04 +00:00
implement rss feeds
This commit is contained in:
parent
e204a524c0
commit
19718ab4e1
@ -28,13 +28,20 @@ class MainController extends AbstractController
|
|||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
public function index(
|
public function index(
|
||||||
?Request $request
|
?Request $request,
|
||||||
|
?Response $response
|
||||||
): Response
|
): Response
|
||||||
{
|
{
|
||||||
$index = new \Kvazar\Index\Manticore();
|
$index = new \Kvazar\Index\Manticore();
|
||||||
|
|
||||||
|
if ($rss = ('rss' == $request->get('feed')))
|
||||||
|
{
|
||||||
|
$response = new Response();
|
||||||
|
$response->headers->set('Content-Type', 'text/xml');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'default/main/index.html.twig',
|
$rss ? 'default/main/index.rss.twig' : 'default/main/index.html.twig',
|
||||||
[
|
[
|
||||||
'request' => $request,
|
'request' => $request,
|
||||||
'records' => $index->get(
|
'records' => $index->get(
|
||||||
@ -46,7 +53,8 @@ class MainController extends AbstractController
|
|||||||
$request->get('part') > 1 ? (int) $request->get('part') * $this->getParameter('app.main.index.limit') : 0,
|
$request->get('part') > 1 ? (int) $request->get('part') * $this->getParameter('app.main.index.limit') : 0,
|
||||||
$this->getParameter('app.main.index.limit')
|
$this->getParameter('app.main.index.limit')
|
||||||
)
|
)
|
||||||
]
|
],
|
||||||
|
$response
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,13 +76,20 @@ class MainController extends AbstractController
|
|||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
public function namespace(
|
public function namespace(
|
||||||
?Request $request
|
?Request $request,
|
||||||
|
?Response $response
|
||||||
): Response
|
): Response
|
||||||
{
|
{
|
||||||
$index = new \Kvazar\Index\Manticore();
|
$index = new \Kvazar\Index\Manticore();
|
||||||
|
|
||||||
|
if ($rss = ('rss' == $request->get('feed')))
|
||||||
|
{
|
||||||
|
$response = new Response();
|
||||||
|
$response->headers->set('Content-Type', 'text/xml');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'default/main/namespace.html.twig',
|
$rss ? 'default/main/namespace.rss.twig' : 'default/main/namespace.html.twig',
|
||||||
[
|
[
|
||||||
'request' => $request,
|
'request' => $request,
|
||||||
'records' => $index->get(
|
'records' => $index->get(
|
||||||
@ -93,7 +108,8 @@ class MainController extends AbstractController
|
|||||||
'title' => $this->_title(
|
'title' => $this->_title(
|
||||||
$request->get('namespace')
|
$request->get('namespace')
|
||||||
)
|
)
|
||||||
]
|
],
|
||||||
|
$response
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,4 +60,9 @@
|
|||||||
}
|
}
|
||||||
) }}">{{ 'newer' | trans }}</a>
|
) }}">{{ 'newer' | trans }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="t-center px-16">
|
||||||
|
<div class="pb-16 f-s-12">
|
||||||
|
<a href="{{ path('main_index',{'feed':'rss'}) }}">{{ 'RSS' | trans }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
17
templates/default/main/index.rss.twig
Normal file
17
templates/default/main/index.rss.twig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
|
<channel>
|
||||||
|
<atom:link href="{{ url('main_index') }}" rel="self" type="application/rss+xml"></atom:link>
|
||||||
|
<title>{{ app.name }}</title>
|
||||||
|
<link>{{ url('main_index') }}</link>
|
||||||
|
{% for record in records %}
|
||||||
|
<item>
|
||||||
|
<title>{{ record.key }}</title>
|
||||||
|
<author>{{ record.namespace }}</author>
|
||||||
|
<pubDate>{{ record.time | date('D, d M Y h:i:s O') }}</pubDate>
|
||||||
|
<guid>{{ url('main_transaction',{'transaction':record.transaction}) }}</guid>
|
||||||
|
<link>{{ url('main_transaction',{'transaction':record.transaction}) }}</link>
|
||||||
|
</item>
|
||||||
|
{% endfor %}
|
||||||
|
</channel>
|
||||||
|
</rss>
|
@ -63,4 +63,9 @@
|
|||||||
}
|
}
|
||||||
) }}">{{ 'newer' | trans }}</a>
|
) }}">{{ 'newer' | trans }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="t-center px-16">
|
||||||
|
<div class="pb-16 f-s-12">
|
||||||
|
<a href="{{ path('main_namespace',{'namespace':request.get('namespace'),'feed':'rss'}) }}">{{ 'RSS' | trans }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
17
templates/default/main/namespace.rss.twig
Normal file
17
templates/default/main/namespace.rss.twig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
|
<channel>
|
||||||
|
<atom:link href="{{ url('main_namespace',{'namespace':request.get('namespace')}) }}" rel="self" type="application/rss+xml"></atom:link>
|
||||||
|
<title>{{ app.name }}</title>
|
||||||
|
<link>{{ url('main_namespace',{'namespace':request.get('namespace')}) }}</link>
|
||||||
|
{% for record in records %}
|
||||||
|
<item>
|
||||||
|
<title>{{ record.key }}</title>
|
||||||
|
<author>{{ record.namespace }}</author>
|
||||||
|
<pubDate>{{ record.time | date('D, d M Y h:i:s O') }}</pubDate>
|
||||||
|
<guid>{{ url('main_transaction',{'transaction':record.transaction}) }}</guid>
|
||||||
|
<link>{{ url('main_transaction',{'transaction':record.transaction}) }}</link>
|
||||||
|
</item>
|
||||||
|
{% endfor %}
|
||||||
|
</channel>
|
||||||
|
</rss>
|
Loading…
x
Reference in New Issue
Block a user