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

Python widgets.get_language_config函数代码示例

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

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



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

示例1: test_default_config

 def test_default_config(self):
     config = get_language_config()
     config_ok = {
         'spellchecker_languages': '+English=en',
         'directionality': 'ltr',
         'language': 'en',
         'spellchecker_rpc_url': '/tinymce/spellchecker/'
     }
     self.assertEqual(config, config_ok)
     with override(None):
         # Even when no language is activated
         config = get_language_config()
         self.assertEqual(config, config_ok)
开发者ID:CollinsMuiruri,项目名称:Instagram,代码行数:13,代码来源:test_widgets.py


示例2: render

    def render(self, name, value, attrs=None):
        if value is None: value = ''
        value = smart_unicode(value)
        final_attrs = self.build_attrs(attrs)
        final_attrs['name'] = name
        assert 'id' in final_attrs, "TinyMCE widget attributes must contain 'id'"
        mce_config = cms.plugins.text.settings.TINYMCE_CONFIG.copy()
        mce_config.update(get_language_config(self.content_language))
        if tinymce.settings.USE_FILEBROWSER:
            mce_config['file_browser_callback'] = "djangoFileBrowser"
        mce_config.update(self.mce_attrs)
        mce_config['mode'] = 'exact'
        mce_config['elements'] = final_attrs['id']
        mce_config['strict_loading_mode'] = 1
        json = simplejson.dumps(mce_config)

        html = [u'<textarea%s>%s</textarea>' % (flatatt(final_attrs), escape(value))]
        if tinymce.settings.USE_COMPRESSOR:
            compressor_config = {
                'plugins': mce_config.get('plugins', ''),
                'themes': mce_config.get('theme', 'advanced'),
                'languages': mce_config.get('language', ''),
                'diskcache': True,
                'debug': False,
                }
            c_json = simplejson.dumps(compressor_config)
            html.append(u'<script type="text/javascript">tinyMCE_GZ.init(%s);</script>' % (c_json))
        html.append(u'<script type="text/javascript">%s;\ntinyMCE.init(%s);</script>' % (
            self.render_additions(name, value, attrs), json))
        return mark_safe(u'\n'.join(html))
开发者ID:ngillard,项目名称:cmsplugin-news,代码行数:30,代码来源:tinymce_widget.py


示例3: test_content_language

 def test_content_language(self):
     config = get_language_config('ru-ru')
     config_ok = {
         'spellchecker_languages': 'English=en',
         'directionality': 'ltr',
         'language': 'en',
         'spellchecker_rpc_url': '/tinymce/spellchecker/'
     }
     self.assertEqual(config, config_ok)
开发者ID:chenesan,项目名称:django-tinymce,代码行数:9,代码来源:test_widgets.py


示例4: test_default_config_rtl

 def test_default_config_rtl(self):
     config = get_language_config()
     config_ok = {
         'spellchecker_languages': '+English=en',
         'directionality': 'rtl',
         'language': 'en',
         'spellchecker_rpc_url': '/tinymce/spellchecker/'
     }
     self.assertEqual(config, config_ok)
开发者ID:chenesan,项目名称:django-tinymce,代码行数:9,代码来源:test_widgets.py


示例5: textareas_js

def textareas_js(request, name, lang=None):
    """
    Returns a HttpResponse whose content is a Javscript file. The template
    is loaded from 'tinymce/<name>_textareas.js' or
    '<name>/tinymce_textareas.js'. Optionally, the lang argument sets the
    content language.
    """
    template_files = ("tinymce/%s_textareas.js" % name, "%s/tinymce_textareas.js" % name)
    template = loader.select_template(template_files)

    vars = get_language_config(lang)
    vars["content_language"] = lang
    context = RequestContext(request, vars)

    return HttpResponse(template.render(context), content_type="application/x-javascript")
开发者ID:wadobo,项目名称:timebank,代码行数:15,代码来源:views.py


示例6: render

    def render(self, name, value, attrs=None):
        if value is None:
            value = ""
        value = smart_unicode(value)
        final_attrs = self.build_attrs(attrs)
        final_attrs["name"] = name
        assert "id" in final_attrs, "TinyMCE widget attributes must contain 'id'"

        mce_config = tinymce.settings.DEFAULT_CONFIG.copy()

        # remove image plugin
        mce_config = self.remove_plugin(mce_config, "image")

        mce_config.update(get_language_config(self.content_language))
        if tinymce.settings.USE_FILEBROWSER:
            mce_config["file_browser_callback"] = "djangoFileBrowser"
        mce_config.update(self.mce_attrs)
        if not "mode" in mce_config:
            mce_config["mode"] = "exact"
        if mce_config["mode"] == "exact":
            mce_config["elements"] = final_attrs["id"]
        mce_config["strict_loading_mode"] = 1

        # Fix for js functions
        js_functions = {}
        for k in ("paste_preprocess", "paste_postprocess"):
            if k in mce_config:
                js_functions[k] = mce_config[k]
                del mce_config[k]
        mce_json = simplejson.dumps(mce_config)
        for k in js_functions:
            index = mce_json.rfind("}")
            mce_json = mce_json[:index] + ", " + k + ":" + js_functions[k].strip() + mce_json[index:]

        html = [u"<textarea%s>%s</textarea>" % (flatatt(final_attrs), escape(value))]
        if tinymce.settings.USE_COMPRESSOR:
            compressor_config = {
                "plugins": mce_config.get("plugins", ""),
                "themes": mce_config.get("theme", "advanced"),
                "languages": mce_config.get("language", ""),
                "diskcache": True,
                "debug": False,
            }
            compressor_json = simplejson.dumps(compressor_config)
            html.append(u'<script type="text/javascript">tinyMCE_GZ.init(%s)</script>' % compressor_json)
        html.append(u'<script type="text/javascript">tinyMCE.init(%s)</script>' % mce_json)

        return mark_safe(u"\n".join(html))
开发者ID:hnejadi,项目名称:EShop-2,代码行数:48,代码来源:admin.py


示例7: render

 def render(self, name, value, attrs=None):
     if value is None: value = ''
     value = smart_unicode(value)
     final_attrs = self.build_attrs(attrs)
     final_attrs['name'] = name
     assert 'id' in final_attrs, "TinyMCE widget attributes must contain 'id'"
     mce_config = cms.plugins.text.settings.TINYMCE_CONFIG.copy()
     mce_config.update(get_language_config(self.content_language))
     if tinymce.settings.USE_FILEBROWSER:
         mce_config['file_browser_callback'] = "djangoFileBrowser"
     mce_config.update(self.mce_attrs)
     mce_config['mode'] = 'exact'
     mce_config['elements'] = final_attrs['id']
     mce_config['strict_loading_mode'] = 1
     plugins = mce_config.get("plugins", "")
     if len(plugins):
         plugins += ","
     plugins += "-cmsplugins"
     mce_config['plugins'] = plugins
     if mce_config['theme'] == "simple":
         mce_config['theme'] = "advanced"
     # Add cmsplugin to first toolbar, if not already present
     all_tools = []
     idx = 0
     while True:
         idx += 1
         buttons = mce_config.get('theme_advanced_buttons%d' % (idx,), None)
         if buttons is None:
             break
         all_tools.extend(buttons.split(','))
     if 'cmsplugins' not in all_tools and 'cmspluginsedit' not in all_tools:
         mce_config['theme_advanced_buttons1_add_before'] = "cmsplugins,cmspluginsedit"
     
     json = simplejson.dumps(mce_config)
     html = [u'<textarea%s>%s</textarea>' % (flatatt(final_attrs), escape(value))]
     if tinymce.settings.USE_COMPRESSOR:
         compressor_config = {
             'plugins': mce_config.get('plugins', ''),
             'themes': mce_config.get('theme', 'advanced'),
             'languages': mce_config.get('language', ''),
             'diskcache': True,
             'debug': False,
         }
         c_json = simplejson.dumps(compressor_config)
         html.append(u'<script type="text/javascript">//<![CDATA[\ntinyMCE_GZ.init(%s);\n//]]></script>' % (c_json))
     html.append(u'<script type="text/javascript">//<![CDATA[\n%s;\ntinyMCE.init(%s);\n//]]></script>' % (self.render_additions(name, value, attrs), json))
     return mark_safe(u'\n'.join(html))
开发者ID:124bit,项目名称:django_ukrhim,代码行数:47,代码来源:tinymce_widget.py


示例8: render

    def render(self, name, value, attrs=None):
        if value is None:
            value = ""
        value = smart_unicode(value)
        final_attrs = self.build_attrs(attrs)
        final_attrs["name"] = name
        assert "id" in final_attrs, "TinyMCE widget attributes must contain 'id'"
        mce_config = cms.plugins.text.settings.TINYMCE_CONFIG.copy()
        mce_config.update(get_language_config(self.content_language))
        if tinymce.settings.USE_FILEBROWSER:
            mce_config["file_browser_callback"] = "djangoFileBrowser"
        mce_config.update(self.mce_attrs)
        mce_config["mode"] = "exact"
        mce_config["elements"] = final_attrs["id"]
        mce_config["strict_loading_mode"] = 1
        plugins = mce_config.get("plugins", "")
        if len(plugins):
            plugins += ","
        plugins += "-cmsplugins"
        mce_config["plugins"] = plugins
        adv2 = mce_config.get("theme_advanced_buttons1", None)
        if adv2 is not None:
            if len(adv2):
                adv2 = "," + adv2
            adv2 = "cmsplugins,cmspluginsedit" + adv2
            mce_config["theme_advanced_buttons1"] = adv2
        json = simplejson.dumps(mce_config)

        html = [u"<textarea%s>%s</textarea>" % (flatatt(final_attrs), escape(value))]
        if tinymce.settings.USE_COMPRESSOR:
            compressor_config = {
                "plugins": mce_config.get("plugins", ""),
                "themes": mce_config.get("theme", "advanced"),
                "languages": mce_config.get("language", ""),
                "diskcache": True,
                "debug": False,
            }
            c_json = simplejson.dumps(compressor_config)
            html.append(u'<script type="text/javascript">tinyMCE_GZ.init(%s);</script>' % (c_json))
        html.append(
            u'<script type="text/javascript">%s;\ntinyMCE.init(%s);</script>'
            % (self.render_additions(name, value, attrs), json)
        )
        return mark_safe(u"\n".join(html))
开发者ID:pcicman,项目名称:django-cms-2.0,代码行数:44,代码来源:tinymce_widget.py


示例9: render

    def render(self, name, value, attrs=None):
        if value is None: value = ''
        value = smart_unicode(value)
        final_attrs = self.build_attrs(attrs)
        final_attrs['name'] = name
        assert 'id' in final_attrs, "TinyMCE widget attributes must contain 'id'"

        mce_config = tinymce.settings.DEFAULT_CONFIG
        mce_config.update(get_language_config(self.content_language))
        if tinymce.settings.USE_FILEBROWSER:
            mce_config['file_browser_callback'] = "djangoFileBrowser"
        mce_config.update(self.mce_attrs)
        mce_config['mode'] = 'exact'
        mce_config['elements'] = final_attrs['id']
        mce_config['strict_loading_mode'] = 1
        mce_json = simplejson.dumps(mce_config)

        html = [u'<textarea%s>%s</textarea>' % (flatatt(final_attrs), escape(value))]
        if tinymce.settings.USE_COMPRESSOR:
            compressor_config = {
                'plugins': mce_config.get('plugins', ''),
                'themes': mce_config.get('theme', 'advanced'),
                'languages': mce_config.get('language', ''),
                'diskcache': True,
                'debug': False,
            }
            compressor_json = simplejson.dumps(compressor_config)
            
            # Now the trick - instead of ouputting <javascript> tags and initializing when they are rendered, 
            # let's simply put the json string in a hidden div and fetch the info / initialize when the view
            # actually displays them :)
            
            #html.append(u'<script type="text/javascript">tinyMCE_GZ.init(%s)</script>' % compressor_json)
            html.append(u'<div style="visibility:hidden" class="uninitialized-tiny-field" id="hidden_div_%s">%s</div>' % (final_attrs['id'], compressor_json))
        
        #html.append(u'<script type="text/javascript">tinyMCE.init(%s)</script>' % mce_json)
        html.append(r'<div style="visibility:hidden" class="uninitialized-tiny-field" id="hidden_div_%s">%s</div>' % (final_attrs['id'], mce_json))    

        return mark_safe(u'\n'.join(html))
开发者ID:ershadul,项目名称:whydjango,代码行数:39,代码来源:widgets.py


示例10: textareas_js

def textareas_js(request, name, lang=None):
    """
    Returns a HttpResponse whose content is a Javscript file. The template
    is loaded from 'tinymce/<name>_textareas.js' or
    '<name>/tinymce_textareas.js'. Optionally, the lang argument sets the
    content language.
    """
    template_files = (
        'tinymce/%s_textareas.js' % name,
        '%s/tinymce_textareas.js' % name,
    )
    try:
        template = loader.select_template(template_files)
    except TemplateDoesNotExist:
        raise Http404("The template couldn't found")

    vars = get_language_config(lang)
    vars['content_language'] = lang
    context = RequestContext(request, vars)

    return HttpResponse(template.render(context),
                        content_type="application/x-javascript")
开发者ID:buremba,项目名称:django-tinymce,代码行数:22,代码来源:views.py


示例11: render

    def render(self, name, value, attrs=None):
        if value is None:
            value = ''
        value = smart_unicode(value)
        final_attrs = self.build_attrs(attrs)
        final_attrs['name'] = name
        assert 'id' in final_attrs, \
            "TinyMCE widget attributes must contain 'id'"

        mce_config = tinymce.settings.DEFAULT_CONFIG.copy()
        mce_config.update(get_language_config(self.content_language))
        if tinymce.settings.USE_FILEBROWSER:
            mce_config['file_browser_callback'] = "djangoFileBrowser"
        mce_config.update(self.mce_attrs)
        if not 'mode' in mce_config:
            mce_config['mode'] = 'exact'
        if mce_config['mode'] == 'exact':
            mce_config['elements'] = final_attrs['id']
        mce_config['strict_loading_mode'] = 1

        # Fix for js functions
        js_functions = {}
        for k in ('paste_preprocess', 'paste_postprocess', 'setup'):
            if k in mce_config:
                js_functions[k] = mce_config[k]
                del mce_config[k]
        mce_json = simplejson.dumps(mce_config)

        pos = final_attrs['id'].find('__prefix__')
        if pos != -1:
            mce_json = mce_json.replace(
                u'"%s"' % final_attrs['id'], u'elements'
            )

        for k in js_functions:
            index = mce_json.rfind('}')
            mce_json = mce_json[:index] + ', ' + k \
                + ':' + js_functions[k].strip() \
                + mce_json[index:]
        html = [
            u'<textarea%s>%s</textarea>' % (
                flatatt(final_attrs), escape(value)
            )
        ]
        if tinymce.settings.USE_COMPRESSOR:
            compressor_config = {
                'plugins': mce_config.get('plugins', ''),
                'themes': mce_config.get('theme', 'advanced'),
                'languages': mce_config.get('language', ''),
                'diskcache': True,
                'debug': False,
            }
            # pylint: disable=W0612
            compressor_json = simplejson.dumps(compressor_config)

        if pos != -1:
            html.append(u'''<script type="text/javascript">
setTimeout(function () {
    var id = '%s';

    if (typeof(window._tinymce_inited) == 'undefined') {
        window._tinymce_inited = [];
    }

    if (typeof(window._tinymce_inited[id]) == 'undefined') {
        window._tinymce_inited[id] = true;
    } else {
        var elements = id.replace(/__prefix__/, parseInt(document.getElementById('%sTOTAL_FORMS').value) - 1);
        console.log(elements);
        if (document.getElementById(elements)) {
            tinymce.init(%s);
        }
    }
}, 0);
</script>''' % (final_attrs['id'], final_attrs['id'][0:pos], mce_json))
        else:
            html.append(
                u'<script type="text/javascript">'
                'tinyMCE.init(%s)</script>' % mce_json
            )

        return mark_safe(u'\n'.join(html))
开发者ID:Ravall,项目名称:sancta_projects_py,代码行数:82,代码来源:MyTinyMCE.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common.Utils类代码示例发布时间:2022-05-27
下一篇:
Python queries.where函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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