Skip to content

Commit

Permalink
feat(YALB-1550): add single_content_sync
Browse files Browse the repository at this point in the history
This update allows exporting and importing of nodes, media, and taxonomy
through either a graphical interface or through a drush command.  Keep
in mind that due to limitations of file size uploads with PHP, Pantheon,
and Drupal, importing large amounts of data should be done via Drush.

* Add single_content_sync module and enable it
* Add custom bulk actions for exporting taxonomy and media in the same
  way as nodes
* Add processors for types not handled by single_content_sync
  * Embed
  * Markup
  * SmartDate
  * ViewsBasicParams
* Add custom admin views for exporting nodes, taxonomy, and media,
  accessible through Configuration->System->Export Nodes
* Add ZipArchive patch
  *  The open method has been deprecated, and a message appears displaying
  this when attempting to export via a zip file.  This patch squelches
  this.  This has been fixed in Drupal 10.1, but is still present in
  9.5
  • Loading branch information
dblanken-yale committed Sep 18, 2023
1 parent b4aaa0a commit 9d782d5
Show file tree
Hide file tree
Showing 29 changed files with 2,699 additions and 7 deletions.
4 changes: 3 additions & 1 deletion web/profiles/custom/yalesites_profile/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"drupal/section_library": "^1.1",
"drupal/selective_better_exposed_filters": "^3.0@beta",
"drupal/simple_sitemap": "^4.1",
"drupal/single_content_sync": "^1.4",
"drupal/smart_date": "^3.5",
"drupal/twig_tweak": "^3.1",
"drupal/typogrify": "^1.2",
Expand Down Expand Up @@ -112,7 +113,8 @@
"drupal/core": {
"plural results summary https://www.drupal.org/project/drupal/issues/2888320": "https://www.drupal.org/files/issues/2021-12-15/2888320-78.patch",
"Prevent media library item overflow https://www.drupal.org/project/drupal/issues/3059955": "https://www.drupal.org/files/issues/2023-03-18/3059955-167.patch",
"Remove for Drupal 10 - CKEditor 5 should not grow to infinite height https://www.drupal.org/project/drupal/issues/3273755": "https://www.drupal.org/files/issues/2023-07-26/ckeditor-height-fix.patch"
"Remove for Drupal 10 - CKEditor 5 should not grow to infinite height https://www.drupal.org/project/drupal/issues/3273755": "https://www.drupal.org/files/issues/2023-07-26/ckeditor-height-fix.patch",
"Fix ZipArchive deprecation: https://www.drupal.org/project/single_content_sync/issues/3364535": "https://www.drupal.org/files/issues/2022-08-22/2850794-51.patch"
},
"drupal/entity_redirect": {
"fix layout route https://www.drupal.org/project/entity_redirect/issues/3352265": "https://git.drupalcode.org/project/entity_redirect/-/merge_requests/6.patch"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php7.c>
php_flag engine off
</IfModule>
<IfModule mod_php.c>
php_flag engine off
</IfModule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
uuid: 9440b8ce-971f-47ff-bc8b-4a5fdbfba7ff
langcode: en
status: true
dependencies:
enforced:
module:
- ys_starterkit
id: ys_images_files
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: ys_starterkit
label: 'Starterkit Images'
source:
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
- profiles/custom/yalesites_profile/modules/custom/ys_starterkit/content/images.json
item_selector: /data/images
fields:
-
name: image_id
label: 'Image ID'
selector: image_id
-
name: image_url
label: 'Image URL'
selector: image_url
ids:
image_id:
type: integer
constants:
drupal_file_dest: 'public://starterkit/'
process:
destination_filename:
-
plugin: callback
callable: basename
source: image_url
-
plugin: skip_on_empty
method: row
message: 'Cannot import empty filename.'
destination_full_path:
-
plugin: concat
source:
- constants/drupal_file_dest
- '@destination_filename'
-
plugin: urlencode
uri:
-
plugin: skip_on_empty
method: process
source: image_url
-
plugin: file_copy
source:
- image_url
- '@destination_full_path'
file_exists: rename
move: false
uid:
plugin: default_value
default_value: 1
destination:
plugin: 'entity:file'
migration_dependencies: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
uuid: 39d4e56f-4151-4461-b4d0-113dc14475fe
langcode: en
status: true
dependencies:
enforced:
module:
- ys_starterkit
id: ys_images_media
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: ys_starterkit
label: 'Starterkit Media'
source:
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
- profiles/custom/yalesites_profile/modules/custom/ys_starterkit/content/images.json
item_selector: /data/images
fields:
-
name: image_id
label: 'Image ID'
selector: image_id
-
name: image_url
label: 'Image URL'
selector: image_url
-
name: alt_text
label: 'Alternate text'
selector: alt_text
ids:
image_id:
type: integer
process:
pseudo_destination_filename:
-
plugin: callback
callable: basename
source: image_url
-
plugin: skip_on_empty
method: row
message: 'Cannot import empty filename.'
name: '@pseudo_destination_filename'
field_media_image/target_id:
plugin: migration_lookup
migration: ys_images_files
source: image_id
thumbnail/target_id:
plugin: migration_lookup
migration: ys_images_files
source: image_id
field_media_image/alt: alt_text
uid:
plugin: default_value
default_value: 1
destination:
plugin: 'entity:media'
default_bundle: image
migration_dependencies:
required:
- ys_images_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
uuid: 63dbb578-58f4-4dd9-b0a1-9edd3dbaa79f
langcode: en
status: true
dependencies:
enforced:
module:
- ys_starterkit
id: ys_menu_links
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: ys_starterkit
label: 'Starterkit Menu Links'
source:
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
- profiles/custom/yalesites_profile/modules/custom/ys_starterkit/content/menu_links.json
item_selector: data
fields:
-
name: src_unique_id
label: 'Unique ID'
selector: unique_id
-
name: page_migration_id
label: 'Reference to migrated page'
selector: page_migration_id
-
name: name
label: Name
selector: name
-
name: parent_ref
label: 'Parent menu link reference'
selector: parent_ref
constants:
path: 'entity:node/'
ids:
src_unique_id:
type: string
process:
menu_name:
plugin: default_value
default_value: main
nid:
-
plugin: skip_on_empty
method: process
source: page_migration_id
-
plugin: migration_lookup
migration: ys_pages
parent_link_id:
-
plugin: migration_lookup
migration: ys_menu_links
source: parent_ref
-
plugin: default_value
default_value: 0
title:
plugin: get
source: name
language: en
link/uri:
plugin: concat
source:
- constants/path
- '@nid'
parent:
plugin: menu_link_parent
source:
- parent_link_id
- main
external:
plugin: default_value
default_value: 0
expanded:
plugin: default_value
default_value: 0
enabled:
plugin: default_value
default_value: 1
destination:
plugin: 'entity:menu_link_content'
bundle: menu_link_content
no_stub: true
migration_dependencies:
required:
- ys_pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
uuid: 52099feb-f57f-4f06-a7b4-57f2fe441095
langcode: en
status: true
dependencies:
enforced:
module:
- ys_starterkit
id: ys_pages
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: ys_starterkit
label: 'Starterkit Pages'
source:
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
- profiles/custom/yalesites_profile/modules/custom/ys_starterkit/content/pages.json
item_selector: /data/pages
fields:
-
name: src_unique_id
label: 'Unique ID'
selector: unique_id
-
name: src_title
label: Title
selector: title
ids:
src_unique_id:
type: string
process:
uid:
plugin: default_value
default_value: 1
status:
plugin: default_value
default_value: true
title: src_title
destination:
plugin: 'entity:node'
default_bundle: page
migration_dependencies:
required:
- ys_images_media
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
uuid: 04681e16-4ad0-4003-ad86-faff4e99879e
langcode: en
status: true
dependencies:
enforced:
module:
- ys_starterkit
id: ys_posts
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: ys_starterkit
label: 'Starterkit Post'
source:
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
- profiles/custom/yalesites_profile/modules/custom/ys_starterkit/content/posts.json
item_selector: /data/posts
fields:
-
name: src_unique_id
label: 'Unique ID'
selector: unique_id
-
name: src_title
label: Title
selector: title
-
name: src_author
label: Author
selector: field_author
ids:
src_unique_id:
type: string
constants:
date_format: Y-m-d
process:
uid:
plugin: default_value
default_value: 1
status:
plugin: default_value
default_value: true
title: src_title
field_author: src_author
field_publish_date:
plugin: callback
callable: date
unpack_source: true
source:
- constants/date_format
destination:
plugin: 'entity:node'
default_bundle: post
migration_dependencies:
required:
- ys_images_media
Loading

0 comments on commit 9d782d5

Please sign in to comment.