-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OEL-1017: [oe_whitelabel] Style the news content type #68
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
054e7b0
OEL-1017: Create OE Whitelabel News submodule and import OE Starter C…
GilNovacomm 88958ee
OEL-1017: Create Full and Teaser display templates for News and prepr…
GilNovacomm 5b03dd4
OEL-1017: Require oe_starter_content as dependency and update php ver…
GilNovacomm 7287bd7
OEL-1017: Create rendering tests for full and teaser displays and upd…
GilNovacomm 231db83
OEL-1017: Use original media instead of an image style when preproces…
GilNovacomm e54ff09
OEL-1017: OEL-1017: Update minimal versions of file_link, pathauto an…
692208f
OEL-1017: Update Drupal 9.1 to 9.2. along with its dependencies.
GilNovacomm 2075ee0
OEL-1017: Code standards.
GilNovacomm b63de56
OEL-1017: Clean pattern variable and code standards.
GilNovacomm 1c1e56b
OEL-1017: Add config dependencies for module.
ac52df4
OEL-1017: Correct test comments and create test instance node.
GilNovacomm 966f14f
OEL-1017: Add whitelabel helper as a dependency.
GilNovacomm 8f3f0cf
OEL-1017: Correctly name OE News date and update the node displays.
GilNovacomm dfc5ca4
OEL-1017: Remove unecessary validation.
GilNovacomm 7f6ac39
OEL-1017: Add dateformat.
GilNovacomm 2d04bc4
OEL-1017: Improve template semantics, remove unused variables and gen…
GilNovacomm 5011331
OEL-1017: Rename base test class, remove browser rendering from test …
GilNovacomm 993902f
OEL-1017: Create a template for field oe_publication_date and remove …
GilNovacomm 349724b
OEL-1017: Use composer v1 until support for 2 is complete in OpenEuropa.
GilNovacomm 7ecbfe1
OEL-1017: Set content variable using markup on teaser template and up…
GilNovacomm e8f1771
OEL-1017: Code standards.
GilNovacomm c24dc68
OEL-1017: Downgrade compose on lowest installation for drone.
GilNovacomm 3fc38c6
OEL-1017: Set variable as protected.
GilNovacomm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# OpenEuropa Whitelabel News |
7 changes: 7 additions & 0 deletions
7
modules/oe_whitelabel_news/config/install/core.date_format.oe_whitelabel_news_date.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
langcode: en | ||
status: true | ||
dependencies: { } | ||
id: oe_whitelabel_news_date | ||
label: 'OE Whitelabel News date' | ||
locked: false | ||
pattern: 'd F Y' |
59 changes: 59 additions & 0 deletions
59
modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
config: | ||
- field.field.node.oe_news.body | ||
- field.field.node.oe_news.oe_featured_media | ||
- field.field.node.oe_news.oe_publication_date | ||
- field.field.node.oe_news.oe_summary | ||
- node.type.oe_news | ||
module: | ||
- datetime | ||
- text | ||
- user | ||
|
||
id: node.oe_news.full | ||
targetEntityType: node | ||
bundle: oe_news | ||
mode: full | ||
content: | ||
body: | ||
type: text_default | ||
label: hidden | ||
settings: { } | ||
third_party_settings: { } | ||
weight: 12 | ||
region: content | ||
links: | ||
settings: { } | ||
third_party_settings: { } | ||
weight: 100 | ||
region: content | ||
oe_featured_media: | ||
type: entity_reference_entity_view | ||
label: hidden | ||
settings: | ||
view_mode: default | ||
link: false | ||
third_party_settings: { } | ||
weight: 10 | ||
region: content | ||
oe_publication_date: | ||
type: datetime_default | ||
label: hidden | ||
settings: | ||
timezone_override: '' | ||
format_type: oe_whitelabel_news_date | ||
third_party_settings: { } | ||
weight: 13 | ||
region: content | ||
oe_summary: | ||
type: basic_string | ||
label: hidden | ||
settings: { } | ||
third_party_settings: { } | ||
weight: 11 | ||
region: content | ||
hidden: | ||
langcode: true | ||
search_api_excerpt: true |
60 changes: 60 additions & 0 deletions
60
modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
config: | ||
- core.entity_view_mode.node.teaser | ||
- field.field.node.oe_news.body | ||
- field.field.node.oe_news.oe_featured_media | ||
- field.field.node.oe_news.oe_publication_date | ||
- field.field.node.oe_news.oe_summary | ||
- node.type.oe_news | ||
module: | ||
- datetime | ||
- text | ||
- user | ||
|
||
id: node.oe_news.teaser | ||
targetEntityType: node | ||
bundle: oe_news | ||
mode: teaser | ||
content: | ||
body: | ||
type: text_default | ||
label: hidden | ||
settings: { } | ||
third_party_settings: { } | ||
weight: 12 | ||
region: content | ||
links: | ||
settings: { } | ||
third_party_settings: { } | ||
weight: 100 | ||
region: content | ||
oe_featured_media: | ||
type: entity_reference_entity_view | ||
label: hidden | ||
settings: | ||
view_mode: default | ||
link: false | ||
third_party_settings: { } | ||
weight: 10 | ||
region: content | ||
oe_publication_date: | ||
type: datetime_default | ||
label: hidden | ||
settings: | ||
timezone_override: '' | ||
format_type: oe_whitelabel_news_date | ||
third_party_settings: { } | ||
weight: 13 | ||
region: content | ||
oe_summary: | ||
type: basic_string | ||
label: hidden | ||
settings: { } | ||
third_party_settings: { } | ||
weight: 11 | ||
region: content | ||
hidden: | ||
langcode: true | ||
search_api_excerpt: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: OpenEuropa Whitelabel News | ||
type: module | ||
description: Companion module to OE News providing styling to nodes. | ||
package: OpenEuropa Whitelabel Theme | ||
core_version_requirement: ^8.9 || ^9.2 | ||
dependencies: | ||
- oe_whitelabel:oe_whitelabel_helper | ||
- oe_starter_content:oe_starter_content_news | ||
brummbar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
config_devel: | ||
install: | ||
- core.date_format.oel_whitelabel_news_date.yml | ||
- core.entity_view_display.node.oe_news.full.yml | ||
- core.entity_view_display.node.oe_news.teaser.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* OE Whitelabel theme News. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
use Drupal\Core\Cache\CacheableMetadata; | ||
use Drupal\media\MediaInterface; | ||
use Drupal\media\Plugin\media\Source\Image; | ||
use Drupal\media_avportal\Plugin\media\Source\MediaAvPortalPhotoSource; | ||
use Drupal\oe_bootstrap_theme\ValueObject\ImageValueObject; | ||
|
||
/** | ||
* Implements template_preprocess_node() for the News node type. | ||
*/ | ||
function oe_whitelabel_news_preprocess_node__oe_news(&$variables) { | ||
if ($variables['view_mode'] !== 'full' && $variables['view_mode'] !== 'teaser') { | ||
return; | ||
} | ||
|
||
/** @var \Drupal\node\NodeInterface $node */ | ||
$node = $variables['node']; | ||
|
||
// Bail out if there is no media present. | ||
if ($node->get('oe_featured_media')->isEmpty()) { | ||
return; | ||
} | ||
|
||
/** @var \Drupal\media\Entity\Media $media */ | ||
$media = $node->get('oe_featured_media')->entity; | ||
if (!$media instanceof MediaInterface) { | ||
// The media entity is not available anymore, bail out. | ||
return; | ||
} | ||
|
||
// Retrieve the correct media translation. | ||
/** @var \Drupal\media\Entity\Media $media */ | ||
$media = \Drupal::service('entity.repository')->getTranslationFromContext($media, $node->language()->getId()); | ||
|
||
// Caches are handled by the formatter usually. Since we are not rendering | ||
// the original render arrays, we need to propagate our caches to the | ||
// paragraph template. | ||
$cacheability = CacheableMetadata::createFromRenderArray($variables); | ||
$cacheability->addCacheableDependency($media); | ||
|
||
// Run access checks on the media entity. | ||
$access = $media->access('view', $variables['user'], TRUE); | ||
$cacheability->addCacheableDependency($access); | ||
if (!$access->isAllowed()) { | ||
$cacheability->applyTo($variables); | ||
return; | ||
} | ||
|
||
// Get the media source. | ||
$source = $media->getSource(); | ||
|
||
$is_image = $source instanceof MediaAvPortalPhotoSource || $source instanceof Image; | ||
|
||
// If it's not an image and not a video, bail out. | ||
if (!$is_image) { | ||
$cacheability->applyTo($variables); | ||
return; | ||
} | ||
|
||
$thumbnail = $media->get('thumbnail')->first(); | ||
$variables['image'] = ImageValueObject::fromImageItem($thumbnail); | ||
|
||
if ($variables['view_mode'] == 'teaser') { | ||
$variables['image'] = ['#markup' => $variables['image']->getSource()]; | ||
} | ||
|
||
$cacheability->applyTo($variables); | ||
} |
16 changes: 16 additions & 0 deletions
16
modules/oe_whitelabel_news/templates/field--node--oe-publication-date--oe-news.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{# | ||
/** | ||
* @file | ||
* Theme override for field oe-publication-date. | ||
*/ | ||
#} | ||
{% if label_hidden %} | ||
{% for item in items %} | ||
{{ item.content }} | ||
{% endfor %} | ||
{% else %} | ||
{{ label }} | ||
{% for item in items %} | ||
{{ item.content }} | ||
{% endfor %} | ||
{% endif %} |
25 changes: 25 additions & 0 deletions
25
modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{# | ||
/** | ||
* @file | ||
* News full display. | ||
*/ | ||
#} | ||
<article{{attributes}}> | ||
{{ pattern('content_banner', { | ||
background: 'gray', | ||
title: label, | ||
content: content.oe_summary, | ||
image: image, | ||
meta: [ | ||
content.oe_publication_date, | ||
] | ||
}) }} | ||
|
||
<div class="container mt-md-4-75 mt-4"> | ||
<div class="row"> | ||
<div class="col-12 col-lg-10 col-xl-9 col-xxl-8 mb-4"> | ||
{{ content.body }} | ||
</div> | ||
</div> | ||
</div> | ||
</article> |
21 changes: 21 additions & 0 deletions
21
modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{# | ||
/** | ||
* @file | ||
* Search result template. | ||
*/ | ||
#} | ||
{% set _title %} | ||
<a class="text-underline-hover" href="{{ url }}">{{ label }}</a> | ||
{% endset %} | ||
{% set _content %} | ||
<span class="text-muted text-nowrap me-4-5">{{ content.oe_publication_date }}</span> | ||
{% endset %} | ||
<article{{attributes}}> | ||
{{ pattern('card', { | ||
variant: 'search', | ||
title: _title, | ||
text: content.oe_summary, | ||
image: image, | ||
content: _content | ||
}) }} | ||
</article> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is due to when installing the lowest versions:
Downgrading drupal/core (9.2.12 => 9.2.0): Loading from cache
these modules do not have the core_version_requirement key on their info file.
An explanation to each is on the _readme key on composer.json
"_readme": [ "Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.", "Explicit requirement for drupal/file_link due to https://www.drupal.org/project/file_link/issues/3147517. It can be removed when oe_media requires version 2.0.4 or above.", "Explicit requirement for drupal/pathauto due to D9.2 compatability according to https://www.drupal.org/node/2979476.", "Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped." ],