from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1272329509.251801
_template_filename='/home/mmior/src/linkdb/linkdb/templates/category/index.mako'
_template_uri='/category/index.mako'
_template_cache=cache.Cache(__name__, _modified_time)
_source_encoding='utf-8'
from webhelpers.html import escape
_exports = ['title']


def _mako_get_namespace(context, name):
    try:
        return context.namespaces[(__name__, name)]
    except KeyError:
        _mako_generate_namespaces(context)
        return context.namespaces[(__name__, name)]
def _mako_generate_namespaces(context):
    pass
def _mako_inherit(template, context):
    _mako_generate_namespaces(context)
    return runtime._inherit_from(context, '/base.mako', _template_uri)
def render_body(context,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        h = context.get('h', UNDEFINED)
        c = context.get('c', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n\n')
        # SOURCE LINE 5
        __M_writer(u'\n\n')
        # SOURCE LINE 7
        if c.categories:
            # SOURCE LINE 8
            __M_writer(u'<ul id="categories">\n')
            # SOURCE LINE 9
            for category in c.categories:
                # SOURCE LINE 10
                __M_writer(u'    <li id="category-')
                __M_writer(escape(category.category_id))
                __M_writer(u'">')
                __M_writer(escape(category.name))
                __M_writer(u' (')
                __M_writer(escape(category.link_count))
                __M_writer(u')<span><a href="')
                __M_writer(escape(h.url_for(controller='category', action='delete', id=category.category_id)))
                __M_writer(u'" class="delete" title="Delete">Delete</a></span></li>\n')
            # SOURCE LINE 12
        else:
            # SOURCE LINE 13
            __M_writer(u'<div class="flash">No categories exist yet. Why not <a href="')
            __M_writer(escape(h.url_for(controller='category', action='edit')))
            __M_writer(u'">add one</a>?</div>\n')
        # SOURCE LINE 15
        __M_writer(u'</ul>\n\n<script type="text/javascript">\n$(document).ready(function() {\n  $(\'ul#categories li > span\').hide()\n  $(\'ul#categories li\').hover(function() {\n    $(\'span\', this).show()\n  }, function() {\n    $(\'span\', this).hide()\n  });\n  $(\'.delete\').click(function() {\n    li = $(this).parents(\'li\').first()[0];\n    id = li.id.split(\'-\')[1];\n    $.ajax({\n      type: \'GET\',\n      url: \'delete/\'+id,\n      cache: false,\n      success: function() {\n        $(li).remove();\n      }\n    });\n    return false;\n  });\n});\n</script>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_title(context):
    context.caller_stack._push_frame()
    try:
        __M_writer = context.writer()
        # SOURCE LINE 3
        __M_writer(u'\n    View Categories\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


