From 9b7793cfce7a1f01b45b12ebe8000f8ffadf45cd Mon Sep 17 00:00:00 2001 From: Fabrice Gangler <fabrice.gangler@adullact.org> Date: Mon, 26 Dec 2022 17:53:19 +0100 Subject: [PATCH] FEAT: add open data page --- config/routes.php | 4 ++++ src/Controller/Api/V1/PagesController.php | 25 ++++++++++++++++++++++- src/Locale/Breadcrumbs.pot | 4 ++++ src/Locale/ElementNavigation.pot | 7 +++++++ src/Locale/Pages.pot | 15 ++++++++++++++ src/Locale/en/Breadcrumbs.po | 4 ++++ src/Locale/en/ElementNavigation.po | 8 ++++++++ src/Locale/en/Pages.po | 21 +++++++++++++++++++ src/Locale/fr/Breadcrumbs.po | 4 ++++ src/Locale/fr/ElementNavigation.po | 8 ++++++++ src/Locale/fr/Pages.po | 22 ++++++++++++++++++++ src/Template/Api/V1/Pages/opendata.ctp | 15 ++++++++++++++ src/Template/Element/Pages/footer.ctp | 10 ++++++++- tests/Acceptance/BasicTestsCest.php | 10 +++++++++ tests/Acceptance/CheckBreadcrumbCest.php | 17 +++++++++++++++ 15 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 src/Template/Api/V1/Pages/opendata.ctp diff --git a/config/routes.php b/config/routes.php index f6a07462..a89a1caa 100644 --- a/config/routes.php +++ b/config/routes.php @@ -89,6 +89,10 @@ $basicRoutes = function (RouteBuilder $routes) { 'action' => 'contact', 'method' => ['GET'], ], + "opendata/" => [ + 'action' => 'opendata', + 'method' => ['GET'], + ], "legal/" => [ 'action' => 'legal', 'method' => ['GET'], diff --git a/src/Controller/Api/V1/PagesController.php b/src/Controller/Api/V1/PagesController.php index 8a6274ac..45f4a791 100644 --- a/src/Controller/Api/V1/PagesController.php +++ b/src/Controller/Api/V1/PagesController.php @@ -50,7 +50,7 @@ class PagesController extends AppController public function beforeFilter(Event $event) { - $this->Auth->allow(['contact', 'legal', 'participate', 'accessibility']); + $this->Auth->allow(['contact', 'opendata', 'legal', 'participate', 'accessibility']); parent::beforeFilter($event); } @@ -313,6 +313,29 @@ class PagesController extends AppController } + public function opendata() + { + $baseUrl = "pages/opendata"; + + // Check that the current URL is correct + $lang = $this->selectedLanguage; + $allowedUrl = "/$lang/$baseUrl"; + if ($allowedUrl !== $this->request->here(false)) { + return $this->redirect("$allowedUrl", 301); + } + + // Breadcrumbs + $links = array(); + $links[] = [ + 'name' => __d('Breadcrumbs', 'Page.Opendata'), + 'url' => $baseUrl + ]; + $this->setBreadcrumbs($links); + $this->set('currentPage', 'page_opendata'); + } + + + public function legal() { $baseUrl = "pages/legal"; diff --git a/src/Locale/Breadcrumbs.pot b/src/Locale/Breadcrumbs.pot index 9bccf31e..d7ee6bcd 100644 --- a/src/Locale/Breadcrumbs.pot +++ b/src/Locale/Breadcrumbs.pot @@ -34,6 +34,10 @@ msgstr "" msgid "Page.Accessibility" msgstr "" +#: Controller/Api/V1/PagesController.php:318 +msgid "Page.Opendata" +msgstr "Open Data" + #: Controller/Api/V1/ReviewsController.php:100;157 #: Controller/Api/V1/SoftwaresController.php:704 msgid "Software.Reviews" diff --git a/src/Locale/ElementNavigation.pot b/src/Locale/ElementNavigation.pot index bf145c42..dda40083 100644 --- a/src/Locale/ElementNavigation.pot +++ b/src/Locale/ElementNavigation.pot @@ -80,3 +80,10 @@ msgstr "" msgid "Contact" msgstr "" +#: Template/Element/Pages/footer.ctp:29;31 +msgid "footer.opendata.link" +msgstr "Open data" + +#: Template/Element/Pages/footer.ctp:29;31 +msgid "footer.opendata.link.title" +msgstr "Use open data" diff --git a/src/Locale/Pages.pot b/src/Locale/Pages.pot index 05263ee1..35e967eb 100644 --- a/src/Locale/Pages.pot +++ b/src/Locale/Pages.pot @@ -67,3 +67,18 @@ msgstr "" msgid "menu.switch" msgstr "" +#: Template/Api/V1/Pages/opendata.ctp:12 +msgid "page.opendata.title" +msgstr "Open data" + +#: Template/Api/V1/Pages/opendata.ctp:12 +msgid "page.opendata.h1" +msgstr "Open data" + +msgid "page.opendata.content1" +msgstr "" + +msgid "page.opendata.content2" +msgstr "" + + diff --git a/src/Locale/en/Breadcrumbs.po b/src/Locale/en/Breadcrumbs.po index c5bf5a8a..c0f77be1 100644 --- a/src/Locale/en/Breadcrumbs.po +++ b/src/Locale/en/Breadcrumbs.po @@ -35,6 +35,10 @@ msgstr "Legal" msgid "Page.Accessibility" msgstr "Accessibility" +#: Controller/Api/V1/PagesController.php:318 +msgid "Page.Opendata" +msgstr "Open Data" + #: Controller/Api/V1/ReviewsController.php:100;157 #: Controller/Api/V1/SoftwaresController.php:704 msgid "Software.Reviews" diff --git a/src/Locale/en/ElementNavigation.po b/src/Locale/en/ElementNavigation.po index e188c063..2a6295ca 100644 --- a/src/Locale/en/ElementNavigation.po +++ b/src/Locale/en/ElementNavigation.po @@ -79,3 +79,11 @@ msgstr "Search" #: Template/Element/Pages/footer.ctp:29;31 msgid "Contact" msgstr "Contact" + +#: Template/Element/Pages/footer.ctp:29;31 +msgid "footer.opendata.link" +msgstr "Open data" + +#: Template/Element/Pages/footer.ctp:29;31 +msgid "footer.opendata.link.title" +msgstr "Use open data" diff --git a/src/Locale/en/Pages.po b/src/Locale/en/Pages.po index 0a0897f6..76849b3e 100644 --- a/src/Locale/en/Pages.po +++ b/src/Locale/en/Pages.po @@ -79,3 +79,24 @@ msgstr "Release of <span lang=\"fr\">Comptoir du Libre</span> " #: Template/Element/Pages/footer.ctp:47 msgid "menu.switch" msgstr "Passer en français." + +#: Template/Api/V1/Pages/opendata.ctp:12 +msgid "page.opendata.title" +msgstr "Open data" + +#: Template/Api/V1/Pages/opendata.ctp:12 +msgid "page.opendata.h1" +msgstr "Open data" + +msgid "page.opendata.content1" +msgstr "" +"A part of <strong>Comptoir du Libre</strong> are published in <strong>open data</strong>. " +" Currently, all <strong>free software</strong> present on <em>Comptoir du Libre</em> website " +" are available in a JSON format export, with for each software: license, name of software, " +" source code repository, website, external resources (Wikipedia, Wikidata, Framalibre and SILL) " +" and declared providers." + +msgid "page.opendata.content2" +msgstr "" +"You can consult this open data and associated documentation on " +"<a href=\"{0}\">{1}</a>." diff --git a/src/Locale/fr/Breadcrumbs.po b/src/Locale/fr/Breadcrumbs.po index bd0ad917..ac7a0c63 100644 --- a/src/Locale/fr/Breadcrumbs.po +++ b/src/Locale/fr/Breadcrumbs.po @@ -35,6 +35,10 @@ msgstr "Mentions légales" msgid "Page.Accessibility" msgstr "Déclaration d'accessibilité" +#: Controller/Api/V1/PagesController.php:318 +msgid "Page.Opendata" +msgstr "Open Data" + #: Controller/Api/V1/ReviewsController.php:100;157 #: Controller/Api/V1/SoftwaresController.php:704 msgid "Software.Reviews" diff --git a/src/Locale/fr/ElementNavigation.po b/src/Locale/fr/ElementNavigation.po index 20f3c589..bb0734dc 100644 --- a/src/Locale/fr/ElementNavigation.po +++ b/src/Locale/fr/ElementNavigation.po @@ -80,3 +80,11 @@ msgstr "Rechercher" #: Template/Element/Pages/footer.ctp:29;31 msgid "Contact" msgstr "Contact" + +#: Template/Element/Pages/footer.ctp:29;31 +msgid "footer.opendata.link" +msgstr "Open Data" + +#: Template/Element/Pages/footer.ctp:29;31 +msgid "footer.opendata.link.title" +msgstr "Open data - Données ouvertes du Comptoir du Libre" diff --git a/src/Locale/fr/Pages.po b/src/Locale/fr/Pages.po index 4ede5fb6..8f4142a2 100644 --- a/src/Locale/fr/Pages.po +++ b/src/Locale/fr/Pages.po @@ -84,3 +84,25 @@ msgstr "Comptoir du Libre version " #: Template/Element/Pages/footer.ctp:47 msgid "menu.switch" msgstr "Switch to english." + +#: Template/Api/V1/Pages/opendata.ctp:12 +msgid "page.opendata.title" +msgstr "Open data - Données ouvertes du Comptoir du Libre" + +#: Template/Api/V1/Pages/opendata.ctp:12 +msgid "page.opendata.h1" +msgstr "Open data : données ouvertes" + +msgid "page.opendata.content1" +msgstr "" +"Une partie des données du <strong>Comptoir du Libre</strong> sont publiées en <strong>open data</strong>. " +" Actuellement, tous les <strong>logiciels libres</strong> présents sur le site web <em>Comptoir du Libre</em> " +" sont mis à votre disposition dans un export au format JSON, avec pour chaque logiciel :" +" la licence, le nom du logiciel, le dépôt du code source, le site web, " +" les ressources externes (<em>Wikipédia</em>, <em>Wikidata</em>, <em>Framalibre</em> et <em>SILL</em>)" +" et les prestataires déclarés." + +msgid "page.opendata.content2" +msgstr "" +"Vous pouvez consulter ces données ouvertes et la documentation associée sur " +"<a href=\"{0}\">{1}</a>." diff --git a/src/Template/Api/V1/Pages/opendata.ctp b/src/Template/Api/V1/Pages/opendata.ctp new file mode 100644 index 00000000..97c82144 --- /dev/null +++ b/src/Template/Api/V1/Pages/opendata.ctp @@ -0,0 +1,15 @@ +<?php +$this->layout = 'base'; +$this->assign('title', __d("Pages", "page.opendata.title")); +?> +<h1><?= __d("Pages", "page.opendata.h1") ?></h1> + +<p> + <?= __d("Pages", "page.opendata.content1") ?> +</p> +<p> + <?= __d("Pages", "page.opendata.content2", [ + 'https://www.data.gouv.fr/fr/datasets/logiciels-libres-sur-le-comptoir-du-libre-org/' , + 'data.gouv.fr', + ]) ?> +</p> diff --git a/src/Template/Element/Pages/footer.ctp b/src/Template/Element/Pages/footer.ctp index ad6b3148..0092b029 100644 --- a/src/Template/Element/Pages/footer.ctp +++ b/src/Template/Element/Pages/footer.ctp @@ -23,6 +23,8 @@ $optionLegalLink = []; $optionA11yLink = []; $optionContactLink = []; + $optionOpendataLink = []; + $optionOpendataLink['title'] = __d("ElementNavigation", "footer.opendata.link.title"); $optionLink = ['aria-current' => 'page']; if(isset($currentPage)){ if($currentPage === 'page_legal'){ @@ -31,6 +33,8 @@ $optionA11yLink = $optionLink; } elseif ($currentPage === 'page_contact'){ $optionContactLink = $optionLink; + } elseif ($currentPage === 'page_opendata'){ + $optionOpendataLink = array_merge($optionOpendataLink, $optionLink); } } ?> @@ -46,7 +50,11 @@ <?= $this->Html->link(__d("Home", "footer-accessibility-link"), "/$selectedLanguage/pages/accessibility", - $optionA11yLink) ?> + $optionA11yLink) ?> - + + <?= $this->Html->link(__d("ElementNavigation", "footer.opendata.link"), + "/$selectedLanguage/pages/opendata", + $optionOpendataLink) ?> <?php if (isset($availableLanguages)): ?> - diff --git a/tests/Acceptance/BasicTestsCest.php b/tests/Acceptance/BasicTestsCest.php index bb0bc29c..f1ed6962 100644 --- a/tests/Acceptance/BasicTestsCest.php +++ b/tests/Acceptance/BasicTestsCest.php @@ -59,5 +59,15 @@ class BasicTestsCest $I->seeInTitle('Information pour nous contacter'); } + public function clickOnOpendataLinkFromHomepage($I) + { + $I->amOnPage('/'); + $I->seeInTitle('Comptoir du libre'); + $I->see('Open Data'); + $I->click('Open Data'); + $I->seeInCurrentUrl('/pages/opendata'); + $I->seeInTitle('Open data - Données ouvertes'); + } + //Todo check pages softwares, users and services providers } diff --git a/tests/Acceptance/CheckBreadcrumbCest.php b/tests/Acceptance/CheckBreadcrumbCest.php index d76c7d40..1c2be34a 100644 --- a/tests/Acceptance/CheckBreadcrumbCest.php +++ b/tests/Acceptance/CheckBreadcrumbCest.php @@ -612,4 +612,21 @@ class CheckBreadcrumbCest $I->amOnPage(\array_key_last($Breadcrumbs)); $this->sharedChecks($I, $Breadcrumbs); } + + /** + * Check Breadcrumb on "OpenData" page + * @group nav + * @group breadcrumb + * @group page + * @param AcceptanceTester $I + */ + public function checkBreadcrumbOnOpenDataPage(AcceptanceTester $I) + { + $Breadcrumbs = [ + '/fr/' => 'Accueil', + '/fr/pages/opendata' => "Open data", + ]; + $I->amOnPage(\array_key_last($Breadcrumbs)); + $this->sharedChecks($I, $Breadcrumbs); + } } -- GitLab