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

	Usage:
		[[IconLink(icon, href)]]
		href can
		
	Notes:
		debugging messages through creosote, uses a dummy object
		if creosote isn't in site-packages (or elsewhere in $PYTHONPATH)

	@copyright:	2006 Ryan Volpe
	@license:	BSD
	
	@version history:
		27 March 2006, v.0, Ryan Volpe
			initial code, concept, etc.
"""
from MoinMoin.request import config

try:
	import creosote
except:
	class mockcreosote(object):
		def spew(self, *args, **kws):
			pass
	creosote = mockcreosote()


def execute(macro, args):
	argl = args.split(',')
	
	smileys = config.smileys

	if argl[0] not in smileys:
		creosote.spew('IconLink: %s not in smileys, ignoring macro.' %argl[0])
		return ""
	
	smiley = smileys[argl[0]]
	link = argl[1].strip()


	link = ("<a href='%s' title='%s'><img alt='%s' src='/wiki/Xmodern/img/%s' width='%s' height='%s' border='%s' /></a>" %(link, link, link, smiley[3], smiley[0], smiley[1], smiley[2]))

	return link
