Edgewall Software

Version 71 (modified by Shun-ichi Goto <gotoh@…>, 19 years ago) ( diff )

Added description of Image macro.

The Macro Bazaar

Looking for fresh macro goodness for your Trac installation? Have you written a clever macro you're dying to share with the world? This is the place.

The macro bazaar is for sharing information about user-developer macros, links to source code and requests.

Note: Please state your name, email, and version of Trac your macro is developed for.

Categories

Examples

HelloWorld

A simple example macro. Distributed with Trac.
Download: source:trunk/trac/wikimacros/HelloWorld.py
By: TracTeamVer: >0.5.2

(categories)


Includes

include

Inserts the output of an external URL.

Example:

[[include(http://www.example.com/)]]


Download: http://randomfoo.net/code/trac/include.py
By: lhl — Ver: 0.7.1

Replacement that also handles the WikFile macro below. Docs are inside the module @ the top.


Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/Include.2.py
By: csawyer@… — Ver: 0.8

WikiInclude

Inserts the contents of another wiki page. It expands arguments in the page in the form {{N}}.

Example:

[[WikiInclude(Foo)]]
[[WikiInclude(Foo|Argument1|Argument2..|ArgumentN)]]

Version: ≥ 0.8
Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/WikiInclude.py
By: Vegard Eriksen zyp at jvnv dot net

WikiFile

Inserts the output of an URL/file as wiki file. The file can be written in trac syntax and the macro will convert it to html.

The macro looks at the suffix of the file and tries to interpret it according to that syntax,

html will be intrepreted as html

rst will be interpreted Restructured Text

cpp as c++ etc

So you can have a file on the filesystem that is written with trac syntax or restructured text and display it within the wiki. The advantage is that you can use version control on file. The disadvantage is that you cant click page history and see the history of the page. You can also not edit the file within the Wiki which takes away alot of the advantages of a Wiki. But within a company it might be ok.

Example:

[[WikiFile(http://www.example.com/myfile.rst)]]

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/WikiFile.py By: Toni Brkic toni.brkic at switchcore.com — Required ver patch for #801 must be implemented

(categories)


First stab at a macro that displays all wiki pages linking to a specified page name.

Usage:

[[BackLinks(pagename)]]

I'd really like it to default to displaying backlinks to the current page when a page name isn't supplied, but, um, I have no idea how to do that. Suggestions greatly appreciated.
Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks.py
By: Dan Hon <danhon+trac@…> — Ver. ≥ 0.7.1

Dan, here's an idea.

thispage = hdf.getValue('wiki.page_name', '')

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks.2.py patches the wikimacro to default to display backlinks to the current page if a page name is not specified.
By: Muness Alrubaie <muness@…> — Ver. ≥ 0.8

Well, both those seem to have a bug: they will list pages for which at least one version linked to thispage, rather than just the latest version. So here's a fixed macro.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/BackLinks3.py patches the wikimacro to display only pages where the latest version links to the specified or current page.
By: Andrew Durdin <adurdin at gmail.com> — Ver. ≥ 0.8
Notes: An outstanding issue with these macros is that it incorrectly registers links from pages where their titles appear like CamelCase (i.e. not a link) or where the name (not a TracLink-style name) is used legitimately in a different context (e.g. a page named 'History' would show backlinks to any other pages with the word 'History' in them).

SubWiki

Derived from TitleIndex. Returns a list of sub-wiki entries. A sub-wiki page is a page that is is deeper in the hierarchy than the current page. e.g. if the current page is People, this will return a list of all wiki entries that start with "People/"

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.py
Version: ≥ 0.8
By: Muness Alrubaie <muness@…>

A different version that lists the contents of the line specified in the second parameter next to the the link.


Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.2.py
By: csawyer@… — Ver: 0.8

A different version that lists the contents of the first heading element next to the link. The second parameter specifies the number of levels to display. Based on the version by csawyer@….


Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SubWiki.3.py
By: muness@… — Ver: 0.8

ParentWiki

Inserts a link to the "parent" wiki entry. This only applies to wikis that have a "/" in their name indicating hierarchy. e.g. an entry named Java/Introduction will have a parent of Java. All other wiki entries have a parent of WikiStart.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ParentWiki.py
Version: ≥ 0.8
By: Muness Alrubaie <muness@…>

ShowPath

Show the path to the specified wiki or the current wiki if none is specified. This is similar to the directory names at the top of the TracBrowser. This applies mainly to hierarchical wiki entries. e.g. the path to a Book/Chapter/Section/Subsection would be WikiStart/Book/Chapter/Section/Subsection (all but the current would be linked).

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ShowPath.py
Version: ≥ 0.8
By: Muness Alrubaie <muness@…>

Redirect

It is sometimes useful to create alias names for wiki pages (or tickets or other trac objects. This can be accomplished using the "redirect" macro.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/redirect.py

Usage: E.g., on page RequestForRedirect use [[redirect(ticket:976)]] to create an alias wiki name for ticket #976.

Note: the argument to the redirect macro must be in general form of TracLinks (item:id).

Note: to edit a page that contains a redirect macro, you must type its URL directly into your browser's location bar and append the string '?edit=true' to it.

Version: ≥ 0.8
By: Bernhard Haumacher <haui at haumacher.de>

TracNav

The TracNav macro implements a fully customizable navigation bar for the Trac wiki engine (a replacement for the pure static TracGuideToc macro). The contents of the navigation bar is a wiki page itself and can be edited like any other wiki page through the web interface. The navigation bar supports hierarchical ordering of topics.

Further information and a life example can be found at the TracNav home page.

Download: TracNav.py
Version: ≥ 0.8
By: Bernhard Haumacher (haui at haumacher.de)

(categories)


Time & Date

Timestamp

Inserts current date and time. Distributed with Trac.
Download: source:trunk/trac/wikimacros/Timestamp.py
By: TracTeamVer: >0.5.2

DateOffset

Returns the date referred to as follows:

  • First arg is the offset, i.e. the date to start from
  • Second arg is the multiplier to multiply the count by (e.g. 7 for a week)
  • Third arg is the count (i.e. the number of additions to make).

So, for example:

  • [[DateOffset(2005/01/05,7,0)]] returns Wed Jan 05
  • [[DateOffset(2005/01/05,7,4)]] returns Wed Feb 02

You can also configure the input and output date formats. (See http://python.org/doc/2.3.4/lib/module-time.html). e.g.:

  • [[DateOffset(01/05/2005,7,0,%m/%d/%Y,%A %B %d)]] returns Wednesday January 05

Please email me fixes and excuse any obvious errors: I've never written any python before this.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/DateOffset.py
Version: ≥ 0.8
By: Muness Alrubaie <muness@…>

LastModified

Shows the last modification date of the specified page, or the page the macro appears in if not specified. An optional argument, delta , can be given to show the time elapsed since the last modification. The output is placed in span with a title that gives the exact modification date and the author of the change. See examples or download it!

Usage:

[[LastModified]]
[[LastModified(delta)]]
[[LastModified(MacroBazaar)]]
[[LastModified(MacroBazaar,delta)]]

Download: http://severinghaus.org/projects/bfgff/LastModified.py
Version: ≥ 0.7
By: Steven N. Severinghaus <sns@…>

(categories)


Miscellaneous

Javadoc

Creates links to Javadoc pages based on a package or fully-qualified class name.

Example usage:

[[javadoc(java.lang)]]
[[javadoc(java.lang.String)]]
[[javadoc(java.lang.String, Text for link)]]

See source for customizing the available Javadoc URLs.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/javadoc.py
By: Matthew Good <matt-good.net> — Ver: ≥0.7.1

(categories)


Uncategorized

UserChanges

Trivial change of the RecentChanges macro that only displays the recently changed pages for a specified user. Usage:

[[UserChange(username)]]
 or
[[UserChange(username, # of last modified pages to display)]]

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/UserChanges.py
By: David Mohr <datrac@…> — Ver. ≥ 0.7.1

TracPoll

This macro adds polls to Trac. Any number of polls can be added to a page and polls are unique to each project.

The pickled state of the poll is stored in polldir (set at the top of the plugin). No locking is performed.

Usage:

[[Poll(Title for poll; Option 1 for poll; Option 2 for poll; etc.)]]

Download: http://svn.swapoff.org/trachacks/wiki/PollMacro
By: Alec Thomas <trac-form@…> — Ver. ≥ 0.7.1

TOC

This macro adds the ability to create table of contents on any set of pages. If a page is not specified, the current page and version is used.

The table of contents is automatically generated from headings in the page.

Usage:

Table of contents for the current page and version:

[[TOC]]

Table of contents for multiple pages:

[[TOC(WikiStart, WikiFormatting)]]

Download: http://svn.swapoff.org/trachacks/wiki/TocMacro
By: Alec Thomas <trac-form@…>
Version: ≥ 0.7.1 (requires patch available at http://svn.swapoff.org/trachacks/wiki/AnchorPatch)

AddComment

Adds a textarea to TracWiki pages allowing for quick comments to be added in a standard format.

The comments are fully integrated into the Wiki, incrementing the version number and adding a log comment.

Download: http://svn.swapoff.org/trachacks/wiki/AddCommentMacro
By: Alec Thomas <trac-form@…>
Version: ≥ 0.8

SvnFiles

This macro autogenerates a list of clickable file links referring to files in a given directory of the repository whose names match a given regular expression. We needed this for a page giving an overall view of project progress for a project broken up into a shallow hierarchy, combined with ReTickets (below) it autogenerates an overview wiki page.

Please don't laugh at the code, I've been playing with trac for 2 days and had never touched python before writing these two…

Usage

[[SvnFiles(directory,regexp)]]

All arguments are needed, god alone knows what happens if you leave them out.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/SvnFiles.py Version: 0.8 By: Simon Stapleton <simon@…>

ReTickets

This macro autogenerates a list of clickable ticket links (link number and person assigned) referring to tickets whose summaries match a given regular expression. We needed this for a page giving an overall view of project progress for a project broken up into a shallow hierarchy, combined with SvnFiles (above) it autogenerates an overview wiki page.

As an added bonus, hovering over the links gives the summary and description of the ticket.

Usage

[[ReTickets(regexp)]]

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/ReTickets.py Version: 0.8 By: Simon Stapleton <simon@…>

Build a search URL for the supplied argument or just a link to a search engine if no args are present. Set to use google. Edit the macro to modify the engine(/url).

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/Search.py
Version: ≥ 0.8
By: Muness Alrubaie <muness@…>

TracSearch

Builds a link to search for a supplied argument in any or all of the wiki, changesets, and tickets.

Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/TracSearch.py
Version: ≥ 0.8
By: Andrew Durdin <adurdin at gmail.com>

Blog

A simple blog macro which renders matched wiki pages on one page. Only one month's wiki pages are shown at once.

Usage example:

[[Blog(blog/%)]]
[[Blog(2004%,blog/%)]]

Note: if you're using macro redirect and AddComment, you may need to modify these macros to disable them by:

    if hdf.getValue('macro.blog.rendering', '0') == '1':
        # workaround: if this wiki is rendering via macro Blog, don't redirect!
        out.write('<div class="system-message">Warning: redirection disabled in Blog mode.</div>')
        return out.getvalue()


Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/Blog.py
By: Walter Wong <wangzq@…>
Version: ≥0.8

Acronym

Add support for HTML acronyms.

Usage example:

[[Acronym(HTML, Hypertext Markup Language]]


Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/acronym.py
By: Justin Palmer <trac at isolated-designs dot net>
Version: ≥0.8

FootNote

Automatically collates and generates foot-notes.

Usage example:

Some text [[FootNote(This is a footnote)]]

This foot-note refers to the first[[FootNote(1)]].

...

Listing the foot-notes in this page:

[[FootNote]]

Multiple sets of foot-notes can be generated and existing foot-notes referred to by index.

Download: http://svn.swapoff.org/trachacks/wiki/FootNoteMacro
By: Alec Thomas <trac-form@…>
Version: ≥ 0.8

Image

Display image of attachment or repository file onto any wiki/ticket document.

Example

Take image from same page:
  [[Image(photo.jpg)]]                          # simple
  [[Image(photo.jpg,120px)]]                    # as specified size
  [[Image(photo.jpg,right)]]                    # place image in right of page

Or from other place:
  [[Image(OtherPage/foo.bmp)]]                  # from OtherPage
  [[Image(wiki/OtherPage/foo.bmp)]]             # same above
  [[Image(ticket/36/boo.jpg)]]                  # from ticket:36
  [[Image(file/images/bee.jpg)]]                # from repository

See heading comment of source file for more detail.


Download: http://projects.edgewall.com/trac/attachment/wiki/MacroBazaar/Image.py
By: Shun-ichi Goto <gotoh@…>
Version: ≥ 0.8

Add your macro here … (categories)


Requests

Requests, comments, etc go here.


Something like pararaph numbers in http://www.blueoxen.org/tools/purplewiki/ helps with documentation authoring.

(categories)


See also: WikiMacros, ProcessorBazaar

Attachments (75)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.