Compare commits

...
Sign in to create a new pull request.

7 commits

15 changed files with 82 additions and 31 deletions

View file

@ -9,10 +9,10 @@
color: #000;
}
.k-panel[data-template="year"] .k-list-items .k-item:first-child {
.k-panel[data-template="year"] .k-section-name-texts .k-list-items .k-item:first-child {
margin-bottom: 2rem;
}
.k-panel[data-template="year"] .k-list-items::before {
.k-panel[data-template="year"] .k-section-name-texts .k-list-items::before {
content: "Texte princeps";
display: block;
padding: 0.5rem;

View file

@ -15,7 +15,7 @@ tabs:
type: pages
template: year
sortBy: title desc
- width: 1/1
- width: 1/2
sections:
allTextsSection:
label: Tous les textes

View file

@ -24,6 +24,14 @@ tabs:
templates:
- linear
- grid
linkedTextsSection:
type: fields
fields:
linkedTexts:
label: Textes liés
type: pages
query : site.find('textes').grandChildren.not(page.children)
help: textes enregistrés à une autre année à inclure aussi dans celle-ci.
- width: 2/3
fields:
edito:

8
site/models/year.php Normal file
View file

@ -0,0 +1,8 @@
<?php
class YearPage extends Page{
public function allTexts(){
$texts = $this->children()->listed();
$linked = $this->linkedTexts()->toPages();
return $texts->merge($linked);
}
}

View file

@ -1,15 +1,15 @@
<?php
Kirby::plugin('sylvainjule/code-editor', [
'options' => [
'options' => array(
'language' => 'css',
'size' => 'small',
'lineNumbers' => true,
'size' => 'small',
'lineNumbers' => true,
'tabSize' => 4,
'insertSpaces' => true,
'ignoreTabKey' => false,
],
'fields' => [
),
'fields' => array(
'code-editor' => require_once __DIR__ . '/lib/fields/code-editor.php',
],
),
]);

View file

@ -1,5 +1,17 @@
<?php
function allYears ($article) {
$years = new Pages([$article->parent()]);
foreach (site()->find('textes')->children() as $year) {
if ($year->linkedTexts()->toPages()->has($article)) {
$years = $years->add($year);
}
}
return $years;
}
function setTitleFontSizeClass($title, $level = 'h1')
{
$length = strlen($title);

View file

@ -37,7 +37,7 @@ $entryTopPos ??= 20;
"name": "<?= $page->author() ?>"
}],
"image": "<?= url('assets/images/logo.png') ?>",
"description": "<?= $page->title() ?>, par <?= $page->author()->toPage()->title() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= $page->parent()->title() ?>/<?= $page->category() ?>",
"description": "<?= $page->title() ?>, par <?= $page->author()->toPage()->title() ?>. Publié le <?= $page->published()->toDate('d/m/Y') ?> dans <?= implode(', ', allYears($page)->pluck('title')) ?>/<?= $page->category() ?>",
"datePublished": "<?= $page->published()->toDate('Y-m-d') ?>",
"dateModified": "<?= $page->modified('Y-m-d') ?>",
"url": "<?= $page->url() ?>",

View file

@ -29,9 +29,12 @@
<span class="light">publié le </span><?php echo $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($article) as $year):?>
<a href="<?= $year->url() ?>"><?= $year->title()?></a>/
<?php endforeach ?>
<a
href="/categories/<?= Str::slug($article->category()) ?>"><?= $article->category() ?></a>
</p>
</div>

View file

@ -18,7 +18,8 @@
class="see-more toggle-btn toggle-btn--left" @click="edito = !edito">Lire</button>
<?php endif ?>
<ul class="panel-item-content__texts texts">
<?php foreach($section->children() as $article): ?>
<?php $articles = method_exists($section, 'allTexts') ? $section->allTexts() : $section->children(); ?>
<?php foreach($articles as $article): ?>
<?php
$author = $article->author()->toPage() == null ? 'inconnu' : $article->author()->toPage()->title();
?>
@ -48,9 +49,11 @@
<span class="light">publié le </span><?php echo $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a
href="/categories/<?= Str::slug($article->category()) ?>"><?= $article->category() ?></a>
</p>
</div>

View file

@ -9,7 +9,11 @@
<span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>
</li>

View file

@ -23,7 +23,11 @@
<div class="text__infos">
<p>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>
</li>

View file

@ -27,9 +27,11 @@
href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le
</span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a
href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>

View file

@ -12,9 +12,11 @@
href="/auteurs/<?= Str::slug($page->author()->toPage()->title()) ?>"><?= $page->author()->toPage()->title() ?></a><br>
<span class="light">publié le
</span><?= $page->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $page->parent()->url() ?>"><?= $page->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($page) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a
href="/categories/<?= $page->category() ?>"><?= $page->category() ?></a>
</p>
<?php endslot() ?>

View file

@ -14,10 +14,11 @@
href="/auteurs/<?= Str::slug($page->author()->toPage()->title()) ?>"><?= $page->author()->toPage()->title() ?></a><br>
<span class="light">publié le
</span><?= $page->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $page->parent()->url() ?>"
title="voir les textes liés à l'année <?= $page->parent()->title() ?>"><?= $page->parent()->title() ?></a>
/ <a href="/categories/<?= Str::slug($page->category()) ?>"
<span class="light">dans</span>
<?php foreach(allYears($page) as $year): ?>
<a href="<?= $year->url() ?>" title="voir les textes liés à l'année <?= $year->title() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= Str::slug($page->category()) ?>"
title="voir les textes de la catégorie <?= $page->category() ?>"><?= $page->category() ?></a>
</p>
<?php endslot() ?>

View file

@ -28,7 +28,7 @@
>Lire</button>
<?php endif ?>
<ul class="texts">
<?php foreach($page->children() as $article): ?>
<?php foreach($page->allTexts() as $article): ?>
<li
class="text"
>
@ -40,7 +40,11 @@
<span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
<span class="light">dans</span>
<?php foreach(allYears($article) as $year):?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>
</li>