add links

This commit is contained in:
Simon Vieille 2021-03-29 22:45:39 +02:00
parent 7db670ff5f
commit c3c49d89cd
5 changed files with 181 additions and 1 deletions

25
src/Api/TTRssClient.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Api;
/**
* class TTRssClient.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class TTRssClient
{
public function getPager(int $page = 1): array
{
$result = @file_get_contents('https://tiny.deblan.org/deblan_api/?page='.$page);
if ($result) {
$result = str_replace('\\u0092', "'", $result);
$result = str_replace('&#039;', "'", $result);
return json_decode($result, true);
}
return [];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Api\TTRssClient;
use App\Core\Controller\Site\PageController;
class LinkController extends PageController
{
public function links(TTRssClient $client, int $page = 1): Response
{
return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
'pager' => $client->getPager($page),
]);
}
}

View File

@ -75,7 +75,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
{% block page_subtitle %}
<p class="h3">
{# {{- 'IT director at Zenitude Groupe, symfony expert and debian addict' -}} #}
{{- 'DevOp animé par la culture du libre et du hacking' -}}
</p>
{% endblock %}

View File

@ -0,0 +1,74 @@
{% extends 'base.html.twig' %}
{%- block meta_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_title -%}
{{- _page.title.value -}}
{% endblock %}
{%- block page_subtitle -%}
{% if _page.subTitle.value %}
<p class="h3">
{{- _page.subTitle.value -}}
</p>
{% endif %}
{% endblock %}
{% block body %}
<div class="col-12">
<div class="body">
<form class="form" data-form="horizontal">
<div class="field col-8">
<label for="query">Mots clés</label>
<input id="query" name="query" type="text" value="{{ query }}" />
</div>
<div class="field col-4">
<input class="button" type="submit" value="Chercher">
</div>
</form>
</div>
</div>
{% if pager %}
{% for post in pager %}
{% if not loop.first %}
<hr class="col-12">
{% endif %}
{{ include('blog/post/_post.html.twig', {post: post}) }}
{% endfor %}
{% if pager.getPaginationData.pageCount > 1 %}
<div class="col-12">
<div class="body">
<div class="pager align-right">
{% block pager %}
{{ include('module/_pager.html.twig', {
route: _node.routeName,
routeParams: {query: query},
pages: pager.paginationData.endPage,
currentPage: pager.paginationData.current
}) }}
{% endblock %}
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endblock %}
{% block metas %}
{#
{{- parent() -}}
{% if page.pager.hasPreviousPage %}
<link rel="prev" href="{{ cms_path('posts', {page: page.pager.getPreviousPage}, true) }}" />
{% endif %}
{% if page.pager.hasNextPage %}
<link rel="next" href="{{ cms_path('posts', {page: page.pager.getNextPage}, true) }}" />
{% endif %}
#}
{% endblock %}

View File

@ -10,12 +10,75 @@
</p>
{% endblock %}
{% block css %}
{{- parent() -}}
<style>
#rss-icon {
color: #fd9f13;
}
</style>
{% endblock %}
{% block body %}
<div class="col-12">
<div class="body">
<div class="body-content">
{{- _page.content.value|markdown('post') -}}
<p>
<a target="_blank" title="RSS" href="{{ safe_path(_node.routeName ~ '_rss') }}">
<span id="rss-icon" class="deblan-icon deblan-icon-rss"></span>
{{- ' Flux RSS' -}}
</a>
</p>
</div>
</div>
</div>
{% if pager.items is defined %}
{% for item in pager.items %}
<div class="col-12">
<div class="body">
<div class="quick">
<div class="quick-body">
<h2 class="h4 no-margin">
<a href="{{ item.link }}" target="_blank">
{{- item.title -}}
</a>
</h2>
<p>
<a href="{{ item.link }}" target="_blank">
{{- item.link -}}
</a>
<br>
{{- item.timestamp|date("d/m/Y à H\\hi") -}}
</p>
</div>
</div>
</div>
</div>
{% endfor %}
{% if pager.maxPage %}
<div class="col-12">
<div class="body">
<div class="pager align-right">
{{ include('module/_pager.html.twig', {
route: _node.routeName,
routeParams: {},
pages: pager.maxPage,
currentPage: pager.page
}) }}
</div>
</div>
</div>
{% endif %}
{% else %}
<div class="grid">
<div class="col-12 alert alert-notice">
{{- 'Aucun lien disponible pour le moment.' -}}
</div>
</div>
{% endif %}
{% endblock %}