Published: June 7, 2024
My LocalGov Drupal contributions for week-ending June 7th, 2024
Here's what I've been working on for my LocalGov Drupal contributions this week. Thanks to Big Blue Door for sponsoring the time to work on these.
I'm actually away this week on holidays with family, but it's hard to keep me from working on open source, so I managed to get a few things done.
- There's been some great work by Cumberland and Westmorland & Furness councils on creating an elections module, created by Rohallion. We're now in the process of making this more generic so it will work for all councils. My current task? Figuring out the frontend for this.
- When you focus on a link in a "Labelled Icon" component, the focus style is only applied to the icon and not the text of the component. Fine, a simple fix ... cue 45 minutes of digging through templates and theories about non-existant CSS until EUREKA! We are rendering a
div
inside aspan
. Everything is easy when you figure it out. - Adding documents inline via the wysiwyg is not very intuitive at all. We're working on extending LinkIt module to allow linking to documents as well as existing pages. This is an issue that came up at LGD Camp, so it's great to see it getting worked on. Thanks to Duncan Davidson for doing most of the work on this so far.
- Like all Drupal sites, LGD sites have a lot of image styles. Now there is some confusion emerging about what image styles are applied where, and if we can rationalise things a bit. If you can contribute to the conversation, it's happening on GitHub.
- How cool would it be if we could see a live preview of our pages as we are editing them? Correct, very cool. Here's a demo of what that might look like and also a demo of what it might look like if you were using it to change the design of a microsite. We'll explore this more with the Same Page Preview module.
- It's not ready just yet, but we're almost there with the "Add to Calendar" functionality for LocalGov Events. The conversation is now down to very small points, which we'll hopefully get ironed out this week and released next week.
- We have one component still using Google maps instead of Leaflet/Open Street Maps. We have a PR for it. This works perfectly locally, but our tests are reporting schema issues. I've no idea why, since the config we have was exported from Drupal, so you'd expect it to validate. I'd love to get this merged asap, so if you have any ideas, please chip in on that merge request.
- My Content Access by Path module does exactly what it says on the tin: allows access to content based on the path of the node you are looking at. George in North Devon council wanted to restrict edit access of the homepage from just one users. Our module does not restrict via just one URL such as "/" (the homepage) as that would allow edit access to every page on the site. So ... wrote him a small module to say "if the user id is 2 and the node id is 66, do not allow the person to edit the node". I'll post the code at the end of this post.
I'm pretty happy with that week's work, especially since I only got to do one day's dev on LGD since I'm no holidays. Next week, we're back to full-steam ahead.
<?php
/**
* @file
* Primary module hooks for no_homepage_edit module.
*/
use Drupal\Core\Access\AccessResult;
use Drupal\user\Entity\User;
/**
* Implements hook_node_access().
*/
function no_homepage_edit_node_access($node, $op, $account) {
$current_user = User::load($account->id());
$current_user_id = $current_user->id();
$node_id = $node->id();
if ($current_user_id == 2 && ($op == 'update' || $op == 'delete') && $node_id == 66) {
return AccessResult::forbidden();
}
}