Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

ISAICP-6122: Allow simple text styling and links in the collection abstract #2441

Merged
merged 5 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ content:
wrap_class: trimmed
more_text: More
more_class: more-link
trim_options:
text: true
trim_zero: false
wrap_output: false
more_link: false
trim_options:
text: false
trim_zero: false
summary_handler: full
third_party_settings:
template_suggestion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ dependencies:
- text
third_party_settings:
allowed_formats:
content_editor: content_editor
basic_html: '0'
basic_html: basic_html
content_editor: '0'
eira_format: '0'
full_html: '0'
glossary_html: '0'
licence: '0'
plain_text: '0'
restricted_html: '0'
simple_html: '0'
simple_text: '0'
plain_text: '0'
_core:
default_config_hash: 1VOX4tmugcY6Vy3QcRmHxAkjRp7JR3DWZznLsDjPFRM
id: rdf_entity.collection.field_ar_abstract
Expand Down
8 changes: 6 additions & 2 deletions config/sync/field.storage.rdf_entity.field_ar_abstract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ langcode: en
status: true
dependencies:
module:
- field_permissions
- rdf_entity
- sparql_entity_storage
- text
third_party_settings:
sparql_entity_storage:
Expand All @@ -12,8 +14,10 @@ third_party_settings:
predicate: 'http://purl.org/dc/terms/abstract'
format: literal
format:
predicate: ''
format: ''
predicate: 'http://joinup.eu/text_format'
format: 'xsd:string'
field_permissions:
permission_type: public
id: rdf_entity.field_ar_abstract
field_name: field_ar_abstract
entity_type: rdf_entity
Expand Down
8 changes: 4 additions & 4 deletions tests/features/collection/collection.about.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Feature: About page
| state | validated |

When I go to the homepage of the "Fitness at work" collection
# Check for HTML so that we assert that actually the HTML has been stripped.
Then the page should contain the html text "Fit while working is dope"
# Check for HTML so that we can assert that text styling is present.
Then the page should contain the html text "<strong>Fit while working</strong> is dope"
And I should see the text "leo blandit a ornare non sollicitudin iaculis…"
# Check that later chunks of text in the abstract are not rendered.
But I should not see the text "purus. Integer nec enim facilisis mi fermentum mollis sed vitae lacus" in the Content region
Expand Down Expand Up @@ -61,8 +61,8 @@ Feature: About page
And I fill in "Abstract" with ""
And I press "Publish"
Then I should see the heading "Fitness at work"
And the page should contain the html text "This collection is intended to show ways of being fit while working"
And I should see the text "In consequat sapien risus a malesuada…" in the Content region
And the page should contain the html text "This collection is intended to show ways of being <strong>fit while working</strong>"
And I should see the text "Vivamus libero leo blandit a ornare non sollicitudin iaculis…" in the Content region
But I should not see the text "malesuada eros auctor eget. Curabitur at" in the Content region
When I click "Read more" in the "Content" region
Then I should see the heading "About Fitness at work"
29 changes: 29 additions & 0 deletions web/modules/custom/joinup_core/joinup_core.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,32 @@
*/

declare(strict_types = 1);

/**
* Switch the filter format of the collection abstract to basic HTML.
*/
function joinup_core_deploy_0107000(array &$sandbox): string {
$storage = \Drupal::entityTypeManager()->getStorage('rdf_entity');

if (!isset($sandbox['total'])) {
$query = $storage->getQuery()
->condition('rid', 'collection')
->exists('field_ar_abstract');
$sandbox['ids'] = array_values($query->execute());
$sandbox['total'] = count($sandbox['ids']);
$sandbox['processed'] = 0;
}

$ids = array_splice($sandbox['ids'], 0, 19);
/** @var \Drupal\collection\Entity\CollectionInterface[] $collections */
$collections = $storage->loadMultiple($ids);
foreach ($collections as $collection) {
$collection->field_ar_abstract->format = 'basic_html';
$collection->save();

}
$sandbox['processed'] += count($ids);
$sandbox['#finished'] = empty($sandbox['ids']) ? 1 : $sandbox['processed'] / $sandbox['total'];

return "Processed {$sandbox['processed']} out of {$sandbox['total']}";
}