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


Python PrefixNode.handle_simple方法代码示例

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


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

示例1: sharewikify

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:62,代码来源:wikitags.py

示例2: fiduswriter_config_js

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:31,代码来源:fiduswriter.py

示例3: render_js_files

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:31,代码来源:basic_tags.py

示例4: handle_simple

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
 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,代码行数:9,代码来源:dipstrapfiles.py

示例5: get_treemenus_static_prefix

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:9,代码来源:tree_menu_tags.py

示例6: admin_media_prefix

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:10,代码来源:adminmedia.py

示例7: flag

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:10,代码来源:accounts_extras.py

示例8: get_thumb

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:16,代码来源:files_extras.py

示例9: static

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
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,代码行数:17,代码来源:defaulttags.py

示例10: handle_simple

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
 def handle_simple(cls, path):
     return os.path.join(PrefixNode.handle_simple('STATIC_ROOT'), path)
开发者ID:fingul,项目名称:pytoolbox,代码行数:4,代码来源:templatetags.py

示例11: admin_media_prefix

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
def admin_media_prefix():
	"""
	Returns the string contained in the setting ADMIN_MEDIA_PREFIX.
	"""
	return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
开发者ID:lapbay,项目名称:milan,代码行数:7,代码来源:adminmedia.py

示例12: sitetree_admin_img_url_prefix

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
def sitetree_admin_img_url_prefix():
    """Returns static admin images URL prefix. """
    if DJANGO_VERSION_INT >= 140:
        return '%sadmin/img' % PrefixNode.handle_simple('STATIC_URL')

    return '%simg/admin' % PrefixNode.handle_simple('ADMIN_MEDIA_PREFIX')
开发者ID:jsheffie,项目名称:django-sitetree,代码行数:8,代码来源:sitetree.py

示例13: handle_simple

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
 def handle_simple(cls, path):
     return urljoin(PrefixNode.handle_simple("STATIC_URL"), path)
开发者ID:0x64746b,项目名称:django-rest-framework,代码行数:4,代码来源:rest_framework.py

示例14: icon_src

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
 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,代码行数:6,代码来源:cms_plugins.py

示例15: handle_simple

# 需要导入模块: from django.templatetags.static import PrefixNode [as 别名]
# 或者: from django.templatetags.static.PrefixNode import handle_simple [as 别名]
 def handle_simple(cls, mimetype, size=icons.SIZE_DEFAULT):
     path = icons.get_icon(mimetype, size=size)
     return urljoin(PrefixNode.handle_simple("STATIC_URL"), path)
开发者ID:Rom4eg,项目名称:django-icons-mimetypes,代码行数:5,代码来源:mimetypes.py


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