root/galaxy-central/database/compiled_templates/root/tool_menu.mako.py @ 3

リビジョン 3, 25.5 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1from mako import runtime, filters, cache
2UNDEFINED = runtime.UNDEFINED
3__M_dict_builtin = dict
4__M_locals_builtin = locals
5_magic_number = 5
6_modified_time = 1287725327.091922
7_template_filename='templates/root/tool_menu.mako'
8_template_uri='/root/tool_menu.mako'
9_template_cache=cache.Cache(__name__, _modified_time)
10_source_encoding=None
11_exports = ['render_label', 'render_tool', 'render_workflow']
12
13
14def render_body(context,**pageargs):
15    context.caller_stack._push_frame()
16    try:
17        __M_locals = __M_dict_builtin(pageargs=pageargs)
18        _ = context.get('_', UNDEFINED)
19        h = context.get('h', UNDEFINED)
20        def render_label(label):
21            return render_render_label(context.locals_(__M_locals),label)
22        t = context.get('t', UNDEFINED)
23        str = context.get('str', UNDEFINED)
24        recent_tools = context.get('recent_tools', UNDEFINED)
25        toolbox = context.get('toolbox', UNDEFINED)
26        trans = context.get('trans', UNDEFINED)
27        def render_tool(tool,section):
28            return render_render_tool(context.locals_(__M_locals),tool,section)
29        def render_workflow(key,workflow,section):
30            return render_render_workflow(context.locals_(__M_locals),key,workflow,section)
31        __M_writer = context.writer()
32        # SOURCE LINE 25
33        __M_writer(u'\n\n')
34        # SOURCE LINE 37
35        __M_writer(u'\n\n')
36        # SOURCE LINE 44
37        __M_writer(u'\n\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html>\n    <head>\n        <title>')
38        # SOURCE LINE 49
39        __M_writer(unicode(_('Galaxy Tools')))
40        __M_writer(u'</title>\n        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n        <link href="')
41        # SOURCE LINE 51
42        __M_writer(unicode(h.url_for('/static/style/base.css')))
43        __M_writer(u'" rel="stylesheet" type="text/css" />\n        <link href="')
44        # SOURCE LINE 52
45        __M_writer(unicode(h.url_for('/static/style/tool_menu.css')))
46        __M_writer(u'" rel="stylesheet" type="text/css" />\n\n')
47        # SOURCE LINE 55
48        __M_writer(u'        ')
49        __M_writer(unicode(h.js( "jquery", "galaxy.base", "json2" )))
50        __M_writer(u'\n\n        <script type="text/javascript">\n            // Set up GalaxyAsync object.\n            var galaxy_async = new GalaxyAsync(')
51        # SOURCE LINE 59
52        __M_writer(unicode(str(trans.app.config.log_actions).lower()))
53        __M_writer(u');\n            galaxy_async.set_func_url(galaxy_async.log_user_action, "')
54        # SOURCE LINE 60
55        __M_writer(unicode(h.url_for( controller='user', action='log_user_action_async' )))
56        __M_writer(u'");\n        \n            $(document).ready(function() { \n                // Init showing/hiding of tool sections.\n                $( "div.toolSectionBody" ).hide();\n                $( "div.toolSectionTitle > span" ).wrap( "<a href=\'#\'></a>" )\n                var last_expanded = null;\n                $( "div.toolSectionTitle" ).each( function() { \n                   var body = $(this).next( "div.toolSectionBody" );\n                   $(this).click( function() {\n                       if ( body.is( ":hidden" ) ) {\n                            if ( last_expanded ) {\n                                last_expanded.slideUp( "fast" );\n                            }\n                            last_expanded = body;\n                            body.slideDown( "fast" );\n                       }\n                       else {\n                           body.slideUp( "fast" );\n                           last_expanded = null;\n                       }\n                       return false;\n                   });\n                });\n                \n                // Log clicks on tools.\n                $("div.toolTitle > a").click( function() \n                {\n                    var tool_title = $(this).attr(\'id\').split("-")[1];\n                    var section_title = $(this).parents("div.toolSectionWrapper").find("div.toolSectionTitle").text().trim();\n                    var search_active = $(this).parents("div.toolTitle").hasClass("search_match");\n                    \n                    // Log action.\n                    galaxy_async.log_user_action("tool_menu_click." + tool_title, section_title, \n                                                    JSON.stringify({"search_active" : search_active}));\n                });\n                \n                $( "a[minsizehint]" ).click( function() {\n                    if ( parent.handle_minwidth_hint ) {\n                        parent.handle_minwidth_hint( $(this).attr( "minsizehint" ) );\n                    }\n                });\n                \n                // Init searching.\n                $("#tool-search-query").click( function (){\n                    $(this).focus();\n                    $(this).select();\n                })\n                .keyup( function () {\n                    // Remove italics.\n                    $(this).css("font-style", "normal");\n                    \n                    // Don\'t update if same value as last time\n                    if ( this.value.length < 3 ) {\n                        reset_tool_search(false);\n                    } else if ( this.value != this.lastValue ) {\n                        // Add class to denote that searching is active.\n                        $(this).addClass("search_active");\n                        // input.addClass(config.loadingClass);\n                        // Add \'*\' to facilitate partial matching.\n                        var q = this.value + \'*\';\n                        // Stop previous ajax-request\n                        if (this.timer) {\n                            clearTimeout(this.timer);\n                        }\n                        // Start a new ajax-request in X ms\n                        $("#search-spinner").show();\n                        this.timer = setTimeout(function () {\n                            $.get("')
57        # SOURCE LINE 128
58        __M_writer(unicode(h.url_for( controller='root', action='tool_search' )))
59        __M_writer(u'", { query: q }, function (data) {\n                                // input.removeClass(config.loadingClass);\n                                // Show live-search if results and search-term aren\'t empty\n                                $("#search-no-results").hide();\n                                // Hide all tool sections.\n                                $(".toolSectionWrapper").hide();\n                                // This hides all tools but not workflows link (which is in a .toolTitle div).\n                                $(".toolSectionWrapper").find(".toolTitle").hide();\n                                if ( data.length != 0 ) {\n                                    // Map tool ids to element ids and join them.\n                                    var s = $.map( data, function( n, i ) { return "#link-" + n; } ).join( ", " );\n                                    \n                                    // First pass to show matching tools and their parents.\n                                    $(s).each( function() {\n                                        // Add class to denote match.\n                                        $(this).parent().addClass("search_match");\n                                        if ($(this).parents("#recently_used_wrapper").length == 0)\n                                            // Default behavior.\n                                            $(this).parent().show().parent().parent().show().parent().show();\n                                        else if ($(this).parents(".user_pref_visible").length != 0)\n                                            // RU menu is visible, so filter it as normal.\n                                            $(this).parent().show().parent().parent().show().parent().show();\n                                        else \n                                        {\n                                            // RU menu is not visible, so set up classes and visibility so that if menu shown matching is \n                                            // aleady in place.\n                                            $(this).parent().show();\n                                        }\n                                    });\n                                    \n                                    // Hide labels that have no visible children.\n                                    $(".toolPanelLabel").each( function() {\n                                       var this_label = $(this);                                   \n                                       var next = this_label.next();\n                                       var no_visible_tools = true;\n                                       // Look through tools following label and, if none are visible, hide label.\n                                       while (next.length != 0 && next.hasClass("toolTitle"))\n                                       {\n                                           if (next.is(":visible"))\n                                           {\n                                               no_visible_tools = false;\n                                               break;\n                                           }\n                                           else\n                                               next = next.next();\n                                        }\n                                        if (no_visible_tools)\n                                            this_label.hide();\n                                    });\n                                } else {\n                                    $("#search-no-results").show();\n                                }\n                                $("#search-spinner").hide();\n                            }, "json" );\n                        }, 200 );\n                    }\n                    this.lastValue = this.value;\n                });                \n            });            \n\n            // Update recently used tools menu. Function inserts a new item and removes the last item.\n            function update_recently_used()\n            {\n                $.ajax({\n                    url: "')
60        # SOURCE LINE 192
61        __M_writer(unicode(h.url_for( controller='/user', action='get_most_recently_used_tool_async' )))
62        __M_writer(u'",\n                    dataType: \'json\',\n                    error: function() { \n                        // console.log( "Failed to update recently used list." );\n                    },\n                    success: function(new_tool_info) {\n                        var recently_used_elts = $("#recently_used").find(".toolTitle");\n                        var first_elt = $(recently_used_elts.first());\n                        var found_in_list = false;\n            \n                        // Look for new tool in current list. If found, rearrange list to move tool to top.\n                        recently_used_elts.each( function(index) {\n                            var anchor = $(this).find("a");\n                            var tool_id = anchor.attr("id").split("-")[1];\n                            if (tool_id == new_tool_info.id)\n                            {\n                                found_in_list = true;\n                    \n                                // If tool is first, do nothing.\n                                if (index == 0)\n                                    return;\n                                else \n                                {\n                                    // Tool not first; reorder.\n                                    $(this).remove();\n                                    first_elt.before($(this));\n                                }\n                            }\n                        });\n            \n                        // If tool not in list, create new element, remove last element, and put new element first in list.\n                        if (!found_in_list)\n                        {\n                            new_tool_elt = $("<div class=\'toolTitle\'> ')
63        # SOURCE LINE 226
64        __M_writer(u'                                                <a id=\'link-" + new_tool_info.id + "\' href=\'" + new_tool_info.link + "\' target=\'" + \n                                                new_tool_info.target + "\' minsizehint=\'" + new_tool_info.minsizehint + "\'>" +\n                                                new_tool_info.name + "</a> " + new_tool_info.description + " ')
65        # SOURCE LINE 229
66        __M_writer(u'                                              </div>");\n                            recently_used_elts.last().remove();\n                            recently_used_elts.first().before(new_tool_elt);                            \n                        }\n                    }\n                });                \n            }\n        </script>\n    </head>\n\n    <body class="toolMenuPage">\n        <div class="toolMenu">\n            \n')
67        # SOURCE LINE 243
68        __M_writer(u'                ')
69
70        show_tool_search = False
71        if trans.user:
72            show_tool_search = trans.user.preferences.get( "show_tool_search", "False" )
73       
74        if show_tool_search == "True":
75            display = "block"
76        else:
77            display = "none"
78                       
79       
80        __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin()[__M_key]) for __M_key in ['display','show_tool_search'] if __M_key in __M_locals_builtin()]))
81        # SOURCE LINE 252
82        __M_writer(u'\n                <div id="tool-search" style="padding-bottom: 5px; position: relative; display: ')
83        # SOURCE LINE 253
84        __M_writer(unicode(display))
85        __M_writer(u'; width: 100%">\n                    <input type="text" name="query" value="search tools" id="tool-search-query" style="width: 100%; font-style:italic; font-size: inherit"/>\n                    <img src="')
86        # SOURCE LINE 255
87        __M_writer(unicode(h.url_for('/static/images/loading_small_white_bg.gif')))
88        __M_writer(u'" id="search-spinner" style="display: none; position: absolute; right: 0; top: 5px;"/>\n                </div>\n                \n')
89        # SOURCE LINE 259
90        if trans.user:
91            # SOURCE LINE 260
92            __M_writer(u'                    ')
93
94            if trans.user.preferences.get( 'show_recently_used_menu', 'False' ) == 'True':
95                display = "block"
96                pref_class = "user_pref_visible"
97            else:
98                display = "none"
99                pref_class = "user_pref_hidden"
100           
101           
102            __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin()[__M_key]) for __M_key in ['pref_class','display'] if __M_key in __M_locals_builtin()]))
103            # SOURCE LINE 267
104            __M_writer(u'\n                    <div class="toolSectionWrapper ')
105            # SOURCE LINE 268
106            __M_writer(unicode(pref_class))
107            __M_writer(u'" id="recently_used_wrapper" \n                            style="display: ')
108            # SOURCE LINE 269
109            __M_writer(unicode(display))
110            __M_writer(u'; padding-bottom: 5px">\n                        <div class="toolSectionTitle">\n                            <span>Recently Used</span>\n                        </div>\n                        <div id="recently_used" class="toolSectionBody">\n                            <div class="toolSectionBg">\n')
111            # SOURCE LINE 275
112            for tool in recent_tools:
113                # SOURCE LINE 276
114                __M_writer(u'                                    ')
115                __M_writer(unicode(render_tool( tool, True )))
116                __M_writer(u'\n')
117            # SOURCE LINE 278
118            __M_writer(u'                            </div>\n                        </div>\n                        <div class="toolSectionPad"></div>\n                    </div>\n')
119        # SOURCE LINE 283
120        __M_writer(u'                \n')
121        # SOURCE LINE 285
122        for key, val in toolbox.tool_panel.items():
123            # SOURCE LINE 286
124            __M_writer(u'                    <div class="toolSectionWrapper">\n')
125            # SOURCE LINE 287
126            if key.startswith( 'tool' ):
127                # SOURCE LINE 288
128                __M_writer(u'                        ')
129                __M_writer(unicode(render_tool( val, False )))
130                __M_writer(u'\n')
131                # SOURCE LINE 289
132            elif key.startswith( 'workflow' ):
133                # SOURCE LINE 290
134                __M_writer(u'                        ')
135                __M_writer(unicode(render_workflow( key, val, False )))
136                __M_writer(u'\n')
137                # SOURCE LINE 291
138            elif key.startswith( 'section' ):
139                # SOURCE LINE 292
140                __M_writer(u'                        ')
141                section = val
142               
143                __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin()[__M_key]) for __M_key in ['section'] if __M_key in __M_locals_builtin()]))
144                __M_writer(u'\n                        <div class="toolSectionTitle" id="title_')
145                # SOURCE LINE 293
146                __M_writer(unicode(section.id))
147                __M_writer(u'">\n                            <span>')
148                # SOURCE LINE 294
149                __M_writer(unicode(section.name))
150                __M_writer(u'</span>\n                        </div>\n                        <div id="')
151                # SOURCE LINE 296
152                __M_writer(unicode(section.id))
153                __M_writer(u'" class="toolSectionBody">\n                            <div class="toolSectionBg">\n')
154                # SOURCE LINE 298
155                for section_key, section_val in section.elems.items():
156                    # SOURCE LINE 299
157                    if section_key.startswith( 'tool' ):
158                        # SOURCE LINE 300
159                        __M_writer(u'                                        ')
160                        __M_writer(unicode(render_tool( section_val, True )))
161                        __M_writer(u'\n')
162                        # SOURCE LINE 301
163                    elif section_key.startswith( 'workflow' ):
164                        # SOURCE LINE 302
165                        __M_writer(u'                                        ')
166                        __M_writer(unicode(render_workflow( section_key, section_val, True )))
167                        __M_writer(u'\n')
168                        # SOURCE LINE 303
169                    elif section_key.startswith( 'label' ):
170                        # SOURCE LINE 304
171                        __M_writer(u'                                        ')
172                        __M_writer(unicode(render_label( section_val )))
173                        __M_writer(u'\n')
174                # SOURCE LINE 307
175                __M_writer(u'                            </div>\n                        </div>\n')
176                # SOURCE LINE 309
177            elif key.startswith( 'label' ):
178                # SOURCE LINE 310
179                __M_writer(u'                        ')
180                __M_writer(unicode(render_label( val )))
181                __M_writer(u'\n')
182            # SOURCE LINE 312
183            __M_writer(u'                    <div class="toolSectionPad"></div>\n                    </div>\n')
184        # SOURCE LINE 315
185        __M_writer(u'                \n')
186        # SOURCE LINE 317
187        __M_writer(u'                <div id="search-no-results" style="display: none; padding-top: 5px">\n                    <em><strong>Search did not match any tools.</strong></em>\n                </div>\n                \n')
188        # SOURCE LINE 324
189        __M_writer(u'                \n')
190        # SOURCE LINE 325
191        if t.user:
192            # SOURCE LINE 326
193            __M_writer(u'                    <div class="toolSectionPad"></div>\n                    <div class="toolSectionPad"></div>\n                    <div class="toolSectionTitle" id="title_XXinternalXXworkflow">\n                      <span>Workflows</span>\n                    </div>\n                    <div id="XXinternalXXworkflow" class="toolSectionBody">\n                        <div class="toolSectionBg">\n')
194            # SOURCE LINE 333
195            if t.user.stored_workflow_menu_entries:
196                # SOURCE LINE 334
197                for m in t.user.stored_workflow_menu_entries:
198                    # SOURCE LINE 335
199                    __M_writer(u'                                    <div class="toolTitle">\n                                        <a href="')
200                    # SOURCE LINE 336
201                    __M_writer(unicode(h.url_for( controller='workflow', action='run', id=trans.security.encode_id(m.stored_workflow_id) )))
202                    __M_writer(u'" target="galaxy_main">')
203                    __M_writer(unicode(m.stored_workflow.name))
204                    __M_writer(u'</a>\n                                    </div>\n')
205            # SOURCE LINE 340
206            __M_writer(u'                            <div class="toolTitle">\n                                <a href="')
207            # SOURCE LINE 341
208            __M_writer(unicode(h.url_for( controller='workflow', action='list_for_run')))
209            __M_writer(u'" target="galaxy_main">All workflows</a>\n                            </div>\n                        </div>\n                    </div>\n')
210        # SOURCE LINE 346
211        __M_writer(u'                \n            </div>\n        </div>\n    </body>\n</html>\n')
212        return ''
213    finally:
214        context.caller_stack._pop_frame()
215
216
217def render_render_label(context,label):
218    context.caller_stack._push_frame()
219    try:
220        __M_writer = context.writer()
221        # SOURCE LINE 40
222        __M_writer(u'\n    <div class="toolPanelLabel" id="title_')
223        # SOURCE LINE 41
224        __M_writer(unicode(label.id))
225        __M_writer(u'">\n        <span>')
226        # SOURCE LINE 42
227        __M_writer(unicode(label.text))
228        __M_writer(u'</span>\n    </div>\n')
229        return ''
230    finally:
231        context.caller_stack._pop_frame()
232
233
234def render_render_tool(context,tool,section):
235    context.caller_stack._push_frame()
236    try:
237        h = context.get('h', UNDEFINED)
238        t = context.get('t', UNDEFINED)
239        _ = context.get('_', UNDEFINED)
240        __M_writer = context.writer()
241        # SOURCE LINE 2
242        __M_writer(u'\n')
243        # SOURCE LINE 3
244        if not tool.hidden:
245            # SOURCE LINE 4
246            if section:
247                # SOURCE LINE 5
248                __M_writer(u'            <div class="toolTitle">\n')
249                # SOURCE LINE 6
250            else:
251                # SOURCE LINE 7
252                __M_writer(u'            <div class="toolTitleNoSection">\n')
253            # SOURCE LINE 9
254            __M_writer(u'            ')
255
256            if tool.input_required:
257                link = h.url_for( controller='tool_runner', tool_id=tool.id )
258            else:
259                link = h.url_for( tool.action, ** tool.get_static_param_values( t ) )
260                       
261           
262            # SOURCE LINE 14
263            __M_writer(u'\n')
264            # SOURCE LINE 18
265            if tool.name:
266                # SOURCE LINE 19
267                __M_writer(u'                <a id="link-')
268                __M_writer(unicode(tool.id))
269                __M_writer(u'" href="')
270                __M_writer(unicode(link))
271                __M_writer(u'" target=')
272                __M_writer(unicode(tool.target))
273                __M_writer(u' minsizehint="')
274                __M_writer(unicode(tool.uihints.get( 'minwidth', -1 )))
275                __M_writer(u'">')
276                __M_writer(unicode(_(tool.name)))
277                __M_writer(u'</a> ')
278                __M_writer(unicode(tool.description))
279                __M_writer(u' \n')
280                # SOURCE LINE 20
281            else:
282                # SOURCE LINE 21
283                __M_writer(u'                <a id="link-')
284                __M_writer(unicode(tool.id))
285                __M_writer(u'" href="')
286                __M_writer(unicode(link))
287                __M_writer(u'" target=')
288                __M_writer(unicode(tool.target))
289                __M_writer(u' minsizehint="')
290                __M_writer(unicode(tool.uihints.get( 'minwidth', -1 )))
291                __M_writer(u'">')
292                __M_writer(unicode(tool.description))
293                __M_writer(u'</a>\n')
294            # SOURCE LINE 23
295            __M_writer(u'        </div>\n')
296        return ''
297    finally:
298        context.caller_stack._pop_frame()
299
300
301def render_render_workflow(context,key,workflow,section):
302    context.caller_stack._push_frame()
303    try:
304        h = context.get('h', UNDEFINED)
305        _ = context.get('_', UNDEFINED)
306        __M_writer = context.writer()
307        # SOURCE LINE 28
308        __M_writer(u'\n')
309        # SOURCE LINE 29
310        if section:
311            # SOURCE LINE 30
312            __M_writer(u'        <div class="toolTitle">\n')
313            # SOURCE LINE 31
314        else:
315            # SOURCE LINE 32
316            __M_writer(u'        <div class="toolTitleNoSection">\n')
317        # SOURCE LINE 34
318        __M_writer(u'        ')
319        encoded_id = key.lstrip( 'workflow_' )
320       
321        __M_writer(u'\n        <a id="link-')
322        # SOURCE LINE 35
323        __M_writer(unicode(workflow.id))
324        __M_writer(u'" href="')
325        __M_writer(unicode( h.url_for( controller='workflow', action='run', id=encoded_id, check_user=False )))
326        __M_writer(u'" target="_parent"}">')
327        __M_writer(unicode(_(workflow.name)))
328        __M_writer(u'</a>\n    </div>\n')
329        return ''
330    finally:
331        context.caller_stack._pop_frame()
332
333
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。