Skip to content

Allow loading examples from GitHub #181

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

Closed
wants to merge 2 commits into from

Conversation

hdgarrood
Copy link
Collaborator

Resolves #164. This commit implements loading module content from GitHub simply by taking a github query string parameter, if present, and tacking that string onto the end of https://raw.githubusercontent.com/ in order to fetch a PureScript source file from somewhere on GitHub. So for example try.purescript.org/?github=purescript/trypurescript/master/client/examples/Main.purs would load the file client/examples/Main.purs from the master branch in this repo.

I'm hoping that by doing it this way, we will make it easier not only for us to maintain examples, but also for people writing documentation for other projects to create and maintain examples that they can link to and collaborate on, since collaborating on GitHub is much easier than collaborating on Gists.

This is a bit rough at the moment, and I've only added the main example in here, which is why I've marked the pull request as draft. I think at least the following needs to happen before this is mergeable:

  • Add handling like we have for gists to allow linking to a github file from within the iframe
  • Move the rest of the examples into client/examples

but before I go ahead and do that I'd like to just check that the approach seems reasonable.

@hdgarrood
Copy link
Collaborator Author

I've verified that this works locally by replacing the mainGithubExample in Try.Config with this:

mainGithubExample :: String
mainGithubExample = "hdgarrood/trypurescript/load-from-github/client/examples/Main.purs"

@JordanMartinez
Copy link
Contributor

Nice!

@natefaubion
Copy link
Contributor

I don't have a solution for this, and maybe I'm just not thinking about it enough, but is it possible to have both content and examples in the same repo, linking to runnable examples from the content and still have both part of a single tag? I know that sounds a little convoluted, but is there a way to use this without always linking to a fixed branch (be it master, or examples, or whatever)?

@natefaubion
Copy link
Contributor

One solution is if you have a publication system, it could potentially rewrite links.

@hdgarrood
Copy link
Collaborator Author

hdgarrood commented Jun 3, 2020

I'm not sure I follow. Eventually you'll always have to specify a branch or a tag, right? Are you thinking that it might be awkward to work on documentation guides in other repositories with this design because you might want to point to a tag that doesn't exist yet?

@thomashoneyman
Copy link
Member

Closed in #218

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.

Move example gists into the repo
4 participants