mitodl / ocw-studio

Open Source Courseware authoring tool
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

feat: add link to external resource rules #2130

Closed HussainTaj-arbisoft closed 6 months ago

HussainTaj-arbisoft commented 6 months ago

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/3678

Description (What does it do?)

This PR creates two new markdown cleanup rules.

Additionally, this PR introduces a new method on the MarkdownCleanupRule class. set_options allows a client to set dynamic options for a rule. This was introduced so that we could forward options like commit down to the rule's implementation.

Example outputs:

How can this be tested?

Prerequisites

Steps

  1. Navigate to your local ocw-studio setup.
  2. Checkout branch hussaintaj/3678-migrate-link-2-external-resource.
  3. Start/Restart Studio.
  4. Run the following set of commands.
    docker compose exec web ./manage.py markdown_cleanup link_to_external_resource --skip-sync --out link_to_external_resource.csv
    docker compose exec web ./manage.py markdown_cleanup nav_item_to_external_resource --skip-sync --out nav_item_to_external_resource.csv
  5. Analyze the output files.
  6. Expect changes to be predictable and valid.
  7. Choose specific courses to apply the changes to and test builds with. For example, this test course.
  8. Run the following set of commands for specific courses. These will run a rule for a specific course, reset the courses sync states, populate the course's pipelines, and sync the course markdown to the backend. So please make sure your GitHub backend is set up.
    COURSE_ID=<course-id>
    docker compose exec web ./manage.py markdown_cleanup <rule> --skip-sync --commit --filter $COURSE_ID
    docker compose exec web ./manage.py reset_sync_states --skip_sync --filter $COURSE_ID && docker compose exec web ./manage.py backpopulate_pipelines --filter $COURSE_ID && docker compose exec web ./manage.py sync_website_to_backend --filter $COURSE_ID --delete
  9. Publish your changes from the Studio UI.
  10. Expect the build to succeed.
  11. Expect the external resources to be functioning properly i.e. they open external links, have the correct icon, and open a warning modal if applicable.