Skip to content

Commit d8c9a37

Browse files
committed
list tags, categories and hotfixes
1 parent c3372ff commit d8c9a37

File tree

8 files changed

+123
-19
lines changed

8 files changed

+123
-19
lines changed

app/public/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
$router->map('GET', '/page/{page:number}', [HomeController::class, 'index']);
3535
$router->map('GET', '/feeds', [FeedController::class, 'index']);
3636
$router->map('GET', '/feeds/page/{page:number}', [FeedController::class, 'index']);
37+
$router->map('GET', '/categories', [HomeController::class, 'categories']);
38+
$router->map('GET', '/tags', [HomeController::class, 'tags']);
39+
$router->map('GET', '/feed-builder', [FeedController::class, 'feedBuilder']);
3740
$router->map('GET', '/feed', [FeedController::class, 'rss']);
3841
$router->map('GET', '/feed/json', [FeedController::class, 'json']);
3942
$router->map('GET', '/feed/rss', [FeedController::class, 'rss']);

app/src/Controllers/HomeController.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,28 @@ private function buildQueryString(array $params): string
134134

135135
return '?' . http_build_query($params);
136136
}
137+
138+
public function categories(ServerRequestInterface $request): ResponseInterface
139+
{
140+
$categories = DB::query("SELECT * FROM categories ORDER BY name");
141+
142+
$html = $this->templates->render('categories-list', [
143+
'categories' => $categories,
144+
'title' => 'Categorias'
145+
]);
146+
147+
return new HtmlResponse($html);
148+
}
149+
150+
public function tags(ServerRequestInterface $request): ResponseInterface
151+
{
152+
$tags = DB::query("SELECT * FROM tags ORDER BY name");
153+
154+
$html = $this->templates->render('tags-list', [
155+
'tags' => $tags,
156+
'title' => 'Tags'
157+
]);
158+
159+
return new HtmlResponse($html);
160+
}
137161
}

app/templates/categories-list.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php $this->layout('layout', ['title' => 'Categorias']) ?>
2+
3+
<?php $this->start('active') ?>categories<?php $this->stop() ?>
4+
5+
<div class="card shadow-sm">
6+
<div class="card-header">
7+
<h3 class="fs-5 fw-medium mb-1 mt-1">
8+
<i class="bi bi-folder me-1"></i>
9+
Categorias
10+
</h3>
11+
</div>
12+
13+
<?php if (empty($categories)): ?>
14+
<div class="card-body text-center p-4">
15+
<p class="text-secondary mb-0">Nenhuma categoria encontrada.</p>
16+
</div>
17+
<?php else: ?>
18+
<div class="list-group list-group-flush">
19+
<?php foreach ($categories as $category): ?>
20+
<a href="/?category=<?= $this->e($category['slug']) ?>" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
21+
<div>
22+
<h5 class="m-0 fs-6 d-flex justify-content-center align-items-center">
23+
<i class="bi bi-folder me-2 text-info"></i>
24+
<span><?= $this->e($category['name']) ?></span>
25+
</h5>
26+
<?php if (!empty($category['description'])): ?>
27+
<p class="mb-0 text-secondary small"><?= $this->e($category['description']) ?></p>
28+
<?php endif; ?>
29+
</div>
30+
<span class="badge bg-info text-dark rounded-pill">
31+
<?= $category['item_count'] ?>
32+
<?= $category['item_count'] == 1 ? 'artigo' : 'artigos' ?>
33+
</span>
34+
</a>
35+
<?php endforeach; ?>
36+
</div>
37+
<?php endif; ?>
38+
</div>

app/templates/feeds.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="col-12 col-md-8 pb-1 pb-md-0 pt-3 pt-md-0">
1515
<form action="/feeds" method="GET">
1616
<div class="row g-2">
17-
<div class="col-12 col-md-5">
17+
<div class="col-6 col-md-5">
1818
<select name="category" class="form-select">
1919
<option value="">Todas Categorias</option>
2020
<?php foreach ($categories as $category): ?>
@@ -24,7 +24,7 @@
2424
<?php endforeach; ?>
2525
</select>
2626
</div>
27-
<div class="col-12 col-md-5">
27+
<div class="col-6 col-md-5">
2828
<select name="tag" class="form-select">
2929
<option value="">Todas Tags</option>
3030
<?php foreach ($tags as $tag): ?>

app/templates/home.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<?php endforeach; ?>
3030
</select>
3131
</div>
32-
<div class="col-12 col-md-3">
32+
<div class="col-6 col-md-3">
3333
<select name="category" class="form-select">
3434
<option value="">Todas Categorias</option>
3535
<?php foreach ($categories as $category): ?>
@@ -39,7 +39,7 @@
3939
<?php endforeach; ?>
4040
</select>
4141
</div>
42-
<div class="col-12 col-md-2">
42+
<div class="col-6 col-md-2">
4343
<select name="tag" class="form-select">
4444
<option value="">Todas Tags</option>
4545
<?php foreach ($tags as $tag): ?>
@@ -68,7 +68,7 @@
6868

6969
<?php if (empty($items)): ?>
7070
<div class="card-body text-center p-4">
71-
<p class="text-secondary">
71+
<p class="text-secondary mb-0">
7272
<i class="bi bi-exclamation-circle me-1"></i>
7373
Nenhum item encontrado. Tente ajustar sua pesquisa ou filtro.
7474
</p>

app/templates/layout.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
<i class="bi bi-journal-text me-1"></i>
6262
Feeds
6363
</a>
64+
<a href="/categories" class="d-inline-flex align-items-center pe-1 py-2 me-3 text-decoration-none <?= $this->section('active') === 'categories' ? 'border-white text-white' : 'text-secondary hover-text-white' ?>">
65+
<i class="bi bi-folder me-1"></i>
66+
Categorias
67+
</a>
68+
<a href="/tags" class="d-inline-flex align-items-center pe-1 py-2 me-3 text-decoration-none <?= $this->section('active') === 'tags' ? 'border-white text-white' : 'text-secondary hover-text-white' ?>">
69+
<i class="bi bi-tags me-1"></i>
70+
Tags
71+
</a>
6472
<a href="/suggest-feed" class="d-inline-flex align-items-center pe-1 py-2 me-3 text-decoration-none <?= $this->section('active') === 'suggest-feed' ? 'border-white text-white' : 'text-secondary hover-text-white' ?>">
6573
<i class="bi bi-plus-circle me-1"></i>
6674
Sugerir
@@ -69,11 +77,8 @@
6977
</nav>
7078
</div>
7179
<div class="d-flex align-items-center">
72-
<a href="/feed/rss" target="_blank" class="btn btn-sm btn-outline-secondary me-2" title="Feed RSS">
73-
<i class="bi bi-rss"></i> RSS
74-
</a>
75-
<a href="/feed/json" target="_blank" class="btn btn-sm btn-outline-secondary me-2" title="Feed JSON">
76-
<i class="bi bi-braces"></i> JSON
80+
<a href="/feed-builder" class="btn btn-sm btn-outline-secondary me-2" title="Construtor de Feed">
81+
<i class="bi bi-braces"></i> Feed
7782
</a>
7883
<button id="darkModeToggle" class="btn btn-sm btn-outline-secondary">
7984
<i class="bi bi-sun d-none" id="lightIcon"></i>
@@ -96,11 +101,8 @@
96101
&copy; <?= date('Y') ?> - Diretório e buscador de blogs pessoais atualizado em tempo real.
97102
</p>
98103
<p class="text-center mt-2 mb-0">
99-
<a href="/feed/rss" target="_blank" class="btn btn-sm btn-outline-secondary mx-1" title="Feed RSS">
100-
<i class="bi bi-rss"></i> RSS
101-
</a>
102-
<a href="/feed/json" target="_blank" class="btn btn-sm btn-outline-secondary mx-1" title="Feed JSON">
103-
<i class="bi bi-braces"></i> JSON
104+
<a href="/feed-builder" class="btn btn-sm btn-outline-secondary mx-1" title="Construtor de Feed">
105+
<i class="bi bi-braces"></i> Feed
104106
</a>
105107
<a href="https://github.com/manualdousuario/lerama" target="_blank" class="btn btn-sm btn-outline-secondary mx-1" title="GitHub">
106108
<i class="bi bi-github"></i> GitHub

app/templates/suggest-feed.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<div class="card shadow-sm">
66
<div class="card-header">
7-
<h3 class="fs-5 fw-medium mb-0 mt-1">
7+
<h3 class="fs-5 fw-medium mb-1 mt-1">
88
<i class="bi bi-megaphone me-1"></i>
99
Sugerir
1010
</h3>
@@ -31,13 +31,12 @@
3131

3232
<p class="text-secondary mb-4">
3333
Conhece um blog interessante que deveria estar no nosso agregador? Sugira aqui!
34-
Valide que o feed é acessível antes de enviar a sugestão.
3534
</p>
3635

3736
<form id="suggest-form" method="POST" action="/suggest-feed">
3837
<div class="mb-3">
3938
<label for="title" class="form-label">
40-
Título do Site
39+
Título
4140
</label>
4241
<div class="input-group">
4342
<span class="input-group-text">
@@ -74,7 +73,7 @@ class="form-control" required
7473

7574
<div class="mb-3">
7675
<label for="site_url" class="form-label">
77-
URL do Blog
76+
URL do Site
7877
</label>
7978
<div class="input-group">
8079
<span class="input-group-text">

app/templates/tags-list.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php $this->layout('layout', ['title' => 'Tags']) ?>
2+
3+
<?php $this->start('active') ?>tags<?php $this->stop() ?>
4+
5+
<div class="card shadow-sm">
6+
<div class="card-header">
7+
<h3 class="fs-5 fw-medium mb-1 mt-1">
8+
<i class="bi bi-tags me-1"></i>
9+
Tags
10+
</h3>
11+
</div>
12+
13+
<?php if (empty($tags)): ?>
14+
<div class="card-body text-center p-4">
15+
<p class="text-secondary mb-0">Nenhuma tag encontrada.</p>
16+
</div>
17+
<?php else: ?>
18+
<div class="list-group list-group-flush">
19+
<?php foreach ($tags as $tag): ?>
20+
<a href="/?tag=<?= $this->e($tag['slug']) ?>" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
21+
<div>
22+
<h5 class="m-0 fs-6 d-flex justify-content-center align-items-center">
23+
<i class="bi bi-tag me-2 text-secondary"></i>
24+
<span><?= $this->e($tag['name']) ?></span>
25+
</h5>
26+
<?php if (!empty($tag['description'])): ?>
27+
<p class="mb-0 text-secondary small"><?= $this->e($tag['description']) ?></p>
28+
<?php endif; ?>
29+
</div>
30+
<span class="badge bg-secondary rounded-pill">
31+
<?= $tag['item_count'] ?>
32+
<?= $tag['item_count'] == 1 ? 'artigo' : 'artigos' ?>
33+
</span>
34+
</a>
35+
<?php endforeach; ?>
36+
</div>
37+
<?php endif; ?>
38+
</div>

0 commit comments

Comments
 (0)