commit/galaxy-central: greg: Add an enhanced version of the cirable URLs for tool shed repositories contributed by Peter Cock.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e27d0dd12752/ changeset: e27d0dd12752 user: greg date: 2013-02-01 22:13:15 summary: Add an enhanced version of the cirable URLs for tool shed repositories contributed by Peter Cock. affected #: 7 files diff -r 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -935,6 +935,11 @@ for repository_components_list in val: tool_shed, name, owner, changeset_revision = repository_components_list repository = get_or_create_tool_shed_repository( trans, tool_shed, name, owner, changeset_revision ) +def generate_citable_link_for_repository_in_tool_shed( trans, repository ): + """Generate the URL for citing a repository that is in the tool shed.""" + base_url = url_for( '/', qualified=True ).rstrip( '/' ) + protocol, base = base_url.split( '://' ) + return '%s://%s/view/%s/%s' % ( protocol, base, repository.user.username, repository.name ) def generate_clone_url_for_installed_repository( app, repository ): """Generate the URL for cloning a repository that has been installed into a Galaxy instance.""" tool_shed_url = get_url_from_repository_tool_shed( app, repository ) @@ -1839,6 +1844,13 @@ elif len( repo_info_tuple ) == 7: description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies = repo_info_tuple return description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies +def get_repository_by_id( app, id ): + """Get a repository from the database via id.""" + sa_session = app.model.context.current + if app.name == 'galaxy': + return sa_session.query( app.model.ToolShedRepository ).get( id ) + else: + return sa_session.query( app.model.Repository ).get( id ) def get_repository_by_name( app, name ): """Get a repository from the database via name.""" sa_session = app.model.context.current diff -r 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 lib/galaxy/webapps/community/buildapp.py --- a/lib/galaxy/webapps/community/buildapp.py +++ b/lib/galaxy/webapps/community/buildapp.py @@ -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 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -893,6 +893,47 @@ url += '&latest_ctx_rev=%s' % str( update_to_ctx.rev() ) return trans.response.send_redirect( url ) @web.expose + def citable_owner( self, trans, owner ): + """Support for citeable URL for each repository owner's tools, e.g. http://example.org/view/owner.""" + try: + user = suc.get_user_by_username( trans, owner ) + except: + user = None + if user: + user_id = trans.security.encode_id( user.id ) + return trans.fill_template( "/webapps/community/citable_repository.mako", + user_id=user_id ) + else: + message = "No repositories exist with owner <b>%s</b>." % str( owner ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_categories', + id=None, + name=None, + owner=None, + message=message, + status='error' ) ) + @web.expose + def citable_repository( self, trans, owner, name ): + """Support for citeable URL for each repository, e.g. http://example.org/view/owner/name.""" + try: + repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) + except: + repository = None + if repository: + repository_id = trans.security.encode_id( repository.id ) + return trans.fill_template( "/webapps/community/citable_repository.mako", + repository_id=repository_id ) + else: + #TODO - If the owner is OK, show their repositories? + message = "No repositories named <b>%s</b> with owner <b>%s</b> exist." % ( str( name ), str( owner ) ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_categories', + id=None, + name=None, + owner=None, + message=message, + status='error' ) ) + @web.expose def contact_owner( self, trans, id, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) @@ -2551,6 +2592,17 @@ message=message, status=status ) @web.expose + def view_citable_repositories_by_owner( self, trans, user_id, **kwd ): + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_repositories', + operation="repositories_by_user", + user_id=user_id ) ) + @web.expose + def view_citable_repository( self, trans, repository_id, **kwd ): + return trans.response.send_redirect( web.url_for( controller='repository', + action='view_repository', + id=repository_id ) ) + @web.expose def view_or_manage_repository( self, trans, **kwd ): repository = suc.get_repository_in_tool_shed( trans, kwd[ 'id' ] ) if trans.user_is_admin() or repository.user == trans.user: diff -r 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 templates/webapps/community/citable_repository.mako --- /dev/null +++ b/templates/webapps/community/citable_repository.mako @@ -0,0 +1,84 @@ +<%inherit file="/webapps/community/base_panels.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +<%def name="stylesheets()"> + ${parent.stylesheets()} + ## Include "base.css" for styling tool menu and forms (details) + ${h.css( "base", "autocomplete_tagging", "tool_menu" )} + + ## But make sure styles for the layout take precedence + ${parent.stylesheets()} + + <style type="text/css"> + body { margin: 0; padding: 0; overflow: hidden; } + #left { + background: #C1C9E5 url(${h.url_for('/static/style/menu_bg.png')}) top repeat-x; + } + </style> +</%def> + +<%def name="javascripts()"> + ${parent.javascripts()} +</%def> + +<%def name="init()"> + <% + self.has_left_panel=True + self.has_right_panel=False + self.active_view="tools" + %> + %if trans.app.config.require_login and not trans.user: + <script type="text/javascript"> + if ( window != top ) { + top.location.href = location.href; + } + </script> + %endif +</%def> + +<%def name="left_panel()"> + <div class="page-container" style="padding: 10px;"> + <div class="toolMenu"> + <div class="toolSectionList"> + <div class="toolSectionPad"></div> + <div class="toolSectionTitle"> + Search + </div> + <div class="toolSectionBody"> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a> + </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a> + </div> + </div> + <div class="toolSectionPad"></div> + <div class="toolSectionTitle"> + All Repositories + </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_categories' )}">Browse by category</a> + </div> + <div class="toolSectionPad"></div> + <div class="toolSectionTitle"> + Available Actions + </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='/user', action='login' )}">Login to create a repository</a> + </div> + </div> + </div> + </div> +</%def> + +<%def name="center_panel()"> + <% + if trans.app.config.require_login and not trans.user: + center_url = h.url_for( controller='user', action='login' ) + elif repository_id: + center_url = h.url_for( controller='repository', action='view_citable_repository', repository_id=repository_id ) + else: + center_url = h.url_for( controller='repository', action='view_citable_repositories_by_owner', user_id=user_id ) + %> + <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url}"></iframe> +</%def> diff -r 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 templates/webapps/community/repository/common.mako --- a/templates/webapps/community/repository/common.mako +++ b/templates/webapps/community/repository/common.mako @@ -163,6 +163,14 @@ </script></%def> +<%def name="render_sharable_str( repository )"> + <% + from galaxy.util.shed_util_common import generate_citable_link_for_repository_in_tool_shed + citable_str = generate_citable_link_for_repository_in_tool_shed( trans, repository ) + %> + ${citable_str} +</%def> + <%def name="render_clone_str( repository )"><% from galaxy.util.shed_util_common import generate_clone_url_for_repository_in_tool_shed diff -r 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 templates/webapps/community/repository/manage_repository.mako --- a/templates/webapps/community/repository/manage_repository.mako +++ b/templates/webapps/community/repository/manage_repository.mako @@ -146,6 +146,10 @@ <div class="toolFormTitle">Repository '${repository.name | h}'</div><div class="toolFormBody"><form name="edit_repository" id="edit_repository" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" > + <div class="form-row"> + <label>Sharable link to this repository:</label> + ${render_sharable_str( repository )} + </div> %if can_download: <div class="form-row"><label>Clone this repository:</label> diff -r 3880939e0186a26f61d4793fafaaf6ab9f45c256 -r e27d0dd127527b613ae77729b8b5b1e2696b09f2 templates/webapps/community/repository/view_repository.mako --- a/templates/webapps/community/repository/view_repository.mako +++ b/templates/webapps/community/repository/view_repository.mako @@ -139,6 +139,10 @@ <div class="toolForm"><div class="toolFormTitle">Repository '${repository.name}'</div><div class="toolFormBody"> + <div class="form-row"> + <label>Sharable link to this repository:</label> + ${render_sharable_str( repository )} + </div> %if can_download: <div class="form-row"><label>Clone this repository:</label> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket