details: http://www.bx.psu.edu/hg/galaxy/rev/4b7a92551151 changeset: 3232:4b7a92551151 user: jeremy goecks <jeremy.goecks@emory.edu> date: Wed Jan 13 13:19:25 2010 -0500 description: Bug fixes and refactoring for displaying semi-public and published items. All display templates are now based on a single template, /display_base.mako Also, all relevant controllers use the same action, list_published, to provide a list of published items. diffstat: lib/galaxy/web/controllers/history.py | 20 +- lib/galaxy/web/controllers/page.py | 2 +- lib/galaxy/web/controllers/workflow.py | 6 +- templates/display_base.mako | 171 ++++++++++++++++++++ templates/display_common.mako | 12 - templates/history/display.mako | 270 +++++++++++++++++++++++++++++++++ templates/history/list_public.mako | 23 -- templates/history/list_published.mako | 23 ++ templates/history/sharing.mako | 2 +- templates/history/view.mako | 127 +++++--------- templates/page/display.mako | 96 +---------- templates/tagging_common.mako | 2 +- templates/workflow/display.mako | 165 ++++--------------- templates/workflow/list_public.mako | 23 -- templates/workflow/list_published.mako | 23 ++ 15 files changed, 598 insertions(+), 367 deletions(-) diffs (1172 lines): diff -r b10ae696a0e9 -r 4b7a92551151 lib/galaxy/web/controllers/history.py --- a/lib/galaxy/web/controllers/history.py Wed Jan 13 10:24:30 2010 -0500 +++ b/lib/galaxy/web/controllers/history.py Wed Jan 13 13:19:25 2010 -0500 @@ -172,11 +172,11 @@ def apply_default_filter( self, trans, query, **kwargs ): return query.filter( model.HistoryUserShareAssociation.user == trans.user ) -class PublicHistoryListGrid( grids.Grid ): +class HistoryAllPublishedGrid( grids.Grid ): class NameURLColumn( PublicURLColumn, NameColumn ): pass - title = "Public Histories" + title = "Published Histories" model_class = model.History default_sort_key = "-update_time" default_filter = dict( public_url="All", username="All", tags="All" ) @@ -212,16 +212,16 @@ stored_list_grid = HistoryListGrid() shared_list_grid = SharedHistoryListGrid() - public_list_grid = PublicHistoryListGrid() + published_list_grid = HistoryAllPublishedGrid() @web.expose - def list_public( self, trans, **kwargs ): - grid = self.public_list_grid( trans, **kwargs ) + def list_published( self, trans, **kwargs ): + grid = self.published_list_grid( trans, **kwargs ) if 'async' in kwargs: return grid else: # Render grid wrapped in panels - return trans.fill_template( "history/list_public.mako", grid=grid ) + return trans.fill_template( "history/list_published.mako", grid=grid ) @web.expose @web.require_login( "work with multiple histories" ) @@ -555,12 +555,8 @@ .options( eagerload_all( "dataset.actions" ) ) # Do not show deleted datasets. query = query.filter( model.HistoryDatasetAssociation.deleted == False ) - user_owns_history = ( trans.get_user() == history.user ) - return trans.stream_template_mako( "history/view.mako", - history = history, - datasets = query.all(), - user_owns_history = user_owns_history, - show_deleted = False ) + return trans.stream_template_mako( "history/display.mako", + item = history, item_data = query.all() ) @web.expose @web.require_login( "share histories with other users" ) diff -r b10ae696a0e9 -r 4b7a92551151 lib/galaxy/web/controllers/page.py --- a/lib/galaxy/web/controllers/page.py Wed Jan 13 10:24:30 2010 -0500 +++ b/lib/galaxy/web/controllers/page.py Wed Jan 13 13:19:25 2010 -0500 @@ -321,7 +321,7 @@ page = trans.sa_session.query( model.Page ).filter_by( user=user, slug=slug, deleted=False, published=True ).first() if page is None: raise web.httpexceptions.HTTPNotFound() - return trans.fill_template( "page/display.mako", page=page ) + return trans.fill_template( "page/display.mako", item=page ) @web.expose @web.require_login("select a history from saved histories") diff -r b10ae696a0e9 -r 4b7a92551151 lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py Wed Jan 13 10:24:30 2010 -0500 +++ b/lib/galaxy/web/controllers/workflow.py Wed Jan 13 13:19:25 2010 -0500 @@ -145,13 +145,13 @@ shared_by_others = shared_by_others ) @web.expose - def list_public( self, trans, **kwargs ): + def list_published( self, trans, **kwargs ): grid = self.public_list_grid( trans, **kwargs ) if 'async' in kwargs: return grid else: # Render grid wrapped in panels - return trans.fill_template( "workflow/list_public.mako", grid=grid ) + return trans.fill_template( "workflow/list_published.mako", grid=grid ) @web.expose def display_by_username_and_slug( self, trans, username, slug ): @@ -187,7 +187,7 @@ # Connections by input name step.input_connections_by_name = dict( ( conn.input_name, conn ) for conn in step.input_connections ) - return trans.fill_template_mako( "workflow/display.mako", workflow = stored_workflow, steps = stored_workflow.latest_workflow.steps ) + return trans.fill_template_mako( "workflow/display.mako", item=stored_workflow, item_data=stored_workflow.latest_workflow.steps ) @web.expose @web.require_login( "use Galaxy workflows" ) diff -r b10ae696a0e9 -r 4b7a92551151 templates/display_base.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/display_base.mako Wed Jan 13 13:19:25 2010 -0500 @@ -0,0 +1,171 @@ +<%inherit file="/base_panels.mako"/> +<%namespace file="./tagging_common.mako" import="render_individual_tagging_element, render_community_tagging_element" /> + +<%! + from galaxy.model import History, StoredWorkflow, Page +%> + +<%def name="init()"> +<% + self.has_left_panel=False + self.has_right_panel=False + self.message_box_visible=False +%> +</%def> + +<%def name="javascripts()"> + ${parent.javascripts()} + ${h.js( "galaxy.base", "jquery", "json2", "jquery.autocomplete", "autocomplete_tagging" )} + + <script type="text/javascript"> + // + // Handle click on community tag. + // + function community_tag_click(tag_name, tag_value) + { + <% controller_name = get_controller_name( item ) %> + var href = '${h.url_for ( controller='/' + controller_name , action='list_published')}'; + href = href + "?f-tags=" + tag_name; + if (tag_value != null && tag_value != "") + href = href + ":" + tag_value; + self.location = href; + } + </script> +</%def> + +<%def name="stylesheets()"> + ${parent.stylesheets()} + ${h.css( "autocomplete_tagging" )} + <style type="text/css"> + .page-body + { + padding: 10px; + float: left; + width: 65%; + } + .page-meta + { + float: right; + width: 27%; + padding: 0.5em; + margin: 0.25em; + vertical-align: text-top; + border: 2px solid #DDDDDD; + border-top: 4px solid #DDDDDD; + } + </style> +</%def> + +<%def name="render_item_links( item )"> + Item Links +</%def> + +<%def name="render_item( item, item_data=None )"> + Item +</%def> + +<%def name="get_item_name( item )"> + <% return item.name %> +</%def> + + +## +## Page content. Pages that inherit this page should override render_item_links() and render_item() +## +<%def name="center_panel()"> + + ## Get URL to other published items owned by user that owns this item. + <% + ##TODO: is there a better way to create this URL? Can't use 'f-username' as a key b/c it's not a valid identifier. + controller_name = get_controller_name( item ) + item_plural = get_item_plural( item ) + href_to_all_items = h.url_for( controller='/' + controller_name, action='list_published') + href_to_user_items = h.url_for( controller='/' + controller_name, action='list_published', xxx=item.user.username) + href_to_user_items = href_to_user_items.replace( 'xxx', 'f-username') + %> + + <div class="unified-panel-header" unselectable="on"> + <div class="unified-panel-header-inner"> + <a href="${href_to_all_items}">Published ${item_plural}</a> | + <a href="${href_to_user_items}">${item.user.username}</a> | ${self.get_item_name( item )} + </div> + </div> + + <div class="unified-panel-body"> + <div style="overflow: auto; height: 100%;"> + <div class="page-body"> + <div style="padding: 0px 0px 5px 0px"> + ${self.render_item_links( item )} + </div> + + ${self.render_item( item, item_data )} + </div> + + <div class="page-meta"> + ## Page meta. + <div><strong>Related ${item_plural}</strong></div> + <p> + <a href="${href_to_all_items}">All published ${item_plural.lower()}</a><br> + <a href="${href_to_user_items}">${item_plural} owned by ${item.user.username}</a> + + ## Tags. + <div><strong>Tags</strong></div> + <p> + ## Community tags. + <div> + Community: + ${render_community_tagging_element( tagged_item=item, tag_click_fn='community_tag_click', use_toggle_link=False )} + %if len ( item.tags ) == 0: + none + %endif + </div> + ## Individual tags. + <p> + <div> + Yours: + ${render_individual_tagging_element( user=trans.get_user(), tagged_item=item, elt_context='view.mako', use_toggle_link=False, tag_click_fn='community_tag_click' )} + </div> + </div> + </div> + </div> +</%def> + + +## +## Utility methods. +## + +## Get plural term for item. +<%def name="get_item_plural( item )"> + <% + items_plural = "items" + if isinstance( item, History ): + items_plural = "Histories" + elif isinstance( item, StoredWorkflow ): + items_plural = "Workflows" + elif isinstance( item, Page ): + items_plural = "Pages" + return items_plural + %> +</%def> + +## Returns the controller name for an item based on its class. +<%def name="get_controller_name( item )"> + <% + if isinstance( item, History ): + return "history" + elif isinstance( item, StoredWorkflow ): + return "workflow" + elif isinstance( item, Page ): + return "page" + %> +</%def> + +## Return a link to view a history. +<%def name="get_history_link( history, qualify=False )"> + %if history.slug and history.user.username: + <% return h.url_for( controller='/history', action='display_by_username_and_slug', username=history.user.username, slug=history.slug, qualified=qualify ) %> + %else: + <% return h.url_for( controller='/history', action='view', id=trans.security.encode_id( history.id ), qualified=qualify ) %> + %endif +</%def> \ No newline at end of file diff -r b10ae696a0e9 -r 4b7a92551151 templates/display_common.mako --- a/templates/display_common.mako Wed Jan 13 10:24:30 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -## -## A set of useful methods for displaying different items. -## - -## Return a link to view a history. -<%def name="get_history_link( history, qualify=False )"> - %if history.slug and history.user.username: - <% return h.url_for( controller='/history', action='display_by_username_and_slug', username=history.user.username, slug=history.slug, qualified=qualify ) %> - %else: - <% return h.url_for( controller='/history', action='view', id=trans.security.encode_id( history.id ), qualified=qualify ) %> - %endif -</%def> \ No newline at end of file diff -r b10ae696a0e9 -r 4b7a92551151 templates/history/display.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/history/display.mako Wed Jan 13 13:19:25 2010 -0500 @@ -0,0 +1,270 @@ +<%inherit file="/display_base.mako"/> +<%namespace file="/root/history_common.mako" import="render_dataset" /> + +<%def name="javascripts()"> + ${parent.javascripts()} + ${h.js( "jquery.jstore-all" )} + + ## Set vars so that there's no need to change the code below. + <% + history = published_item + datasets = published_item_data + %> + + <script type="text/javascript"> + $(function() { + // Load jStore for local storage + $.extend(jQuery.jStore.defaults, { project: 'galaxy', flash: '/static/jStore.Flash.html' }) + $.jStore.load(); // Auto-select best storage + + $.jStore.ready(function(engine) { + engine.ready(function() { + // Init stuff that requires the local storage to be running + initShowHide(); + setupHistoryItem( $("div.historyItemWrapper") ); + }); + }); + + // Generate 'collapse all' link + $("#top-links").append( "| " ).append( $("<a href='#'>${_('collapse all')}</a>").click( function() { + $( "div.historyItemBody:visible" ).each( function() { + if ( $.browser.mozilla ) { + $(this).find( "pre.peek" ).css( "overflow", "hidden" ); + } + $(this).slideUp( "fast" ); + }); + $.jStore.remove("history_expand_state"); + })); + + }); + // Functionized so AJAX'd datasets can call them + function initShowHide() { + + // Load saved state and show as necessary + try { + var stored = $.jStore.store("history_expand_state"); + if (stored) { + var st = JSON.parse(stored); + for (var id in st) { + $("#" + id + " div.historyItemBody" ).show(); + } + } + } catch(err) { + // Something was wrong with values in storage, so clear storage + $.jStore.remove("history_expand_state"); + } + + // If Mozilla, hide scrollbars in hidden items since they cause animation bugs + if ( $.browser.mozilla ) { + $( "div.historyItemBody" ).each( function() { + if ( ! $(this).is( ":visible" ) ) $(this).find( "pre.peek" ).css( "overflow", "hidden" ); + }) + } + } + // Add show/hide link and delete link to a history item + function setupHistoryItem( query ) { + query.each( function() { + var id = this.id; + var body = $(this).children( "div.historyItemBody" ); + var peek = body.find( "pre.peek" ) + $(this).children( ".historyItemTitleBar" ).find( ".historyItemTitle" ).wrap( "<a href='#'></a>" ).click( function() { + if ( body.is(":visible") ) { + // Hiding stuff here + if ( $.browser.mozilla ) { peek.css( "overflow", "hidden" ) } + body.slideUp( "fast" ); + + // Save setting + var stored = $.jStore.store("history_expand_state") + var prefs = stored ? JSON.parse(stored) : null + if (prefs) { + delete prefs[id]; + $.jStore.store("history_expand_state", JSON.stringify(prefs)); + } + } else { + // Showing stuff here + body.slideDown( "fast", function() { + if ( $.browser.mozilla ) { peek.css( "overflow", "auto" ); } + }); + + // Save setting + var stored = $.jStore.store("history_expand_state") + var prefs = stored ? JSON.parse(stored) : new Object; + prefs[id] = true; + $.jStore.store("history_expand_state", JSON.stringify(prefs)); + } + return false; + }); + // Delete link + $(this).find( "div.historyItemButtons > .delete" ).each( function() { + var data_id = this.id.split( "-" )[1]; + $(this).click( function() { + $( '#historyItem-' + data_id + "> div.historyItemTitleBar" ).addClass( "spinner" ); + $.ajax({ + url: "${h.url_for( action='delete_async', id='XXX' )}".replace( 'XXX', data_id ), + error: function() { alert( "Delete failed" ) }, + success: function() { + %if show_deleted: + var to_update = {}; + to_update[data_id] = "none"; + updater( to_update ); + %else: + $( "#historyItem-" + data_id ).fadeOut( "fast", function() { + $( "#historyItemContainer-" + data_id ).remove(); + if ( $( "div.historyItemContainer" ).length < 1 ) { + $( "#emptyHistoryMessage" ).show(); + } + }); + %endif + } + }); + return false; + }); + }); + // Undelete link + $(this).find( "a.historyItemUndelete" ).each( function() { + var data_id = this.id.split( "-" )[1]; + $(this).click( function() { + $( '#historyItem-' + data_id + " > div.historyItemTitleBar" ).addClass( "spinner" ); + $.ajax({ + url: "${h.url_for( controller='dataset', action='undelete_async', id='XXX' )}".replace( 'XXX', data_id ), + error: function() { alert( "Undelete failed" ) }, + success: function() { + var to_update = {}; + to_update[data_id] = "none"; + updater( to_update ); + } + }); + return false; + }); + }); + }); + }; + // Looks for changes in dataset state using an async request. Keeps + // calling itself (via setTimeout) until all datasets are in a terminal + // state. + var updater = function ( tracked_datasets ) { + // Check if there are any items left to track + var empty = true; + for ( i in tracked_datasets ) { + empty = false; + break; + } + if ( ! empty ) { + // console.log( "Updater running in 3 seconds" ); + setTimeout( function() { updater_callback( tracked_datasets ) }, 3000 ); + } else { + // console.log( "Updater finished" ); + } + }; + var updater_callback = function ( tracked_datasets ) { + // Build request data + var ids = [] + var states = [] + var force_history_refresh = false + $.each( tracked_datasets, function ( id, state ) { + ids.push( id ); + states.push( state ); + }); + // Make ajax call + $.ajax( { + type: "POST", + url: "${h.url_for( controller='root', action='history_item_updates' )}", + dataType: "json", + data: { ids: ids.join( "," ), states: states.join( "," ) }, + success : function ( data ) { + $.each( data, function( id, val ) { + // Replace HTML + var container = $("#historyItemContainer-" + id); + container.html( val.html ); + setupHistoryItem( container.children( ".historyItemWrapper" ) ); + initShowHide(); + // If new state was terminal, stop tracking + if (( val.state == "ok") || ( val.state == "error") || ( val.state == "empty") || ( val.state == "deleted" ) || ( val.state == "discarded" )) { + if ( val.force_history_refresh ){ + force_history_refresh = true; + } + delete tracked_datasets[ parseInt(id) ]; + } else { + tracked_datasets[ parseInt(id) ] = val.state; + } + }); + if ( force_history_refresh ) { + parent.frames.galaxy_history.location.reload(); + } else { + // Keep going (if there are still any items to track) + updater( tracked_datasets ); + } + }, + error: function() { + // Just retry, like the old method, should try to be smarter + updater( tracked_datasets ); + } + }); + }; + </script> +</%def> + +<%def name="stylesheets()"> + ${parent.stylesheets()} + ${h.css( "history" )} + <style type="text/css"> + .visible-right-border { + padding-right: 3px; + border-right-style: solid; + border-right-color: #66AA66; + } + .historyItemBody { + display: none; + } + </style> + + <noscript> + <style> + .historyItemBody { + display: block; + } + </style> + </noscript> +</%def> + +<%def name="render_item_links( history )"> + %if history.user != trans.get_user(): + <a href="${h.url_for( controller='/history', action='imp', id=trans.security.encode_id(history.id) )}">import and start using history</a> | + %else: + your history | + %endif + <a href="${self.get_history_link( history )}">${_('refresh')}</a> + %if show_deleted: + | <a href="${h.url_for('history', show_deleted=False)}">${_('hide deleted')}</a> + %endif +</%def> + +<%def name="render_item( history, datasets )"> + <div id="history-name-area" class="historyLinks" style="color: gray; font-weight: bold; padding: 0px 0px 5px 0px"> + <div id="history-name">${history.get_display_name()}</div> + </div> + + %if history.deleted: + <div class="warningmessagesmall"> + ${_('You are currently viewing a deleted history!')} + </div> + <p></p> + %endif + + %if not datasets: + <div class="infomessagesmall" id="emptyHistoryMessage"> + %else: + ## Render requested datasets, ordered from newest to oldest + %for data in datasets: + %if data.visible: + <div class="historyItemContainer visible-right-border" id="historyItemContainer-${data.id}"> + ${render_dataset( data, data.hid, show_deleted_on_refresh = show_deleted, user_owns_dataset=user_owns_history )} + </div> + %endif + %endfor + <div class="infomessagesmall" id="emptyHistoryMessage" style="display:none;"> + %endif + ${_("Your history is empty. Click 'Get Data' on the left pane to start")} + </div> + +</%def> \ No newline at end of file diff -r b10ae696a0e9 -r 4b7a92551151 templates/history/list_public.mako --- a/templates/history/list_public.mako Wed Jan 13 10:24:30 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="init()"> -<% - self.has_left_panel=False - self.has_right_panel=False - self.active_view="page" - self.message_box_visible=False -%> -</%def> - -<%def name="center_panel()"> - - ## <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${h.url_for( controller="page", action="list" )}"> </iframe> - - <div style="overflow: auto; height: 100%;"> - <div class="page-container" style="padding: 10px;"> - ${unicode( grid, 'utf-8' )} - </div> - </div> - - -</%def> diff -r b10ae696a0e9 -r 4b7a92551151 templates/history/list_published.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/history/list_published.mako Wed Jan 13 13:19:25 2010 -0500 @@ -0,0 +1,23 @@ +<%inherit file="/base_panels.mako"/> + +<%def name="init()"> +<% + self.has_left_panel=False + self.has_right_panel=False + self.active_view="page" + self.message_box_visible=False +%> +</%def> + +<%def name="center_panel()"> + + ## <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${h.url_for( controller="page", action="list" )}"> </iframe> + + <div style="overflow: auto; height: 100%;"> + <div class="page-container" style="padding: 10px;"> + ${unicode( grid, 'utf-8' )} + </div> + </div> + + +</%def> diff -r b10ae696a0e9 -r 4b7a92551151 templates/history/sharing.mako --- a/templates/history/sharing.mako Wed Jan 13 10:24:30 2010 -0500 +++ b/templates/history/sharing.mako Wed Jan 13 13:19:25 2010 -0500 @@ -1,6 +1,6 @@ <%inherit file="/base.mako"/> <%namespace file="/message.mako" import="render_msg" /> -<%namespace file="/display_common.mako" import="get_history_link" /> +<%namespace file="/display_base.mako" import="get_history_link" /> ##<h2>Import via link</h2> diff -r b10ae696a0e9 -r 4b7a92551151 templates/history/view.mako --- a/templates/history/view.mako Wed Jan 13 10:24:30 2010 -0500 +++ b/templates/history/view.mako Wed Jan 13 13:19:25 2010 -0500 @@ -1,7 +1,7 @@ <%inherit file="/base_panels.mako"/> -<%namespace file="/display_common.mako" import="get_history_link" /> +<%namespace file="/display_base.mako" import="get_history_link, get_controller_name" /> <%namespace file="/root/history_common.mako" import="render_dataset" /> -<%namespace file="../tagging_common.mako" import="render_individual_tagging_element, render_community_tagging_element" /> +<%namespace file="/tagging_common.mako" import="render_individual_tagging_element, render_community_tagging_element" /> <%def name="javascripts()"> ${parent.javascripts()} @@ -256,7 +256,7 @@ // function community_tag_click(tag_name, tag_value) { - var href = '${h.url_for( controller='/history', action='list_public')}'; + var href = '${h.url_for( controller='/history', action='list_published')}'; href = href + "?f-tags=" + tag_name; if (tag_value != null && tag_value != "") href = href + ":" + tag_value; @@ -324,91 +324,60 @@ ## Get URL to other histories owned by user that owns this history. <% ##TODO: is there a better way to create this URL? Can't use 'f-username' as a key b/c it's not a valid identifier. - href_to_user_histories = h.url_for( controller='/history', action='list_public', xxx=history.user.username) + href_to_published_histories = h.url_for( controller='/history', action='list_published') + href_to_user_histories = h.url_for( controller='/history', action='list_published', xxx=history.user.username) href_to_user_histories = href_to_user_histories.replace( 'xxx', 'f-username') %> <div class="unified-panel-header" unselectable="on"> - <div class="unified-panel-header-inner"> - <a href="${h.url_for ( controller='/history', action='list_public' )}">Public Histories</a> | - <a href="${href_to_user_histories}">${history.user.username}</a> | ${history.name} - </div> </div> <div class="unified-panel-body"> - <div style="overflow: auto; height: 100%;"> - <div class="page-body"> - ## Render view of history. - <div id="top-links" class="historyLinks" style="padding: 0px 0px 5px 0px"> - %if not user_owns_history: - <a href="${h.url_for( controller='history', action='imp', id=trans.security.encode_id(history.id) )}">import and start using history</a> | + <div style="overflow: auto; height: 100%;"> + ## Render view of history. + <div id="top-links" class="historyLinks" style="padding: 0px 0px 5px 0px"> + %if not user_owns_history: + <a href="${h.url_for( action='imp', id=trans.security.encode_id(history.id) )}">import and start using history</a> | + %endif + <a href="${get_history_link( history )}">${_('refresh')}</a> + %if show_deleted: + | <a href="${h.url_for('history', show_deleted=False)}">${_('hide deleted')}</a> + %endif + </div> + + <div id="history-name-area" class="historyLinks" style="color: gray; font-weight: bold; padding: 0px 0px 5px 0px"> + %if user_owns_history: + <div style="float: right"><a id="history-rename" title="Rename" class="icon-button edit" target="galaxy_main" href="${h.url_for( controller='history', action='rename' )}"></a></div> + %endif + <div id="history-name">${history.get_display_name()}</div> + </div> + + %if history.deleted: + <div class="warningmessagesmall"> + ${_('You are currently viewing a deleted history!')} + </div> + <p></p> + %endif + + %if not datasets: + + <div class="infomessagesmall" id="emptyHistoryMessage"> + + %else: + + ## Render requested datasets, ordered from newest to oldest + %for data in datasets: + %if data.visible: + <div class="historyItemContainer visible-right-border" id="historyItemContainer-${data.id}"> + ${render_dataset( data, data.hid, show_deleted_on_refresh = show_deleted, user_owns_dataset=user_owns_history )} + </div> %endif - <a href="${get_history_link( history )}">${_('refresh')}</a> - %if show_deleted: - | <a href="${h.url_for('history', show_deleted=False)}">${_('hide deleted')}</a> - %endif + %endfor + + <div class="infomessagesmall" id="emptyHistoryMessage" style="display:none;"> + %endif + ${_("Your history is empty. Click 'Get Data' on the left pane to start")} </div> - - <div id="history-name-area" class="historyLinks" style="color: gray; font-weight: bold; padding: 0px 0px 5px 0px"> - %if user_owns_history: - <div style="float: right"><a id="history-rename" title="Rename" class="icon-button edit" target="galaxy_main" href="${h.url_for( controller='history', action='rename' )}"></a></div> - %endif - <div id="history-name">${history.get_display_name()}</div> - </div> - - %if history.deleted: - <div class="warningmessagesmall"> - ${_('You are currently viewing a deleted history!')} - </div> - <p></p> - %endif - - %if not datasets: - - <div class="infomessagesmall" id="emptyHistoryMessage"> - - %else: - - ## Render requested datasets, ordered from newest to oldest - %for data in datasets: - %if data.visible: - <div class="historyItemContainer visible-right-border" id="historyItemContainer-${data.id}"> - ${render_dataset( data, data.hid, show_deleted_on_refresh = show_deleted, user_owns_dataset=user_owns_history )} - </div> - %endif - %endfor - - <div class="infomessagesmall" id="emptyHistoryMessage" style="display:none;"> - %endif - ${_("Your history is empty. Click 'Get Data' on the left pane to start")} - </div> - </div> - - <div class="page-meta"> - ## Histories. - <div><strong>Related Histories</strong></div> - <p> - <a href="${h.url_for ( controller='/history', action='list_public' )}">All public histories</a><br> - <a href="${href_to_user_histories}">Histories owned by ${history.user.username}</a> - - ## Tags. - <div><strong>Tags</strong></div> - <p> - ## Community tags. - <div> - Community: - ${render_community_tagging_element( tagged_item=history, tag_click_fn='community_tag_click', use_toggle_link=False )} - %if len ( history.tags ) == 0: - none - %endif - </div> - ## Individual tags. - <p> - <div> - Yours: - ${render_individual_tagging_element( user=trans.get_user(), tagged_item=history, elt_context='view.mako', use_toggle_link=False )} - </div> - </div> </div> </div> </%def> diff -r b10ae696a0e9 -r 4b7a92551151 templates/page/display.mako --- a/templates/page/display.mako Wed Jan 13 10:24:30 2010 -0500 +++ b/templates/page/display.mako Wed Jan 13 13:19:25 2010 -0500 @@ -1,6 +1,9 @@ -<%inherit file="/base_panels.mako"/> +<%inherit file="/display_base.mako"/> -<%def name="title()">Galaxy :: ${page.user.username} :: ${page.title}</%def> +<%def name="title()"> + <% page = item %> + Galaxy :: ${page.user.username} :: ${page.title} +</%def> <%def name="javascripts()"> ${parent.javascripts()} @@ -144,43 +147,12 @@ count++; return count; }; - - // - // Handle click on community tag. - // - function community_tag_click(tag_name, tag_value) - { - // Do nothing until community tags implemented in published pages grid. - var href = '${h.url_for( controller='/page', action='list_published')}'; - href = href + "?f-tags=" + tag_name; - if (tag_value != null && tag_value != "") - href = href + ":" + tag_value; - self.location = href; - } </script> </%def> <%def name="stylesheets()"> ${parent.stylesheets()} ${h.css( "base", "history", "autocomplete_tagging" )} - <style> - .page-body - { - padding: 10px; - float: left; - width: 65%; - } - .page-meta - { - float: right; - width: 27%; - padding: 0.5em; - margin: 0.25em; - vertical-align: text-top; - border: 2px solid #DDDDDD; - border-top: 4px solid #DDDDDD; - } - </style> </%def> <%def name="init()"> @@ -192,55 +164,13 @@ %> </%def> -<%namespace file="../tagging_common.mako" import="render_individual_tagging_element, render_community_tagging_element" /> +<%def name="get_item_name( page )"> + <% return page.title %> +</%def> -<%def name="center_panel()"> +<%def name="render_item_links( page )"> +</%def> - ## Get URL to other pages owned by user that owns this page. - <% - ##TODO: is there a better way to create this URL? Can't use 'f-username' as a key b/c it's not a valid identifier. - href_to_user_pages = h.url_for( controller='/page', action='list_published', xxx=page.user.username) - href_to_user_pages = href_to_user_pages.replace( 'xxx', 'f-username') - %> - - <div class="unified-panel-header" unselectable="on"> - <div class="unified-panel-header-inner"> - <a href="${h.url_for ( controller='/page', action='list_published' )}">Published Pages</a> | - <a href="${href_to_user_pages}">${page.user.username}</a> | ${page.title} - </div> - </div> - - <div class="unified-panel-body"> - <div style="overflow: auto; height: 100%;"> - <div class="page text-content page-body"> - ${page.latest_revision.content.decode( "utf-8" )} - </div> - <div class="page-meta"> - ## Pages. - <div><strong>Related Pages</strong></div> - <p> - <a href="${h.url_for ( controller='/page', action='list_published' )}">All published pages</a><br> - <a href="${href_to_user_pages}">Pages published by ${page.user.username}</a> - - ## Tags. - <div><strong>Tags</strong></div> - <p> - ## Community tags. - <div> - Community: - ${render_community_tagging_element( tagged_item=page, tag_click_fn='community_tag_click', use_toggle_link=False )} - %if len ( page.tags ) == 0: - none - %endif - </div> - ## User tags. - <p> - <div> - Yours: - ${render_individual_tagging_element( tagged_item=page, elt_context='display.mako', use_toggle_link=False )} - </div> - </div> - </div> - </div> - -</%def> +<%def name="render_item( page, page_data=None )"> + ${page.latest_revision.content.decode( "utf-8" )} +</%def> \ No newline at end of file diff -r b10ae696a0e9 -r 4b7a92551151 templates/tagging_common.mako --- a/templates/tagging_common.mako Wed Jan 13 10:24:30 2010 -0500 +++ b/templates/tagging_common.mako Wed Jan 13 13:19:25 2010 -0500 @@ -76,7 +76,7 @@ %if in_form: <textarea class="tag-input" rows='1' cols='${input_size}'></textarea> %else: - <input class="tag-input" type='text' size='${input_size}'></input> + <input class="tag-input" type='text' size='${input_size}'/> %endif ## Add "add tag" button. <img src='${h.url_for('/static/images/add_icon.png')}' rollover='${h.url_for('/static/images/add_icon_dark.png')}' class="add-tag-button"/> diff -r b10ae696a0e9 -r 4b7a92551151 templates/workflow/display.mako --- a/templates/workflow/display.mako Wed Jan 13 10:24:30 2010 -0500 +++ b/templates/workflow/display.mako Wed Jan 13 13:19:25 2010 -0500 @@ -1,68 +1,16 @@ -<%inherit file="/base_panels.mako"/> -<%namespace file="/display_common.mako" import="get_history_link" /> -<%namespace file="../tagging_common.mako" import="render_individual_tagging_element, render_community_tagging_element" /> +<%inherit file="/display_base.mako"/> -<%! from galaxy.tools.parameters import DataToolParameter %> - -<%def name="javascripts()"> - ${parent.javascripts()} - ${h.js( "galaxy.base", "jquery", "json2", "jquery.autocomplete", "autocomplete_tagging" )} - - <script type="text/javascript"> - // - // Handle click on community tag. - // - function community_tag_click(tag_name, tag_value) - { - var href = '${h.url_for( controller='/workflow', action='list_public')}'; - href = href + "?f-tags=" + tag_name; - if (tag_value != null && tag_value != "") - href = href + ":" + tag_value; - self.location = href; - } - </script> -</%def> +<%! from galaxy.tools.parameters import DataToolParameter, RuntimeValue %> <%def name="stylesheets()"> ${parent.stylesheets()} - ${h.css( "workflow", "autocomplete_tagging" )} + ${h.css( "workflow" )} <style type="text/css"> - .page-body - { - padding: 10px; - float: left; - width: 65%; - } - .page-meta - { - float: right; - width: 27%; - padding: 0.5em; - margin: 0.25em; - vertical-align: text-top; - border: 2px solid #DDDDDD; - border-top: 4px solid #DDDDDD; - } div.toolForm{ margin-top: 10px; margin-bottom: 10px; } </style> - <noscript> - <style> - .historyItemBody { - display: block; - } - </style> - </noscript> -</%def> - -<%def name="init()"> -<% - self.has_left_panel=False - self.has_right_panel=False - self.message_box_visible=False -%> </%def> <%def name="do_inputs( inputs, values, prefix, step, other_values=None )"> @@ -107,8 +55,10 @@ ## FIXME: Initialize in the controller <% if value is None: + other_values = {} value = other_values[ param.name ] = param.get_initial_value( t, other_values ) %> + <% print param.__class__ %> ${param.get_html_field( t, value, other_values ).get_html( str(step.id) + "|" + prefix )} %endif %else: @@ -118,78 +68,35 @@ </div> </%def> -<%def name="center_panel()"> - ## Get URL to other workflows owned by user that owns this workflow. - <% - ##TODO: is there a better way to create this URL? Can't use 'f-username' as a key b/c it's not a valid identifier. - href_to_user_workflows = h.url_for( action='list_public', xxx=workflow.user.username ) - href_to_user_workflows = href_to_user_workflows.replace( 'xxx', 'f-username' ) - %> - - <div class="unified-panel-header" unselectable="on"> - <div class="unified-panel-header-inner"> - <a href="${h.url_for ( action='list_public' )}">Public Workflows</a> | - <a href="${href_to_user_workflows}">${workflow.user.username}</a> | ${workflow.name} - </div> - </div> - - <div class="unified-panel-body"> - <div style="overflow: auto; height: 100%;"> - <div class="page-body"> - ## Render top links. - <div id="top-links" style="padding: 0px 0px 5px 0px"> - %if workflow.user != trans.get_user(): - <a href="${h.url_for( action='imp', id=trans.security.encode_id(workflow.id) )}">import and start using workflow</a> - %endif - </div> - - ## Render Workflow. - <h2>${workflow.name}</h2> - %for i, step in enumerate( steps ): - %if step.type == 'tool' or step.type is None: - <% tool = app.toolbox.tools_by_id[step.tool_id] %> - <div class="toolForm"> - <div class="toolFormTitle">Step ${int(step.order_index)+1}: ${tool.name}</div> - <div class="toolFormBody"> - ${do_inputs( tool.inputs, step.state.inputs, "", step )} - </div> - </div> - %else: - <% module = step.module %> - <div class="toolForm"> - <div class="toolFormTitle">Step ${int(step.order_index)+1}: ${module.name}</div> - <div class="toolFormBody"> - </div> - </div> - %endif - %endfor - </div> - - <div class="page-meta"> - ## Workflows. - <div><strong>Related Workflows</strong></div> - <p> - <a href="${h.url_for ( action='list_public' )}">All public workflows</a><br> - <a href="${href_to_user_workflows}">Workflows owned by ${workflow.user.username}</a> - - ## Tags. - <div><strong>Tags</strong></div> - <p> - ## Community tags. - <div> - Community: - ${render_community_tagging_element( tagged_item=workflow, tag_click_fn='community_tag_click', use_toggle_link=False )} - %if len ( workflow.tags ) == 0: - none - %endif - </div> - ## Individual tags. - <p> - <div> - Yours: - ${render_individual_tagging_element( user=trans.get_user(), tagged_item=workflow, elt_context='view.mako', use_toggle_link=False )} - </div> - </div> - </div> - </div> + +<%def name="render_item_links( workflow )"> + %if workflow.user != trans.get_user(): + <a href="${h.url_for( controller='/workflow', action='imp', id=trans.security.encode_id(workflow.id) )}">import and start using workflow</a> + %else: + you own this workflow + %endif </%def> + +<%def name="render_item( workflow, steps )"> + <h2>${workflow.name}</h2> + %for i, step in enumerate( steps ): + %if step.type == 'tool' or step.type is None: + <% tool = app.toolbox.tools_by_id[step.tool_id] %> + <div class="toolForm"> + <div class="toolFormTitle">Step ${int(step.order_index)+1}: ${tool.name}</div> + <div class="toolFormBody"> + ${do_inputs( tool.inputs, step.state.inputs, "", step )} + </div> + </div> + %else: + <% module = step.module %> + <div class="toolForm"> + <div class="toolFormTitle">Step ${int(step.order_index)+1}: ${module.name}</div> + <div class="toolFormBody"> + ##Need to do more work to print only dataset label and not combo box as well. + ##${do_inputs( module.get_runtime_inputs(), step.state.inputs, "", step )} + </div> + </div> + %endif + %endfor +</%def> \ No newline at end of file diff -r b10ae696a0e9 -r 4b7a92551151 templates/workflow/list_public.mako --- a/templates/workflow/list_public.mako Wed Jan 13 10:24:30 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="init()"> -<% - self.has_left_panel=False - self.has_right_panel=False - self.active_view="page" - self.message_box_visible=False -%> -</%def> - -<%def name="center_panel()"> - - ## <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${h.url_for( controller="page", action="list" )}"> </iframe> - - <div style="overflow: auto; height: 100%;"> - <div class="page-container" style="padding: 10px;"> - ${unicode( grid, 'utf-8' )} - </div> - </div> - - -</%def> diff -r b10ae696a0e9 -r 4b7a92551151 templates/workflow/list_published.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/workflow/list_published.mako Wed Jan 13 13:19:25 2010 -0500 @@ -0,0 +1,23 @@ +<%inherit file="/base_panels.mako"/> + +<%def name="init()"> +<% + self.has_left_panel=False + self.has_right_panel=False + self.active_view="page" + self.message_box_visible=False +%> +</%def> + +<%def name="center_panel()"> + + ## <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${h.url_for( controller="page", action="list" )}"> </iframe> + + <div style="overflow: auto; height: 100%;"> + <div class="page-container" style="padding: 10px;"> + ${unicode( grid, 'utf-8' )} + </div> + </div> + + +</%def>