Skip to content

Commit

Permalink
Merge pull request #87 from localgovdrupal/1.x
Browse files Browse the repository at this point in the history
1.0.0-alpha2 release
  • Loading branch information
finnlewis authored Sep 7, 2023
2 parents d9d4acd + dcf8272 commit 053e570
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 144 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
strategy:
fail-fast: false
matrix:
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'
include:
- localgov-version: '2.x'
drupal-version: '~9.4'
php-version: '8.1'
- localgov-version: '3.x'
drupal-version: '~10.0'
php-version: '8.1'

steps:

Expand Down Expand Up @@ -108,13 +108,13 @@ jobs:
strategy:
fail-fast: false
matrix:
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'
include:
- localgov-version: '2.x'
drupal-version: '~9.4'
php-version: '8.1'
- localgov-version: '3.x'
drupal-version: '~10.0'
php-version: '8.1'

steps:

Expand Down Expand Up @@ -144,13 +144,13 @@ jobs:
strategy:
fail-fast: false
matrix:
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'
include:
- localgov-version: '2.x'
drupal-version: '~9.4'
php-version: '8.1'
- localgov-version: '3.x'
drupal-version: '~10.0'
php-version: '8.1'

steps:

Expand Down Expand Up @@ -179,13 +179,13 @@ jobs:
strategy:
fail-fast: false
matrix:
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'
include:
- localgov-version: '2.x'
drupal-version: '~9.4'
php-version: '8.1'
- localgov-version: '3.x'
drupal-version: '~10.0'
php-version: '8.1'

steps:

Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ composer require localgovdrupal/localgov_publications:^1.0.0-alpha1

Please do install and test with real publication content and report any issues to Github at https://github.com/localgovdrupal/localgov_publications/issues

## Testing on Gitpod

You should be able to spin up a Gitpod install of LocalGov Drupal by:

1. [Create an account on gitpod.io](https://gitpod.io/login), if you haven't already.
2. Follow this link to [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/localgovdrupal/localgov_project)

Once Gitpod is fired up, you should have a command line in VSCode where you can execute commands to download and enable Localgov Pulications.

```
ddev composer require localgovdrupal/localgov_publications:^1.0.0-alpha1
ddev drush en localgov_publications
```
Then you might want to use drush to generate a one time login link with

```
ddev drush uli
```

Control click the link to open in a new tab and you can start to test creating publication content.

## Maintainers

This project is currently maintained by:
Expand Down
1 change: 1 addition & 0 deletions config/install/filter.format.publications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ filters:
settings:
footnotes_collapse: '1'
footnotes_html: '1'
footnotes_css: '1'
4 changes: 2 additions & 2 deletions config/install/views.view.publications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ display:
alter_text: false
text: 'Edit order and titles'
make_link: false
path: 'admin/structure/book/ {{ nid__value }}'
path: 'admin/structure/publications/{{ nid__value }}'
absolute: false
external: false
replace_spaces: false
Expand Down Expand Up @@ -151,7 +151,7 @@ display:
alter_text: true
text: 'Edit order and titles'
make_link: true
path: 'admin/structure/book/{{ nid }}'
path: 'admin/structure/publications/{{ nid }}'
absolute: false
external: false
replace_spaces: false
Expand Down
7 changes: 7 additions & 0 deletions css/localgov-publications.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
.book-navigation--publication .next-link {
margin-left: auto;
}

/* Leaving this in the module until it passes Alpha. */
.lgd-page-title-block__publication-title {
font-size: var(--page-title-lede-font-size);
color: var(--color-grey-dark);
display: block;
}
54 changes: 27 additions & 27 deletions localgov_publications.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* Module file for the LocalGov Publications module.
*/

use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\block\Entity\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\node\NodeInterface;
use Drupal\block\Entity\Block;
use Drupal\user\Entity\Role;
use Drupal\Core\Url;

/**
* Implements hook_theme().
Expand All @@ -28,7 +28,8 @@ function localgov_publications_theme($existing, $type, $theme, $path) {
],
'localgov_publication_page_header_block' => [
'variables' => [
'title' => NULL,
'title' => '',
'node_title' => '',
'published_date' => NULL,
'last_updated_date' => NULL,
],
Expand All @@ -37,7 +38,7 @@ function localgov_publications_theme($existing, $type, $theme, $path) {
}

/**
* Implements hook_install().
* Implements hook_modules_installed().
*/
function localgov_publications_modules_installed($modules, $is_syncing) {
if (!$is_syncing && in_array('localgov_publications', $modules)) {
Expand All @@ -64,8 +65,7 @@ function localgov_publications_theme_suggestions_book_navigation(array $variable
// Only add suggestion on publication pages and publication landing pages.
$node = \Drupal::routeMatch()->getParameter('node');
if (localgov_publications_is_publication_type($node->getType())) {
$original = $variables['theme_hook_original'] . '__';
$suggestions[] = $original . 'publication';
$suggestions[] = $variables['theme_hook_original'] . '__' . 'publication';
}

return $suggestions;
Expand All @@ -83,6 +83,18 @@ function localgov_publications_block_access(Block $block, $operation, AccountInt
}
}

/**
* Implements hook_form_FORM_ID_alter() for book_admin_edit.
*/
function localgov_publications_form_book_admin_edit_alter(&$form, FormStateInterface $form_state, $form_id) {

// If we're on the route this module uses for this form, change some wording.
$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name === 'publication.admin_edit') {
$form['save']['#value'] = t('Save publication pages');
}
}

/**
* Implements hook_form_alter().
*/
Expand Down Expand Up @@ -116,38 +128,26 @@ function localgov_publications_form_alter(&$form, FormStateInterface $form_state
// Alter the select element.
$form['book']['bid']['#title'] = t('Publication');

// Change the "Create new book".
if (!empty($form['book']['bid']['#options'][$node->id()])) {
$form['book']['bid']['#options'][$node->id()] = t(
'- Create a new publication -',
);
}
elseif (!empty($form['book']['bid']['#options']['new'])) {
$form['book']['bid']['#options']['new'] = t(
'- Create a new publication -',
);
// Change "Create new book" to "Create a new publication".
if (!empty($form['book']['bid']['#options']['new'])) {
$form['book']['bid']['#options']['new'] = t('- Create a new publication -');
}

$form['book']['bid']['#description'] = t(
'Your page will be part of the selected publication',
);
$form['book']['bid']['#description'] = t('Your page will be part of the selected publication');

// Alter "No book selected".
if (empty($book_values)) {
$form['book']['pid']['#prefix'] =
'<div id="edit-book-plid-wrapper"><em>No publication selected.</em>';
$form['book']['pid']['#prefix'] = '<div id="edit-book-plid-wrapper"><em>No publication selected.</em>';
}
else {
switch ($book_values['bid']) {
case '0':
$form['book']['pid']['#prefix'] =
'<div id="edit-book-plid-wrapper"><em>No publication selected.</em>';
$form['book']['pid']['#prefix'] = '<div id="edit-book-plid-wrapper"><em>No publication selected.</em>';
break;

case 'new':
case $node->id():
$form['book']['pid']['#prefix'] =
'<div id="edit-book-plid-wrapper"><em>This will be the top-level page in this publication.</em>';
$form['book']['pid']['#prefix'] = '<div id="edit-book-plid-wrapper"><em>This will be the top-level page in this publication.</em>';
break;

default:
Expand Down
9 changes: 9 additions & 0 deletions localgov_publications.routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
publication.admin_edit:
path: '/admin/structure/publications/{node}'
defaults:
_form: '\Drupal\book\Form\BookAdminEditForm'
_title: 'Re-order publication pages and change titles'
requirements:
_permission: 'administer book outlines'
_entity_access: 'node.view'
node: \d+
3 changes: 3 additions & 0 deletions localgov_publications.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ services:
- { name: event_subscriber }
localgov_publications.heading_finder:
class: Drupal\localgov_publications\Service\HeadingFinder
localgov_publications.publication_manager:
class: Drupal\localgov_publications\Service\PublicationManager
arguments: ['@entity_type.manager']
1 change: 1 addition & 0 deletions localgov_publications.tokens.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function localgov_publications_tokens_alter(array &$replacements, array $context
}
$query = \Drupal::entityQuery('node');
$query->condition('localgov_publication', $bid);
$query->accessCheck(FALSE);
$result = $query->execute();
if (!empty($result)) {
$landingPageNid = reset($result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function alterRoutes(RouteCollection $collection) {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events = parent::getSubscribedEvents();

// Use a lower priority than \Drupal\views\EventSubscriber\RouteSubscriber
Expand Down
Loading

0 comments on commit 053e570

Please sign in to comment.