# -*- coding: utf-8 -*-
"""
    MoinMoin - LoginHint

    Usage:
        <<LoginHint(Please login using the link at the top border!)>>

    @copyright: 2006 Thomas Waldmann
    @license: GNU GPL, see COPYING for details

    changes:
        12.2007 - conversion to new syntax by Bolesław Kulbabiński
"""
hint_style = "background-color: orange; text-align: center;"

from MoinMoin import wikiutil

def macro_LoginHint(macro, hint_text=u'Please login using the link at the top border!'):
    if macro.request.user.valid:
        return ''
    f = macro.request.formatter
    return (f.div(1, id="LoginHint", style=hint_style) +
            f.text(hint_text) +
            f.div(0))


def execute(macro, args):
    try:
        return wikiutil.invoke_extension_function(
                   macro.request, macro_LoginHint,
                   args, [macro])
    except ValueError, err:
        return macro.request.formatter.text(
                   "<<LoginHint: %s>>" % err.args[0])

