Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.macro.FootNote Namespace Reference

Functions

def execute
def emit_footnotes

Variables

list Dependencies = ["time"]

Function Documentation

def MoinMoin.macro.FootNote.emit_footnotes (   request,
  formatter 
)

Definition at line 63 of file FootNote.py.

00063 
00064 def emit_footnotes(request, formatter):
00065     # emit collected footnotes
00066     if request.footnotes:
00067         result = []
00068 
00069         result.append(formatter.div(1, css_class='footnotes'))
00070 
00071         # Add footnotes list
00072         result.append(formatter.number_list(1))
00073         subidx = 0
00074         for ctr in range(request.footnote_ctr):
00075             fn_txt = request.footnotes[ctr]
00076             if not fn_txt in request.footnotes:
00077                 continue
00078             this_txt_footnotes, fwdlink_id, showidx = request.footnotes[fn_txt]
00079             # this text was handled
00080             del request.footnotes[fn_txt]
00081 
00082             result.append(formatter.listitem(1))
00083             result.append(formatter.paragraph(1))
00084             result.append(formatter.anchorlink(1, None, id=fwdlink_id))
00085             result.append(formatter.anchorlink(0))
00086             result.append(wikiutil.renderText(request, WikiParser, fn_txt))
00087 
00088             items = []
00089             # ToDo check why that loop is needed?
00090             for backlink_id, idx in this_txt_footnotes:
00091                 # Add item
00092                 item = formatter.anchorlink(1, backlink_id)
00093                 item += formatter.text(str(subidx+1))
00094                 item += formatter.anchorlink(0)
00095                 items.append(item)
00096                 subidx += 1
00097 
00098             result.append(formatter.text(" ("))
00099             result.append(formatter.text(" ").join(items))
00100             result.append(formatter.text(")"))
00101 
00102             result.append(formatter.paragraph(0))
00103             result.append(formatter.listitem(0))
00104 
00105         result.append(formatter.number_list(0))
00106 
00107         # Finish div
00108         result.append(formatter.div(0))
00109 
00110         del request.footnotes
00111         del request.footnote_ctr
00112         del request.footnote_show_ctr
00113         return ''.join(result)
00114 
00115     return ''
00116 

Here is the caller graph for this function:

def MoinMoin.macro.FootNote.execute (   macro,
  args 
)

Definition at line 20 of file FootNote.py.

00020 
00021 def execute(macro, args):
00022     request = macro.request
00023     formatter = macro.formatter
00024 
00025     # create storage for footnotes
00026     if not hasattr(request, 'footnotes'):
00027         request.footnotes = {}
00028         request.footnote_ctr = 0
00029         request.footnote_show_ctr = 0
00030 
00031     if not args:
00032         return emit_footnotes(request, formatter)
00033     else:
00034         # grab new footnote backref number
00035         idx = request.footnote_ctr
00036         request.footnote_ctr += 1
00037 
00038         shahex = hash_new('sha1', args.encode(config.charset)).hexdigest()
00039         backlink_id = "fndef-%s-%d" % (shahex, idx)
00040         fwdlink_id = "fnref-%s" % shahex
00041 
00042         if not args in request.footnotes:
00043             showidx = request.footnote_show_ctr
00044             request.footnote_show_ctr += 1
00045             request.footnotes[args] = ([], fwdlink_id, showidx)
00046         flist, dummy, showidx = request.footnotes[args]
00047         request.footnotes[args] = (flist + [(backlink_id, idx)], fwdlink_id, showidx)
00048 
00049         # do index -> text mapping in the same dict, that's fine because
00050         # args is always a string and idx alwas a number.
00051         request.footnotes[idx] = args
00052 
00053         return "%s%s%s%s%s" % (
00054             formatter.sup(1),
00055             formatter.anchorlink(1, fwdlink_id, id=backlink_id),
00056             formatter.text(str(showidx+1)),
00057             formatter.anchorlink(0),
00058             formatter.sup(0), )
00059 
00060     # nothing to do or emit
00061     return ''
00062 

Here is the call graph for this function:


Variable Documentation

Definition at line 18 of file FootNote.py.