Beispiel #1
0
def comauthor(context):
	"""Display the author information for a comment, drawing on
	the given name, website URL, DWiki login, and comment IP address
	as necessary and available. Only works inside comment::showall.
	This potentially generates HTML, not just plain text."""
	if com_stash_var not in context:
		return ''
	c = context[com_stash_var]
	ares = []
	udata = context.model.get_user(c.user)
	#uname = c.username if c.username else udata.username if udata else None
	uname = c.username
	uurl = c.userurl if c.userurl else \
	       wikirend.gen_wikilink_url(context, udata.userurl) if udata else None
	if uname:
		ares.append("By")
		ares.append(com_optlink(uname, uurl))
		if not c.is_anon(context):
			ares.append("(%s)" % c.user)
	elif not c.is_anon(context):
		ares.append("By")
		if udata and udata.username:
			uname = '<abbr title="%s">%s</abbr>' % \
				(httputil.quotehtml(udata.username),
				 httputil.quotehtml(c.user))
			if uurl:
				ares.append('<a href="%s">%s</a>' % \
					    (httputil.quoteurl(uurl), uname))
			else:
				ares.append(uname)
		else:
			ares.append(com_optlink(c.user, uurl))
	else:
		ares.append("From")
		ares.append(com_optlink(c.ip, uurl))
	return ' '.join(ares)
Beispiel #2
0
def comauthor(context):
    """Display the author information for a comment, drawing on
	the given name, website URL, DWiki login, and comment IP address
	as necessary and available. Only works inside comment::showall.
	This potentially generates HTML, not just plain text."""
    if com_stash_var not in context:
        return ''
    c = context[com_stash_var]
    ares = []
    udata = context.model.get_user(c.user)
    #uname = c.username if c.username else udata.username if udata else None
    uname = c.username
    uurl = c.userurl if c.userurl else \
           wikirend.gen_wikilink_url(context, udata.userurl) if udata else None
    if uname:
        ares.append("By")
        ares.append(com_optlink(uname, uurl))
        if not c.is_anon(context):
            ares.append("(%s)" % c.user)
    elif not c.is_anon(context):
        ares.append("By")
        if udata and udata.username:
            uname = '<abbr title="%s">%s</abbr>' % \
             (httputil.quotehtml(udata.username),
              httputil.quotehtml(c.user))
            if uurl:
                ares.append('<a href="%s">%s</a>' % \
                     (httputil.quoteurl(uurl), uname))
            else:
                ares.append(uname)
        else:
            ares.append(com_optlink(c.user, uurl))
    else:
        ares.append("From")
        ares.append(com_optlink(c.ip, uurl))
    return ' '.join(ares)
Beispiel #3
0
def com_optlink(txt, url):
	if not url:
		return httputil.quotehtml(txt)
	return htmlrends.makelink(txt, httputil.quoteurl(url))
Beispiel #4
0
def com_optlink(txt, url):
    if not url:
        return httputil.quotehtml(txt)
    return htmlrends.makelink(txt, httputil.quoteurl(url))