Index: macros.py
===================================================================
--- macros.py	(revision 10020)
+++ macros.py	(working copy)
@@ -25,7 +25,8 @@
 
 from trac.core import *
 from trac.resource import Resource, ResourceNotFound, get_resource_name, \
-                          get_resource_summary, get_resource_url
+                          get_resource_summary, get_resource_url, \
+                          render_resource_link
 from trac.util.compat import any, rpartition
 from trac.util.datefmt import format_date, from_utimestamp
 from trac.util.html import escape
@@ -710,3 +711,44 @@
                            class_=(prefix+ref == curpage and 'active'))
                     for ref, title in self.TOC]),
             class_='wiki-toc')
+
+
+class ResourceMacro(WikiMacroBase):
+    """Display a link to the specified resource
+
+    A resource is specified using `realm`, `id` and optionally `version`.
+    The `format` of the resulting link can also be specified: default,
+    compact or summary (or a combination of formats separated by the | 
+    character.
+    """
+
+    def expand_macro(self, formatter, name, args):
+        args, kw = parse_args(args)
+        
+        args = dict(
+            zip(('realm', 'id', 'version', 'format'), args))
+        args.update(kw)
+        
+        realm = args.get('realm', '').strip() or formatter.resource.realm
+        res_id = args.get('id', '').strip()
+        
+        if not res_id:
+            raise TracError('Resource Macro requires a resource ID')
+        
+        formats = [f.strip() for f in args.get('format', 'default').split('|')]
+
+        version = args.get('version', False)
+        if version:
+            version.strip()
+        
+        res = Resource(realm, res_id, version)
+        
+        links = []
+        for format in formats:
+            # insert a space before every part except the first
+            if links:
+                links.append(" ")
+            links.append(
+                render_resource_link(self.env, formatter, res, format))
+
+        return  tag.span(links)

