当前位置: 首页>>代码示例>>Python>>正文


Python static.PrefixNode类代码示例

本文整理汇总了Python中django.templatetags.static.PrefixNode的典型用法代码示例。如果您正苦于以下问题:Python PrefixNode类的具体用法?Python PrefixNode怎么用?Python PrefixNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PrefixNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sharewikify

def sharewikify(value):
    if value is not None:
        
        WIKI_WORD = r'http[s]?://(?:[a-zA-Z]|[0-9]|[[email protected]&+]|[!*\(\)\|,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
        wikifier = re.compile(r'\b(%s)\b' % WIKI_WORD)
        value = wikifier.sub(r'<a href="\1" target="_blank">\1</a>', value)

        # happy :) :-) 
        emot1 = re.compile(r'\:[\-]?\)', re.VERBOSE)
        value = emot1.sub(r'<img src="%simage/emots/tinymce_smiley-smile18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # wink ;) ;-) 
        emot11 = re.compile(r'\;[\-]?\)', re.VERBOSE)
        value = emot11.sub(r'<img src="%simage/emots/tinymce_smiley-wink18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # very sad :-(( :(( 
        emot22 = re.compile(r'\:[\-]?\(\(', re.VERBOSE)
        value = emot22.sub(r'<img src="%simage/emots/tinymce_smiley-cry18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # sad :( :-( 
        emot2 = re.compile(r'\:[\-]?\(', re.VERBOSE)
        value = emot2.sub(r'<img src="%simage/emots/tinymce_smiley-frown18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # kiss =* :-* :* 
        emot3 = re.compile(r'[=\:][\-]?\*', re.VERBOSE)
        value = emot3.sub(r'<img src="%simage/emots/tinymce_smiley-kiss18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # big smile :-D :D 
        emot4 = re.compile(r'\:[\-]?[dD]', re.VERBOSE)
        value = emot4.sub(r'<img src="%simage/emots/tinymce_smiley-laughing18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # tongue sticking out :-P :P :-p :p 
        emot5 = re.compile(r'\:[\-]?[pP]', re.VERBOSE)
        value = emot5.sub(r'<img src="%simage/emots/tinymce_smiley-tongue-out18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # surprised / o, no :-o :O 
        emot6 = re.compile(r'\:[\-]?[oO]', re.VERBOSE)
        value = emot6.sub(r'<img src="%simage/emots/tinymce_smiley-surprised18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # embarrassed :"> 
        emot7 = re.compile(r'\:\"\>', re.VERBOSE)
        value = emot7.sub(r'<img src="%simage/emots/tinymce_smiley-embarassed18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # wearing sunglasses B-) 
        emot8 = re.compile(r'B\-\)', re.VERBOSE)
        value = emot8.sub(r'<img src="%simage/emots/tinymce_smiley-cool18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # confused :-/ :-\ 
        emot9 = re.compile(r'\:\-[\\/]', re.VERBOSE)
        value = emot9.sub(r'<img src="%simage/emots/tinymce_smiley-undecided18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)

        # angry X-( x-( X( x(
        emot9 = re.compile(r'[xX][\-]?\(', re.VERBOSE)
        value = emot9.sub(r'<img src="%simage/emots/tinymce_smiley-yell18.gif" />' % PrefixNode.handle_simple("STATIC_URL"), value)
        
        # TODO: Beta 4.1
        #quote = re.compile(r'\[quote\](.*)\[/quote\]', re.DOTALL)
        #value = quote.sub(r'<p class="quote">\1</p>', value)
        
    return value
开发者ID:emilroz,项目名称:openmicroscopy,代码行数:60,代码来源:wikitags.py

示例2: render_js_files

def render_js_files(file_location):
    """
    Loads js files references from 'file_location' parameter.

    Usage::

        {% render_js_files file_location %}

    Example::

        {% render_js_files 'js/general.json' %}

    This method is assuming 'file_location' is under settings.STATIC_DIR dir.

    """
    result = ""
    static_base_path = settings.STATIC_DIR
    json_js_files_path = os.path.join(static_base_path, file_location)
    json_data = open(json_js_files_path)
    data = json.load(json_data)
    files_dirs = data['files']
    json_data.close()
    src_template = "<script src='%s'></script>\n"
    for js_file_path in files_dirs:
        result += src_template % urljoin(
            PrefixNode.handle_simple("STATIC_URL"),
            js_file_path)

    return result
开发者ID:loadimpact,项目名称:http2-frontend,代码行数:29,代码来源:basic_tags.py

示例3: get_treemenus_static_prefix

def get_treemenus_static_prefix():
    if django.VERSION >= (1, 3):
        from django.templatetags.static import PrefixNode
        return PrefixNode.handle_simple("STATIC_URL") + 'treemenus/img'
    else:
        from django.contrib.admin.templatetags.adminmedia import admin_media_prefix
        return admin_media_prefix() + 'img/admin/'
开发者ID:cary929,项目名称:django-treemenus,代码行数:7,代码来源:tree_menu_tags.py

示例4: fiduswriter_config_js

def fiduswriter_config_js(context):
    """
    Add Fidus Writer config variables to the window object in JavaScript.
    Usage::
        {% fiduswriter_config_js %}
    """
    if apps.is_installed('django.contrib.staticfiles'):
        from django.contrib.staticfiles.storage import staticfiles_storage
        static_url = staticfiles_storage.base_url
    else:
        static_url = PrefixNode.handle_simple("STATIC_URL")
    if 'WS_PORT' in settings.SERVER_INFO:
        ws_port = settings.SERVER_INFO['WS_PORT']
    else:
        ws_port = ''
    if 'WS_SERVER' in settings.SERVER_INFO:
        ws_server = settings.SERVER_INFO['WS_SERVER']
    else:
        ws_server = ''
    if 'user' in context:
        username = context['user'].get_username()
    else:
        username = ''
    return {
        'static_url': static_url,
        'ws_port': ws_port,
        'ws_server': ws_server,
        'username': username
    }
开发者ID:fiduswriter,项目名称:fiduswriter,代码行数:29,代码来源:fiduswriter.py

示例5: handle_simple

 def handle_simple(cls, path):
     static_dipstrap = getattr(settings, 'DIPSTRAP_STATIC_URL', '')
     if static_dipstrap:
         return urljoin(PrefixNode.handle_simple('DIPSTRAP_STATIC_URL'),
                        path)
     else:
         return super(DipstrapNode, cls).handle_simple(path)
开发者ID:unistra,项目名称:django-drybones,代码行数:7,代码来源:dipstrapfiles.py

示例6: admin_media_prefix

def admin_media_prefix():
    """
    Returns the string contained in the setting ADMIN_MEDIA_PREFIX.
    """
    warnings.warn(
        "The admin_media_prefix template tag is deprecated. "
        "Use the static template tag instead.", PendingDeprecationWarning)
    return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
开发者ID:15580056814,项目名称:hue,代码行数:8,代码来源:adminmedia.py

示例7: flag

def flag(country_code):
    filename = ''
    for flag in getattr(settings, 'FLAGS'):
        if flag[0] == country_code:
            filename = flag[1]

    path = getattr(settings, 'FLAGS_ROOT') + filename
    return urljoin(PrefixNode.handle_simple("STATIC_URL"), path)
开发者ID:hayk912,项目名称:bidpart,代码行数:8,代码来源:accounts_extras.py

示例8: get_thumb

def get_thumb(image, thumb_format):
    try:
        thumb = image.get_thumb(thumb_format=thumb_format)
    except AttributeError:
        thumb =  ''

    if thumb:
        return thumb
    else:
        for default_thumb in settings.IMAGE_THUMB_DEFAULTS:
            if default_thumb[0] == thumb_format:
                return urljoin(PrefixNode.handle_simple("STATIC_URL"), default_thumb[1])

    return ''
开发者ID:hayk912,项目名称:bidpart,代码行数:14,代码来源:files_extras.py

示例9: static

def static(path):
    """
    Joins the given path with the STATIC_URL setting.

    Usage::

        {% static path %}

    Examples::

        {% static "myapp/css/base.css" %}
        {% static variable_with_path %}

    """
    return urljoin(PrefixNode.handle_simple("STATIC_URL"), path)
开发者ID:DirkHaehnel,项目名称:openmicroscopy,代码行数:15,代码来源:defaulttags.py

示例10: get_static_webadmin_prefix

def get_static_webadmin_prefix(parser, token):
    """
    Populates a template variable with the static prefix,
    ``settings.WEBADMIN_STATIC_URL``.

    Usage::

        {% get_static_webadmin_prefix [as varname] %}

    Examples::

        {% get_static_webadmin_prefix %}
        {% get_static_webadmin_prefix as STATIC_WEBADMIN_PREFIX %}

    """
    return PrefixNode.handle_token(parser, token, "STATIC_WEBADMIN_URL")
开发者ID:hflynn,项目名称:openmicroscopy,代码行数:16,代码来源:webadmin_tags.py

示例11: get_static_feedback_prefix

def get_static_feedback_prefix(parser, token):
    """
    Populates a template variable with the static prefix,
    ``settings.FEEDBACK_STATIC_URL``.

    Usage::

        {% get_static_feedback_prefix [as varname] %}

    Examples::

        {% get_static_feedback_prefix %}
        {% get_static_feedback_prefix as STATIC_FEEDBACK_PREFIX %}

    """
    return PrefixNode.handle_token(parser, token, "STATIC_FEEDBACK_URL")
开发者ID:DirkHaehnel,项目名称:openmicroscopy,代码行数:16,代码来源:feedback_tags.py

示例12: handle_simple

 def handle_simple(cls, path):
     return urljoin(PrefixNode.handle_simple("MEDIA_URL"), path)
开发者ID:d9pouces,项目名称:django-floor,代码行数:2,代码来源:djangofloor.py

示例13: icon_src

 def icon_src(self, instance):
     path = 'img/aldryn_video/video-32x32.png'
     prefix = PrefixNode.handle_simple("STATIC_URL") or PrefixNode.handle_simple("MEDIA_URL")
     return urljoin(prefix, path)
开发者ID:aldryn,项目名称:aldryn-video,代码行数:4,代码来源:cms_plugins.py

示例14: handle_simple

 def handle_simple(cls, path):
     return os.path.join(PrefixNode.handle_simple('STATIC_ROOT'), path)
开发者ID:fingul,项目名称:pytoolbox,代码行数:2,代码来源:templatetags.py

示例15: admin_media_prefix

def admin_media_prefix():
	"""
	Returns the string contained in the setting ADMIN_MEDIA_PREFIX.
	"""
	return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
开发者ID:lapbay,项目名称:milan,代码行数:5,代码来源:adminmedia.py


注:本文中的django.templatetags.static.PrefixNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。