• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python whitelist.attribute_rule函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: whitelister_element_rules

def whitelister_element_rules():
    allow_html_class = attribute_rule({
        'class': True,
        'itemprop': True,
        'itemscope': True,
        'itemtype': True,
    })

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

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


示例17: whitelist_blockquote

def whitelist_blockquote():
    return {
        'style': blacklist_tag(),
        'font': unwrap_tag(),
        'span': unwrap_tag(),
        'blockquote': attribute_rule({'class': True}),
        'p': attribute_rule({'class': True}),
        'h2': attribute_rule({'class': True}),
        'h3': attribute_rule({'class': True}),
        'h4': attribute_rule({'class': True}),
        'h5': attribute_rule({'class': True}),
        'iframe': attribute_rule({
            'style': True, 'src': True,
            'width': True, 'height': True
        }),
        'img': attribute_rule({
            'srcset': True, 'class': True,
            'alt': True, 'sizes': True,
            'width': True, 'height': True,
            'src': True
        })
    }
开发者ID:PARINetwork,项目名称:pari,代码行数:22,代码来源:wagtail_hooks.py


示例18: whitelister_element_rules

def whitelister_element_rules():
    return {
        'span': attribute_rule({'style': True}),
        'font': attribute_rule({'size': True, 'face': True, 'color': True}),
        'p': attribute_rule({'align': True}),
    }
开发者ID:tucarga,项目名称:ultracms,代码行数:6,代码来源:wagtail_hooks.py


示例19: whitelister_element_rules

def whitelister_element_rules():
    return {"blockquote": allow_without_attributes, "a": attribute_rule({"href": check_url, "target": True})}
开发者ID:Frankie-666,项目名称:wagtail,代码行数:2,代码来源:wagtail_hooks.py


示例20: whitelister_element_rules

def whitelister_element_rules():
    return {
        'a': attribute_rule({'href': check_url, 'id': True}),
        'span': attribute_rule({'class': True}),
    }
开发者ID:kcl-ddh,项目名称:chopin-online,代码行数:5,代码来源:wagtail_hooks.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.get_document_model函数代码示例发布时间:2022-05-26
下一篇:
Python utils.resolve_model_string函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap