ised-isde/epic_import

EPIC Import Module

dev-master 2021-02-14 19:14 UTC

This package is not auto-updated.

Last update: 2021-04-26 17:45:29 UTC


README

Note to developers

Nov 2020: This module is under rapid development at this time and is going through a lot of change. It is important to know that it started out as a GUI tool with an upload feature, but is now moving in the direction of drush scripts. The plan at this time is to reduce the GUI component, but for now there is a lot of code that needs to be moved.

There is however, a good role for the GUI component when it comes to downloading assets (images, etc) from intranet sites. We can make use of a browser that has access to both intranet and internet, and using javascript, can copy files from one site to another.

Setup

The content type Basic Page needs to have the following fields added:

  • Epic Filename (field_epic_filename) - plain text
  • Epic Type (field_epic_type) - plain text
  • Show Nav Menu (field_show_nav_menu) - boolean

Also go into Manage display and disable two options:
Use Layout Builder and
Allow content editors to use stored layouts
In Custom Display Settings enable Full Content

Need to enable Media Library. Use Configuration > Content authoring > Text formats and editors Add Media Library button to toolbar, and there are options below that need to be enabled and moved around. Just try to save and it will tell you what to do.

How to run in drush mode

vendor/bin/drush scr html/sites/default/modules/epic_import/drush/reset-content.php vendor/bin/drush scr html/sites/default/modules/epic_import/drush/convert.php ~/data/CleanGrowthHubData.zip vendor/bin/drush scr html/sites/default/modules/epic_import/drush/import.php vendor/bin/drush scr html/sites/default/modules/epic_import/drush/list-images.php

The import happens in two stages:

  • Convert into JSON format
  • Import JSON into Drupal

Settings

$ vendor/bin/drush cget epic_import.settings
path:
  base: /opt/app-root/src/data/epic-import
  zip: zip-files
  import: import-files
  files: /opt/app-root/src/data/sites/default/files
  imgdir: /opt/app-root/src/data/sites/default/files/img

Config changes required per site

  • Hide the Sidebar block to make it one column. Actually there is something odd here. We do need it to be enabled so that the epic_import module (currently) is able to hide/show it. But that doesn't seem to work until we disable and then enable the block.

  • Enable search module

Things to do

  • Create constants/globals for paths etc.
  • If a directory is needed, then create it
  • Need a better way to indicate which is the home page for a site

Notes

  • For Epic Ref, the only page to have 1 column (no left nav) is 000762.html
  • An "Annotation Document" in EPIC puts an h_ in front of the filename. It is determined by the Type field:
    0=Annotation doc, 1=Document
  • If 'Layout' is set to 2, then display the left nav.
  • A Notes "document" is also referred to as a "page" in the import code.

Proposed new workflow!

After some consideration, it is actually preferable to go back to the original GUI mode. This will allow non-developers to import content, and it will also provide a very organized process.

Create a home page for import which guides the process. Divide it into steps. The page can provide a dashboard view showing current state.

  • Upload the source zip file(s). They would go in the data directory, in a place designated for source files.
  • Convert source files to JSON. The JSON files would go into their own directory.
  • Press button to reset all content.
  • Run a script to download images from the source site and add them as managed files.
  • Run a script to change image src links to the Drupal managed images. The links could be changed in JSON (faster) or Drupal.
  • Run the import.
  • Run a script to fix internal links by converting them from old locations to new. This needs to be done after the import because it requires the URL alias.
  • Button to clean up the import environment (source files)