Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359080

Summary: Click to clone from external site
Product: [ECD] Orion Reporter: John Arthorne <john.arthorne>
Component: GitAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: simon_kaegi, susan, Szymon.Brandys
Version: unspecified   
Target Milestone: 0.4 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 358769, 363977    
Bug Blocks:    
Attachments:
Description Flags
A script for git.eclipse.org none

Description John Arthorne CLA 2011-09-27 10:35:11 EDT
It would be useful if we could provide a URL that could be embedded into another web site that will initiate cloning a particular repository in OrionHub. This is very similar to Boris' work to install a plugin from external site with a click. 

I suggest a URL that would open orionhub.org to the repositories page, with the clone dialog already opened and populated with the URL of the repository to be cloned. It wouldn't actually start the clone operation. In case it is a malicious link the user should be able to control whether the clone operation starts or not. Just throwing out a possible syntax:

http://orionhub.org/git/git-clone.html?cloneurl=<repoURL>

Since we've already done this once before, we should think about whether there is any common infrastructure to put in place to simplify such workflows. Bug 358769 is capturing a more general description of this problem.
Comment 1 Susan McCourt CLA 2011-11-16 14:05:16 EST
I've released a first cut of the command changes in
cd996e841b80a02bee205c727e4f4e671e68514d
(Gosia, it was simpler for me to evolve the framework while doing the git client side than try to guess what was needed.  I'll start documenting how some of this works in bug 358769.  Things are still immature/very specific to the few scenarios that I've implemented.)

You can now use a URL like this to trigger a clone:
http://127.0.0.2:8080/git/git-clone.html#/workspace/A?cloneGitRepository=someURL

You'll get the parameter slideout with the URL filled in, and a "More" button that will let you invoke the dialog if you want to use the advanced options.

We can evolve the URL syntax in bug 358769, and if you don't like the command name "cloneGitRepository" it can be changed in the URL binding in git-clones.js

To finish this green thread, someone needs to figure out where this link would appear.  The scenario is usually a bugzilla link/greasemonkey script which figures out the repo URL based on the bug product and component.

Leaving this bug open as I'm not sure if it represents the entire green thread or just the client/command side.
Comment 2 Tomasz Zarna CLA 2011-11-21 09:01:19 EST
(In reply to comment #1)
> To finish this green thread, someone needs to figure out where this link would
> appear.  The scenario is usually a bugzilla link/greasemonkey script which
> figures out the repo URL based on the bug product and component.

I can prepare a greasemonkey script for GitHub if nobody else is working on this.
Comment 3 Malgorzata Janczarska CLA 2011-11-21 09:25:16 EST
(In reply to comment #2)
> (In reply to comment #1)
> > To finish this green thread, someone needs to figure out where this link would
> > appear.  The scenario is usually a bugzilla link/greasemonkey script which
> > figures out the repo URL based on the bug product and component.
> 
> I can prepare a greasemonkey script for GitHub if nobody else is working on
> this.

Be my guest if you have time. You can take over this bug if you want.
Comment 4 John Arthorne CLA 2011-11-21 12:05:47 EST
Bug 363977 really needs to be resolved first so we actually know what the URL looks like in the general case for a random user. But if you want to do a Greasemonkey script for GitHub (and maybe git.eclipse.org web UI) that would also be useful. Once we know the URL syntax we can also start using it immediately in documentation, wiki, blogs, etc.
Comment 5 Szymon Brandys CLA 2011-11-21 12:46:37 EST
(In reply to comment #4)
> Bug 363977 really needs to be resolved first
Tomek, if you have some free cycles, could you help with the mentioned bug first?
Comment 6 Tomasz Zarna CLA 2011-11-30 07:53:24 EST
Created attachment 207716 [details]
A script for git.eclipse.org

A rough version of a Greasemonkey script for http://git.eclipse.org/c/*. I haven't added any null checks yet.

What would you say if I added a new project under org.eclipse.orion.client\bundles called org.eclipse.orion.client.git.greasemonkey? I would keep scripts like this there, grouped by target site name eg. git.eclipse.org/cloneIntoOrion.user.js and github.com/cloneIntoOrion.user.js.

I'm planning to add "am I on the right page?"  checks and a way to provide Orion's location. For now, it's hard-coded 'localhost'.
Comment 7 Tomasz Zarna CLA 2011-11-30 09:29:18 EST
(In reply to comment #6)
> What would you say if I added a new project under org.eclipse.orion.client\bundles [...]?

Having it in the Orion repo, rather then keep it at userscripts.org, would make it easier to edit these scripts with Orion's editor in the future. Speaking of the latter, I think it's another place where a script for "Edit in Orion" could be added.

Also, when done, I was planing to update the landing page with info about these scripts.
Comment 8 Susan McCourt CLA 2011-11-30 12:01:28 EST
+1 for keeping these scripts around in Orion's git repo.

> What would you say if I added a new project under
> org.eclipse.orion.client\bundles called
> org.eclipse.orion.client.git.greasemonkey? I would keep scripts like this
> there, grouped by target site name eg. git.eclipse.org/cloneIntoOrion.user.js
> and github.com/cloneIntoOrion.user.js.

I wonder if we should instead have org.eclipse.orion.client/bundles/org.eclipse.orion.client.greasemonkey

(no git)

Because we might have other greasemonkey scripts for non-git actions, and I don't see having separate bundles for each?  Just a thought...

I cc'ed Simon since he has worked on the bundle structure/naming in the past and might have an opinion here...
Comment 9 Tomasz Zarna CLA 2011-11-30 12:08:19 EST
Oops, I've already pushed rough cuts of these scripts as c15686020fd305f3f1767a2bb3b5c42502f80e7a. I'm fine with moving them to a different location though.

For the github.com script I included a getElementsByClassName method developed by Robert Nyman[1]. I'm not sure if this is something I should create a CQ for as the script is still unsettled.

[1] http://code.google.com/p/getelementsbyclassname/
Comment 10 John Arthorne CLA 2011-11-30 13:30:47 EST
(In reply to comment #9)
> For the github.com script I included a getElementsByClassName method developed
> by Robert Nyman[1]. I'm not sure if this is something I should create a CQ for
> as the script is still unsettled.
> 
> [1] http://code.google.com/p/getelementsbyclassname/

This doesn't seem worth the hassle of an external dependency. I believe document.getElementsByClassName is supported on all the browsers we care about so it's easier to just do it yourself. We may not end up distributing this particular script in our releases so it might not be a big deal, but we just avoid dragging in new dependencies unless they add real value for us.
Comment 11 Tomasz Zarna CLA 2011-12-01 05:09:04 EST
(In reply to comment #10)
> This doesn't seem worth the hassle of an external dependency. I believe
> document.getElementsByClassName is supported on all the browsers we care about

Got rid of the Robert's script and added safety checks in 47862ed52942cd2bc25c306059d79223e60db045. You are still limited to clone into Orion running on localhost only, but I'm planing to work this out. If you don't mind that and you're on Chrome, installing scripts is as easy as visiting these pages:

* http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/plain/bundles/org.eclipse.orion.client.git.greasemonkey/bugs.eclipse.org/cloneIntoOrion.user.js
* http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/plain/bundles/org.eclipse.orion.client.git.greasemonkey/git.eclipse.org/cloneIntoOrion.user.js
* http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/plain/bundles/org.eclipse.orion.client.git.greasemonkey/github.com/cloneIntoOrion.user.js
Comment 12 Tomasz Zarna CLA 2012-01-27 07:54:53 EST
Updated the scripts to work with orion.eclipse.org. I also made the button for Github look more friendly. See 4596b029cee400115784d76bc399faa3103c2013

Marking this one as resolved. As soon as we fix issues with the new repo page mentioned in bug 363977, comment 12 I will update the scripts so they point to the new page.
Comment 13 Szymon Brandys CLA 2012-01-27 08:40:35 EST
New repo page is updated to support command bindings now.
Comment 14 Szymon Brandys CLA 2012-01-27 09:02:06 EST
(In reply to comment #12)
> Updated the scripts to work with orion.eclipse.org. 

I would use Orion on http://orionhub.org/ which will be updated to .4M2. Otherwise the scripts will be useful just for the Orion dev team.
Comment 15 John Arthorne CLA 2012-01-30 16:01:20 EST
I agree the scripts should use orionhub.org so they are interesting beyond the team.

Also, I installed all three scripts and I can't find any link added on github.com or bugzilla. I'm probably just missing it, so can you describe where it adds the link?
Comment 16 Tomasz Zarna CLA 2012-01-31 10:36:35 EST
(In reply to comment #15)
> I agree the scripts should use orionhub.org so they are interesting beyond the
> team.

Will do that once we ship 0.4M2 on orionhub.org

> Also, I installed all three scripts and I can't find any link added on
> github.com or bugzilla. I'm probably just missing it, so can you describe where
> it adds the link?

Created a wiki page http://wiki.eclipse.org/Orion/Documentation/User_Guide/Reference/Greasemonkey_scripts with install steps and screenshots. The bugzilla script stopped to work for me as well, see bug 370231.