[hg] galaxy 3713: Community: Display tool tarball contents on th...
details: http://www.bx.psu.edu/hg/galaxy/rev/c63fad1c7d3c changeset: 3713:c63fad1c7d3c user: Nate Coraor <nate@bx.psu.edu> date: Wed Apr 28 14:20:24 2010 -0400 description: Community: Display tool tarball contents on the view page and allow streaming contents directly from the tarball diffstat: lib/galaxy/web/framework/base.py | 7 +++ lib/galaxy/webapps/community/controllers/common.py | 3 + lib/galaxy/webapps/community/controllers/tool.py | 16 ++++++- static/images/silk/page_white.png | 0 templates/webapps/community/tool/edit_tool.mako | 42 ++++++++++------- templates/webapps/community/tool/view_tool.mako | 49 ++++++++++++++++++++- 6 files changed, 98 insertions(+), 19 deletions(-) diffs (224 lines): diff -r 811b4794da70 -r c63fad1c7d3c lib/galaxy/web/framework/base.py --- a/lib/galaxy/web/framework/base.py Wed Apr 28 12:47:44 2010 -0400 +++ b/lib/galaxy/web/framework/base.py Wed Apr 28 14:20:24 2010 -0400 @@ -7,6 +7,7 @@ import logging import os.path import sys +import tarfile from Cookie import SimpleCookie @@ -135,6 +136,12 @@ elif isinstance( body, types.FileType ): # Stream the file back to the browser return send_file( start_response, trans, body ) + elif isinstance( body, tarfile.ExFileObject ): + # Stream the tarfile member back to the browser + body = iterate_file( body ) + start_response( trans.response.wsgi_status(), + trans.response.wsgi_headeritems() ) + return body else: start_response( trans.response.wsgi_status(), trans.response.wsgi_headeritems() ) diff -r 811b4794da70 -r c63fad1c7d3c lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py Wed Apr 28 12:47:44 2010 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Wed Apr 28 14:20:24 2010 -0400 @@ -1,3 +1,4 @@ +import tarfile from galaxy.web.base.controller import * #from galaxy.web.controllers.admin import get_user, get_group, get_role from galaxy.webapps.community import model @@ -79,8 +80,10 @@ status='error' ) ) tool = get_tool( trans, id ) categories = [ tca.category for tca in tool.categories ] + tool_file_contents = tarfile.open( tool.file_name, 'r' ).getnames() return trans.fill_template( '/webapps/community/tool/view_tool.mako', tool=tool, + tool_file_contents=tool_file_contents, categories=categories, cntrller=cntrller, message=message, diff -r 811b4794da70 -r c63fad1c7d3c lib/galaxy/webapps/community/controllers/tool.py --- a/lib/galaxy/webapps/community/controllers/tool.py Wed Apr 28 12:47:44 2010 -0400 +++ b/lib/galaxy/webapps/community/controllers/tool.py Wed Apr 28 14:20:24 2010 -0400 @@ -1,4 +1,4 @@ -import sys, os, operator, string, shutil, re, socket, urllib, time, logging, mimetypes +import os, logging, urllib, tarfile from galaxy.web.base.controller import * from galaxy.webapps.community import model @@ -249,3 +249,17 @@ trans.response.headers['Content-Length'] = int( os.stat( tool.file_name ).st_size ) trans.response.headers['Content-Disposition'] = 'attachment; filename=%s' % tool.download_file_name return open( tool.file_name ) + @web.expose + def view_tool_file( self, trans, **kwd ): + params = util.Params( kwd ) + id = params.get( 'id', None ) + if not id: + return trans.response.send_redirect( web.url_for( controller='tool', + action='browse_tools', + message='Select a tool to download', + status='error' ) ) + tool = get_tool( trans, id ) + tool_file_name = urllib.unquote_plus( kwd['file_name'] ) + tool_file = tarfile.open( tool.file_name ).extractfile( tool_file_name ) + trans.response.set_content_type( 'text/plain' ) + return tool_file diff -r 811b4794da70 -r c63fad1c7d3c static/images/silk/page_white.png Binary file static/images/silk/page_white.png has changed diff -r 811b4794da70 -r c63fad1c7d3c templates/webapps/community/tool/edit_tool.mako --- a/templates/webapps/community/tool/edit_tool.mako Wed Apr 28 12:47:44 2010 -0400 +++ b/templates/webapps/community/tool/edit_tool.mako Wed Apr 28 14:20:24 2010 -0400 @@ -45,24 +45,24 @@ <%def name="title()">Edit Tool</%def> -<h2>Edit ${tool.name} <em>${tool.description}</em></h2> +<h2>Edit Tool: ${tool.name} <em>${tool.description}</em></h2> %if message: ${render_msg( message, status )} %endif %if cntrller == 'admin' or ( tool.is_new() and trans.user == tool.user ): - <div class="toolForm"> - <div class="toolFormTitle">${tool.name} - <a id="tool-${tool.id}-popup" class="popup-arrow" style="display: none;">▼</a> - <div popupmenu="tool-${tool.id}-popup"> - <a class="action-button" href="${h.url_for( controller='common', action='view_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">View information</a> - <a class="action-button" href="${h.url_for( controller='common', action='manage_categories', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Manage categories</a> - <a class="action-button" href="${h.url_for( controller='common', action='upload_new_tool_version', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Upload a new version</a> - <a class="action-button" href="${h.url_for( controller='tool', action='download_tool', id=trans.app.security.encode_id( tool.id ) )}">Download tool</a> + <form id="edit_tool" name="edit_tool" action="${h.url_for( controller='common', action='edit_tool' )}" method="post"> + <div class="toolForm"> + <div class="toolFormTitle">${tool.name} + <a id="tool-${tool.id}-popup" class="popup-arrow" style="display: none;">▼</a> + <div popupmenu="tool-${tool.id}-popup"> + <a class="action-button" href="${h.url_for( controller='common', action='view_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">View information</a> + <a class="action-button" href="${h.url_for( controller='common', action='manage_categories', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Manage categories</a> + <a class="action-button" href="${h.url_for( controller='common', action='upload_new_tool_version', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Upload a new version</a> + <a class="action-button" href="${h.url_for( controller='tool', action='download_tool', id=trans.app.security.encode_id( tool.id ) )}">Download tool</a> + </div> </div> - </div> - <form id="edit_tool" name="edit_tool" action="${h.url_for( controller='common', action='edit_tool' )}" method="post"> <div class="toolFormBody"> <input type="hidden" name="id" value="${trans.app.security.encode_id( tool.id )}"/> <input type="hidden" name="cntrller" value="${cntrller}"/> @@ -85,6 +85,9 @@ <input type="submit" id="edit_tool_button" name="edit_tool_button" value="Save"> </div> </div> + </div> + <p/> + <div class="toolForm"> <div class="toolFormTitle">Manage categories</div> <div class="toolFormBody"> <div class="form-row"> @@ -103,7 +106,10 @@ <input type="submit" id="edit_tool_button" name="edit_tool_button" value="Save"/> </div> </div> - </form> + </div> + </form> + <p/> + <div class="toolForm"> %if tool.is_new(): <div class="toolFormTitle">Get approval for publishing</div> <div class="toolFormBody"> @@ -113,11 +119,13 @@ <div class="form-row"> <input type="submit" name="approval_button" value="Submit for approval"/> </div> - <div class="toolParamHelp" style="clear: both;"> - Tools must be approved before they are made available to others in the community. After you have submitted - your tool to be published, you will no longer be able to modify it, so make sure to save the information in - each of the forms above before submitting for approval. - </div> + <div class="form-row"> + <div class="toolParamHelp" style="clear: both;"> + Tools must be approved before they are made available to others in the community. After you have submitted + your tool to be published, you will no longer be able to modify it, so make sure the information above is + correct and has been saved before submitting for approval. + </div> + </div> </form> </div> %endif diff -r 811b4794da70 -r c63fad1c7d3c templates/webapps/community/tool/view_tool.mako --- a/templates/webapps/community/tool/view_tool.mako Wed Apr 28 12:47:44 2010 -0400 +++ b/templates/webapps/community/tool/view_tool.mako Wed Apr 28 14:20:24 2010 -0400 @@ -2,6 +2,7 @@ <% from galaxy.web.framework.helpers import time_ago + from urllib import quote_plus if cntrller in [ 'tool' ]: can_edit = trans.app.security_agent.can_edit_item( trans.user, tool ) @@ -16,9 +17,37 @@ %> <%inherit file="${inherit(context)}"/> +<%def name="stylesheets()"> + ${parent.stylesheets()} + <style type="text/css"> + ul.fileBrowser, + ul.toolFile { + margin-left: 0; + padding-left: 0; + list-style: none; + } + ul.fileBrowser { + margin-left: 20px; + } + .fileBrowser li, + .toolFile li { + padding-left: 20px; + background-repeat: no-repeat; + background-position: 0; + min-height: 20px; + } + .toolFile li { + background-image: url( ${h.url_for( '/static/images/silk/page_white_compressed.png' )} ); + } + .fileBrowser li { + background-image: url( ${h.url_for( '/static/images/silk/page_white.png' )} ); + } + </style> +</%def> + <%def name="title()">View Tool</%def> -<h2>View ${tool.name} <em>${tool.description}</em></h2> +<h2>View Tool: ${tool.name} <em>${tool.description}</em></h2> %if message: ${render_msg( message, status )} @@ -71,3 +100,21 @@ </div> </div> </div> + +<p/> + +<div class="toolForm"> + <div class="toolFormTitle">Tool Contents</div> + <div class="toolFormBody"> + <div class="form-row"> + <ul class="toolFile"> + <li><a href="${h.url_for( controller='tool', action='download_tool', id=trans.app.security.encode_id( tool.id ) )}">${tool.download_file_name}</a></li> + <ul class="fileBrowser"> + %for name in tool_file_contents: + <li><a href="${h.url_for( controller='tool', action='view_tool_file', id=trans.app.security.encode_id( tool.id ), file_name=quote_plus( name ) )}">${name}</a></li> + %endfor + </ul> + </ul> + </div> + </div> +</div>
participants (1)
-
Nate Coraor