Attachment 'Backlinks.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """MoinMoin - Backlinks
3
4 A macro to embed backlinks into the current page.
5
6 Syntax:
7 [[Backlinks]]
8
9 $Id: Backlinks.py,v 1.1.1.1 2007-06-07 20:36:15 gber Exp $
10 Copyright 2007 by Guido Berhoerster <guido+moinmoin@berhoerster.name>
11 Licensed under the GNU GPL, see COPYING for details.
12
13 $Log: Backlinks.py,v $
14 Revision 1.1.1.1 2007-06-07 20:36:15 gber
15 initial import into CVS
16
17
18 """
19
20 from MoinMoin import search
21
22 # do not cache
23 Dependencies = ["namespace"]
24
25 def execute(macro, args):
26 request = macro.request
27 _ = request.getText
28 content = []
29
30 # do not show to spiders in order to avoid heavy cpu load
31 if request.isSpiderAgent:
32 return ''
33
34 page_name = macro.formatter.page.page_name
35
36 # backlinks get wrapped and a heading
37 content.append(macro.formatter.div(1, css_class="backlinks"))
38 content.append(macro.formatter.heading(1,1))
39 content.append(macro.formatter.escapedText(_("Backlinks")))
40 content.append(macro.formatter.heading(0,1))
41
42 # search for pages linking to this one and sort results by name
43 query = search.LinkSearch(page_name)
44 results = search.searchPages(request, query)
45 results.sortByPagename()
46
47 content.append(results.pageList(request, request.formatter,
48 numbered=0))
49 content.append(macro.formatter.div(0))
50
51 return "".join(content)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.