From 8d8992a8b51c182f26d33ff4c95c50c5f9d587f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sat, 19 Jan 2019 21:19:12 -0500 Subject: [PATCH 01/10] Override author field for dc:creator --- .../field/field--node--field-authors--rss-teaser.html.twig | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 agaric/templates/field/field--node--field-authors--rss-teaser.html.twig diff --git a/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig b/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig new file mode 100644 index 0000000..54dbe71 --- /dev/null +++ b/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig @@ -0,0 +1,6 @@ + +{% for item in items %} + {% if loop.length > 1 and loop.index == loop.length %}and {% endif %} + {{ item.content }}{% if loop.length > 2 and not loop.last %}, {% endif %} +{% endfor %} + From d2660cd7902c38d6fc29872b57b05ea4c01292f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sat, 19 Jan 2019 21:57:54 -0500 Subject: [PATCH 02/10] Don't print anything from the created date field this is handled in the views row template. But we can't stop this field from being printed. --- .../templates/field/field--node--created--rss-teaser.html.twig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 agaric/templates/field/field--node--created--rss-teaser.html.twig diff --git a/agaric/templates/field/field--node--created--rss-teaser.html.twig b/agaric/templates/field/field--node--created--rss-teaser.html.twig new file mode 100644 index 0000000..adb2984 --- /dev/null +++ b/agaric/templates/field/field--node--created--rss-teaser.html.twig @@ -0,0 +1,2 @@ +{# In views/views-view-row-rss--taxonomy-term--feed-teasers.html.twig we print + everything we'd want to do with the created date, so blank it here. #} From 253e6e971661b6f884811a70c92fdd8359740e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sat, 19 Jan 2019 21:59:59 -0500 Subject: [PATCH 03/10] Suppress any output from the UID field We print dc:creator from the authors field (we allow multiple authors) --- agaric/templates/field/field--node--uid--rss-teaser.html.twig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 agaric/templates/field/field--node--uid--rss-teaser.html.twig diff --git a/agaric/templates/field/field--node--uid--rss-teaser.html.twig b/agaric/templates/field/field--node--uid--rss-teaser.html.twig new file mode 100644 index 0000000..d6aff21 --- /dev/null +++ b/agaric/templates/field/field--node--uid--rss-teaser.html.twig @@ -0,0 +1,2 @@ +{# In field/field--node--field-authors--rss-teaser.html.twig we print the author + so blank it here (since the views RSS handler forces printing this field. #} From 8c3e1dcc88e3cedacd0eae9110e415567d4f70b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sat, 19 Jan 2019 22:01:41 -0500 Subject: [PATCH 04/10] Per RSS conventions multiple authors means multiple dc:creator tags See http://www.rssboard.org/rss-profile --- .../field/field--node--field-authors--rss-teaser.html.twig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig b/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig index 54dbe71..4f9cb5b 100644 --- a/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig +++ b/agaric/templates/field/field--node--field-authors--rss-teaser.html.twig @@ -1,6 +1,5 @@ - {% for item in items %} - {% if loop.length > 1 and loop.index == loop.length %}and {% endif %} - {{ item.content }}{% if loop.length > 2 and not loop.last %}, {% endif %} + + {{ item.content }} + {% endfor %} - From 183434e5bad0a996d9c26a237ceeb54cfc772898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sat, 19 Jan 2019 23:49:16 -0500 Subject: [PATCH 05/10] Fix read more link, make it a paragraph, escape the HTML --- .../views-view-row-rss--taxonomy-term--feed-teasers.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agaric/templates/views/views-view-row-rss--taxonomy-term--feed-teasers.html.twig b/agaric/templates/views/views-view-row-rss--taxonomy-term--feed-teasers.html.twig index 8a2104c..acdc70c 100644 --- a/agaric/templates/views/views-view-row-rss--taxonomy-term--feed-teasers.html.twig +++ b/agaric/templates/views/views-view-row-rss--taxonomy-term--feed-teasers.html.twig @@ -39,7 +39,7 @@ {# The RSS Teaser view mode *must* be configured to output the body paragraph (summary) LAST; see below for why. #} {{ description|raw }} - Read more and discuss at agaric.coop. + {{ '

Read more and discuss at agaric.coop.

'|escape('html') }} {# Opening description tag is in paragraph template used for description, see field/field--field-body-paragraph--rss-teaser.html.twig and only the closing description tag is here so that we can have the read more link From 29f7fce47f4607613ea6adad4b65a2589e48b7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Mon, 21 Jan 2019 00:30:47 -0500 Subject: [PATCH 06/10] Print only the first *text* paragraph --- .../field--field-body-paragraph--rss-teaser.html.twig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/agaric/templates/field/field--field-body-paragraph--rss-teaser.html.twig b/agaric/templates/field/field--field-body-paragraph--rss-teaser.html.twig index 4ce44cf..3d0dbe6 100644 --- a/agaric/templates/field/field--field-body-paragraph--rss-teaser.html.twig +++ b/agaric/templates/field/field--field-body-paragraph--rss-teaser.html.twig @@ -34,11 +34,17 @@ * - label_display: The display settings for the label. * * @see template_preprocess_field() + {% for i, paragraph in content.field_body_paragraph if i|first != '#' %} */ #} -{% for item in items %} - {{ item.content|render|escape }} +{% set one_and_done = false %} +{% for item in items if not one_and_done %} +{{ item.content['#paragraph'].type.0.entity.id }} + {% if item.content['#paragraph'].type.0.entity.id == 'text' %} + {% set one_and_done = true %} + {{ item.content|render|escape }} + {% endif %} {% endfor %} {# the closing description tag is found in the RSS view template so that we can add a Read more link — we don't have the node information to make it here! From f93bfb0b0614810c07e6fb5a224c05192897dd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Mon, 21 Jan 2019 12:11:13 -0500 Subject: [PATCH 07/10] Override bulma/templates/field/field--text-long.html.twig --- .../field/field--paragraph--text--field-text--preview.html.twig | 1 + 1 file changed, 1 insertion(+) create mode 100644 agaric/templates/field/field--paragraph--text--field-text--preview.html.twig diff --git a/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig b/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig new file mode 100644 index 0000000..07ce721 --- /dev/null +++ b/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig @@ -0,0 +1 @@ +{% extends "field--text.html.twig" %} From 6e05b62f7c220625e13051bfad7a95ae0e58a2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Mon, 21 Jan 2019 12:14:07 -0500 Subject: [PATCH 08/10] Override the thing that's extended --- ...graph--text--field-text--preview.html.twig | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig b/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig index 07ce721..cb36254 100644 --- a/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig +++ b/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig @@ -1 +1,19 @@ -{% extends "field--text.html.twig" %} +{% extends "field.html.twig" %} +{# +/** + * @file + * Default theme implementation for a text field. + * + * A 'content' class is added to provide default styling of base elements such + * as paragraphs and lists that may not have classes assigned to them. This + * allows user entered content to have default styling without interfering with + * the styles of other UI components such as system generated lists or other + * dynamic content. + * + * @see https://www.drupal.org/node/2539860 + * @see http://bulma.io/documentation/elements/content + * + * @ingroup themeable + */ +#} +{% set attributes = attributes.addClass('content') %} \ No newline at end of file From 8c4e7dd184cde2958b48f3022bbb4399f4e0ce86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Mon, 21 Jan 2019 13:00:12 -0500 Subject: [PATCH 09/10] Turns out we don't need to override the field at all; our surrounding HTML comes from the paragraph --- ...graph--text--field-text--preview.html.twig | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 agaric/templates/field/field--paragraph--text--field-text--preview.html.twig diff --git a/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig b/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig deleted file mode 100644 index cb36254..0000000 --- a/agaric/templates/field/field--paragraph--text--field-text--preview.html.twig +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "field.html.twig" %} -{# -/** - * @file - * Default theme implementation for a text field. - * - * A 'content' class is added to provide default styling of base elements such - * as paragraphs and lists that may not have classes assigned to them. This - * allows user entered content to have default styling without interfering with - * the styles of other UI components such as system generated lists or other - * dynamic content. - * - * @see https://www.drupal.org/node/2539860 - * @see http://bulma.io/documentation/elements/content - * - * @ingroup themeable - */ -#} -{% set attributes = attributes.addClass('content') %} \ No newline at end of file From 07b835a12b603b956f580afec838761c110fc11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Mon, 21 Jan 2019 13:03:22 -0500 Subject: [PATCH 10/10] Remove surrounding cruft from pure teaser/preview paragraph for RSS --- .../paragraph--text--preview.html.twig | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 agaric/templates/paragraph/paragraph--text--preview.html.twig diff --git a/agaric/templates/paragraph/paragraph--text--preview.html.twig b/agaric/templates/paragraph/paragraph--text--preview.html.twig new file mode 100644 index 0000000..9b19d8c --- /dev/null +++ b/agaric/templates/paragraph/paragraph--text--preview.html.twig @@ -0,0 +1,45 @@ +{# +/** + * @file + * Default theme implementation to display a paragraph. + * + * Available variables: + * - paragraph: Full paragraph entity. + * Only method names starting with "get", "has", or "is" and a few common + * methods such as "id", "label", and "bundle" are available. For example: + * - paragraph.getCreatedTime() will return the paragraph creation timestamp. + * - paragraph.id(): The paragraph ID. + * - paragraph.bundle(): The type of the paragraph, for example, "image" or "text". + * - paragraph.getOwnerId(): The user ID of the paragraph author. + * See Drupal\paragraphs\Entity\Paragraph for a full list of public properties + * and methods for the paragraph object. + * - content: All paragraph items. Use {{ content }} to print them all, + * or print a subset such as {{ content.field_example }}. Use + * {{ content|without('field_example') }} to temporarily suppress the printing + * of a given child element. + * - attributes: HTML attributes for the containing element. + * The attributes.class element may contain one or more of the following + * classes: + * - paragraphs: The current template type (also known as a "theming hook"). + * - paragraphs--type-[type]: The current paragraphs type. For example, if the paragraph is an + * "Image" it would result in "paragraphs--type--image". Note that the machine + * name will often be in a short form of the human readable label. + * - paragraphs--view-mode--[view_mode]: The View Mode of the paragraph; for example, a + * preview would result in: "paragraphs--view-mode--preview", and + * default: "paragraphs--view-mode--default". + * - view_mode: View mode; for example, "preview" or "full". + * - logged_in: Flag for authenticated user status. Will be true when the + * current user is a logged-in member. + * - is_admin: Flag for admin user status. Will be true when the current user + * is an administrator. + * + * @see template_preprocess_paragraph() + * + * @ingroup themeable + */ +#} +{% block paragraph %} + {% block content %} + {{ content }} + {% endblock %} +{% endblock paragraph %}