diff --git a/config/routes.php b/config/routes.php index 4c80617..18d2ef9 100644 --- a/config/routes.php +++ b/config/routes.php @@ -67,8 +67,6 @@ [ 'controller' => 'Listings', 'action' => 'list', - 'sc25', - 'production', ] ); $builder->connect( diff --git a/src/Controller/ListingsController.php b/src/Controller/ListingsController.php index fc0f302..990e2ec 100644 --- a/src/Controller/ListingsController.php +++ b/src/Controller/ListingsController.php @@ -25,10 +25,34 @@ public function list($bof = null, $url = null) { $limit = Configure::read('IO500.pagination'); + if ($url === null) { + $url = 'production'; + } + // When the homepage route is hit (no $bof), serve the most recent BoF + // that already has a published listing for the requested type. This + // skips a release whose listing hasn't been built yet so the homepage + // doesn't fall over between release-date and listing-creation. + if ($bof === null) { + $latest = $this->Listings->find('all') + ->contain(['Types', 'Releases']) + ->where([ + 'Types.url' => $url, + 'Releases.release_date <=' => date('Y-m-d'), + ]) + ->order(['Releases.release_date' => 'DESC']) + ->first(); + if ($latest === null) { + throw new \Cake\Http\Exception\NotFoundException( + __('No published lists yet') + ); + } + $bof = $latest->release->acronym; + } + $release = $this->Listings->Releases->find('all') ->contain([ 'Listings' => [ - 'Types', + 'Types', 'sort'=> [ 'Types.position' => 'ASC' ] diff --git a/templates/Listings/list.php b/templates/Listings/list.php index 3c25501..a16a568 100644 --- a/templates/Listings/list.php +++ b/templates/Listings/list.php @@ -1,12 +1,12 @@ -assign('title', strtoupper($this->request->getParam('pass')[0]) . ' - ' . $type->name . ' List'); ?> +assign('title', strtoupper($release->acronym) . ' - ' . $type->name . ' List'); ?>