MishkaCmsBuilderWeb.Paths (Mishka CMS Builder v0.0.1-alpha.2)

Copy Markdown View Source

The visual editor's addresses, spelled in one place.

The editor owns how its own routes are written; the rest of the admin asks for them through runtime:document:editor_url (MishkaCmsCore.Runtime.Authoring.Section.editor_url/3), which MishkaCmsBuilder.Plugins.EditorUrl answers from builder_path/3. Inside the editor — the error page's status strip, a component's own editor opened from a page, the share link, a mention's notification — the same function writes every address, and back_path/2 honours only what it writes.

Summary

Functions

Where the builder's back link goes: return_to when it names another builder, the section's list otherwise.

The builder's address for one document, or for making a new one when id is nil.

The builder's address for one document, opened at one of its review notes.

Functions

back_path(section, return_to)

@spec back_path(String.t(), String.t() | nil) :: String.t()

Where the builder's back link goes: return_to when it names another builder, the section's list otherwise.

THE ADDRESS IS SOMETHING A URL SUPPLIED, so it is matched on the builder's own prefix rather than trusted. That prefix starts with a single /, which is what rules out //elsewhere.example and https://elsewhere.example — a back link that could be pointed off-site is an open redirect with the admin's session behind it.

builder_path(section, id \\ nil, status \\ nil)

@spec builder_path(
  String.t() | atom(),
  String.t() | nil,
  MishkaCmsCore.Runtime.ErrorStatus.t() | nil
) ::
  String.t()

The builder's address for one document, or for making a new one when id is nil.

status names the error-page entry being edited. Without it an error page reopens on its 404 entry, which is not the one the author left.

THE ONE SPELLING. back_path/2 honours an address by this prefix, so an address written out by hand somewhere else is one the two could disagree about.

note_path(section, id, note_id)

@spec note_path(String.t() | atom(), String.t(), String.t()) :: String.t()

The builder's address for one document, opened at one of its review notes.

The editor reads ?note= on its connected mount: the Review sheet opens, the element the note is about is selected and the note is marked. A note that is gone by the time the address is followed opens the document as builder_path/2 would.