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

missing mention of a jquery dependency #19

Closed
Pomax opened this issue Mar 6, 2014 · 9 comments
Closed

missing mention of a jquery dependency #19

Pomax opened this issue Mar 6, 2014 · 9 comments

Comments

@Pomax
Copy link

Pomax commented Mar 6, 2014

the readme does not mention needing jquery (hurray!) but then the code complains jquery isn't available (boo!). Loading jquery before octokits still says "jquery not loaded" despite the jQuery variable very much existing in global scope.

@philschatz
Copy link
Owner

Oops, you're right; jQuery (or zepto/src/ajax.js) is extremely heavyweight for this library; I've been meaning to replace it with XMLHTTPRequest directly.

I can remove the jQuery not loaded message (but still use jQuery) in a few hours and then remove jQuery maybe this weekend; would that work?

@Pomax
Copy link
Author

Pomax commented Mar 6, 2014

that sounds great!

@philschatz
Copy link
Owner

hmm, the unit tests in test/index.html load jQuery 1.8+ using just a <script> tag.

Are you using the <script async> attribute? That could explain why jQuery is not available when octokit looks for it but is available later (and another reason to refactor using XMLHTTPRequest directly).

I was reading through gh-blog and in case you're interested:

This library was created to "Make Textbooks using only GitHub". I've got a blog post about it at http://philschatz.com/2013/06/03/github-bookeditor/ with links to demos and more recent work is being done by http://kefletcher.blogspot.com (screenshots and such).

@Pomax
Copy link
Author

Pomax commented Mar 6, 2014

hm, I had forgotten the loader doesn't force sync. good point. Also: yeah, I love the idea of gh-pages for ebook hosting, and bonus points for writing the github handler!

@Pomax
Copy link
Author

Pomax commented Mar 6, 2014

with forced sync loading octokit.js seems to work, but I get a 422 error when trying to actually remove files in a branch. Initially I kept getting a Refused to set unsafe header "User-Agent" error in jQuery, but removing that header leads to:

var gh = new Octokit({
  username: "Pomax",
  password: "my github password"
});
var repo = gh.getRepo("Pomax", "pomax.github.io")
var branch = repo.getBranch("master")
branch.remove("gh-weblog/content/2013-10-31-11-26-36.json", "no longer required");

yielding

POST https://api.github.com/repos/Pomax/pomax.github.io/git/trees 422 (Unprocessable Entity) 

examining the network tab, the full response is

{
  "message": "Must supply tree.sha or tree.content",
  "documentation_url": "http://developer.github.com/v3/git/trees/#create-a-tree"
}

(I kept getting this error on the github.js that you forked from, too... is this a new thing in the API v3 that requires a code update?)

@philschatz
Copy link
Owner

Thanks for the detailed description!

GitHub v3 requires you to pass in the sha of the file you plan to remove. #20 allows an optional sha (so you don't accidentally goof up and remove a file that was changed in the meantime) but defaults to the latest sha.

Try it out and I'll probably merge #20 and bump the version tomorrow ; )

@Pomax
Copy link
Author

Pomax commented Mar 7, 2014

#20 works a treat!

@Pomax
Copy link
Author

Pomax commented Mar 7, 2014

hm, getting some GET https://api.github.com/repos/Pomax/gh-blog/git/refs/heads/undefined 404 (Not Found) but that might be me trying to massage my own code to work with octokits.js as interface rather than what it was using before

@philschatz
Copy link
Owner

I think this unfortunate "bug" was fixed in c1cad56. I created #29 for explicitly removing jQuery as a dependency.

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

No branches or pull requests

2 participants