-
Notifications
You must be signed in to change notification settings - Fork 475
Solution for Exercises: Gists, jsFiddles #30
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
Conversation
but basic idea is here
also make sure to provide gh config holder during gists generation
|
Thanks so much for your work on this so far (and the pull request), Mickael. @ajpiano, I think it would be useful to have you review this before it gets merged just so we can tweak any changes needed beforehand. |
|
Thanks guys - I'll be looking this over like, right now. |
fiddles/bin/fiddles
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be http://stage.learn.jquery.com while we're in a staging only mode, and then changed to the proper http://learn.jquery.com when we're ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the configuration needs some more love. I'm thinking about using a real opt parser, and possibly the option of prompting users at the beginning of the script (to override default values). That way, the host value may be easily changed either through command line usage, or when prompted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely add a normal opt parser, it's not really clear to me how to pass the options to it as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
So first off, this is incredible -- really great work so far. A couple of things I'm noticing as I review it this and try to get it going
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a lot easier to just pull this code out of the exercise templates themselves than stripping it out here? Unless we're aiming for the 'exercises' to work properlywhen the repository is cloned...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it could probably be done that way. Like you mentioned, letting the fiddle tool handle this allows one to get the exercises that work when the repo is cloned, or when an exercise is downloaded (thanks to the download archive you also mentioned).
|
Thanks for the review, Adam! On the second point, the idea was for us to allow visitors to see all of the code needed for a particular exercise in-page without needing to rely on jsFiddle's embed features - as you know the site's reliability has been sketchy lately which is why we wanted to still let them view code samples using a reliable source (GitHub - includes version history for updates, easy to fork) but also offer the fiddle link. If I've misinterpreted your concern, let me know!. |
|
Totally hear you on the jsFiddle reliability stuff - unfortunately with the gists, the pages get LOOOOOOOOONNGGGG really quickly, and most of that is noise like uncompressed CSS and the instructions duplicated inside of the gist. That's why I was saying we could just embed the fiddle and provide links, but not embedded gists. We could also investigate actually hosting the built example and solution files on the site, or as a download, as another backup, or for people who want to actually do the work outside of jsfiddle. If we aren't planning to have the source from Are we planning to do this same process for the solutions as well? Would seem to be nice...? |
|
I think it would make sense to have the same process in place for the solutions. If we don't end up opting for embedded gists, having something like hosted examples/solutions or another backup that tied to this overall process could definitely be helpful. Was there a preference here for how that might be done or what form it might take? Again, just thinking of the people that might land on a page, click a fiddle link and give up if it times out or anything like that. |
|
Seems to me like the preferable thing to have would be the link to the fiddle and a link to download that entire exercise in an archive? I imagine something like that could be built into the nanoc preprocess. |
|
Thanks Adam for the review!
I totally agree, actually it's something that I should have mentioned in the pull request description. Instead of embedding all the gist's files, we may add a <script src="https://gist.github.com/7de1f9aab65218225f04.js?file=fiddle.js"></script>At first I didn't see that option, but using this may reduce all the noise that the pages are getting.
Sounds like a reasonable options too. For the download archive, maybe we could rely on the download feature for gists (eg. https://gist.github.com/gists/7de1f9aab65218225f04/download). That way, the script could add the corresponding links.
I'm not sure this is the ideal implementation, but I've added some code to handle solutions as well (see here or here). Basically, I'm switching the path depending on the solution mode, looking in Basically, I change the path to lookup the js file depending on the solution mode, looking in solutions/ instead of exercises/ dir. Though, you may want to edit the way it's done to handle both sources at once. Right now, it is quite exclusive. I'll add a few notes and commits related to your other comments. |
|
For the images part:
First implementation did use inline base64 img to do this, but it was removed in favor of this host/assets mechanism from config (due to the fact that we ideally want it to work cross-browser). It may require some repo restructure, either by making the img used in exercises available in the static content or other option. Though, in this first version of this fiddle tool, I really wanted it to work as is, without any modifications from your part. |
|
@mklabs has made further updates to the original PR related to how we handle images. From my perspective the above looks fine to merge, but it would be great to know if you had further thoughts about our approach to this PR as a whole or were mostly happy with the direction it was going. We can tweak it further if needed. |
|
A bunch is changing in terms of how the contents of this repo will be making it online (the content is being shoved into wordpress, after being processed by nanoc), so i've been holding off on merging this in until that piece of the puzzle is in place. I'm definitely mostly happy with the direction, and I'll be working on mixing this in to the rest of the build process before we merge it. |
|
Feel free to ping me whenever you need some support with this, or if it needs further work (I'm sure it does). november-december is a super busy period for me, so it is a bit difficult for me at the moment. Hopefully, that will soon change. Anyway, if the content changes, the script will most likely need some adjustments. That's perfectly fine, if it needs to, I'll be happy to make the necessary changes or help doing so. |
|
For historic reference, we initially discussed the exercise handling in #27. I'm closing that issue as the work here supersedes it. |
|
@ajpiano given there was a relatively non-trivial amount of work done for this PR do we want to try getting it in? I know earlier in the year there were still a lot of moving parts to the project infrastructure wise. Have those settled down? :) |
|
My gut instinct here is that this actually makes sense to be adapted into a grunt task, as now everything is being handled by grunt-wordpress and friends. Then the hard work would actually be able to be leveraged by a lot more projects than just the learn site! |
|
Absolutely! That sounds like a very sensible idea. Given @mklabs experience Ps: Do we have any ideas about site launch timelines just yet? :) I know On Jun 30, 2012 4:26 PM, "adam j. sontag" <
Addy Osmani Developer Programs Engineer at Google |
|
@ajpiano Just pinging to find out what the current status on the site architecture is. Would sometime in the next few weeks be realistic for us to look at a grunt task capturing the word in this issue? |
|
Hate to be a party pooper, but after the long silence on this issue, I think we're not going to be including interactive exercises as part of the learn.jquery.com project (we discussd this today more at the summit) - we have an exciting project in the works for interactive examples as part of a course, and I think that will supersede this in terms of the jQuery network. However, I think there's still a lot of value in the fundamental idea of a grunt task that takes structured files and and creates the proper gists for consumption by jsfiddle. Thanks for all your hard work here @mklabs, and sorry that this didn't quite end up working out as we'd hoped for now. |
|
@ajpiano no worries! happy to help whenever I can, not a big deal it doesn't end up into something actually used. Was fun to experiment on the idea. |
Hello there,
So here is a pull request asking you to review and merge the work @addyosmani and I have done the last few weeks into trying to find a simple mechanism to handle exercises, relying on gists to both have fiddles and embed snippets of code.
This is a little node package exposing a basic cli tool to parse/generate/update repository files, intended to be used right after a
nanoc compile.I've included in the pull request a readme with more informations on what this "build script" is trying to do.
In a nutshell:
content/folder, looking for any files ending withexercises.md.Use the fileandOpen the filepatterns. They're usually employed to know to which files the exercises are related, to then generate the fiddles folder.*-exercises.mdpage may include a few) the corresponding jsfiddle ready folder. Withfiddle.jsmatching theUse the file <path>andfiddle.htmlmatching theOpen the file <path>.fiddle.cssis always the same (guessed from the relative path found in html).fiddle.details.config.gistsis set to true, the script then uses ngist to create a new private gist based ongit config --get github.userandgit config --get github.tokenvalues.output/that were generated by a previousnanoc compilebuild, with the according jsfiddle link and the gists created as embed code.Note that I've also included in this pull request a slight modification of the Rakefile. I've added a new rake task to generate the website with fiddles integration (which is simply running
nanoc compile && cd fiddles && npm install && ./bin/fiddles).There is some edge case, and things I'd like to see improved. I'll probably do another pull request to address some of these issues:
I wanted to paste here the command line result of running the script, but this pull request description is getting really verbose :) (and it's included in
fiddles/readme.mdanyway).Cheers,