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


Python whitelist.attribute_rule函数代码示例

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


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

示例1: whitelister_element_rules

def whitelister_element_rules():
    return {
        # Commenting out disallowed tags so its easier to remember & revert
        'a': attribute_rule({'href': check_url}),
        'b': allow_without_attributes,
        # 'br': allow_without_attributes,
        # 'div': allow_without_attributes,
        'em': allow_without_attributes,
        'h1': allow_without_attributes,
        'h2': allow_without_attributes,
        'h3': allow_without_attributes,
        'h4': allow_without_attributes,
        'h5': allow_without_attributes,
        'h6': allow_without_attributes,
        'hr': allow_without_attributes,
        'i': allow_without_attributes,
        'img': attribute_rule({'src': check_url, 'width': True, 'height': True,
                               'alt': True}),
        'li': allow_without_attributes,
        'ol': allow_without_attributes,
        'p': allow_without_attributes,
        'strong': allow_without_attributes,
        'sub': allow_without_attributes,
        'sup': allow_without_attributes,
        'ul': allow_without_attributes,
    }
开发者ID:18F,项目名称:fec-cms,代码行数:26,代码来源:wagtail_hooks.py

示例2: whitelister_element_rules

def whitelister_element_rules():
    return {
        'p': attribute_rule({'class': True}),
        'a': attribute_rule({'href': check_url, 'id': True, 'class': True}),
        'span': attribute_rule({'class': True}),
        'i': attribute_rule({'class': True}),
        'iframe': attribute_rule({'id': True, 'class': True, 'src': True, 'style': True, 'frameborder': True, 'allowfullscreen': True, 'width': True, 'height': True }),
    }
开发者ID:kingsdigitallab,项目名称:hgl-django,代码行数:8,代码来源:wagtail_hooks.py

示例3: whitelister_element_rules

def whitelister_element_rules():
    return {
        'h2': attribute_rule({'style': True}),
        'h3': attribute_rule({'style': True}),
        'h4': attribute_rule({'style': True}),
        'h5': attribute_rule({'style': True}),
        'p': attribute_rule({'style': True}),
    }
开发者ID:sinnwerkstatt,项目名称:landmatrix,代码行数:8,代码来源:models.py

示例4: whitelister_element_rules

def whitelister_element_rules():
    return {
        'iframe': attribute_rule(ALLTAGS),
        'object': attribute_rule(ALLTAGS),
        'script': attribute_rule(ALLTAGS),
        'style': attribute_rule(ALLTAGS),
        'embed': attribute_rule(ALLTAGS),
        'src': attribute_rule(ALLTAGS),
        'video': attribute_rule(ALLTAGS),
        'div': attribute_rule(ALLTAGS),
        'noscript': attribute_rule(ALLTAGS),
        'param': attribute_rule(ALLTAGS),
    }
开发者ID:nikonikoniko,项目名称:syrianarchive,代码行数:13,代码来源:wagtail_hooks.py

示例5: whitelister_element_rules

def whitelister_element_rules():
    """
    Whitelist custom elements to the hallo.js editor
    """
    return {
        'blockquote': allow_without_attributes,
        'cite': allow_without_attributes,
        'a': attribute_rule({'href': check_url, 'class': True}),
        'h2': attribute_rule({'id': True}),
        'h3': attribute_rule({'id': True}),
        'h4': attribute_rule({'id': True}),
        'h5': attribute_rule({'id': True}),
    }
开发者ID:JoshBarr,项目名称:yasha,代码行数:13,代码来源:wagtail_hooks.py

示例6: allow_iframes

def allow_iframes():
    return {
        'iframe': attribute_rule(
            {
                'src': True,
                'width': True,
                'height': True,
                'frameborder': True,
                'marginheight': True,
                'marginwidth': True
            }),
        'tito-widget': attribute_rule({'event': True}),
        'tito-button': attribute_rule({'event': True}),
    }
开发者ID:Irishsmurf,项目名称:website,代码行数:14,代码来源:wagtail_hooks.py

示例7: whitelister_element_rules

def whitelister_element_rules():
    """
    Whitelist custom elements to the hallo.js editor
    """
    return {
        'a': attribute_rule({'href': check_url, 'class': True}),
    }
开发者ID:doru-rocod,项目名称:madewithwagtail,代码行数:7,代码来源:wagtail_hooks.py

示例8: whitelister_element_rules

def whitelister_element_rules():
    allow_html_class = attribute_rule({'class': True})

    allowed_tags = ['aside', 'table', 'tr', 'th', 'td', 'tbody', 'thead',
                    'tfoot', 'col', 'colgroup']

    return {tag: allow_html_class for tag in allowed_tags}
开发者ID:OrlandoSoto,项目名称:cfgov-refresh,代码行数:7,代码来源:wagtail_hooks.py

示例9: test_rule_false_for_attr

 def test_rule_false_for_attr(self):
     """
     Test that attribute_rule() drops atrributes
     when the corresponding rule returns False
     """
     tag = self.soup.b
     fn = attribute_rule({'foo': False})
     fn(tag)
     self.assertEqual(str(tag), '<b>baz</b>')
开发者ID:Anlim,项目名称:wagtail,代码行数:9,代码来源:test_whitelist.py

示例10: test_rule_true_for_attr

 def test_rule_true_for_attr(self):
     """
     Test that attribute_rule() does not change atrributes
     when the corresponding rule returns True
     """
     tag = self.soup.b
     fn = attribute_rule({'foo': True})
     fn(tag)
     self.assertEqual(str(tag), '<b foo="bar">baz</b>')
开发者ID:Anlim,项目名称:wagtail,代码行数:9,代码来源:test_whitelist.py

示例11: test_no_rule_for_attr

 def test_no_rule_for_attr(self):
     """
     Test that attribute_rule() drops attributes for
     which no rule has been defined.
     """
     tag = self.soup.b
     fn = attribute_rule({'snowman': 'barbecue'})
     fn(tag)
     self.assertEqual(str(tag), '<b>baz</b>')
开发者ID:Anlim,项目名称:wagtail,代码行数:9,代码来源:test_whitelist.py

示例12: whitelister_element_rules

def whitelister_element_rules():
    return {
        'blockquote': allow_without_attributes,
        'code': allow_without_attributes,
        'table': allow_without_attributes,
        'tr': allow_without_attributes,
        'td': allow_without_attributes,
        'pre': attribute_rule({'class': True}),
    }
开发者ID:alexgleason,项目名称:wagtail-blog-app,代码行数:9,代码来源:wagtail_hooks.py

示例13: test_callable_returns_None

 def test_callable_returns_None(self):
     """
     Test that when the rule returns a callable,
     attribute_rule() replaces the attribute with
     the result of calling the callable on the attribute.
     """
     tag = self.soup.b
     fn = attribute_rule({'foo': lambda x: None})
     fn(tag)
     self.assertEqual(str(tag), '<b>baz</b>')
开发者ID:Anlim,项目名称:wagtail,代码行数:10,代码来源:test_whitelist.py

示例14: test_callable_called_on_attr

 def test_callable_called_on_attr(self):
     """
     Test that when the rule returns a callable,
     attribute_rule() replaces the attribute with
     the result of calling the callable on the attribute.
     """
     tag = self.soup.b
     fn = attribute_rule({'foo': len})
     fn(tag)
     self.assertEqual(str(tag), '<b foo="3">baz</b>')
开发者ID:Anlim,项目名称:wagtail,代码行数:10,代码来源:test_whitelist.py

示例15: allow_iframes

def allow_iframes():
    return {
        'iframe': attribute_rule(
            {
                'src': True,
                'width': True,
                'height': True,
                'frameborder': True,
                'marginheight': True,
                'marginwidth': True
            })
    }
开发者ID:rdavl,项目名称:website,代码行数:12,代码来源:wagtail_hooks.py


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