Add configuration and scripts for daily emails

This commit is contained in:
Oliver Davies 2024-06-02 07:54:54 +01:00
parent 46d8e3c347
commit df79fb7060
11 changed files with 4367 additions and 0 deletions

View file

@ -0,0 +1,22 @@
uuid: 1cec9098-9a97-48a0-8b75-c0129fe2187a
langcode: en
status: true
dependencies:
config:
- node.type.daily_email
id: node.daily_email.promote
field_name: promote
entity_type: node
bundle: daily_email
label: 'Promoted to front page'
description: ''
required: false
translatable: true
default_value:
-
value: 0
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean

View file

@ -0,0 +1,82 @@
uuid: 4de70dfa-13cf-4eef-a1c5-df22a9f227a0
langcode: en
status: true
dependencies:
config:
- field.field.node.daily_email.body
- node.type.daily_email
module:
- path
- text
id: node.daily_email.default
targetEntityType: node
bundle: daily_email
mode: default
content:
body:
type: text_textarea_with_summary
weight: 121
region: content
settings:
rows: 9
summary_rows: 3
placeholder: ''
show_summary: false
third_party_settings: { }
created:
type: datetime_timestamp
weight: 10
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 30
region: content
settings: { }
third_party_settings: { }
promote:
type: boolean_checkbox
weight: 15
region: content
settings:
display_label: true
third_party_settings: { }
status:
type: boolean_checkbox
weight: 120
region: content
settings:
display_label: true
third_party_settings: { }
sticky:
type: boolean_checkbox
weight: 16
region: content
settings:
display_label: true
third_party_settings: { }
title:
type: string_textfield
weight: -5
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
region: content
settings:
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { }
url_redirects:
weight: 50
region: content
settings: { }
third_party_settings: { }
hidden: { }

View file

@ -0,0 +1,28 @@
uuid: 29a419e1-d32b-480f-b2a5-5b53bd304fa0
langcode: en
status: true
dependencies:
config:
- field.field.node.daily_email.body
- node.type.daily_email
module:
- text
- user
id: node.daily_email.default
targetEntityType: node
bundle: daily_email
mode: default
content:
body:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 101
region: content
links:
settings: { }
third_party_settings: { }
weight: 100
region: content
hidden: { }

View file

@ -0,0 +1,30 @@
uuid: 49c930bc-7524-41ba-a8e0-241c657f5f66
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- field.field.node.daily_email.body
- node.type.daily_email
module:
- text
- user
id: node.daily_email.teaser
targetEntityType: node
bundle: daily_email
mode: teaser
content:
body:
type: text_summary_or_trimmed
label: hidden
settings:
trim_length: 600
third_party_settings: { }
weight: 101
region: content
links:
settings: { }
third_party_settings: { }
weight: 100
region: content
hidden: { }

View file

@ -0,0 +1,24 @@
uuid: c909819c-22ba-462f-8277-9bc514799ad7
langcode: en
status: true
dependencies:
config:
- field.storage.node.body
- node.type.daily_email
module:
- text
id: node.daily_email.body
field_name: body
entity_type: node
bundle: daily_email
label: Body
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
display_summary: true
required_summary: false
allowed_formats: { }
field_type: text_with_summary

View file

@ -0,0 +1,17 @@
uuid: c40f9dd1-769b-4ebf-8fbf-2fef1f2b34cb
langcode: en
status: true
dependencies:
module:
- menu_ui
third_party_settings:
menu_ui:
available_menus: { }
parent: ''
name: 'Daily email'
type: daily_email
description: ''
help: ''
new_revision: true
preview_mode: 1
display_submitted: true

View file

@ -0,0 +1,14 @@
uuid: 5ecc8902-0c21-4e80-9bf4-a8db1ab93de5
langcode: en
status: true
dependencies:
config:
- node.type.daily_email
id: node_type_daily_email
entity_type_id: node_type
entity_id: daily_email
action: display_page
allow_override: 0
redirect: ''
redirect_code: 301
redirect_fallback_action: access_denied

View file

@ -0,0 +1,431 @@
uuid: 5ea1f419-9ff4-4ef8-8ba5-5faf94279ac8
langcode: en
status: true
dependencies:
config:
- node.type.daily_email
- system.menu.main
module:
- node
- user
id: daily_emails
label: 'Daily emails'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
display:
default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options:
title: 'The Daily Drupaler: Email Archive'
fields:
view_node:
id: view_node
table: node
field: view_node
relationship: none
group_type: group
admin_label: ''
entity_type: node
plugin_id: entity_link
label: ''
exclude: true
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: view
output_url_as_text: true
absolute: false
created:
id: created
table: node_field_data
field: created
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: created
plugin_id: field
label: ''
exclude: true
alter:
alter_text: true
text: '{{ created }}:'
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: '0'
element_class: ''
element_label_type: '0'
element_label_class: ''
element_label_colon: false
element_wrapper_type: '0'
element_wrapper_class: ''
element_default_classes: false
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
tooltip:
date_format: long
custom_date_format: ''
time_diff:
enabled: false
future_format: '@interval hence'
past_format: '@interval ago'
granularity: 2
refresh: 60
description: ''
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
plugin_id: field
label: ''
exclude: false
alter:
alter_text: true
text: '{{ created }} {{ title }}'
make_link: true
path: '{{ view_node }}'
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
pager:
type: mini
options:
offset: 0
items_per_page: 31
total_pages: null
id: 0
tags:
next:
previous:
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
empty: { }
sorts:
created:
id: created
table: node_field_data
field: created
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: created
plugin_id: date
order: DESC
expose:
label: ''
field_identifier: ''
exposed: false
granularity: second
arguments: { }
filters:
status:
id: status
table: node_field_data
field: status
entity_type: node
entity_field: status
plugin_id: boolean
value: '1'
group: 1
expose:
operator: ''
type:
id: type
table: node_field_data
field: type
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: type
plugin_id: bundle
operator: in
value:
daily_email: daily_email
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
style:
type: html_list
options:
grouping: { }
row_class: ''
default_row_class: true
type: ul
wrapper_class: item-list
class: ''
row:
type: fields
options:
default_field_elements: true
inline: { }
separator: ' - '
hide_empty: false
query:
type: views_query
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
replica: false
query_tags: { }
relationships: { }
header:
area:
id: area
table: views
field: area
relationship: none
group_type: group
admin_label: ''
plugin_id: text
empty: false
content:
value: '<p>This is an archive of the 520+ email messages I have sent to <a href="/daily">my daily mailing list</a> since the 12th of August, 2022. Enjoy!</p>'
format: basic_html
tokenize: false
footer: { }
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags: { }
feed_1:
id: feed_1
display_title: Feed
display_plugin: feed
position: 2
display_options:
title: "The Daily Drupaler: Oliver Davies' Daily Email List"
pager:
type: some
options:
offset: 0
items_per_page: 1
row:
type: node_rss
options: { }
defaults:
title: false
sitename_title: false
display_extenders: { }
path: rss/daily.xml
sitename_title: false
displays:
page_1: page_1
default: '0'
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- 'user.node_grants:view'
- user.permissions
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 1
display_options:
display_extenders: { }
path: archive
menu:
type: normal
title: 'Daily email archive'
menu_name: main
parent: ''
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags: { }

3686
tools/scripts/daily.json Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
<?php
$entityTypeManager = \Drupal::entityTypeManager();
$nodeStorage = $entityTypeManager->getStorage('node');
$emails = $nodeStorage->loadByProperties(['type' => 'daily_email']);
$nodeStorage->delete($emails);

View file

@ -0,0 +1,26 @@
<?php
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
$json = json_decode(file_get_contents(__DIR__ . '/daily.json'), TRUE);
$emails = $json['emails'];
foreach ($emails as $email) {
$title = $email['title'];
$title = str_replace(search: '&#039;', replace: '\'', subject: $title);
$title = str_replace(search: '&quot;', replace: '`', subject: $title);
/** @var NodeInterface */
$node = Node::create(['type' => 'daily_email']);
$node->setTitle($title);
$node->setCreatedTime($email['date']);
$node->setChangedTime($email['date']);
$node->setOwnerId(1);
$node->set('body', [
'format' => 'basic_html',
'value' => $email['text'],
]);
$node->set('path', $email['permalink']);
$node->save();
}