[hg] galaxy 1590: Convert tool_form/tool_executed to mako (for p...
details: http://www.bx.psu.edu/hg/galaxy/rev/7e94f40ee9e8 changeset: 1590:7e94f40ee9e8 user: James Taylor <james@jamestaylor.org> date: Thu Oct 30 17:34:46 2008 -0400 description: Convert tool_form/tool_executed to mako (for performance) 5 file(s) affected in this change: lib/galaxy/tools/__init__.py templates/tool_executed.mako templates/tool_executed.tmpl templates/tool_form.mako templates/tool_form.tmpl diffs (573 lines): diff -r 1d113c5386da -r 7e94f40ee9e8 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Thu Oct 30 16:17:46 2008 -0400 +++ b/lib/galaxy/tools/__init__.py Thu Oct 30 17:34:46 2008 -0400 @@ -676,7 +676,7 @@ # on the standard run form) or "URL" (a parameter provided by # external data source tools). if "runtool_btn" not in incoming and "URL" not in incoming: - return "tool_form.tmpl", dict( errors={}, tool_state=state, param_values={}, incoming={} ) + return "tool_form.mako", dict( errors={}, tool_state=state, param_values={}, incoming={} ) # Process incoming data if not( self.check_values ): # If `self.check_values` is false we don't do any checking or @@ -702,20 +702,20 @@ # error messages if errors: error_message = "One or more errors were found in the input you provided. The specific errors are marked below." - return "tool_form.tmpl", dict( errors=errors, tool_state=state, incoming=incoming, error_message=error_message ) + return "tool_form.mako", dict( errors=errors, tool_state=state, incoming=incoming, error_message=error_message ) # If we've completed the last page we can execute the tool elif state.page == self.last_page: out_data = self.execute( trans, incoming=params ) - return 'tool_executed.tmpl', dict( out_data=out_data ) + return 'tool_executed.mako', dict( out_data=out_data ) # Otherwise move on to the next page else: state.page += 1 # Fill in the default values for the next page self.fill_in_new_state( trans, self.inputs_by_page[ state.page ], state.inputs ) - return 'tool_form.tmpl', dict( errors=errors, tool_state=state ) + return 'tool_form.mako', dict( errors=errors, tool_state=state ) else: # Just a refresh, render the form with updated state and errors. - return 'tool_form.tmpl', dict( errors=errors, tool_state=state ) + return 'tool_form.mako', dict( errors=errors, tool_state=state ) def update_state( self, trans, inputs, state, incoming, prefix="", context=None, update_only=False, old_errors={}, changed_dependencies={} ): diff -r 1d113c5386da -r 7e94f40ee9e8 templates/tool_executed.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/tool_executed.mako Thu Oct 30 17:34:46 2008 -0400 @@ -0,0 +1,63 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + +<head> +<title>Galaxy</title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> +<link href="${h.url_for('/static/style/base.css')}" rel="stylesheet" type="text/css" /> +<script type="text/javascript"> + var inside_galaxy_frameset = false; + + if ( parent.frames && parent.frames.galaxy_history ) { + parent.frames.galaxy_history.location.href="${h.url_for( controller='root', action='history' )}"; + inside_galaxy_frameset = true; + } + + if ( parent.handle_minwidth_hint ) { + parent.handle_minwidth_hint( -1 ); + } + + function main() { + // If called from outside the galaxy frameset, redirect there + %if tool.options.refresh: + if ( ! inside_galaxy_frameset ) { + setTimeout( "refresh()", 1000 ); + document.getElementById( "refresh_message" ).style.display = "block"; + } + %endif + } + + function refresh() { + top.location.href = '${request.base}'; + } + +</script> + +</head> + +<body onLoad="main()"> + +<div class="donemessage"> + +<p>The following job has been succesfully added to the queue:</p> + +%for data in out_data.values(): + <div style="padding: 10px"><b> ${data.hid}: ${data.name}</b></div> +%endfor + +<p> +You can check the status of queued jobs and view the resulting +data by refreshing the <b>History</b> pane. When the job has been run +the status will change from 'running' to 'finished' if completed +succesfully or 'error' if problems were encountered. +</p> + +%if tool.options.refresh: +<p id="refresh_message" style="display: none;">You are now being redirected back to <a href="${request.base}">Galaxy</a></div> +%endif + +</div> + +</body> + +</html> \ No newline at end of file diff -r 1d113c5386da -r 7e94f40ee9e8 templates/tool_executed.tmpl --- a/templates/tool_executed.tmpl Thu Oct 30 16:17:46 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> - -<head> -<title>Galaxy</title> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> -<link href="$h.url_for('/static/style/base.css')" rel="stylesheet" type="text/css" /> -<script type="text/javascript"> - var inside_galaxy_frameset = false; - - if ( parent.frames && parent.frames.galaxy_history ) - { - parent.frames.galaxy_history.location.href="$h.url_for( controller='root', action='history' )"; - - inside_galaxy_frameset = true; - } - - if ( parent.handle_minwidth_hint ) - { - parent.handle_minwidth_hint( -1 ); - } - - function main() - { - // If called from outside the galaxy frameset, redirect there - #if $tool.options.refresh - if ( ! inside_galaxy_frameset ) - { - setTimeout( "refresh()", 1000 ); - document.getElementById( "refresh_message" ).style.display = "block"; - } - #end if - } - - function refresh() - { - top.location.href = '$request.base'; - } - -</script> - -</head> - -<body onLoad="main()"> - - -<div class="donemessage"> - -<p>The following job has been succesfully added to the queue:</p> - -#for $data in $out_data.values - <div style="padding: 10px"><b> $data.hid: $data.name</b></div> -#end for - -<p> -You can check the status of queued jobs and view the resulting -data by refreshing the <b>History</b> pane. When the job has been run -the status will change from 'running' to 'finished' if completed -succesfully or 'error' if problems were encountered. -</p> - -#if $tool.options.refresh -<p id="refresh_message" style="display: none;">You are now being redirected back to <a href="$request.base">Galaxy</a></div> -#end if - -</div> - -</body> - -</html> \ No newline at end of file diff -r 1d113c5386da -r 7e94f40ee9e8 templates/tool_form.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/tool_form.mako Thu Oct 30 17:34:46 2008 -0400 @@ -0,0 +1,194 @@ +<!-- --> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> + +<% +from galaxy.util.expressions import ExpressionContext +%> + +<html> + +<head> +<title>Galaxy</title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> +<link href="${h.url_for('/static/style/base.css')}" rel="stylesheet" type="text/css" /> +<script type='text/javascript' src="${h.url_for('/static/scripts/jquery.js')}"> </script> +<script type="text/javascript"> +$( function() { + $( "select[@refresh_on_change='true']").change( function() { + $( "#tool_form" ).submit(); + }); +}); +%if not add_frame.debug: + if( window.name != "galaxy_main" ) { + location.replace( '${h.url_for( controller='root', action='index', tool_id=tool.id )}' ); + } +%endif +</script> +</head> + +<body> + +<%def name="do_inputs( inputs, tool_state, errors, prefix, other_values=None )"> + <% other_values = ExpressionContext( tool_state, other_values ) %> + %for input_index, input in enumerate( inputs.itervalues() ): + %if input.type == "repeat": + <div class="repeat-group"> + <div class="form-title-row"><b>${input.title_plural}</b></div> + <% repeat_state = tool_state[input.name] %> + %for i in range( len( repeat_state ) ): + <div class="repeat-group-item"> + <% + if input.name in errors: + rep_errors = errors[input.name][i] + else: + rep_errors = dict() + index = repeat_state[i]['__index__'] + %> + <div class="form-title-row"><b>${input.title} ${i + 1}</b></div> + ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )} + <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div> + </div> + %endfor + <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div> + </div> + %elif input.type == "conditional": + <% + group_state = tool_state[input.name] + group_errors = errors.get( input.name, {} ) + current_case = group_state['__current_case__'] + group_prefix = prefix + input.name + "|" + %> + ${row_for_param( group_prefix, input.test_param, group_state, group_errors, other_values )} + ${do_inputs( input.cases[current_case].inputs, group_state, group_errors, group_prefix, other_values )} + %else: + ${row_for_param( prefix, input, tool_state, errors, other_values )} + %endif + %endfor +</%def> + +<%def name="row_for_param( prefix, param, parent_state, parent_errors, other_values )"> + <% + if parent_errors.has_key( param.name ): + cls = "form-row form-row-error" + else: + cls = "form-row" + %> + <div class="${cls}"> + <% label = param.get_label() %> + %if label: + <label> + ${label}: + </label> + %endif + <% + field = param.get_html_field( trans, parent_state[ param.name ], other_values ) + field.refresh_on_change = param.refresh_on_change + %> + <div style="float: left; width: 250px; margin-right: 10px;">${field.get_html( prefix )}</div> + %if parent_errors.has_key( param.name ): + <div style="float: left; color: red; font-weight: bold; padding-top: 1px; padding-bottom: 3px;"> + <div style="width: 300px;"><img style="vertical-align: middle;" src="${h.url_for('/static/style/error_small.png')}"> <span style="vertical-align: middle;">${parent_errors[param.name]}</span></div> + </div> + %endif + + %if param.help: + <div class="toolParamHelp" style="clear: both;"> + ${param.help} + </div> + %endif + + <div style="clear: both"></div> + + </div> +</%def> + +%if add_frame.from_noframe: + <div class="warningmessage"> + <strong>Welcome to Galaxy</strong> + <hr/> + It appears that you found this tool from a link outside of Galaxy. + If you're not familiar with Galaxy, please consider visiting the + <a href="${h.url_for( controller='root' )}" target="_top">welcome page</a>. + To learn more about what Galaxy is and what it can do for you, please visit + the <a href="$add_frame.wiki_url" target="_top">Galaxy wiki</a>. + </div> + <br/> +%endif + +<div class="toolForm" id="$tool.id"> + %if tool.has_multiple_pages: + <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div> + %else: + <div class="toolFormTitle">${tool.name}</div> + %endif + <div class="toolFormBody"> + <form id="tool_form" name="tool_form" action="${h.url_for( tool.action )}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}"> + <input type="hidden" name="tool_id" value="${tool.id}"> + <input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}"> + + %if tool.display_by_page[tool_state.page]: + ${trans.fill_template_string( tool.display_by_page[tool_state.page], other_values=tool.get_param_html_map( trans, tool_state.page, tool_state.inputs ) )} + <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> + + %else: + + <div style="display: none;"> + %if tool_state.page == tool.last_page: + <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> + %else: + <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> + %endif + </div> + ${do_inputs( tool.inputs_by_page[ tool_state.page ], tool_state.inputs, errors, "" )} + <div class="form-row"> + %if tool_state.page == tool.last_page: + <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> + %else: + <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> + %endif + </div> + + %endif + + </form> + </div> +</div> + +%if tool.help: +<div class="toolHelp"> + <div class="toolHelpBody"> + %if tool.has_multiple_pages: + ${tool.help_by_page[tool_state.page]} + %else: + ${tool.help} + %endif + </div> +</div> +%endif + +</body> + +<script type="text/javascript"> + $( function() { + $( 'li > ul' ).each( function( i ) { + if ( $( this )[0].className == 'toolParameterExpandableCollapsable' ) + { + var parent_li = $( this ).parent( 'li' ); + var sub_ul = $( this ).remove(); + parent_li.find( 'span' ).wrapInner( '<a/>' ).find( 'a' ).click( function() { + sub_ul.toggle(); + $( this )[0].innerHTML = ( sub_ul[0].style.display=='none' ) ? '[+]' : '[-]'; + }); + parent_li.append( sub_ul ); + } + }); + $( 'ul ul' ).each( function(i) { + if ( $( this )[0].className == 'toolParameterExpandableCollapsable' && this.attributes.getNamedItem( 'default_state' ).value == 'collapsed' ) + { + $( this ).hide(); + } + }); + }); +</script> + +</html> diff -r 1d113c5386da -r 7e94f40ee9e8 templates/tool_form.tmpl --- a/templates/tool_form.tmpl Thu Oct 30 16:17:46 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ -<!-- --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> - -#from galaxy.util.expressions import ExpressionContext - -<html> - -<head> -<title>Galaxy</title> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> -<link href="$h.url_for('/static/style/base.css')" rel="stylesheet" type="text/css" /> -<script type='text/javascript' src="$h.url_for('/static/scripts/jquery.js')"> </script> -<script type="text/javascript"> -jQuery( function() { - jQuery( "select[@refresh_on_change='true']").change( function() { - jQuery( "#tool_form" ).submit(); - }); -}); -#if not $add_frame.debug - if( window.name != "galaxy_main" ) { - location.replace( '$h.url_for( controller='root', action='index', tool_id=$tool.id )' ); - } -#end if -</script> -</head> - -<body> - -## #if $getVar( 'error_message', None ) -## <div class="errormessagesmall">$error_message</div> -## <p></p> -## #end if - -#def do_inputs( $inputs, $tool_state, $errors, $prefix, $context=None ) - #set $context = ExpressionContext( $tool_state, $context ) - #for $input_index, $input in enumerate( $inputs.itervalues() ) - #if $input.type == "repeat" - <div class="repeat-group"> - <div class="form-title-row"><b>${input.title_plural}</b></div> - #set repeat_state = $tool_state[$input.name] - #for i in range( len( $repeat_state ) ): - <div class="repeat-group-item"> - #if $input.name in errors - #set rep_errors = $errors[$input.name][$i] - #else - #set rep_errors = dict() - #end if - #set index = $repeat_state[$i]['__index__'] - <div class="form-title-row"><b>${input.title} ${i + 1}</b></div> - $do_inputs( $input.inputs, $repeat_state[$i], $rep_errors, $prefix + $input.name + "_" + str($index) + "|", $context ) - <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div> - </div> - #end for - <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div> - </div> - #elif $input.type == "conditional" - #set group_state = $tool_state[$input.name] - #set group_errors = $errors.get( $input.name, {} ) - #set current_case = $group_state['__current_case__'] - #set group_prefix = $prefix + $input.name + "|" - $row_for_param( $group_prefix, $input.test_param, $group_state, $group_errors, $context ) - $do_inputs( $input.cases[$current_case].inputs, $group_state, $group_errors, $group_prefix, $context ) - #else - $row_for_param( $prefix, $input, $tool_state, $errors, $context ) - #end if - #end for -#end def - -#def row_for_param( $prefix, $param, $parent_state, $parent_errors, $context ) - #if $parent_errors.has_key( $param.name ): - #set cls = "form-row form-row-error" - #else - #set cls = "form-row" - #end if - <div class="$cls"> - #set label = $param.get_label() - #if $label: - <label> - $label: - </label> - #end if - #set field = $param.get_html_field( $caller, $parent_state[ $param.name ], $context ) - #set $field.refresh_on_change = $param.refresh_on_change - <div style="float: left; width: 250px; margin-right: 10px;">$field.get_html( $prefix )</div> - #if $parent_errors.has_key( $param.name ): - <div style="float: left; color: red; font-weight: bold; padding-top: 1px; padding-bottom: 3px;"> - <div style="width: 300px;"><img style="vertical-align: middle;" src="$h.url_for('/static/style/error_small.png')"> <span style="vertical-align: middle;">$parent_errors[$param.name]</span></div> - </div> - #elif $param.help - ##<div class="toolParamHelp" style="float: right;">$param.help</div> - #end if - - #if $param.help - <div class="toolParamHelp" style="clear: both;"> - $param.help - </div> - - #end if - - <div style="clear: both"></div> - - </div> -#end def - -#if $add_frame.from_noframe - <div class="warningmessage"> - <strong>Welcome to Galaxy</strong> - <hr/> - It appears that you found this tool from a link outside of Galaxy. If you're not familiar with Galaxy, please consider visiting the <a href="$h.url_for( controller='root' )" target="_top">welcome page</a>. To learn more about what Galaxy is and what it can do for you, please visit the <a href="$add_frame.wiki_url" target="_top">Galaxy wiki</a>. - </div> - <br/> -#end if - -<div class="toolForm" id="$tool.id"> - #if $tool.has_multiple_pages - <div class="toolFormTitle">$tool.name (step #echo $tool_state.page+1 # of $tool.npages)</div> - #else - <div class="toolFormTitle">$tool.name</div> - #end if - <div class="toolFormBody"> - <form id="tool_form" name="tool_form" action="$h.url_for( $tool.action )" enctype="$tool.enctype" target="$tool.target" method="$tool.method"> - <input type="hidden" name="tool_id" value="$tool.id"> - <input type="hidden" name="tool_state" value="$util.object_to_string( $tool_state.encode( $tool, $app ) )"> - - #if $tool.display_by_page[$tool_state.page] - - $caller.fill_template_string( $tool.display_by_page[$tool_state.page], context=$tool.get_param_html_map( $caller, $tool_state.page, $tool_state.inputs ) ) - <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> - - #else - - <div style="display: none;"> - #if $tool_state.page == $tool.last_page - <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> - #else - <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> - #end if - </div> - $do_inputs( $tool.inputs_by_page[ $tool_state.page ], $tool_state.inputs, $errors, "" ) - <div class="form-row"> - #if $tool_state.page == $tool.last_page - <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> - #else - <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> - #end if - </div> - - #end if - - </form> - </div> -</div> - -#if $tool.help -<div class="toolHelp"> - <div class="toolHelpBody"> - #if $tool.has_multiple_pages - $tool.help_by_page[$tool_state.page] - #else - $tool.help - #end if - </div> -</div> -#end if - -</body> - -<script type="text/javascript"> - \$( function() { - \$( 'li > ul' ).each( function( i ) { - if ( \$( this )[0].className == 'toolParameterExpandableCollapsable' ) - { - var parent_li = \$( this ).parent( 'li' ); - var sub_ul = \$( this ).remove(); - parent_li.find( 'span' ).wrapInner( '<a/>' ).find( 'a' ).click( function() { - sub_ul.toggle(); - \$( this )[0].innerHTML = ( sub_ul[0].style.display=='none' ) ? '[+]' : '[-]'; - }); - parent_li.append( sub_ul ); - } - }); - \$( 'ul ul' ).each( function(i) { - if ( \$( this )[0].className == 'toolParameterExpandableCollapsable' && this.attributes.getNamedItem( 'default_state' ).value == 'collapsed' ) - { - \$( this ).hide(); - } - }); - }); -</script> - -</html>
participants (1)
-
Greg Von Kuster