示例#1
0
    def resource(self, resname, context = 'base'):
        for path in hooks.each('infobox.content.resource', resname):
            if path is not None:
                return path

        dir = self.get_res_dir(context)
        file = dir / resname
        return file.abspath()
示例#2
0
    def resource(self, resname, context='base'):
        for path in hooks.each('infobox.content.resource', resname):
            if path is not None:
                return path

        dir = self.get_res_dir(context)
        file = dir / resname
        return file.abspath()
示例#3
0
def set_hosted_content(webview, account, infobox_js=None):
    script = JScript()
    key = u'%s_%s' % (account.protocol, account.username)

    from .interfaces import IInfoboxHTMLProvider
    ip = IInfoboxHTMLProvider(account)
    ip.load_files(ip.get_context())
    dir = ip.app.get_res_dir('base')

    dirty = account._dirty
    if dirty:
        new_content = ''
        account.loaded_count = getattr(account, 'loaded_count', 0) + 1
        if not getattr(account, '_did_load_head', False):
            account._did_load_head = True
            new_content += ip.get_html(file='head.tenjin', dir=dir)

        new_content += ip.get_html(file='content.tenjin', dir=dir)

        script.updateContent(key, new_content)
        account._dirty = False

    jsscript = 'callOnHide();\n'

    script.swapToContent(key)

    jsscript += script.js()

    jsscript = SkinMemoizedCssScript(webview).get_css(jsscript)

    # switch our <link rel="stylesheet"> tag to app's infobox.css file
    css_url = simplejson.dumps((dir / 'infobox.css').url())

    jsscript = ('document.getElementById("appCSS").setAttribute("href", %s);\n' % css_url) + jsscript

    # replace $ if we are initializing
    if dirty:

        jsscript += 'clearOnHide();\n'

        if infobox_js is None:
            ijs_file = dir / 'infobox.js'
            if ijs_file.isfile(): infobox_js = ijs_file.bytes()

        infobox_js = infobox_js or ''

        infobox_js += '\n'.join(hooks.each('infobox.content.infoboxjs', account))

        jsscript += ('(function() {if (window.DCallbacks !== undefined) {var D = new DCallbacks(%s);}; %s})();\n' % (simplejson.dumps(key), infobox_js))

        jsscript = 'callWithInfoboxOnLoad(function() {' + jsscript +'});'
        jsscript += '\ncallSwapIn(currentContentName);'

    account.last_script = jsscript
    webview.RunScript(jsscript)
示例#4
0
def get(hook_name, impl_default, default, *a, **k):
    impl = getattr(sys, 'BRAND', impl_default) or impl_default
    try:
        k.update(impl=impl)
        vals = list(hooks.each(hook_name, *a, **k))
    except Exception:
        traceback.print_exc()
    else:
        if vals:
            return vals[0]
    return default
示例#5
0
def branding_re():
    return '( ((' + ')|('.join(
        hooks.each('digsby.status.url.for_protocol_re')) + ')))'
示例#6
0
 def get_plugin_head_content():
     return hooks.each('infobox.content.head', protocol)
示例#7
0
def branding_re():
    return '( ((' + ')|('.join(hooks.each('digsby.status.url.for_protocol_re')) + ')))'