from mako import runtime, filters, cache UNDEFINED = runtime.UNDEFINED __M_dict_builtin = dict __M_locals_builtin = locals _magic_number = 5 _modified_time = 1287725327.3571129 _template_filename=u'templates/tagging_common.mako' _template_uri=u'root/../tagging_common.mako' _template_cache=cache.Cache(__name__, _modified_time) _source_encoding=None _exports = ['render_tagging_element_html', 'render_individual_tagging_element', 'render_community_tagging_element'] # SOURCE LINE 1 from cgi import escape from galaxy.web.framework.helpers import iff from random import random from sys import maxint from math import floor from galaxy.model import Tag, ItemTagAssociation def render_body(context,**pageargs): context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) in_form = context.get('in_form', UNDEFINED) def render_community_tagging_element(tagged_item=None,elt_context=None,use_toggle_link=False,tag_click_fn='default_tag_click_fn'): return render_render_community_tagging_element(context.locals_(__M_locals),tagged_item,elt_context,use_toggle_link,tag_click_fn) elt_context = context.get('elt_context', UNDEFINED) use_toggle_link = context.get('use_toggle_link', UNDEFINED) user = context.get('user', UNDEFINED) def render_individual_tagging_element(user=None,tagged_item=None,elt_context=None,use_toggle_link=True,in_form=False,input_size='15',tag_click_fn='default_tag_click_fn',get_toggle_link_text_fn='default_get_toggle_link_text_fn',editable=True,render_add_tag_button=True): return render_render_individual_tagging_element(context.locals_(__M_locals),user,tagged_item,elt_context,use_toggle_link,in_form,input_size,tag_click_fn,get_toggle_link_text_fn,editable,render_add_tag_button) tag_click_fn = context.get('tag_click_fn', UNDEFINED) input_size = context.get('input_size', UNDEFINED) tagged_item = context.get('tagged_item', UNDEFINED) tag_type = context.get('tag_type', UNDEFINED) __M_writer = context.writer() # SOURCE LINE 8 __M_writer(u'\n\n') # SOURCE LINE 11 if tagged_item is not None: # SOURCE LINE 12 if tag_type == "individual": # SOURCE LINE 13 __M_writer(u' ') __M_writer(unicode(render_individual_tagging_element( user=user, tagged_item=tagged_item, elt_context=elt_context, in_form=in_form, input_size=input_size, tag_click_fn=tag_click_fn, use_toggle_link=use_toggle_link ))) __M_writer(u'\n') # SOURCE LINE 14 elif tag_type == "community": # SOURCE LINE 15 __M_writer(u' ') __M_writer(unicode(render_community_tagging_element(tagged_item=tagged_item, elt_context=elt_context, tag_click_fn=tag_click_fn))) __M_writer(u'\n') # SOURCE LINE 18 __M_writer(u'\n') # SOURCE LINE 85 __M_writer(u'\n\n') # SOURCE LINE 103 __M_writer(u'\n\n\n') return '' finally: context.caller_stack._pop_frame() def render_render_tagging_element_html(context,elt_id=None,tags=None,editable=True,use_toggle_link=True,input_size='15',in_form=False,tag_type='individual',render_add_tag_button=True): context.caller_stack._push_frame() try: h = context.get('h', UNDEFINED) unicode = context.get('unicode', UNDEFINED) isinstance = context.get('isinstance', UNDEFINED) len = context.get('len', UNDEFINED) str = context.get('str', UNDEFINED) __M_writer = context.writer() # SOURCE LINE 20 __M_writer(u'\n') # SOURCE LINE 22 __M_writer(u' ') num_tags = len( tags ) # SOURCE LINE 24 __M_writer(u'\n \n') return '' finally: context.caller_stack._pop_frame() def render_render_individual_tagging_element(context,user=None,tagged_item=None,elt_context=None,use_toggle_link=True,in_form=False,input_size='15',tag_click_fn='default_tag_click_fn',get_toggle_link_text_fn='default_get_toggle_link_text_fn',editable=True,render_add_tag_button=True): context.caller_stack._push_frame() try: isinstance = context.get('isinstance', UNDEFINED) unicode = context.get('unicode', UNDEFINED) int = context.get('int', UNDEFINED) h = context.get('h', UNDEFINED) self = context.get('self', UNDEFINED) dict = context.get('dict', UNDEFINED) str = context.get('str', UNDEFINED) trans = context.get('trans', UNDEFINED) __M_writer = context.writer() # SOURCE LINE 107 __M_writer(u'\n') # SOURCE LINE 109 __M_writer(u' ') # Useful ids. tagged_item_id = str( trans.security.encode_id ( tagged_item.id ) ) elt_id = int ( floor ( random()*maxint ) ) # Get list of user's item tags. TODO: this could be moved to a database query for speed purposes. item_tags = [ tag for tag in tagged_item.tags if ( tag.user == user ) ] # SOURCE LINE 116 __M_writer(u'\n \n') # SOURCE LINE 119 __M_writer(u' ') __M_writer(unicode(self.render_tagging_element_html(elt_id=elt_id, tags=item_tags, editable=editable, use_toggle_link=use_toggle_link, input_size=input_size, in_form=in_form, render_add_tag_button=render_add_tag_button))) __M_writer(u'\n \n') # SOURCE LINE 122 __M_writer(u' \n \n") # SOURCE LINE 203 __M_writer(u' \n\n \n') return '' finally: context.caller_stack._pop_frame() def render_render_community_tagging_element(context,tagged_item=None,elt_context=None,use_toggle_link=False,tag_click_fn='default_tag_click_fn'): context.caller_stack._push_frame() try: int = context.get('int', UNDEFINED) self = context.get('self', UNDEFINED) trans = context.get('trans', UNDEFINED) __M_writer = context.writer() # SOURCE LINE 88 __M_writer(u'\n') # SOURCE LINE 90 __M_writer(u' ') elt_id = int ( floor ( random()*maxint ) ) community_tags = trans.app.tag_handler.get_community_tags( trans, item=tagged_item, limit=5 ) # SOURCE LINE 93 __M_writer(u'\n ') # SOURCE LINE 94 __M_writer(unicode(self.render_tagging_element_html(elt_id=elt_id, \ tags=community_tags, \ use_toggle_link=use_toggle_link, \ editable=False, tag_type="community"))) # SOURCE LINE 97 __M_writer(u'\n \n') # SOURCE LINE 100 __M_writer(u' \n') return '' finally: context.caller_stack._pop_frame()