Hide
Solve a problem – Filter by language, license, keyword, owner, or search text to find code & info fast. Join Siafoo Now or Learn More

Pass arbitrary options from conf.ini to templates in Trac

Revision 2 vs. Revision 3

Changelog: Added info on project list for regular trac pages

Legend:

Unmodified
Added
Removed
  • Description

    r2 r3  
    11This is the meat for an arbitrary options plugin for Trac.  You put whatever options you'd like in a ``[project_info]`` stanza inside your trac's .ini file.  These are passed to the template as key-value pairs inside the dictionary 'project_info'.  
     2  
     3You can also access data for other projects in your trac env under the list 'projects'.  That list will have a dictionary with keys 'name', 'description', 'href', and 'info', where the first three are the same as in a `project list <http://trac.edgewall.org/wiki/TracInterfaceCustomization#ProjectList>`_, and the 'info' is the dictionary of arbitrary options you've passed for that project.  
    24  
    35This is also a great super-simple example of a Trac plugin.   
    46  
    57For example, if your .ini had this:  
    68  
     
    2325  
    2426Project Lists  
    2527-------------  
    2628You can include arbitrary per-project info inside your `project list page <http://trac.edgewall.org/wiki/TracInterfaceCustomization#ProjectList>`_, too.  However trac doesn't call plugins when generating this page, so you'll have to apply the patch :snippet:`260`.  Note that the top half isn't strictly necessary, as this plugin does the same thing, but this way nothing will crash if you *don't* have the plugin installed.  
    2729  
    28 In the project list you access each project's info as ``project.info``.  
     30This will pass a 'projects' list to your list page, the same list that is passed to each regular Trac page as described above.  
    2931  
    3032Download  
    3133--------  
    3234For the time being, you can `download the entire plugin <http://crew.icapsid.net/david/downloads/projects/tracarbitraryoptionsplugin.tar.bz2>`_.  
    3335