MishkaCmsMigration.Targets.Helpers.Scripts (Mishka CMS Migration v0.0.1)

Copy Markdown View Source

The scripts and inline event handlers a post's or a page's content holds, for the targets that write the content (MishkaCmsMigration.Targets.CmsPage, MishkaCmsMigration.Targets.BlogPost): each <script> element and each on… attribute (onclick, onerror, ...), whatever the source and the editor that made the content.

Such an item is never written on its own: it waits for an admin's decision (MishkaCmsMigration.MigrationItem's Decide…) on "scripts", its reason naming them after ": " in the order the content has them, a handler with its element, as in "scripts: onclick on a, script", in the dry run (the target's waiting/2, waiting/2 here) and in prepare/3 for any write (call/2). Remove them ("import") writes the content without them (removed/3), and Keep them, I trust this content ("trust"), writes it as it is; the report says which (note/2: "scripts_removed: <found>", "scripts_kept: <found>"). Keep them is not a choice the Items table's Keep the site as it is makes for picked rows: trusting a script is decided item by item.

Summary

Functions

:ok for item to be written: its content holds no script, or an admin decided to remove them or to keep them; else {:undecided, conflict}.

The conflict item waits on: "scripts: <found>" for content that holds a script or an inline event handler, else nil.

What the report says of item's scripts once it is written: "scripts_removed: <found>" or "scripts_kept: <found>", as an admin decided, else nil.

html, the content of item, without its scripts and inline event handlers once an admin decided to remove them; as it is otherwise.

What the target's waiting/2 says of item: {:undecided, conflict} until an admin decides, then nil, to be written, as for content with no script.

Functions

call(item, context)

:ok for item to be written: its content holds no script, or an admin decided to remove them or to keep them; else {:undecided, conflict}.

conflict(item)

@spec conflict(MishkaCmsMigration.Source.Item.t()) :: String.t() | nil

The conflict item waits on: "scripts: <found>" for content that holds a script or an inline event handler, else nil.

note(item, context)

What the report says of item's scripts once it is written: "scripts_removed: <found>" or "scripts_kept: <found>", as an admin decided, else nil.

removed(html, item, context)

html, the content of item, without its scripts and inline event handlers once an admin decided to remove them; as it is otherwise.

waiting(item, context)

What the target's waiting/2 says of item: {:undecided, conflict} until an admin decides, then nil, to be written, as for content with no script.