Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for URL interpolation when setting up panels #156

Merged
merged 6 commits into from
Jan 9, 2024

Conversation

szschaler
Copy link
Contributor

@szschaler szschaler commented Jan 5, 2024

This PR adds support for interpolation in panel URLs in the activity specification.

This is useful to allow dependent activities to access information from other activities. The concrete motivating example was the generation of Xtext editors, where I may wish to allow students to access the meta-model generated by Xtext in the activity where they can try out their new language. The URL to that file is generated by the platform (specifically, the xtext tool) and so isn't known at the time when the activity specification file is written.

With this PR, I can now write something like:

{
  "id": "panel-mm",
  "name": "The meta-model generated by Xtext",
  "ref": "ecore",
  "file": "{{ID-panel-turtles}}/xtext-resources/generated/meta-model.ecore"
},

and have {{ID-panel-turtles}} replaced from session storage associated with the panel-turtles panel at runtime. For generated editors, the platform stores the editor URL in that session storage key.

This is a somewhat pragmatic change, which could be made more powerful, but for now I suggest we keep things simple. We may need to invest in a more systematic architecture should there be a need for more flexibility at any point down the line.

The change consists of two separate changes:

  1. Changing ActivityManager.js to perform the URL interpolation, and
  2. Changing FileHandler.js to gracefully manage unknown types of URLs even for private repositories.

The latter change isn't strictly related to URL interpolation, but is required so that the generated URL can actually be used by the platform even when the activity lives in a private repository. To make this compatible with how file saving is managed, I have also adjusted the code for canSave in various panel types to ensure we only attempt to save a panel when it actually has an associated SHA and, thus, we know that it came from the original repository. This may make it difficult for the platform to save back to public repositories.

@szschaler szschaler self-assigned this Jan 5, 2024
@szschaler szschaler added the enhancement New feature or request label Jan 5, 2024
@szschaler
Copy link
Contributor Author

Documentation on the Wiki still needs updating when this PR is merged.

@szschaler szschaler marked this pull request as ready for review January 5, 2024 15:56
Copy link
Collaborator

@barnettwilliam barnettwilliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, just the question on syntax overlap with bash.

Copy link
Collaborator

@barnettwilliam barnettwilliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@szschaler szschaler merged commit 0c5e816 into main Jan 9, 2024
2 checks passed
@szschaler szschaler deleted the feature/url-interpolation branch January 9, 2024 08:56
barnettwilliam added a commit to mdenet/educationplatform-docker that referenced this pull request Jan 9, 2024
…anel url interpolation, and mdenet/platformtools#32 switch to Epsilon micronaught.

Fix for mdenet/platformtools#27 highlighting does not work in generated editor,
barnettwilliam added a commit to mdenet/educationplatform-docker that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants