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

Adds load-from-repo functionality to gist services and new embed #1295

Merged
merged 8 commits into from
Oct 2, 2019

Conversation

RedBrogdon
Copy link
Contributor

Changes:

  • Updates the new embed to look for four new params in its query string: gh_repo, gh_owner, gh_path, and an optional gh_ref.
  • Adds a loadGistFromRepo to GistLoader for loading exercises directly from a GitHub repo.
  • Removes the old shareAnon methods, since they no longer function.
  • Standardizes gist loading on package:http instead of dart:html requests.
  • Moves GistStorage into its own file
  • Adds tests for GistLoader's new and existing functions.

GistLoader is getting a little big at this point, but is unlikely to grow again in the short term, so I've left it as a single class with three load methods.

I've added a couple new classes to parse the JSON in the metadata file. These could have been done with built_value or json_serializeable. Since the entire file is <100 lines and neither of those packages is in use elsewhere in the project, though, I've chosen to roll my own rather than take on a new dependency and build step.

A field for "exercise mode" (dart, html, flutter) will need to be added to the Gist class. The new playground will also need to examine that field and set its editors up accordingly. This hasn't been done yet, since John is still finishing the new playground.

@RedBrogdon
Copy link
Contributor Author

CC @theacodes for research purposes and drive-by comments.

// ID for a GitHub gist that should be loaded into the editors.
String get gistId {
final id = _getQueryParam('id');
return isLegalGistId(id) ? id : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: why an empty string instead of null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly it's a "that's how it was done in the codebase when I arrived" thing.

lib/sharing/gists.dart Outdated Show resolved Hide resolved
test/sharing/gist_loader_test.dart Show resolved Hide resolved
lib/sharing/exercise_metadata.dart Show resolved Hide resolved
lib/sharing/gists.dart Outdated Show resolved Hide resolved
test/sharing/gist_loader_test.dart Show resolved Hide resolved
Copy link
Contributor

@johnpryan johnpryan left a comment

Choose a reason for hiding this comment

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

comments are mostly nits- would like to consider using YAML instead of JSON for the metadata but otherwise LGTM

@RedBrogdon
Copy link
Contributor Author

PTAL.

@RedBrogdon RedBrogdon merged commit ebb360f into dart-lang:master Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants