view MoinMoin/macro/ @ 4093:742cabb168b9

browser._format: refactored input parameter "method". The default value is changed from "GET" to None. Now it does not add a form tag to the table on default. You have to give a value of "GET" or "POST" to add a form tag using the given method.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 13 Sep 2008 15:12:14 +0200
parents 1008dd34b71c
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - List all defined smileys

    <<ShowSmileys>> will display a table of all the available smileys.

    Based on code by Nick Trout <>

    @copyright: 2003 Juergen Hermann <>
    @license: GNU GPL, see COPYING for details.

from MoinMoin import config
from MoinMoin.util.dataset import TupleDataset, Column
from MoinMoin.widget.browser import DataBrowserWidget


Dependencies = ['user'] # different users have different themes and different user prefs (text/gfx)

def macro_ShowSmileys(macro):
    _ = macro.request.getText
    fmt = macro.formatter

    # create data description
    data = TupleDataset()
    data.columns = []
    for dummy in range(COLUMNS):
            Column('markup', label=_('Markup')),
            Column('image', label=_('Display'), align='center'),
            Column('', label=''),
    data.columns[-1].hidden = 1

    # iterate over smileys, in groups of size COLUMNS
    smileys = config.smileys
    for idx in range(0, len(smileys), COLUMNS):
        row = []
        for off in range(COLUMNS):
            if idx+off < len(smileys):
                markup = smileys[idx+off]
                row.extend([fmt.code(1) + fmt.text(markup) + fmt.code(0), fmt.smiley(markup), '', ])
                row.extend(['&nbsp;'] * 3)

    # display table
    if data:
        browser = DataBrowserWidget(macro.request)
        return browser.render(method="GET")

    return ''