Hello Peter, I've added an enhanced version of your implementation for citable URLS in the tool shed to change set revision 8720:e27d0dd12752. This is currently running on the test tool shed, and viewing repositories now displays a link like this: I've used the same routes you set up, so both of the following work: http://testtoolshed.g2.bx.psu.edu/view/peterjc/mira_assembler http://testtoolshed.g2.bx.psu.edu/view/peterjc/ i was under a rush to get this in before the next release cutoff. There is still some work to do on this (e.g., we can add additions routes for citing a specific repository revision, etc) but this should be a good start and it will be in the next Galaxy release currently scheduled for next week. Thanks very much for your contribution on this and please let me know if you encounter any issues or have any additional suggestions. Greg Von Kuster On Jan 31, 2013, at 11:49 AM, Peter Cock wrote:
On Tue, Jan 29, 2013 at 4:44 PM, Peter Cock <p.j.a.cock@googlemail.com> wrote:
I do have some progress to report :)
I could get http://example.org/repositoties/owner/name to work, but http://example.org/repositoties/owner would conflict with the other URLs used as actions by the repository controller. Perhaps there is an elegant solution in the routing? For now, I am using http://example.org/view/owner/name and http://example.org/view/owner instead.
I haven't worked out how to show a full frame set, rather than just the content frame - but the following is close to what I want to do. Also, I'm using a redirect (rather than staying at the citable URL) as some of the URLs in the displayed page.
Peter
$ hg diff diff -r 04e221996871 lib/galaxy/webapps/community/buildapp.py --- a/lib/galaxy/webapps/community/buildapp.py Wed Jan 30 16:47:20 2013 -0500 +++ b/lib/galaxy/webapps/community/buildapp.py Thu Jan 31 16:42:52 2013 +0000 @@ -63,6 +63,8 @@ # Create the universe WSGI application webapp = CommunityWebApplication( app, session_cookie='galaxycommunitysession', name="community" ) add_ui_controllers( webapp, app ) + webapp.add_route( '/view/{owner}/', controller='repository', action='citable_owner' ) + webapp.add_route( '/view/{owner}/{name}/', controller='repository', action='citable_repository' ) webapp.add_route( '/:controller/:action', action='index' ) webapp.add_route( '/:action', controller='repository', action='index' ) webapp.add_route( '/repos/*path_info', controller='hg', action='handle_request', path_info='/' ) diff -r 04e221996871 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py Wed Jan 30 16:47:20 2013 -0500 +++ b/lib/galaxy/webapps/community/controllers/repository.py Thu Jan 31 16:42:52 2013 +0000 @@ -688,6 +688,60 @@
id=trans.security.encode_id( repository.id ),
changeset_revision=v ) ) return self.repository_grid( trans, **kwd ) + + @web.expose + def citable_owner( self, trans, owner): + """Support for citeable URL for each contributor's tools, e.g. http://example.org/view/owner""" + try: + user = suc.get_user_by_username( trans, owner ) + except: + user = None + if user is None: + #Would a specific 404 error page be better? + message = "Unknown repository owner %s" % owner + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_categories', + id=None, + name=None, + owner=None, + message=message, + status='error' ) ) + #TODO - Ideally this would load the frameset, not just the frame! + #TODO - Remove the redirect (assuming the links on the page OK) + id = trans.security.encode_id( user.id ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_repositories', + operation="repositories_by_user", + user_id=id) ) + + @web.expose + def citable_repository( self, trans, owner, name): + """Support for citeable URL for each tool, e.g. http://example.org/view/owner/name""" + try: + repository = suc.get_repository_by_name_and_owner( trans, name, owner ) + except: + repository = None + if repository is None: + #TODO - If the owner is OK, show their repositories? + #Would a specific 404 error page be better? + message = "Unknown repository %s/%s" % (owner, name) + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_categories', + id=None, + name=None, + owner=None, + message=message, + status='error' ) ) + #Good, found the repository + id = trans.security.encode_id( repository.id ) + #TODO - Ideally this would load the frameset, not just the frame! + #TODO - Remove the redirect (assuming the links on the page OK) + #return self.view_repository(trans, id) + return trans.response.send_redirect( web.url_for( controller='repository', + action='view_repository', + id=id) ) + + @web.expose def browse_repository( self, trans, id, **kwd ): params = util.Params( kwd ) ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at: