PKZ4^) ctxtnavadd/web_ui.pyfrom trac.core import * from trac.web.chrome import INavigationContributor, ITemplateProvider from trac.util import Markup try: from trac.web.chrome import add_javascript have_aj = True except ImportError: have_aj = False from ctxtnavadd.api import ICtxtnavAdder inc_script = """""" class CtxtnavAddModule(Component): """An evil module that adds buttons to the ctxtnav bar of other plugins.""" implements(INavigationContributor, ITemplateProvider) ctxtnav_adders = ExtensionPoint(ICtxtnavAdder) # INavigationContributor methods def get_active_navigation_item(self, req): return '' # This is never called def get_navigation_items(self, req): evil_js = '/'.join(['ctxtnavadd','js','ctxtnavadd.js']) if have_aj: add_javascript(req, evil_js) else: self._add_js_inc(req, req.href.chrome(evil_js)) self._add_js(req,self._make_js(req)) return [] # This returns no buttons # ITemplateProvider methods def get_templates_dirs(self): """ Return the absolute path of the directory containing the provided ClearSilver templates. """ from pkg_resources import resource_filename #return [resource_filename(__name__, 'templates')] return [] def get_htdocs_dirs(self): """ Return a list of directories with static resources (such as style sheets, images, etc.) Each item in the list must be a `(prefix, abspath)` tuple. The `prefix` part defines the path in the URL that requests to these resources are prefixed with. The `abspath` is the absolute path to the directory containing the resources on the local file system. """ from pkg_resources import resource_filename return [('ctxtnavadd', resource_filename(__name__, 'htdocs'))] # Internal methods def _add_js(self, req, data): """Add javascript to a page via hdf['project.footer']""" footer = req.hdf['project.footer'] footer += data req.hdf['project.footer'] = Markup(footer) def _add_js_inc(self, req, file): """Add a javascript include via hdf['project.footer']""" self._add_js(req, inc_script%file) def _make_js(self, req): """Generate the needed Javascript.""" adds = [] for adder in self.ctxtnav_adders: if adder.match_ctxtnav_add(req): for add in adder.get_ctxtnav_adds(req): if isinstance(add, Markup): adds.append(Markup(add.replace("'","\\'"))) else: href, text = add adds.append(Markup('%s'%(href,Markup.escape(text,False)))) js = "" for add in adds: js += "add_ctxtnav('%s');\n"%add return """"""%js PKʩ4p__ctxtnavadd/api.pyfrom trac.core import * class ICtxtnavAdder(Interface): """An extension point interface to adding ctxtnav entries.""" def match_ctxtnav_add(req): """Return True if you want to alter this requests ctxtnav bar.""" def get_ctxtnav_adds(req): """Return a list of the form (path, text) to be added to the bar.""" PKi4ctxtnavadd/__init__.pyPKpj4hIPEEctxtnavadd/web_ui.pyc; Dc@sdkTdklZlZdklZydklZeZWne j o e ZnXdk l Z dZ defdYZdS( (s*(sINavigationContributorsITemplateProvider(sMarkup(sadd_javascript(s ICtxtnavAdders1sCtxtnavAddModulecBsftZdZeeeeeZdZ dZ dZ dZ dZ dZdZRS(sEAn evil module that adds buttons to the ctxtnav bar of other plugins.cCsdSdS(Ns((sselfsreq((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pysget_active_navigation_itemscCsmdidddg}tot||n|i||ii||i ||i |gSdS(Ns/s ctxtnavaddsjss ctxtnavadd.js( sjoinsevil_jsshave_ajsadd_javascriptsreqsselfs _add_js_incshrefschromes_add_jss_make_js(sselfsreqsevil_js((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pysget_navigation_itemss cCsdkl}gSdS(sr Return the absolute path of the directory containing the provided ClearSilver templates. (sresource_filenameN(s pkg_resourcessresource_filename(sselfsresource_filename((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pysget_templates_dirs%s cCs'dkl}d|tdfgSdS(s Return a list of directories with static resources (such as style sheets, images, etc.) Each item in the list must be a `(prefix, abspath)` tuple. The `prefix` part defines the path in the URL that requests to these resources are prefixed with. The `abspath` is the absolute path to the directory containing the resources on the local file system. (sresource_filenames ctxtnavaddshtdocsN(s pkg_resourcessresource_filenames__name__(sselfsresource_filename((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pysget_htdocs_dirs.s  cCs.|id}||7}t||ids  cCs|i|t|dS(s2Add a javascript include via hdf['project.footer']N(sselfs_add_jssreqs inc_scriptsfile(sselfsreqsfile((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pys _add_js_incDsc Csg}x|iD]}|i|ox|i|D]n}t|t o#|i t |i ddq6|\}}|i t d|t i|tfq6WqqWd}x|D]}|d|7}qWd|SdS(sGenerate the needed Javascript.s's\'s%sssadd_ctxtnav('%s'); s*N(saddssselfsctxtnav_adderssaddersmatch_ctxtnav_addsreqsget_ctxtnav_addssadds isinstancesMarkupsappendsreplaceshrefstextsescapesFalsesjs(sselfsreqsaddsstextsjssaddshrefsadder((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pys_make_jsHs  # 5(s__name__s __module__s__doc__s implementssINavigationContributorsITemplateProvidersExtensionPoints ICtxtnavAddersctxtnav_adderssget_active_navigation_itemsget_navigation_itemssget_templates_dirssget_htdocs_dirss_add_jss _add_js_incs_make_js(((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pysCtxtnavAddModules       N(s trac.corestrac.web.chromesINavigationContributorsITemplateProviders trac.utilsMarkupsadd_javascriptsTrueshave_ajs ImportErrorsFalsesctxtnavadd.apis ICtxtnavAdders inc_scripts ComponentsCtxtnavAddModule(sINavigationContributorshave_ajs ICtxtnavAddersMarkups inc_scriptsITemplateProvidersadd_javascriptsCtxtnavAddModule((s/build/bdist.linux-i686/egg/ctxtnavadd/web_ui.pys?s     PKpj4ctxtnavadd/api.pyc; lDc@s!dkTdefdYZdS((s*s ICtxtnavAddercBs tZdZdZdZRS(s7An extension point interface to adding ctxtnav entries.cCsdS(s;Return True if you want to alter this requests ctxtnav bar.N((sreq((s,build/bdist.linux-i686/egg/ctxtnavadd/api.pysmatch_ctxtnav_addscCsdS(s>Return a list of the form (path, text) to be added to the bar.N((sreq((s,build/bdist.linux-i686/egg/ctxtnavadd/api.pysget_ctxtnav_adds s(s__name__s __module__s__doc__smatch_ctxtnav_addsget_ctxtnav_adds(((s,build/bdist.linux-i686/egg/ctxtnavadd/api.pys ICtxtnavAdders  N(s trac.cores Interfaces ICtxtnavAdder(s ICtxtnavAdder((s,build/bdist.linux-i686/egg/ctxtnavadd/api.pys?sPKpj4JB)ctxtnavadd/__init__.pyc; &`Dc@sdS(N((((s1build/bdist.linux-i686/egg/ctxtnavadd/__init__.pys?sPKh4kPP"ctxtnavadd/templates/ctxtnavadd.csadd_ctxtnav(''); PKf4vcc"ctxtnavadd/htdocs/js/ctxtnavadd.jsfunction find_old_last() { var ctxtnav = document.getElementById('ctxtnav'); for (var i in ctxtnav.childNodes) { if(ctxtnav.childNodes[i].tagName == 'UL') { var ul_node = ctxtnav.childNodes[i]; for (var j in ul_node.childNodes) { if(ul_node.childNodes[j].tagName == 'LI') { var li_node = ul_node.childNodes[j]; if(li_node.getAttribute('class') == 'last') { return(li_node); } } } } } } function add_ctxtnav(txt) { // Make a new
  • and find the old
  • var new_li = document.createElement('LI'); var old_li = find_old_last(); // Insert content new_li.innerHTML = txt; // Set the class on the new
  • and clear the old one new_li.setAttribute('class','last'); old_li.removeAttribute('class'); // Insert the new node old_li.parentNode.appendChild(new_li); } function add_ctxtnav_link(href, txt) { var html = '' + txt + ''; add_ctxtnav(html); } PKpj4Wu'EGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: TracCtxtnavAdd Version: 1.1-r1 Summary: Allow adding to the ctxtnav bar of other plugins. Home-page: http://trac-hacks.org/wiki/CtxtnavAddPlugin Author: Noah Kantrowitz Author-email: coderanger@yahoo.com License: BSD Description: Exposes an extension point interface for manipulating the ctxtnav bar (the little bar below the main navigation bar) of other plugins Keywords: trac plugin ctxtnav Platform: UNKNOWN PKpj4w"!!EGG-INFO/SOURCES.txtsetup.py TracCtxtnavAdd.egg-info/PKG-INFO TracCtxtnavAdd.egg-info/SOURCES.txt TracCtxtnavAdd.egg-info/entry_points.txt TracCtxtnavAdd.egg-info/top_level.txt ctxtnavadd/__init__.py ctxtnavadd/api.py ctxtnavadd/web_ui.py ctxtnavadd/htdocs/js/ctxtnavadd.js ctxtnavadd/templates/ctxtnavadd.cs PKpj4=66EGG-INFO/entry_points.txt[trac.plugins] ctxtnavadd.web_ui = ctxtnavadd.web_ui PKpj4} EGG-INFO/top_level.txtctxtnavadd PKpj4EGG-INFO/zip-safePKZ4^) ctxtnavadd/web_ui.pyPKʩ4p__" ctxtnavadd/api.pyPKi4 ctxtnavadd/__init__.pyPKpj4hIPEE ctxtnavadd/web_ui.pycPKpj4\ ctxtnavadd/api.pycPKpj4JB)R$ctxtnavadd/__init__.pycPKh4kPP"%ctxtnavadd/templates/ctxtnavadd.csPKf4vcc"%ctxtnavadd/htdocs/js/ctxtnavadd.jsPKpj4Wu';*EGG-INFO/PKG-INFOPKpj4w"!!",EGG-INFO/SOURCES.txtPKpj4=66u-EGG-INFO/entry_points.txtPKpj4} -EGG-INFO/top_level.txtPKpj4!.EGG-INFO/zip-safePK xP.