Attachment 'CiteThisPage.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - CiteThisPage action
4
5 Providing bibliographic details for a current page
6 Features citation styles: ABNT, Modern Language Association and BibTeX (LaTeX)
7 Only tested in MoinMoin 1.5.5a
8
9 @copyright: 2007 by Leonardo Gregianin <leogregianin@gmail.com>
10 @license: GNU GPL, see COPYING for details.
11 """
12
13 import re
14 from MoinMoin.Page import Page
15 from MoinMoin.action import ActionBase
16
17 class CiteThisPage(ActionBase):
18 def __init__(self, pagename, request):
19 ActionBase.__init__(self, pagename, request)
20
21 def get_form_html(self, buttons_html):
22 page = Page(self.request, self.pagename)
23
24 # URL
25 revision = page.current_rev()
26 interwiki = self.request.getBaseURL()
27 url = '%s%s?action=recall&rev=%i' % (interwiki, page.url(self.request), revision)
28
29 # Date of last revision
30 time = page.mtime_printable(self.request)
31 date = re.search("(?P<date>.+?) (?P<time>.+?)", time)
32
33 # Site name
34 publisher = interwiki.split("http://")[1].capitalize()
35 if publisher.startswith("www."):
36 publisher = interwiki.split("http://www.")[1].capitalize()
37
38 _ = self._
39 cite = {
40 'comment1': (_("Page name")),
41 'comment2': (_("Publisher")),
42 'comment3': (_("Permanent URL")),
43 'comment4': (_("Date of last revision")),
44 'comment5': (_("Bibliographic details for")),
45 'comment6': (_("Citation styles")),
46 'comment7': (_("Available in")),
47 'comment8': "%s" % self.pagename,
48 'comment9': "%s" % publisher,
49 'comment10': "%s" % url,
50 'comment11': "%s" % date.group("date"), # year-month-day
51 'comment12': "%s" % date.group("date").split("-")[0], # year
52 }
53
54 return """
55 <strong>%(comment5)s %(comment8)s</strong><br />
56 <tr>
57 <td class="label"><label>%(comment1)s: %(comment8)s</label></td><br />
58 <td class="label"><label>%(comment2)s: <i>%(comment9)s</i></label></td><br />
59 <td class="label"><label>%(comment3)s: %(comment10)s</label></td><br />
60 <td class="label"><label>%(comment4)s: %(comment11)s</label></td><br />
61 </tr>
62 <br />
63 <strong>%(comment6)s:</strong><br />
64 <br />
65 <tr>
66 <strong>ABNT:</strong><br />
67 <td class="label"><label><i>%(comment9)s</i>. %(comment7)s <label>%(comment10)s. %(comment4)s: %(comment11)s.</label>
68 </td><br />
69 </tr>
70 <br />
71 <tr>
72 <strong>Modern Language Association:</strong><br />
73 <td class="label"><label>"%(comment8)s". <i>%(comment9)s</i>. %(comment11)s %(comment7)s %(comment10)s</label>.
74 </td><br />
75 <tr>
76 <br />
77 <tr>
78 <strong>BibTeX:</strong><br />
79 <td class="label"><label>
80 @misc{ wiki:xxx,<br />
81 author = "%(comment9)s",<br />
82 title = "%(comment8)s",<br />
83 year = "%(comment12)s",<br />
84 url = "\url{%(comment10)s}",<br />
85 note = "[Online; "%(comment11)s"]"}<br />
86 </td><br />
87 <tr>
88 """ % cite
89
90 def execute(pagename, request):
91 CiteThisPage(pagename, request).render()
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.