From efbd099515adf64ec560e01e390897c148d0e71a Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Sep 2021 23:47:14 +0100 Subject: [PATCH] refactor: Remove the sortable_date for talks Automatically calculate the sortable date for a talk using the event dates. This means that the `sortable_date` in the YAML front matter can be removed. Fixes #4 --- source/_pages/talks.html.twig | 2 +- source/_talks/about-drupal-association.md | 1 - ...esting-test-driven-development-drupal-8.md | 1 - ...building-presenting-slide-decks-rst2pdf.md | 1 - .../building-static-websites-sculpin.md | 1 - .../configuring-all-the-things-drupal-8.md | 1 - source/_talks/dancing-for-drupal.md | 1 - source/_talks/decoupling-drupal-vuejs.md | 1 - source/_talks/deploying-drupal-fabric.md | 1 - .../deploying-php-ansible-ansistrano.md | 1 - source/_talks/deploying-php-fabric.md | 1 - source/_talks/drupal-8-module-development.md | 1 - .../drupal-8-php-libraries-drupalorg-api.md | 1 - source/_talks/drupal-8-rejoining-the-herd.md | 1 - source/_talks/drupal-8.md | 1 - source/_talks/drupal-ldap-module.md | 1 - source/_talks/drupal-vm-generator.md | 1 - .../_talks/drupal-vm-meet-symfony-console.md | 1 - source/_talks/drupalorg-2015.md | 1 - source/_talks/drush-make-drupalbristol.md | 1 - .../_talks/getting-your-data-into-drupal-8.md | 1 - source/_talks/git-flow.md | 1 - .../goodbye-drush-make-hello-composer.md | 1 - source/_talks/it-all-started-with-a-patch.md | 1 - ...modern-drupal-development-with-composer.md | 1 - .../out-of-the-box-initiative-update.md | 1 - source/_talks/so-what-is-this-drupal-thing.md | 1 - .../_talks/taking-flight-with-tailwind-css.md | 1 - source/_talks/tdd-test-driven-drupal.md | 1 - source/_talks/test-drive-twig-with-sculpin.md | 1 - .../things-you-should-know-about-php.md | 1 - source/_talks/upgrading-your-site-drupal-9.md | 1 - ...-illuminate-collections-outside-laravel.md | 1 - source/_talks/working-with-workspace.md | 1 - src/TwigExtension/TalkExtension.php | 9 +++++++++ tests/TalkExtensionTest.php | 20 +++++++++++++++++++ 36 files changed, 30 insertions(+), 34 deletions(-) diff --git a/source/_pages/talks.html.twig b/source/_pages/talks.html.twig index 93850a458..ef35e7b68 100644 --- a/source/_pages/talks.html.twig +++ b/source/_pages/talks.html.twig @@ -8,7 +8,7 @@ use:
- {% for talk in data.talks|sort((a,b) => a.sortable_date < b.sortable_date) %} + {% for talk in data.talks|sort((a, b) => get_last_event_date_for_talk(a) < get_last_event_date_for_talk(b)) %}

diff --git a/source/_talks/about-drupal-association.md b/source/_talks/about-drupal-association.md index a20976c6e..14ad83615 100644 --- a/source/_talks/about-drupal-association.md +++ b/source/_talks/about-drupal-association.md @@ -6,7 +6,6 @@ events: name: South Wales Drupal user group (SWDUG) location: Cardiff, UK date: 2014-08-19 -sortable_date: 2014-08-19 --- An impromptu talk about what the Drupal Association is, and what work I’ve been doing since I joined the Association staff. diff --git a/source/_talks/automated-testing-test-driven-development-drupal-8.md b/source/_talks/automated-testing-test-driven-development-drupal-8.md index 3407c8bca..07646c0f5 100644 --- a/source/_talks/automated-testing-test-driven-development-drupal-8.md +++ b/source/_talks/automated-testing-test-driven-development-drupal-8.md @@ -17,5 +17,4 @@ events: url: https://2020.drupalcamp.nyc/training/automated-testing-and-test-driven-development-drupal-8 date: 2020-11-14 online: true -sortable_date: 2020-11-14 --- diff --git a/source/_talks/building-presenting-slide-decks-rst2pdf.md b/source/_talks/building-presenting-slide-decks-rst2pdf.md index e7287ff2f..b77b9c120 100644 --- a/source/_talks/building-presenting-slide-decks-rst2pdf.md +++ b/source/_talks/building-presenting-slide-decks-rst2pdf.md @@ -14,7 +14,6 @@ events: url: https://www.meetup.com/PHP-South-Wales/events/275625320 date: 2021-01-28 online: true -sortable_date: 2021-01-28 --- I've recently used [rst2pdf](https://rst2pdf.org) for building presentation slides. This short talk will show some examples of how I built and presented a slide deck using reStructuredText and rst2pdf. diff --git a/source/_talks/building-static-websites-sculpin.md b/source/_talks/building-static-websites-sculpin.md index f0c05b252..3eb120a8a 100644 --- a/source/_talks/building-static-websites-sculpin.md +++ b/source/_talks/building-static-websites-sculpin.md @@ -30,7 +30,6 @@ events: location: Manchester, UK url: ~ is_online: true -sortable_date: 2021-09-07 --- [Sculpin][0] is a static site generator written in PHP. It converts Markdown files, Twig templates and standard HTML into a static HTML site that can be easily deployed. diff --git a/source/_talks/configuring-all-the-things-drupal-8.md b/source/_talks/configuring-all-the-things-drupal-8.md index c77a8ae84..1a9d0b6c4 100644 --- a/source/_talks/configuring-all-the-things-drupal-8.md +++ b/source/_talks/configuring-all-the-things-drupal-8.md @@ -14,7 +14,6 @@ events: location: Bristol, UK url: https://www.drupalbristol.org.uk date: 2018-07-25 -sortable_date: 2018-07-25 --- A short notice talk on configuration management in Drupal 8, and things I’ve learned working on my current Drupal 8 project. diff --git a/source/_talks/dancing-for-drupal.md b/source/_talks/dancing-for-drupal.md index c1eb797f2..4a9705f4e 100644 --- a/source/_talks/dancing-for-drupal.md +++ b/source/_talks/dancing-for-drupal.md @@ -13,7 +13,6 @@ events: location: Bristol, UK url: http://umbristol.co.uk date: 2015-08-25 -sortable_date: 2015-08-25 --- As part of their [CMS Dance-Off][1], I was selected to speak about Drupal alongside other speakers representing Umbraco, Sitecore and Episerver. diff --git a/source/_talks/decoupling-drupal-vuejs.md b/source/_talks/decoupling-drupal-vuejs.md index 4866af906..83528dcef 100644 --- a/source/_talks/decoupling-drupal-vuejs.md +++ b/source/_talks/decoupling-drupal-vuejs.md @@ -12,7 +12,6 @@ events: location: Cardiff, UK url: https://blueconf.co.uk date: 2019-06-07 -sortable_date: 2019-06-07 --- Decoupled or headless Drupal has been a trend for a number of years, with modules like RESTful Web Services available for Drupal 7 to expose data, and Drupal 8 becoming more API-first with JSON:API module now included as part of core. This makes it easier for third party systems or alternative front-end applications to consume and work with the data provided by Drupal. diff --git a/source/_talks/deploying-drupal-fabric.md b/source/_talks/deploying-drupal-fabric.md index 8132b2604..c9c01d93c 100644 --- a/source/_talks/deploying-drupal-fabric.md +++ b/source/_talks/deploying-drupal-fabric.md @@ -21,7 +21,6 @@ events: - name: Drupal Somerset date: 2017-10-26 -sortable_date: 2017-10-26 --- You’ve built your website, and now you just need to deploy it. There are various ways that this could be done - from (S)FTP, to SCP and rsync, to running commands like “git pull” and “composer install” directly on the server (not recommended). diff --git a/source/_talks/deploying-php-ansible-ansistrano.md b/source/_talks/deploying-php-ansible-ansistrano.md index 7d9bba276..0f09dc8ba 100644 --- a/source/_talks/deploying-php-ansible-ansistrano.md +++ b/source/_talks/deploying-php-ansible-ansistrano.md @@ -89,7 +89,6 @@ events: location: New York, USA url: https://ti.to/drupalnyc/lunch-learn-2021-06-15 is_online: true -sortable_date: 2021-06-15 --- Great! You’ve built your website, and now you just need to deploy it. There are various ways that this could be done - from (S)FTP, to SCP and rsync, to running commands like `git pull` and `composer install` directly on the server which is not ideal. diff --git a/source/_talks/deploying-php-fabric.md b/source/_talks/deploying-php-fabric.md index 8e4fc2680..6335e0cfa 100644 --- a/source/_talks/deploying-php-fabric.md +++ b/source/_talks/deploying-php-fabric.md @@ -36,7 +36,6 @@ events: time: '09:00 - 09:45' url: http://conference.phpnw.org.uk/phpnw17 joindin: https://joind.in/talk/4e35d -sortable_date: 2017-10-01 --- You’ve built your application, and now you just need to deploy it. There are various ways that this could be done – from (S)FTP, to SCP and rsync, to running commands like “git pull” and “composer install” directly on the server (not recommended). diff --git a/source/_talks/drupal-8-module-development.md b/source/_talks/drupal-8-module-development.md index dcf583aa9..8db0a509d 100644 --- a/source/_talks/drupal-8-module-development.md +++ b/source/_talks/drupal-8-module-development.md @@ -24,7 +24,6 @@ events: name: DrupalCamp London 2016 location: London, UK date: 2016-03-05 -sortable_date: 2016-03-05 --- New to object-orientated PHP, Symfony or YAML, and want to get started building modules in Drupal 8? This is the session for you! diff --git a/source/_talks/drupal-8-php-libraries-drupalorg-api.md b/source/_talks/drupal-8-php-libraries-drupalorg-api.md index 6b803f7a1..c49bb89c2 100644 --- a/source/_talks/drupal-8-php-libraries-drupalorg-api.md +++ b/source/_talks/drupal-8-php-libraries-drupalorg-api.md @@ -25,7 +25,6 @@ events: url: http://drupalcamp.london date: 2019-03-03 time: '12:05 - 12:50' -sortable_date: 2019-03-03 --- A overview and demo of some of the open source projects that I’ve been working on lately that are based on information from the Drupal.org API, including a PHP library for the API itself as well as some Drupal 8 modules that use it. diff --git a/source/_talks/drupal-8-rejoining-the-herd.md b/source/_talks/drupal-8-rejoining-the-herd.md index 7020dc19d..287fc619c 100644 --- a/source/_talks/drupal-8-rejoining-the-herd.md +++ b/source/_talks/drupal-8-rejoining-the-herd.md @@ -13,7 +13,6 @@ events: url: http://2016.phpsouthcoast.co.uk date: 2016-06-11 joindin: https://joind.in/talk/41d0f -sortable_date: 2016-06-11 --- [Drupal 8][0] was (finally) released on November 19th 2015, after almost 4 years of work and code commits by over 3,200 different contributors. Whilst it’s pretty much the same as the Drupal that we know and, hopefully, love, a lot has changed behind the scenes and under the hood! diff --git a/source/_talks/drupal-8.md b/source/_talks/drupal-8.md index b70893726..410246499 100644 --- a/source/_talks/drupal-8.md +++ b/source/_talks/drupal-8.md @@ -17,7 +17,6 @@ events: location: Bristol, UK url: https://phpsw.uk date: 2015-04-08 -sortable_date: 2015-04-08 --- This was a ten minute lightning talk, designed to highlight the major changes diff --git a/source/_talks/drupal-ldap-module.md b/source/_talks/drupal-ldap-module.md index 6c4935eda..90c915d96 100644 --- a/source/_talks/drupal-ldap-module.md +++ b/source/_talks/drupal-ldap-module.md @@ -6,7 +6,6 @@ events: name: South Wales Drupal user group (SWDUG) location: Cardiff, UK date: 2013-07-10 -sortable_date: 2013-07-10 --- A review and demonstration of some of the recent single sign-on work that I did using Drupal’s LDAP module. diff --git a/source/_talks/drupal-vm-generator.md b/source/_talks/drupal-vm-generator.md index c107c5386..d2197e0c4 100644 --- a/source/_talks/drupal-vm-generator.md +++ b/source/_talks/drupal-vm-generator.md @@ -22,7 +22,6 @@ events: location: Bristol, UK url: https://www.drupalbristol.org.uk date: 2016-04-02 -sortable_date: 2016-04-02 --- An short talk about the [Drupal VM Generator][1] project. diff --git a/source/_talks/drupal-vm-meet-symfony-console.md b/source/_talks/drupal-vm-meet-symfony-console.md index 078891e4e..911240d14 100644 --- a/source/_talks/drupal-vm-meet-symfony-console.md +++ b/source/_talks/drupal-vm-meet-symfony-console.md @@ -11,7 +11,6 @@ events: name: DrupalCamp Bristol 2016 location: Bristol, UK date: 2016-07-23 -sortable_date: 2016-07-23 --- _TL;DR - Come and learn about Symfony Console, with examples from a real-world diff --git a/source/_talks/drupalorg-2015.md b/source/_talks/drupalorg-2015.md index 7e8a82e0a..c294a8c4a 100644 --- a/source/_talks/drupalorg-2015.md +++ b/source/_talks/drupalorg-2015.md @@ -15,7 +15,6 @@ events: name: DrupalCamp London 2015 location: London, UK date: 2015-02-28 -sortable_date: 2015-02-28 --- A retrospective of the Drupal Association’s work in 2014 and a look forward to what we’ll be working on in 2015. diff --git a/source/_talks/drush-make-drupalbristol.md b/source/_talks/drush-make-drupalbristol.md index 289d149ec..db7560312 100644 --- a/source/_talks/drush-make-drupalbristol.md +++ b/source/_talks/drush-make-drupalbristol.md @@ -11,7 +11,6 @@ events: location: Bristol, UK url: https://www.drupalbristol.org.uk date: 2014-08-19 -sortable_date: 2014-08-19 --- An introduction to Drush Make and how to use it to build reusable custom installation profiles or entire websites. diff --git a/source/_talks/getting-your-data-into-drupal-8.md b/source/_talks/getting-your-data-into-drupal-8.md index 97db2ba55..52b1166cf 100644 --- a/source/_talks/getting-your-data-into-drupal-8.md +++ b/source/_talks/getting-your-data-into-drupal-8.md @@ -30,7 +30,6 @@ events: date: 2017-03-04 time: '12:05 - 12:50' location: London, UK -sortable_date: 2017-03-04 --- If you’ve moved a site from Drupal 6 to 7, the chances are that you’ve either used the upgrade path to update your old site in-place, or you built a new site from scratch and used the Migrate module from contrib to migrate your data from the old database. diff --git a/source/_talks/git-flow.md b/source/_talks/git-flow.md index 99fff1b5a..40fe65f14 100644 --- a/source/_talks/git-flow.md +++ b/source/_talks/git-flow.md @@ -14,7 +14,6 @@ events: name: DrupalCamp London 2014 location: London, UK date: 2014-03-01 -sortable_date: 2014-03-01 --- An introduction to the Git Flow branching model and the git-flow plugin, and how I’ve used them to manage a Drupal development project. diff --git a/source/_talks/goodbye-drush-make-hello-composer.md b/source/_talks/goodbye-drush-make-hello-composer.md index b0c2da568..6867b5cc0 100644 --- a/source/_talks/goodbye-drush-make-hello-composer.md +++ b/source/_talks/goodbye-drush-make-hello-composer.md @@ -22,7 +22,6 @@ events: time: '14:40 - 15:40' url: https://www.phpconference.co.uk joindin: https://joind.in/talk/650ab -sortable_date: 2018-02-16 --- One of the main outcomes of Drupal 8 was “getting off the island” with third-party code included in core and adopting modern best practices from the wider PHP ecosystem - including [Composer][1], PHP’s dependency manager. diff --git a/source/_talks/it-all-started-with-a-patch.md b/source/_talks/it-all-started-with-a-patch.md index e6c9babc5..e51a5c66d 100644 --- a/source/_talks/it-all-started-with-a-patch.md +++ b/source/_talks/it-all-started-with-a-patch.md @@ -14,7 +14,6 @@ events: location: Bristol, UK url: https://phpsw.uk date: 2017-02-08 -sortable_date: 2017-02-08 --- A crash course of why and how to get involved with open source. diff --git a/source/_talks/modern-drupal-development-with-composer.md b/source/_talks/modern-drupal-development-with-composer.md index 3f3d0d89f..54dc257d3 100644 --- a/source/_talks/modern-drupal-development-with-composer.md +++ b/source/_talks/modern-drupal-development-with-composer.md @@ -16,7 +16,6 @@ events: location: Bristol, UK url: https://phpsw.uk date: 2016-11-09 -sortable_date: 2016-11-09 --- Building a Drupal application? You no longer need to download archives to add new modules or update core, or deal with Drupal specific tools to manage your codebase. diff --git a/source/_talks/out-of-the-box-initiative-update.md b/source/_talks/out-of-the-box-initiative-update.md index ab6666b98..b157ec440 100644 --- a/source/_talks/out-of-the-box-initiative-update.md +++ b/source/_talks/out-of-the-box-initiative-update.md @@ -14,7 +14,6 @@ events: location: Bristol, UK url: https://www.drupalbristol.org.uk date: 2019-03-27 -sortable_date: 2019-03-27 --- From the [DrupalCamp London website](https://drupalcamp.london/session/out-box-initiative-update): diff --git a/source/_talks/so-what-is-this-drupal-thing.md b/source/_talks/so-what-is-this-drupal-thing.md index 44ea469fa..704abd48e 100644 --- a/source/_talks/so-what-is-this-drupal-thing.md +++ b/source/_talks/so-what-is-this-drupal-thing.md @@ -10,7 +10,6 @@ events: location: Cardiff, UK url: http://unifieddiff.co.uk date: 2012-09-05 -sortable_date: 2012-09-05 --- My very first talk, where I talk about Drupal, what it is and what it can do. diff --git a/source/_talks/taking-flight-with-tailwind-css.md b/source/_talks/taking-flight-with-tailwind-css.md index 00d6e48cb..269495d79 100644 --- a/source/_talks/taking-flight-with-tailwind-css.md +++ b/source/_talks/taking-flight-with-tailwind-css.md @@ -83,7 +83,6 @@ events: date: 2021-02-09 url: https://www.meetup.com/nashvillephp/events/kzkdwryccdbmb online: true -sortable_date: 2021-02-09 meta: og: title: Taking Flight with Tailwind CSS diff --git a/source/_talks/tdd-test-driven-drupal.md b/source/_talks/tdd-test-driven-drupal.md index 773c3cf41..19c22c04f 100644 --- a/source/_talks/tdd-test-driven-drupal.md +++ b/source/_talks/tdd-test-driven-drupal.md @@ -63,7 +63,6 @@ events: date: 2020-12-08 url: https://events.drupal.org/europe2020/sessions/tdd-test-driven-drupal online: true -sortable_date: 2020-12-08 --- {% block content %} diff --git a/source/_talks/test-drive-twig-with-sculpin.md b/source/_talks/test-drive-twig-with-sculpin.md index 29c900686..c4dbfa29c 100644 --- a/source/_talks/test-drive-twig-with-sculpin.md +++ b/source/_talks/test-drive-twig-with-sculpin.md @@ -13,7 +13,6 @@ events: location: Sunderland, UK url: http://drupalcampnorth.org date: 2015-07-25 -sortable_date: 2015-07-25 --- [Sculpin][1] is a static site generator written in PHP, and based on [Symfony components][2]. It uses [YAML][3] and [Twig][4], which makes it very appealing to Drupal people wanting to learn these in preparation for Drupal 8. diff --git a/source/_talks/things-you-should-know-about-php.md b/source/_talks/things-you-should-know-about-php.md index 3fb3be81a..3c03ffa87 100644 --- a/source/_talks/things-you-should-know-about-php.md +++ b/source/_talks/things-you-should-know-about-php.md @@ -14,7 +14,6 @@ events: location: Swansea, UK url: https://www.meetup.com/Swansea-Software-Development-Meetup date: 2019-01-28 -sortable_date: 2019-01-28 --- An introduction to PHP, presented to the Swansea Software Development Community (SSDC) meetup. diff --git a/source/_talks/upgrading-your-site-drupal-9.md b/source/_talks/upgrading-your-site-drupal-9.md index c720306b0..e0c2c6bdc 100644 --- a/source/_talks/upgrading-your-site-drupal-9.md +++ b/source/_talks/upgrading-your-site-drupal-9.md @@ -26,7 +26,6 @@ events: url: https://midwestphp.org/talks/7C0m4I87vq72cDoXvsHFRp/Upgrading_your_site_to_Drupal_9 date: 2021-04-22 online: true -sortable_date: 2021-04-22 --- For most Drupal Developers and users, the idea of moving a project from one major version of Drupal to another can be daunting, with modules and themes having to being changed significantly or rebuilt completely, and data being migrated from the old site to the new one. diff --git a/source/_talks/using-illuminate-collections-outside-laravel.md b/source/_talks/using-illuminate-collections-outside-laravel.md index 36363d621..96c557db5 100644 --- a/source/_talks/using-illuminate-collections-outside-laravel.md +++ b/source/_talks/using-illuminate-collections-outside-laravel.md @@ -22,7 +22,6 @@ events: location: Cardiff, UK url: https://www.phpsouthwales.uk date: 2018-08-28 -sortable_date: 2018-08-28 --- Laravel's Illuminate Collections are a powerful object-orientated way of interacting with PHP arrays, but did you know that they can be used outside of Laravel, in any PHP project? diff --git a/source/_talks/working-with-workspace.md b/source/_talks/working-with-workspace.md index d6086aa1a..c6e723769 100644 --- a/source/_talks/working-with-workspace.md +++ b/source/_talks/working-with-workspace.md @@ -26,7 +26,6 @@ events: url: https://www.phpnw.org.uk date: 2021-02-02 online: true -sortable_date: 2021-02-02 --- [Workspace](https://github.com/my127/workspace) is an open source tool developed by [Inviqa](https://inviqa.com), as a way to create custom commands for your project environments, and an alternative to a bash script or a Makefile. diff --git a/src/TwigExtension/TalkExtension.php b/src/TwigExtension/TalkExtension.php index 782ec6a3a..0c538b39a 100644 --- a/src/TwigExtension/TalkExtension.php +++ b/src/TwigExtension/TalkExtension.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\TwigExtension; use App\Collection\TalkCollection; +use Illuminate\Support\Collection; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -13,10 +14,18 @@ final class TalkExtension extends AbstractExtension public function getFunctions() { return [ + new TwigFunction('get_last_event_date_for_talk', [$this, 'getLastEventDate']), new TwigFunction('get_past_talk_count', [$this, 'getPastTalkCount']), ]; } + public function getLastEventDate($talk): ?string + { + $events = new Collection($talk['events']); + + return $events->pluck('date')->sort()->last(); + } + public function getPastTalkCount(iterable $talks = []): int { return $this->getEventsFromTalks($talks)->count(); diff --git a/tests/TalkExtensionTest.php b/tests/TalkExtensionTest.php index a01683ad9..3868e2cac 100644 --- a/tests/TalkExtensionTest.php +++ b/tests/TalkExtensionTest.php @@ -107,4 +107,24 @@ final class TalkExtensionTest extends TestCase $this->assertSame(1, $this->subject->getPastTalkCount($talks)); } + + /** @test */ + public function should_get_the_last_event_date_for_a_talk(): void + { + $talkA = [ + 'events' => [ + ['date' => '2015-10-14'], + ['date' => '2021-09-07'], + ['date' => '2021-08-19'], + ], + ]; + + $talkB = [ + 'events' => [], + ]; + + $this->assertSame('2021-09-07', $this->subject->getLastEventDate($talkA)); + + $this->assertNull($this->subject->getLastEventDate($talkB)); + } }