Beispiel #1
0
def FontTagify(string, fonttype, nowrap = False):
    font  = skin_get('infobox.fonts.%s' % fonttype, default_font)
    color = skin_get('infobox.fontcolors.%s' % fonttype, wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)

    if isinstance(string, str):
        try:
            string = string.decode('fuzzy') # Last ditch attempt
        except UnicodeDecodeError, e:
            log.info('Couldn\'t put %r into a font tag- decode failed with error %r', string, e)
            return ''
Beispiel #2
0
def GenStatusIconHTML(contact):

    sicon = skin_get("statusicons." + contact.status_orb)
    margins = skin_get('infobox.margins')

    iconinfo = {'iconurl': sicon.path.url(),
                'iwidth': sicon.Width,
                'iheight': sicon.Height,
                'iposx': margins.right + (16-sicon.Width)//2,
                'iposy': margins.top}

    return u'<img src= "%(iconurl)s" style="width: %(iwidth)ipx; height: %(iheight)ipx; position: absolute; top: %(iposy)ipx; right: %(iposx)ipx;" >' % iconinfo
Beispiel #3
0
def get_hr(key = None, padding = True):

    if key is not None:
        separator = skin_get('infobox.%s' % key, None)
    else:
        separator = None

    if separator is not None:
        html = '<div style="width: 100%%; padding: %ipx 0;"><img src = "%s" width = 100%% height = %spx /></div>' % ((4 if padding else 0), separator.path.url(), separator.Size.height)
    else:
        html = '<hr />'

    return html
Beispiel #4
0
def GetInfo(contact, showprofile=False, showhide=True, overflow_hidden=True):#showicon=True):

    css = '''\
table{
    table-layout: fixed;
}
body{
    word-wrap: break-word;
    %s
}
div{
    overflow: hidden;
}
''' % ('overflow: hidden' if overflow_hidden else '') + LINK_CSS + skin.get_css()

    no_icon_path = skin.get('BuddiesPanel.BuddyIcons.NoIcon').path.url()

    constanttop    = u'''\
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <style>
%(css)s
        </style>
        <script type="text/javascript">
            /* used to replace missing or BMP buddy icons with the default digsby one */
            function imgError(img) {
                img.onerror = "";
                img.src = "%(no_icon_path)s";
            }
        </script>
    </head>
    <body><div id="content"><TABLE WIDTH=100%% cellpadding=0 border=0><TR><TD valign=top>
''' % dict(css=css, no_icon_path=no_icon_path)

    constantmiddle = u'</TD><TD width="68" valign="top" align="center">'
    constantbottom = u'</TD></TR></TABLE></div></body></html>'

    s = contact.serviceicon

    if contact.service == 'digsby' and getattr(contact, 'iswidget', False):
        s = 'widget'

    ico = skin_get('serviceicons.' + s) if isinstance(s, basestring) else s
    servico=u''.join([u'<div style="white-space: nowrap; position: relative;"><div style = "position: absolute; left: 0px; top: 0px;">',
                      GenBitmapHTML(ico.path.url(), 16, 16),
                      u'</div>'])

    alias = contact.alias
    name=u''.join([u'<div style="white-space: normal; overflow: hidden; word-wrap: break-word; min-height: 20; margin: 0 0 0 20;">',
                   FontTagify(escape(alias),'header'),
                   u'</div></div>'])

    if s=='widget':
        location = GetLocationFromIP(contact) #odict
        moreinfo = u''

        if location:
            moreinfo = u''.join(['<div style="white-space: nowrap; width: 100%;">',
                                 TitleHTML(_(u'Location:')),
                                 BodyHTML(', '.join(location.values())),
                                 '</div>'])

        ip = u''.join(['<div style="white-space: nowrap; width: 100%;">',
                       TitleHTML(_(u'IP Address:')),
                      '<a href="http://www.geoiptool.com/en/?IP=%s">' % contact.ip,
                      BodyHTML(contact.ip),
                      '</a>',
                      '</div>'])

        time_ = u''.join(['<div style="white-space: nowrap;">',
                          TitleHTML(_(u'Time on Page:')),
                          DetailHTML(GenTimedString(contact.online_time)),
                          '</div>'])


        html = u''.join([constanttop, servico, name, time_, ip, moreinfo, constantbottom])

        return html

    nicename = contact.nice_name

    if nicename != alias:
        username = u''.join(['<div style="white-space: nowrap;">',
                             TitleHTML(protocols[contact.service].username_desc + u':'),
                             BodyHTML(nicename),
                             '</div>'])
    else:
        username = ''

    profile = ProfileHTML(contact.pretty_profile) if showprofile else u''

    times = ''
    if contact.service in ('icq', 'aim') and contact.online_time:
        times = u''.join([TitleHTML(_(u'Online:')),
                          DetailHTML(GenTimedString(contact.online_time))
                          ])

    idle_since = contact.idle
    if contact.service in ('icq', 'aim', 'yahoo') and idle_since and idle_since is not True:

        times += (u''.join([TitleHTML(('&nbsp; ' if times else '') + _(u'Idle:')),
                            DetailHTML(GenTimedString(idle_since)),
                            ]))

    away_since = getattr(contact, 'away_updated', None)
    if getattr(contact, 'away', False) and away_since:
        times += (u''.join([TitleHTML(_(('&nbsp; ' if times else '') + _(u'Away:'))),
                            DetailHTML(GenTimedString(away_since))
                            ]))
    if times:
        times = '<div>%s</div>' % times

    if contact.status_orb == 'unknown' or contact.service not in JABBER_SERVICES:
        status = u''.join(['<div style="white-space: nowrap;">',
                           TitleHTML(_(u'Status:')),
                           BodyHTML((_('{status} + Idle').format(status = contact.sightly_status) if contact.status == u'away' and contact.idle else contact.sightly_status)),
                           '</div>'])
    else:
        status = JabberStatusMagic(contact)

    statusmsg = getattr(contact, '_infobox_status_message', contact.status_message)
    import hooks
    if statusmsg is not None:
        statusmsg = hooks.reduce('digsby.status.tagging.strip_tag', statusmsg, impl='text')
    if not statusmsg or contact.service in JABBER_SERVICES:
        statusmsg = ''
    else:
        if contact.service not in ('aim', 'icq'):
            statusmsg = BodyHTML(statusmsg)

        statusmsg = u''.join((separatorshort(), statusmsg))

    icon = ''.join([constantmiddle,
                    GenStatusIconHTML(contact),
                    GenBuddyIconHTML(contact),
                    LinkHTML(u'profile', (_(u'Hide Profile') if showprofile else _(u'Show Profile')) if showhide else '', nowrap = True)])

    html = u''.join([constanttop, servico, name, username,
                     times, status, statusmsg, icon, profile, constantbottom])

    return linkify(html)