1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c28c5f906c6b/ changeset: c28c5f906c6b user: greg date: 2012-09-27 16:33:55 summary: Add the ability to view a tool shed repository's README file from the pop-up menu on pages in the tool shed repository as well as in Galaxy for the installed repository. affected #: 28 files diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce lib/galaxy/tool_shed/install_manager.py --- a/lib/galaxy/tool_shed/install_manager.py +++ b/lib/galaxy/tool_shed/install_manager.py @@ -133,6 +133,7 @@ for k, v in tool_panel_dict_for_tool_config.items(): tool_panel_dict_for_display[ k ] = v metadata_dict, invalid_file_tups = generate_metadata_for_changeset_revision( app=self.app, + repository=tool_shed_repository, repository_clone_url=repository_clone_url, relative_install_dir=relative_install_dir, repository_files_dir=None, diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -31,8 +31,8 @@ '&' : '&', '\'' : ''' } MAX_CONTENT_SIZE = 32768 +NOT_TOOL_CONFIGS = [ 'datatypes_conf.xml', 'tool_dependencies.xml' ] VALID_CHARS = set( string.letters + string.digits + "'\"-=_.()/+*^,:?!#[]%\\$@;{}" ) -NOT_TOOL_CONFIGS = [ 'datatypes_conf.xml', 'tool_dependencies.xml' ] class ShedCounter( object ): def __init__( self, model ): @@ -602,7 +602,7 @@ else: tool_dependencies_dict[ 'set_environment' ] = [ requirements_dict ] return tool_dependencies_dict -def generate_metadata_for_changeset_revision( app, repository_clone_url, relative_install_dir=None, repository_files_dir=None, +def generate_metadata_for_changeset_revision( app, repository, repository_clone_url, relative_install_dir=None, repository_files_dir=None, resetting_all_metadata_on_repository=False, webapp='galaxy' ): """ Generate metadata for a repository using it's files on disk. To generate metadata for changeset revisions older than the repository tip, @@ -610,6 +610,7 @@ disk files, so the value of repository_files_dir will not always be repository.repo_path (it could be an absolute path to a temporary directory containing a clone). If it is an absolute path, the value of relative_install_dir must contain repository.repo_path. """ + readme_file_names = get_readme_file_names( repository.name ) metadata_dict = {} invalid_file_tups = [] invalid_tool_configs = [] @@ -653,14 +654,24 @@ tool_data_path=app.config.tool_data_path, tool_data_table_config_path=app.config.tool_data_table_config_path, persist=False ) - # Find all tool configs and exported workflows and add them to the repository's metadata. for root, dirs, files in os.walk( files_dir ): if root.find( '.hg' ) < 0 and root.find( 'hgrc' ) < 0: if '.hg' in dirs: dirs.remove( '.hg' ) for name in files: - # Find all tool configs. - if name not in NOT_TOOL_CONFIGS and name.endswith( '.xml' ): + # See if we have a READ_ME file. + if name.lower() in readme_file_names: + if resetting_all_metadata_on_repository: + full_path_to_readme = os.path.join( root, name ) + stripped_path_to_readme = full_path_to_readme.replace( work_dir, '' ) + if stripped_path_to_readme.startswith( '/' ): + stripped_path_to_readme = stripped_path_to_readme[ 1: ] + relative_path_to_readme = os.path.join( relative_install_dir, stripped_path_to_readme ) + else: + relative_path_to_readme = os.path.join( root, name ) + metadata_dict[ 'readme' ] = relative_path_to_readme + # See if we have a tool config. + elif name not in NOT_TOOL_CONFIGS and name.endswith( '.xml' ): full_path = os.path.abspath( os.path.join( root, name ) ) if os.path.getsize( full_path ) > 0: if not ( check_binary( full_path ) or check_image( full_path ) or check_gzip( full_path )[ 0 ] @@ -699,7 +710,7 @@ else: for tup in invalid_files_and_errors_tups: invalid_file_tups.append( tup ) - # Find all exported workflows + # Find all exported workflows. elif name.endswith( '.ga' ): relative_path = os.path.join( root, name ) if os.path.getsize( os.path.abspath( relative_path ) ) > 0: @@ -1195,6 +1206,25 @@ if contents: contents.sort() return contents +def get_repository_metadata_by_changeset_revision( trans, id, changeset_revision ): + """Get metadata for a specified repository change set from the database""" + # Make sure there are no duplicate records, and return the single unique record for the changeset_revision. Duplicate records were somehow + # created in the past. The cause of this issue has been resolved, but we'll leave this method as is for a while longer to ensure all duplicate + # records are removed. + all_metadata_records = trans.sa_session.query( trans.model.RepositoryMetadata ) \ + .filter( and_( trans.model.RepositoryMetadata.table.c.repository_id == trans.security.decode_id( id ), + trans.model.RepositoryMetadata.table.c.changeset_revision == changeset_revision ) ) \ + .order_by( trans.model.RepositoryMetadata.table.c.update_time.desc() ) \ + .all() + if len( all_metadata_records ) > 1: + # Delete all recrds older than the last one updated. + for repository_metadata in all_metadata_records[ 1: ]: + trans.sa_session.delete( repository_metadata ) + trans.sa_session.flush() + return all_metadata_records[ 0 ] + elif all_metadata_records: + return all_metadata_records[ 0 ] + return None def get_repository_owner( cleaned_repository_url ): items = cleaned_repository_url.split( 'repos' ) repo_path = items[ 1 ] @@ -1405,6 +1435,13 @@ return shed_url # The tool shed from which the repository was originally installed must no longer be configured in tool_sheds_conf.xml. return None +def get_readme_file_names( repository_name ): + readme_files = [ 'readme', 'read_me', 'install' ] + valid_filenames = [ r for r in readme_files ] + for r in readme_files: + valid_filenames.append( '%s.txt' % r ) + valid_filenames.append( '%s.txt' % repository_name ) + return valid_filenames def handle_missing_data_table_entry( app, relative_install_dir, tool_path, repository_tools_tups ): """ Inspect each tool to see if any have input parameters that are dynamically generated select lists that require entries in the @@ -1907,6 +1944,19 @@ elif c not in [ '\r' ]: translated.append( '' ) return ''.join( translated ) +def translate_string( raw_text, to_html=True ): + if raw_text: + if to_html: + if len( raw_text ) <= MAX_CONTENT_SIZE: + translated_string = to_html_str( raw_text ) + else: + large_str = '\nFile contents truncated because file size is larger than maximum viewing size of %s\n' % util.nice_size( MAX_CONTENT_SIZE ) + translated_string = to_html_str( '%s%s' % ( raw_text[ 0:MAX_CONTENT_SIZE ], large_str ) ) + else: + raise Exception( "String translation currently only supports text to HTML." ) + else: + translated_string = '' + return translated_string def update_repository( repo, ctx_rev=None ): """ Update the cloned repository to changeset_revision. It is critical that the installed repository is updated to the desired diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -342,8 +342,10 @@ message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) repository = get_repository( trans, kwd[ 'id' ] ) + has_readme = repository.metadata and 'readme' in repository.metadata return trans.fill_template( '/admin/tool_shed_repository/browse_repository.mako', repository=repository, + has_readme=has_readme, message=message, status=status ) @web.expose @@ -388,8 +390,11 @@ message += "Choose <b>Uninstall this tool dependency</b> from the <b>Repository Actions</b> menu, correct problems " message += "if necessary, and try installing the dependency again." status = "error" + tool_shed_repository = tool_dependency.tool_shed_repository + has_readme = tool_shed_repository.metadata and 'readme' in tool_shed_repository.metadata return trans.fill_template( '/admin/tool_shed_repository/browse_tool_dependency.mako', - repository=tool_dependency.tool_shed_repository, + repository=tool_shed_repository, + has_readme=has_readme, tool_dependency=tool_dependency, in_error_state=in_error_state, can_uninstall=can_uninstall, @@ -487,9 +492,11 @@ message=message, status=status ) ) remove_from_disk_check_box = CheckboxField( 'remove_from_disk', checked=remove_from_disk_checked ) + has_readme = tool_shed_repository.metadata and 'readme' in tool_shed_repository.metadata return trans.fill_template( '/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako', repository=tool_shed_repository, remove_from_disk_check_box=remove_from_disk_check_box, + has_readme=has_readme, message=message, status=status ) @web.expose @@ -716,6 +723,7 @@ when an admin is installing a new repository or reinstalling an uninstalled repository. """ metadata_dict, invalid_file_tups = generate_metadata_for_changeset_revision( app=trans.app, + repository=tool_shed_repository, repository_clone_url=repository_clone_url, relative_install_dir=relative_install_dir, repository_files_dir=None, @@ -837,8 +845,10 @@ trans.sa_session.add( repository ) trans.sa_session.flush() message = "Repository metadata has been reset." + has_readme = repository.metadata and 'readme' in repository.metadata return trans.fill_template( '/admin/tool_shed_repository/manage_repository.mako', repository=repository, + has_readme=has_readme, in_error_state=in_error_state, can_install=can_install, description=description, @@ -914,14 +924,14 @@ tool_shed_repository = tool_dependency.tool_shed_repository self.tool_dependency_grid.title = "Tool shed repository '%s' tool dependencies" % tool_shed_repository.name self.tool_dependency_grid.global_actions = \ - [ grids.GridAction( label='Browse repository', + [ grids.GridAction( label='Manage repository', + url_args=dict( controller='admin_toolshed', + action='manage_repository', + id=trans.security.encode_id( tool_shed_repository.id ) ) ), + grids.GridAction( label='Browse repository', url_args=dict( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( tool_shed_repository.id ) ) ), - grids.GridAction( label='Manage repository', - url_args=dict( controller='admin_toolshed', - action='manage_repository', - id=trans.security.encode_id( tool_shed_repository.id ) ) ), grids.GridAction( label='Get repository updates', url_args=dict( controller='admin_toolshed', action='check_for_updates', @@ -934,6 +944,12 @@ url_args=dict( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( tool_shed_repository.id ) ) ) ] + if tool_shed_repository.metadata and 'readme' in tool_shed_repository.metadata: + view_readme_action = grids.GridAction( label='View README', + url_args=dict( controller='admin_toolshed', + action='view_readme', + id=trans.security.encode_id( tool_shed_repository.id ) ) ) + self.tool_dependency_grid.global_actions.insert( 1, view_readme_action ) if 'operation' in kwd: operation = kwd[ 'operation' ].lower() if not tool_dependency_ids: @@ -1181,13 +1197,7 @@ response = urllib2.urlopen( url ) raw_text = response.read() response.close() - readme_text = '' - for i, line in enumerate( raw_text ): - readme_text = '%s%s' % ( readme_text, to_html_str( line ) ) - if len( readme_text ) > MAX_CONTENT_SIZE: - large_str = '\nFile contents truncated because file size is larger than maximum viewing size of %s\n' % util.nice_size( MAX_CONTENT_SIZE ) - readme_text = '%s%s' % ( readme_text, to_html_str( large_str ) ) - break + readme_text = translate_string( raw_text, to_html=True ) else: readme_text = '' if trans.app.config.tool_dependency_dir is None: @@ -1418,8 +1428,19 @@ status = 'warning' includes_tool_dependencies = 'tool_dependencies' in metadata install_tool_dependencies_check_box = CheckboxField( 'install_tool_dependencies', checked=True ) + if metadata and 'readme' in metadata: + url = url_join( tool_shed_url, + 'repository/get_readme?name=%s&owner=%s&changeset_revision=%s&webapp=galaxy' % \ + ( repository.name, repository.owner, repository.installed_changeset_revision ) ) + response = urllib2.urlopen( url ) + raw_text = response.read() + response.close() + readme_text = translate_string( raw_text, to_html=True ) + else: + readme_text = '' return trans.fill_template( '/admin/tool_shed_repository/reselect_tool_panel_section.mako', repository=repository, + readme_text=readme_text, no_changes_check_box=no_changes_check_box, original_section_name=original_section_name, install_tool_dependencies_check_box=install_tool_dependencies_check_box, @@ -1527,6 +1548,8 @@ for tool_dependency_id in tool_dependency_ids: tool_dependency = get_tool_dependency( trans, tool_dependency_id ) tool_dependencies.append( tool_dependency ) + tool_shed_repository = tool_dependencies[ 0 ].tool_shed_repository + has_readme = tool_shed_repository.metadata and 'readme' in tool_shed_repository.metadata if kwd.get( 'uninstall_tool_dependencies_button', False ): errors = False # Filter tool dependencies to only those that are installed. @@ -1545,7 +1568,6 @@ status = 'error' else: message = "These tool dependencies have been uninstalled: %s" % ','.join( td.name for td in tool_dependencies_for_uninstallation ) - tool_shed_repository = tool_dependencies[ 0 ].tool_shed_repository td_ids = [ trans.security.encode_id( td.id ) for td in tool_shed_repository.tool_dependencies ] return trans.response.send_redirect( web.url_for( controller='admin_toolshed', action='manage_tool_dependencies', @@ -1553,6 +1575,9 @@ status=status, message=message ) ) return trans.fill_template( '/admin/tool_shed_repository/uninstall_tool_dependencies.mako', + repository=tool_shed_repository, + has_readme=has_readme, + tool_dependency_ids=tool_dependency_ids, tool_dependencies=tool_dependencies, message=message, status=status ) @@ -1616,27 +1641,55 @@ status=status ) ) @web.expose @web.require_admin + def view_readme( self, trans, id, **kwd ): + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + cntrller = params.get( 'cntrller', 'admin_toolshed' ) + status = params.get( 'status', 'done' ) + repository = get_repository( trans, id ) + metadata = repository.metadata + if metadata and 'readme' in metadata: + f = open( metadata[ 'readme' ], 'r' ) + raw_text = f.read() + f.close() + readme_text = translate_string( raw_text, to_html=True ) + else: + readme_text = '' + is_malicious = False + return trans.fill_template( '/webapps/community/common/view_readme.mako', + cntrller=cntrller, + repository=repository, + changeset_revision=repository.changeset_revision, + readme_text=readme_text, + is_malicious=is_malicious, + webapp='galaxy', + message=message, + status=status ) + @web.expose + @web.require_admin def view_tool_metadata( self, trans, repository_id, tool_id, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) webapp = get_webapp( trans, **kwd ) repository = get_repository( trans, repository_id ) - metadata = {} + repository_metadata = repository.metadata + tool_metadata = {} tool_lineage = [] tool = None - if 'tools' in repository.metadata: - for tool_metadata_dict in repository.metadata[ 'tools' ]: + if 'tools' in repository_metadata: + for tool_metadata_dict in repository_metadata[ 'tools' ]: if tool_metadata_dict[ 'id' ] == tool_id: - metadata = tool_metadata_dict - tool = trans.app.toolbox.load_tool( os.path.abspath( metadata[ 'tool_config' ] ), guid=metadata[ 'guid' ] ) + tool_metadata = tool_metadata_dict + tool = trans.app.toolbox.load_tool( os.path.abspath( tool_metadata[ 'tool_config' ] ), guid=metadata[ 'guid' ] ) if tool: tool_lineage = self.get_versions_of_tool( trans.app, tool.id ) break return trans.fill_template( "/admin/tool_shed_repository/view_tool_metadata.mako", repository=repository, + repository_metadata=repository_metadata, tool=tool, - metadata=metadata, + tool_metadata=tool_metadata, tool_lineage=tool_lineage, message=message, status=status ) diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -7,9 +7,9 @@ from galaxy.util.hash_util import * from galaxy.util.shed_util import check_tool_input_params, clone_repository, concat_messages, copy_sample_file, generate_metadata_for_changeset_revision from galaxy.util.shed_util import get_changectx_for_changeset, get_config_from_disk, get_configured_ui, get_file_context_from_ctx, get_named_tmpfile_from_ctx -from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_disk, handle_sample_files_and_load_tool_from_tmp_config -from galaxy.util.shed_util import handle_sample_tool_data_table_conf_file, INITIAL_CHANGELOG_HASH, load_tool_from_config, reset_tool_data_tables -from galaxy.util.shed_util import reversed_upper_bounded_changelog, strip_path +from galaxy.util.shed_util import get_repository_metadata_by_changeset_revision, handle_sample_files_and_load_tool_from_disk +from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_tmp_config, handle_sample_tool_data_table_conf_file, INITIAL_CHANGELOG_HASH +from galaxy.util.shed_util import load_tool_from_config, reset_tool_data_tables, reversed_upper_bounded_changelog, strip_path from galaxy.web.base.controller import * from galaxy.webapps.community import model from galaxy.model.orm import * @@ -473,25 +473,6 @@ .filter( and_( trans.model.Repository.table.c.name == name, trans.model.Repository.table.c.user_id == user.id ) ) \ .first() -def get_repository_metadata_by_changeset_revision( trans, id, changeset_revision ): - """Get metadata for a specified repository change set from the database""" - # Make sure there are no duplicate records, and return the single unique record for the changeset_revision. Duplicate records were somehow - # created in the past. The cause of this issue has been resolved, but we'll leave this method as is for a while longer to ensure all duplicate - # records are removed. - all_metadata_records = trans.sa_session.query( trans.model.RepositoryMetadata ) \ - .filter( and_( trans.model.RepositoryMetadata.table.c.repository_id == trans.security.decode_id( id ), - trans.model.RepositoryMetadata.table.c.changeset_revision == changeset_revision ) ) \ - .order_by( trans.model.RepositoryMetadata.table.c.update_time.desc() ) \ - .all() - if len( all_metadata_records ) > 1: - # Delete all recrds older than the last one updated. - for repository_metadata in all_metadata_records[ 1: ]: - trans.sa_session.delete( repository_metadata ) - trans.sa_session.flush() - return all_metadata_records[ 0 ] - elif all_metadata_records: - return all_metadata_records[ 0 ] - return None def get_repository_metadata_by_id( trans, id ): """Get repository metadata from the database""" return trans.sa_session.query( trans.model.RepositoryMetadata ).get( trans.security.decode_id( id ) ) @@ -762,6 +743,7 @@ if cloned_ok: log.debug( "Generating metadata for changset revision: %s", str( ctx.rev() ) ) current_metadata_dict, invalid_file_tups = generate_metadata_for_changeset_revision( app=trans.app, + repository=repository, repository_clone_url=repository_clone_url, relative_install_dir=repo_dir, repository_files_dir=work_dir, @@ -836,6 +818,7 @@ repo_dir = repository.repo_path repo = hg.repository( get_configured_ui(), repo_dir ) metadata_dict, invalid_file_tups = generate_metadata_for_changeset_revision( app=trans.app, + repository=repository, repository_clone_url=repository_clone_url, relative_install_dir=repo_dir, repository_files_dir=None, diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -10,9 +10,10 @@ from galaxy.util.json import from_json_string, to_json_string from galaxy.model.orm import * from galaxy.util.shed_util import create_repo_info_dict, get_changectx_for_changeset, get_configured_ui, get_repository_file_contents -from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_disk, handle_sample_files_and_load_tool_from_tmp_config, INITIAL_CHANGELOG_HASH -from galaxy.util.shed_util import load_tool_from_config, NOT_TOOL_CONFIGS, open_repository_files_folder, reversed_lower_upper_bounded_changelog -from galaxy.util.shed_util import reversed_upper_bounded_changelog, strip_path, to_html_escaped, update_repository, url_join +from galaxy.util.shed_util import get_repository_metadata_by_changeset_revision, handle_sample_files_and_load_tool_from_disk +from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_tmp_config, INITIAL_CHANGELOG_HASH, load_tool_from_config, NOT_TOOL_CONFIGS +from galaxy.util.shed_util import open_repository_files_folder, reversed_lower_upper_bounded_changelog, reversed_upper_bounded_changelog, strip_path +from galaxy.util.shed_util import to_html_escaped, translate_string, update_repository, url_join from galaxy.tool_shed.encoding_util import * from common import * @@ -23,7 +24,6 @@ log = logging.getLogger( __name__ ) VALID_REPOSITORYNAME_RE = re.compile( "^[a-z0-9\_]+$" ) -README_FILES = [ 'readme', 'read_me', 'install' ] class CategoryListGrid( grids.Grid ): class NameColumn( grids.TextColumn ): @@ -613,8 +613,10 @@ # Update repository files for browsing. update_repository( repo ) is_malicious = changeset_is_malicious( trans, id, repository.tip ) + metadata = self.get_metadata( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/browse_repository.mako', repository=repository, + metadata=metadata, commit_message=commit_message, is_malicious=is_malicious, webapp=webapp, @@ -828,9 +830,11 @@ message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) repository = get_repository( trans, id ) + metadata = self.get_metadata( trans, id, repository.tip ) if trans.user and trans.user.email: return trans.fill_template( "/webapps/community/repository/contact_owner.mako", repository=repository, + metadata=metadata, message=message, status=status ) else: @@ -939,9 +943,11 @@ repository, tool, message = load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) tool_state = self.__new_state( trans ) is_malicious = changeset_is_malicious( trans, repository_id, repository.tip ) + metadata = self.get_metadata( trans, repository_id, changeset_revision ) try: return trans.fill_template( "/webapps/community/repository/tool_form.mako", repository=repository, + metadata=metadata, changeset_revision=changeset_revision, tool=tool, tool_state=tool_state, @@ -1181,6 +1187,11 @@ trans.response.headers['Pragma'] = 'no-cache' trans.response.headers['Expires'] = '0' return get_repository_file_contents( file_path ) + def get_metadata( self, trans, repository_id, changeset_revision ): + repository_metadata = get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) + if repository_metadata and repository_metadata.metadata: + return repository_metadata.metadata + return None @web.json def get_repository_information( self, trans, repository_ids, changeset_revisions, **kwd ): """ @@ -1208,23 +1219,18 @@ return dict( includes_tools=includes_tools, includes_tool_dependencies=includes_tool_dependencies, repo_info_dicts=repo_info_dicts ) @web.expose def get_readme( self, trans, **kwd ): - """If the received changeset_revision includes a file named readme (case ignored), return it's contents.""" + """If the received changeset_revision includes a readme file, return it's contents.""" repository_name = kwd[ 'name' ] repository_owner = kwd[ 'owner' ] changeset_revision = kwd[ 'changeset_revision' ] - valid_filenames = [ r for r in README_FILES ] - for r in README_FILES: - valid_filenames.append( '%s.txt' % r ) - valid_filenames.append( '%s.txt' % repository_name ) repository = get_repository_by_name_and_owner( trans, repository_name, repository_owner ) - repo_dir = repository.repo_path - for root, dirs, files in os.walk( repo_dir ): - for name in files: - if name.lower() in valid_filenames: - f = open( os.path.join( root, name ), 'r' ) - text = f.read() - f.close() - return str( text ) + repository_metadata = get_repository_metadata_by_changeset_revision( trans, trans.security.encode_id( repository.id ), changeset_revision ) + metadata = repository_metadata.metadata + if metadata and 'readme' in metadata: + f = open( metadata[ 'readme' ], 'r' ) + text = f.read() + f.close() + return str( text ) return '' @web.expose def get_tool_dependencies( self, trans, **kwd ): @@ -1829,8 +1835,10 @@ display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) rra = self.get_user_item_rating( trans.sa_session, trans.user, repository, webapp_model=trans.model ) is_malicious = changeset_is_malicious( trans, id, repository.tip ) + metadata = self.get_metadata( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/rate_repository.mako', repository=repository, + metadata=metadata, avg_rating=avg_rating, display_reviews=display_reviews, num_ratings=num_ratings, @@ -2156,8 +2164,10 @@ # Make sure we'll view latest changeset first. changesets.insert( 0, change_dict ) is_malicious = changeset_is_malicious( trans, id, repository.tip ) + metadata = self.get_metadata( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/view_changelog.mako', repository=repository, + metadata=metadata, changesets=changesets, is_malicious=is_malicious, message=message, @@ -2185,8 +2195,10 @@ for diff in patch.diff( repo, node1=ctx_parent.node(), node2=ctx.node() ): diffs.append( to_html_escaped( diff ) ) is_malicious = changeset_is_malicious( trans, id, repository.tip ) + metadata = self.get_metadata( trans, id, ctx_str ) return trans.fill_template( '/webapps/community/repository/view_changeset.mako', repository=repository, + metadata=metadata, ctx=ctx, anchors=anchors, modified=modified, @@ -2201,6 +2213,33 @@ message=message, status=status ) @web.expose + def view_readme( self, trans, id, changeset_revision, **kwd ): + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + cntrller = params.get( 'cntrller', 'repository' ) + webapp = params.get( 'webapp', 'community' ) + repository = get_repository( trans, id ) + repository_metadata = get_repository_metadata_by_changeset_revision( trans, trans.security.encode_id( repository.id ), changeset_revision ) + metadata = repository_metadata.metadata + if metadata and 'readme' in metadata: + f = open( metadata[ 'readme' ], 'r' ) + raw_text = f.read() + f.close() + readme_text = translate_string( raw_text, to_html=True ) + else: + readme_text = '' + is_malicious = changeset_is_malicious( trans, id, changeset_revision ) + return trans.fill_template( '/webapps/community/common/view_readme.mako', + cntrller=cntrller, + repository=repository, + changeset_revision=changeset_revision, + readme_text=readme_text, + is_malicious=is_malicious, + webapp=webapp, + message=message, + status=status ) + @web.expose def view_repository( self, trans, id, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) @@ -2318,6 +2357,8 @@ break if guid: tool_lineage = self.get_versions_of_tool( trans, repository, repository_metadata, guid ) + else: + metadata = None is_malicious = changeset_is_malicious( trans, repository_id, repository.tip ) changeset_revision_select_field = build_changeset_revision_select_field( trans, repository, @@ -2327,6 +2368,7 @@ trans.app.config.tool_data_path = original_tool_data_path return trans.fill_template( "/webapps/community/repository/view_tool_metadata.mako", repository=repository, + metadata=metadata, tool=tool, tool_metadata_dict=tool_metadata_dict, tool_lineage=tool_lineage, diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce lib/galaxy/webapps/community/controllers/workflow.py --- a/lib/galaxy/webapps/community/controllers/workflow.py +++ b/lib/galaxy/webapps/community/controllers/workflow.py @@ -151,6 +151,7 @@ changeset_revision=repository_metadata.changeset_revision, repository_metadata_id=repository_metadata_id, workflow_name=workflow_name, + metadata=repository_metadata, webapp=webapp, message=message, status=status ) diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/browse_repository.mako --- a/templates/admin/tool_shed_repository/browse_repository.mako +++ b/templates/admin/tool_shed_repository/browse_repository.mako @@ -18,6 +18,9 @@ <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup"><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a> + %if has_readme: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='view_readme', id=trans.security.encode_id( repository.id ) )}">View README</a> + %endif <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or uninstall repository</a> %if repository.tool_dependencies: diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/browse_tool_dependency.mako --- a/templates/admin/tool_shed_repository/browse_tool_dependency.mako +++ b/templates/admin/tool_shed_repository/browse_tool_dependency.mako @@ -19,8 +19,11 @@ <ul class="manage-table-actions"><li><a class="action-button" id="tool_dependency-${tool_dependency.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="tool_dependency-${tool_dependency.id}-popup"> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a> + %if has_readme: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='view_readme', id=trans.security.encode_id( repository.id ) )}">View README</a> + %endif <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or uninstall repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', tool_dependency_ids=tool_dependency_ids )}">Manage tool dependencies</a> diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako --- a/templates/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako +++ b/templates/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako @@ -6,8 +6,11 @@ <ul class="manage-table-actions"><li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a> + %if has_readme: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='view_readme', id=trans.security.encode_id( repository.id ) )}">View README</a> + %endif <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a> %if repository.tool_dependencies: <% tool_dependency_ids = [ trans.security.encode_id( td.id ) for td in repository.tool_dependencies ] %> diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/manage_repository.mako --- a/templates/admin/tool_shed_repository/manage_repository.mako +++ b/templates/admin/tool_shed_repository/manage_repository.mako @@ -11,6 +11,9 @@ %elif can_install: <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ), operation='install' )}">Install</a> %else: + %if has_readme: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='view_readme', id=trans.security.encode_id( repository.id ) )}">View README</a> + %endif <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a> %if repository.includes_tools: diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/manage_tool_dependencies.mako --- a/templates/admin/tool_shed_repository/manage_tool_dependencies.mako +++ /dev/null @@ -1,79 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> - -<% import os %> - -<br/><br/> -<ul class="manage-table-actions"> - <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> - <div popupmenu="repository-${repository.id}-popup"> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a> - %if repository.includes_tools: - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='set_tool_versions', id=trans.security.encode_id( repository.id ) )}">Set tool versions</a> - %endif - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or uninstall repository</a> - </div> -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -<div class="toolForm"> - <div class="toolFormTitle">Repository '${repository.name}' tool dependencies</div> - <div class="toolFormBody"> - <div class="form-row"> - <table class="grid"> - %for tool_dependency in repository.tool_dependencies: - <% - name = tool_dependency.name - version = tool_dependency.version - type = tool_dependency.type - installed = tool_dependency.status == 'trans.model.ToolDependency.installation_status.INSTALLED - install_dir = tool_dependency.installation_directory( trans.app ) - %> - <tr> - <td bgcolor="#D8D8D8"> - <div style="float: left; margin-left: 1px;" class="menubutton split popup" id="dependency-${tool_dependency.id}-popup"> - %if not installed: - <a class="view-info" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', operation='browse', tool_dependency_id=trans.security.encode_id( tool_dependency.id ) )}"> - <b>Name</b> - </a> - <div popupmenu="dependency-${tool_dependency.id}-popup"> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', operation='install', tool_dependency_id=trans.security.encode_id( tool_dependency.id ) )}">Install this tool dependency</a> - </div> - %else: - <a class="view-info" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', operation='browse', tool_dependency_id=trans.security.encode_id( tool_dependency.id ) )}"> - <b>Name</b> - </a> - <div popupmenu="dependency-${tool_dependency.id}-popup"> - <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', operation='uninstall', tool_dependency_id=trans.security.encode_id( tool_dependency.id ) )}">Uninstall this tool dependency</a> - </div> - %endif - </div> - </td> - <td bgcolor="#D8D8D8">${name}</td> - </tr> - <tr><th>Version</th><td>${version}</td></tr> - <tr><th>Type</th><td>${type}</td></tr> - <tr> - <th>Install directory</th> - <td> - %if not installed: - This dependency is not currently installed - %else: - <a class="view-info" href="${h.url_for( controller='admin_toolshed', action='browse_tool_dependency', id=trans.security.encode_id( tool_dependency.id ), repository_id=trans.security.encode_id( repository.id ) )}"> - ${install_dir} - </a> - %endif - </td> - </tr> - <tr><th>Installed</th><td>${not installed}</td></tr> - %endfor - </table> - <div style="clear: both"></div> - </div> - </div> -</div> diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/reselect_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako @@ -1,6 +1,7 @@ <%inherit file="/base.mako"/><%namespace file="/message.mako" import="render_msg" /><%namespace file="/admin/tool_shed_repository/common.mako" import="render_tool_dependency_section" /> +<%namespace file="/webapps/community/common/common.mako" import="render_readme" /> %if message: ${render_msg( message, status )} @@ -42,3 +43,6 @@ </form></div></div> +%if readme_text: + ${render_readme( readme_text )} +%endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/select_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/select_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/select_tool_panel_section.mako @@ -1,6 +1,7 @@ <%inherit file="/base.mako"/><%namespace file="/message.mako" import="render_msg" /><%namespace file="/admin/tool_shed_repository/common.mako" import="render_tool_dependency_section" /> +<%namespace file="/webapps/community/common/common.mako" import="render_readme" /> %if message: ${render_msg( message, status )} @@ -77,13 +78,5 @@ </div></div> %if readme_text: - <div class="toolForm"> - <div class="toolFormTitle">Repository README file (may contain important installation or license information)</div> - <div class="toolFormBody"> - <input type="hidden" name="readme_text" value="${readme_text}"/> - <div class="form-row"> - <pre>${readme_text}</pre> - </div> - </div> - </div> + ${render_readme( readme_text )} %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/uninstall_tool_dependencies.mako --- a/templates/admin/tool_shed_repository/uninstall_tool_dependencies.mako +++ b/templates/admin/tool_shed_repository/uninstall_tool_dependencies.mako @@ -3,6 +3,24 @@ <% import os %> +<br/><br/> +<ul class="manage-table-actions"> + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + %if has_readme: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='view_readme', id=trans.security.encode_id( repository.id ) )}">View README</a> + %endif + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a> + %if repository.tool_dependencies: + <% tool_dependency_ids = [ trans.security.encode_id( td.id ) for td in repository.tool_dependencies ] %> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', tool_dependency_ids=tool_dependency_ids )}">Manage tool dependencies</a> + %endif + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or uninstall repository</a> + </div> +</ul> + %if message: ${render_msg( message, status )} %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/admin/tool_shed_repository/view_tool_metadata.mako --- a/templates/admin/tool_shed_repository/view_tool_metadata.mako +++ b/templates/admin/tool_shed_repository/view_tool_metadata.mako @@ -5,6 +5,9 @@ <ul class="manage-table-actions"><li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup"> + %if repository_metadata and 'readme' in repository_metadata: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='view_readme', id=trans.security.encode_id( repository.id ) )}">View README</a> + %endif <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a><a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a> @@ -20,10 +23,10 @@ ${render_msg( message, status )} %endif -%if metadata: +%if tool_metadata: <p/><div class="toolForm"> - <div class="toolFormTitle">${metadata[ 'name' ]} tool metadata</div> + <div class="toolFormTitle">${tool_metadata[ 'name' ]} tool metadata</div><div class="toolFormBody"><div class="form-row"><table width="100%"> @@ -32,41 +35,41 @@ </div><div class="form-row"><label>Name:</label> - ${metadata[ 'name' ]} + ${tool_metadata[ 'name' ]} <div style="clear: both"></div></div> - %if 'description' in metadata: + %if 'description' in tool_metadata: <div class="form-row"><label>Description:</label> - ${metadata[ 'description' ]} + ${tool_metadata[ 'description' ]} <div style="clear: both"></div></div> %endif - %if 'id' in metadata: + %if 'id' in tool_metadata: <div class="form-row"><label>Id:</label> - ${metadata[ 'id' ]} + ${tool_metadata[ 'id' ]} <div style="clear: both"></div></div> %endif - %if 'guid' in metadata: + %if 'guid' in tool_metadata: <div class="form-row"><label>Guid:</label> - ${metadata[ 'guid' ]} + ${tool_metadata[ 'guid' ]} <div style="clear: both"></div></div> %endif - %if 'version' in metadata: + %if 'version' in tool_metadata: <div class="form-row"><label>Version:</label> - ${metadata[ 'version' ]} + ${tool_metadata[ 'version' ]} <div style="clear: both"></div></div> %endif - %if 'version_string_cmd' in metadata: + %if 'version_string_cmd' in tool_metadata: <div class="form-row"><label>Version command string:</label> - ${metadata[ 'version_string_cmd' ]} + ${tool_metadata[ 'version_string_cmd' ]} <div style="clear: both"></div></div> %endif @@ -81,7 +84,7 @@ %for guid in tool_lineage: <tr><td> - %if guid == metadata[ 'guid' ]: + %if guid == tool_metadata[ 'guid' ]: ${guid} <b>(this tool)</b> %else: ${guid} @@ -100,8 +103,8 @@ </table></div><% - if 'requirements' in metadata: - requirements = metadata[ 'requirements' ] + if 'requirements' in tool_metadata: + requirements = tool_metadata[ 'requirements' ] else: requirements = None %> @@ -172,8 +175,8 @@ </table></div><% - if 'tests' in metadata: - tests = metadata[ 'tests' ] + if 'tests' in tool_metadata: + tests = tool_metadata[ 'tests' ] else: tests = None %> diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/common/common.mako --- a/templates/webapps/community/common/common.mako +++ b/templates/webapps/community/common/common.mako @@ -13,3 +13,26 @@ %> ${html} </%def> + +<%def name="render_readme( readme_text )"> + <style type="text/css"> + #readme_table{ table-layout:fixed; + width:100%; + overflow-wrap:normal; + overflow:hidden; + border:0px; + word-break:keep-all; + word-wrap:break-word; + line-break:strict; } + </style> + <div class="toolForm"> + <div class="toolFormTitle">Repository README file (may contain important installation or license information)</div> + <div class="toolFormBody"> + <div class="form-row"> + <table id="readme_table"> + <tr><td>${readme_text}</td></tr> + </table> + </div> + </div> + </div> +</%def> diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/common/view_readme.mako --- /dev/null +++ b/templates/webapps/community/common/view_readme.mako @@ -0,0 +1,88 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> +<%namespace file="/webapps/community/common/common.mako" import="render_readme" /> + +<% + if webapp == 'community': + is_admin = trans.user_is_admin() + is_new = repository.is_new + can_contact_owner = trans.user and trans.user != repository.user + can_push = trans.app.security_agent.can_push( trans.user, repository ) + can_rate = not is_new and trans.user and repository.user != trans.user + can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) + can_browse_contents = not is_new + can_view_change_log = not is_new + can_manage = is_admin or repository.user == trans.user + if can_push: + browse_label = 'Browse or delete repository tip files' + else: + browse_label = 'Browse repository tip files' +%> + +<br/><br/> +<ul class="manage-table-actions"> + %if webapp == 'community': + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + %if can_manage: + <a class="action-button" href="${h.url_for( controller='repository', action='manage_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip )}">Manage repository</a> + %else: + <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View repository</a> + %endif + %if can_upload: + <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp=webapp )}">Upload files to repository</a> + %endif + %if can_view_change_log: + <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp=webapp )}">View change log</a> + %endif + %if can_rate: + <a class="action-button" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ), webapp=webapp )}">Rate repository</a> + %endif + %if can_browse_contents: + <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ), webapp=webapp )}">${browse_label}</a> + %endif + %if can_contact_owner: + <a class="action-button" href="${h.url_for( controller='repository', action='contact_owner', id=trans.security.encode_id( repository.id ), webapp=webapp )}">Contact repository owner</a> + %endif + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, file_type='gz', webapp=webapp )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, file_type='bz2', webapp=webapp )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, file_type='zip', webapp=webapp )}">Download as a zip file</a> + %endif + </div> + %else: + %if cntrller=='repository': + <li><a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', operation='preview_tools_in_changeset', id=trans.security.encode_id( repository.id ), webapp=webapp )}">Preview tools for install</a></li> + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_categories', webapp=webapp )}">Browse valid repositories</a> + <a class="action-button" href="${h.url_for( controller='repository', action='find_tools', webapp=webapp )}">Search for valid tools</a> + <a class="action-button" href="${h.url_for( controller='repository', action='find_workflows', webapp=webapp )}">Search for workflows</a> + </div> + %else: + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_repository', id=trans.security.encode_id( repository.id ) )}">Manage repository</a> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_repository', id=trans.security.encode_id( repository.id ) )}">Browse repository files</a> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='check_for_updates', id=trans.security.encode_id( repository.id ) )}">Get repository updates</a> + %if repository.includes_tools: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='set_tool_versions', id=trans.security.encode_id( repository.id ) )}">Set tool versions</a> + %endif + %if repository.tool_dependencies: + <% tool_dependency_ids = [ trans.security.encode_id( td.id ) for td in repository.tool_dependencies ] %> + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', tool_dependency_ids=tool_dependency_ids )}">Manage tool dependencies</a> + %endif + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='deactivate_or_uninstall_repository', id=trans.security.encode_id( repository.id ) )}">Deactivate or uninstall repository</a> + </div> + %endif + %endif +</ul> + +%if message: + ${render_msg( message, status )} +%endif + +%if readme_text: + ${render_readme( readme_text )} +%endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/browse_repository.mako --- a/templates/webapps/community/repository/browse_repository.mako +++ b/templates/webapps/community/repository/browse_repository.mako @@ -15,6 +15,7 @@ can_rate = trans.user and repository.user != trans.user can_manage = is_admin or repository.user == trans.user can_view_change_log = not is_new + has_readme = metadata and 'readme' in metadata %><%! @@ -76,6 +77,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp='community' )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/contact_owner.mako --- a/templates/webapps/community/repository/contact_owner.mako +++ b/templates/webapps/community/repository/contact_owner.mako @@ -16,6 +16,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -42,6 +43,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp='community' )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/manage_repository.mako --- a/templates/webapps/community/repository/manage_repository.mako +++ b/templates/webapps/community/repository/manage_repository.mako @@ -21,6 +21,7 @@ browse_label = 'Browse repository tip files' can_set_malicious = metadata and can_set_metadata and is_admin and changeset_revision == repository.tip can_reset_all_metadata = is_admin and len( repo ) > 0 + has_readme = metadata and 'readme' in metadata %><%! @@ -32,35 +33,6 @@ %><%inherit file="${inherit(context)}"/> -<%def name="stylesheets()"> - ${parent.stylesheets()} - ${h.css( "jquery.rating" )} - <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="javascripts()"> ${parent.javascripts()} ${h.js( "libs/jquery/jquery.rating" )} @@ -77,6 +49,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp='community' )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp='community' )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/preview_tools_in_changeset.mako --- a/templates/webapps/community/repository/preview_tools_in_changeset.mako +++ b/templates/webapps/community/repository/preview_tools_in_changeset.mako @@ -16,6 +16,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -27,35 +28,6 @@ %><%inherit file="${inherit(context)}"/> -<%def name="stylesheets()"> - ${parent.stylesheets()} - ${h.css( "jquery.rating" )} - <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="javascripts()"> ${parent.javascripts()} ${h.js( "libs/jquery/jquery.rating" )} @@ -67,6 +39,9 @@ <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revisions=changeset_revision )}">Install to local Galaxy</a></li><li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li><div popupmenu="repository-${repository.id}-popup"> + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp=webapp )}">View README</a> + %endif <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_categories', webapp=webapp )}">Browse valid repositories</a><a class="action-button" href="${h.url_for( controller='repository', action='find_tools', webapp=webapp )}">Search for valid tools</a><a class="action-button" href="${h.url_for( controller='repository', action='find_workflows', webapp=webapp )}">Search for workflows</a> diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/rate_repository.mako --- a/templates/webapps/community/repository/rate_repository.mako +++ b/templates/webapps/community/repository/rate_repository.mako @@ -19,6 +19,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -83,6 +84,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp='community' )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/tool_form.mako --- a/templates/webapps/community/repository/tool_form.mako +++ b/templates/webapps/community/repository/tool_form.mako @@ -21,6 +21,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><html> @@ -146,6 +147,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp=webapp )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp=webapp )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp=webapp )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/view_changelog.mako --- a/templates/webapps/community/repository/view_changelog.mako +++ b/templates/webapps/community/repository/view_changelog.mako @@ -18,6 +18,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -51,6 +52,9 @@ %else: <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp='community' )}">View README</a> + %endif %if can_rate: <a class="action-button" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ) )}">Rate repository</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/view_changeset.mako --- a/templates/webapps/community/repository/view_changeset.mako +++ b/templates/webapps/community/repository/view_changeset.mako @@ -19,6 +19,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -52,6 +53,9 @@ %else: <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp='community' )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/view_repository.mako --- a/templates/webapps/community/repository/view_repository.mako +++ b/templates/webapps/community/repository/view_repository.mako @@ -17,6 +17,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -28,35 +29,6 @@ %><%inherit file="${inherit(context)}"/> -<%def name="stylesheets()"> - ${parent.stylesheets()} - ${h.css( "jquery.rating" )} - <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="javascripts()"> ${parent.javascripts()} ${h.js( "libs/jquery/jquery.rating" )} @@ -74,6 +46,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp=webapp )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp=webapp )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp=webapp )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/view_tool_metadata.mako --- a/templates/webapps/community/repository/view_tool_metadata.mako +++ b/templates/webapps/community/repository/view_tool_metadata.mako @@ -20,6 +20,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -59,6 +60,9 @@ %if can_upload: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp=webapp )}">Upload files to repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp=webapp )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp=webapp )}">View change log</a> %endif diff -r f0eea6ef482453ccc3cc466917ae4ed93920666b -r c28c5f906c6bdbbe799cfcc559760f26029090ce templates/webapps/community/repository/view_workflow.mako --- a/templates/webapps/community/repository/view_workflow.mako +++ b/templates/webapps/community/repository/view_workflow.mako @@ -22,6 +22,7 @@ browse_label = 'Browse or delete repository tip files' else: browse_label = 'Browse repository tip files' + has_readme = metadata and 'readme' in metadata %><%! @@ -54,6 +55,9 @@ %else: <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, webapp='community' )}">View repository</a> %endif + %if has_readme: + <a class="action-button" href="${h.url_for( controller='repository', action='view_readme', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, webapp='community' )}">View README</a> + %endif %if can_view_change_log: <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ), webapp='community' )}">View change log</a> %endif 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.