From aea050f6cc2d5f1ce7147f68c3388329c07780da Mon Sep 17 00:00:00 2001 From: isUnknown Date: Sun, 26 Jan 2025 13:00:50 +0100 Subject: [PATCH] fix #14 --- site/blueprints/pages/author.yml | 5 ++++- site/blueprints/users/author.yml | 25 ------------------------- site/config/config.php | 1 - site/config/routes/virtual-author.php | 25 ------------------------- site/plugins/helpers/index.php | 12 +++--------- site/templates/author.php | 24 ++++++++++++------------ site/templates/error.php | 16 ++++++++++++++++ site/templates/linear.php | 1 + 8 files changed, 36 insertions(+), 73 deletions(-) delete mode 100644 site/blueprints/users/author.yml delete mode 100644 site/config/routes/virtual-author.php create mode 100644 site/templates/error.php diff --git a/site/blueprints/pages/author.yml b/site/blueprints/pages/author.yml index ad0cf12..879435b 100644 --- a/site/blueprints/pages/author.yml +++ b/site/blueprints/pages/author.yml @@ -10,7 +10,10 @@ tabs: fields: presentation: extends: fields/body - help: Optionnelle + label: Présentation + help: | + Optionnelle, sans mention du poste. Peut inclure un lien. + Exemple : "Co-fondateur des éditions [Athom](http://www.athom.xyz/)." texts: label: Textes type: pages diff --git a/site/blueprints/users/author.yml b/site/blueprints/users/author.yml deleted file mode 100644 index 04e5565..0000000 --- a/site/blueprints/users/author.yml +++ /dev/null @@ -1,25 +0,0 @@ -title: Auteur -description: Droits de lecture et écriture de certaines pages. -image: - icon: pen - color: "#FFF" - -permissions: - access: - *: false - files: - *: false - languages: - *: false - pages: - *: false - site: - *: false - user: - *: false - users: - *: false - -fields: - presentation: - type: writer diff --git a/site/config/config.php b/site/config/config.php index b173029..1b90d2f 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -18,7 +18,6 @@ return array( ] ], 'routes' => array( - require __DIR__ . '/routes/virtual-author.php', require __DIR__ . '/routes/virtual-category.php', require __DIR__ . '/routes/send-newsletter.php', ), diff --git a/site/config/routes/virtual-author.php b/site/config/routes/virtual-author.php deleted file mode 100644 index 0a067a1..0000000 --- a/site/config/routes/virtual-author.php +++ /dev/null @@ -1,25 +0,0 @@ - 'auteurs/(:any)', - 'action' => function ($slug) { - $kirby = kirby(); - $author = getAuthorBySlug($slug); - - return Page::factory( - [ - 'slug' => '', - 'template' => 'author', - 'model' => 'authors', - 'content' => [ - 'title' => $author->name(), - 'presentation' => $author->presentation(), - 'author' => $author->name(), - 'uuid' => Uuid::generate(), - ] - ] - ); - } -]; diff --git a/site/plugins/helpers/index.php b/site/plugins/helpers/index.php index c01e7ad..c52d137 100644 --- a/site/plugins/helpers/index.php +++ b/site/plugins/helpers/index.php @@ -23,15 +23,9 @@ function setTitleFontSizeClass($title, $level = 'h1') function getAuthorBySlug($slug) { - $kirby = kirby(); - $author = ''; - foreach ($kirby->users() as $user) { - - if (Str::slug($user->name()) === $slug) { - - $author = $user; - } - } + $site = site(); + $authors = page("auteurs")->children(); + $author = $authors->find($slug); return $author; } diff --git a/site/templates/author.php b/site/templates/author.php index bd2acf8..d002cf9 100644 --- a/site/templates/author.php +++ b/site/templates/author.php @@ -1,13 +1,16 @@
-
- - -

title() ?>

- presentation() ?> + + + +
\ No newline at end of file diff --git a/site/templates/error.php b/site/templates/error.php new file mode 100644 index 0000000..bda07bd --- /dev/null +++ b/site/templates/error.php @@ -0,0 +1,16 @@ + +
+ +
+ + \ No newline at end of file diff --git a/site/templates/linear.php b/site/templates/linear.php index efc503e..796f743 100644 --- a/site/templates/linear.php +++ b/site/templates/linear.php @@ -12,6 +12,7 @@

+
body() ?>