Skip to content

Add an options field for the filename template #49

Description

@jamditis

#47 added the filenameTemplate setting and reads it in both download paths, but the options page has no field for it, so it is storage-only and unreachable in practice.

Why it was not in that PR

options.js is loaded as a plain script (<script src="options.js">), so it cannot import validateTemplate from platforms/common.js. Reusing the validator needs the options page converted to type="module".

The alternative — reimplementing validation inline in a non-module script — would recreate exactly the drift #47 removed. The validator in that PR had a bug precisely because it re-derived a rule the renderer already owned, and the fix was to make it call the renderer instead. Writing a third copy in the options page would be the same mistake with a wider gap between the copies.

Scope

  • Convert options.html to load options.js as a module.
  • Add a text input beside the existing folder field, with the token list in the description. The folder field already documents {platform}; both settings now share one vocabulary, so document them together.
  • Validate on input with validateTemplate(value) for the filename and validateTemplate(value, { allowSlash: true }) for the folder, showing reason inline. The reasons are written to be read by a user, including the case-sensitivity hint and the pointer from "no slashes in a filename" to the folder setting.
  • Extend the existing live preview to render the filename too, so the effect is visible before saving. renderTemplate against a sample field bag is what the preview should call — the same reason as above.
  • Refuse to save an invalid template rather than storing it and failing quietly at download time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions