Skip to content
Snippets Groups Projects

Allow different recipes to be called via the INK component

Merged Alf Eaton requested to merge ink-backend-recipe-parameter into master

The existing INK components (frontend and backend) were built to handle conversion of DOCX files to HTML; this change allows any INK recipe to be called in the same way.

  • Adds a "recipe" parameter (fixes #54)
  • Adds an "outputFile" parameter (so the backend knows which file to download at the end of the process)
  • Refactor to improve promise handling

The changes to the backend component are backwards-compatible (tested in Editoria) - finding the recipe id works as follows:

  1. Read the "recipe" parameter.
  2. If there's a matching key (e.g. 'editoria-typescript') in config['pubsweet-component-ink-backend']['recipes'] use that value as the recipe ID. This is the ideal situation, where the app configuration maps keys used in the frontend to recipe IDs in the configured INK instance.
  3. If there's no key, use "Editoria Typescript" as the default (for backwards compatibility). Fetch the list of recipes from the INK API and find the recipe with title that matches this key (this is how it used to work, but is inefficient as it has to fetch and filter that list for every conversion).
Edited by Alf Eaton

Merge request reports

Pipeline #3186 passed

Pipeline passed for bfba4946 on ink-backend-recipe-parameter

Test coverage 84.71% (0.00%) from 1 job

Merged by JureJure 7 years ago (Dec 4, 2017 11:30am UTC)

Loading

Pipeline #3239 passed

Pipeline passed for a0176b98 on master

Test coverage 84.92% (0.00%) from 1 job

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Alf Eaton added 46 commits

    added 46 commits

    Compare with previous version

  • Alf Eaton changed the description

    changed the description

  • :thumbsup: Two thumbs up on the backwards compatible implementation. :thumbsup:

  • Yannis Barlas assigned to @jure

    assigned to @jure

  • Alf Eaton added 3 commits

    added 3 commits

    Compare with previous version

  • Cool, this looks good! Authorization happening on app boot up in particular, was an issue for several users of the component. Now it's happening on request, which makes a lot more sense :thumbsup:

    I had to look twice at !113 (diffs) as it uses options.recipe twice, but then it made sense. Containing a map of recipeKey to recipeId in the config makes sense, since it's human readable then. One source of confusion though might be, that the user configures options.recipe to be 'editoria-typescript', and the options.recipes map points to say id 7. To the user that all seems OK, but the options.recipe is of course not linked in any way to how INK itself is configured, so its id might be e.g. 12. So, what I'm saying is, that using options.recipe without options.recipes is more intuitive, but worse in a performance sense. Not really something that can be addressed in this MR, but we should add config docs in a separate MR.

    LGTM :thumbsup:

  • merged

  • Jure mentioned in commit a0176b98

    mentioned in commit a0176b98

  • This will be a patch release, due to the backwards compatibility. Thanks @alf!

  • Author Contributor

    Agreed, keeping the recipe mapping backwards-compatible makes it a bit confusing - we can probably simplify later (maybe allowing INK recipes to choose a non-numeric ID, or having separate pubsweet-server API endpoints for each recipe, or something else…).

  • Successfully published: pubsweet-component-ink-backend@0.1.1 pubsweet-component-ink-frontend@0.2.3

Please register or sign in to reply