Dynamically generate genuine django inlines for all registered content item types.
    When the `plugins` parameter is ``None``, all plugin inlines are returned.
357656
def get_content_item_inlines(plugins=None, base=BaseContentItemInline):
    
    COPY_FIELDS = (
        'form', 'raw_id_fields', 'filter_vertical', 'filter_horizontal',
        'radio_fields', 'prepopulated_fields', 'formfield_overrides', 'readonly_fields',
    )
    if plugins is None:
        plugins = extensions.plugin_pool.get_plugins()

    inlines = []
    for plugin in plugins:  # self.model._supported_...()
        # Avoid errors that are hard to trace
        if not isinstance(plugin, extensions.ContentPlugin):
            raise TypeError("get_content_item_inlines() expects to receive ContentPlugin instances, not {0}".format(plugin))

        ContentItemType = plugin.model

        # Create a new Type that inherits CmsPageItemInline
        # Read the static fields of the ItemType to override default appearance.
        # This code is based on FeinCMS, (c) Simon Meers, BSD licensed
        class_name = '%s_AutoInline' %  ContentItemType.__name__
        attrs = {
            '__module__': plugin.__class__.__module__,
            'model': ContentItemType,

            # Add metadata properties for template
            'name': plugin.verbose_name,
            'plugin': plugin,
            'type_name': plugin.type_name,
            'extra_fieldsets': plugin.fieldsets,
            'cp_admin_form_template': plugin.admin_form_template,
            'cp_admin_init_template': plugin.admin_init_template,
        }

        # Copy a restricted set of admin fields to the inline model too.
        for name in COPY_FIELDS:
            if getattr(plugin, name):
                attrs[name] = getattr(plugin, name)

        inlines.append(type(class_name, (base,), attrs))

    # For consistency, enforce ordering
    inlines.sort(key=lambda inline: inline.name.lower())

    return inlines
1191136
def plugins(self):
        
        from fluent_contents import extensions
        if self._plugins is None:
            return extensions.plugin_pool.get_plugins()
        else:
            try:
                return extensions.plugin_pool.get_plugins_by_name(*self._plugins)
            except extensions.PluginNotFound as e:
                raise extensions.PluginNotFound(str(e) + " Update the plugin list of '{0}.{1}' field or FLUENT_CONTENTS_PLACEHOLDER_CONFIG['{2}'] setting.".format(self.model._meta.object_name, self.name, self.slot))
504884
function Plugin(regexp, replacer, id) {
    // return value should be a callable function
    // with strictly defined options passed by markdown-it
    var self = function(md, options) {
        self.options = options;
        self.init(md);
    };

    // initialize plugin object
    self.__proto__ = Plugin.prototype;

    // clone regexp with all the flags
    var flags = (regexp.global ? 'g' : '') + (regexp.multiline ? 'm' : '') + (regexp.ignoreCase ? 'i' : '');

    self.regexp = RegExp('^' + regexp.source, flags);

    // copy init options
    self.replacer = replacer;

    // this plugin can be inserted multiple times,
    // so we're generating unique name for it
    self.id = id ? id : 'regexp-' + counter;
    counter++;

    return self;
}
988199
function (type, args, htmlpath, projectRoot, pageName) {
    var plugin = plugins.use(args);
    if (plugin[type] !== undefined) {
        return plugin[type](args[0], htmlpath, projectRoot, pageName, concatServerBaseUrl, projectPublishRoot);
    } else {
        return args[0];
    }
}
1343507
def all_plugins(self):
        '''  '''
        unique = set()
        for p in reversed(self.app.plugins + self.plugins):
            if True in self.skiplist: break
            name = getattr(p, 'name', False)
            if name and (name in self.skiplist or name in unique): continue
            if p in self.skiplist or type(p) in self.skiplist: continue
            if name: unique.add(name)
            yield p
801036
def _inline_styles(self):
        
        styles = self._get_styles(self.assets.style_urls, url_for('asset'))
        self.assets.styles.extend(styles)
        self.assets.style_urls[:] = []
866283
def js_reverse_inline(context):
    
    if 'request' in context:
        default_urlresolver = get_resolver(getattr(context['request'], 'urlconf', None))
    else:
        default_urlresolver = get_resolver(None)
    return mark_safe(generate_js(default_urlresolver))
433663
def attachedimages_inline_factory(lang='en', max_width='', debug=False):
    '''  
    '''

    class _AttachedImagesInline(GenericTabularInline):
        model = AttachedImage
        form = attachedimage_form_factory(lang, debug)
        template = 'generic_images/attached_images_inline.html'
        max_w = max_width

    return _AttachedImagesInline
1200498
def wrap_default(self, data, renderer_context):
        

        wrapper = self.dict_class()
        view = renderer_context.get("view", None)
        request = renderer_context.get("request", None)

        model = self.model_from_obj(view)
        resource_type = self.model_to_resource_type(model)

        if isinstance(data, list):
            many = True
            resources = data
        else:
            many = False
            resources = [data]

        items = []
        links = self.dict_class()
        linked = self.dict_class()
        meta = self.dict_class()

        for resource in resources:
            converted = self.convert_resource(resource, data, request)
            item = converted.get('data', {})
            linked_ids = converted.get('linked_ids', {})
            if linked_ids:
                item["links"] = linked_ids
            items.append(item)

            links.update(converted.get('links', {}))
            linked = self.update_nested(linked,
                                        converted.get('linked', {}))
            meta.update(converted.get('meta', {}))

        if many:
            wrapper[resource_type] = items
        else:
            wrapper[resource_type] = items[0]

        if links:
            links = self.prepend_links_with_name(links, resource_type)
            wrapper["links"] = links

        if linked:
            wrapper["linked"] = linked

        if meta:
            wrapper["meta"] = meta

        return wrapper
314630
def render(request, template_name, context=None, content_type=None, status=None, using=None, logs=None):
    
    if logs:
        obj_logger = ObjectLogger()
        if not isinstance(logs, list):
            logs = [logs, ]
        for log in logs:
            log = obj_logger.log_response(
                log,
                context,
                status=str(status),
                headers='',
                content_type=str(content_type))
            log.save()
    return django_render(
        request,
        template_name,
        context=context,
        content_type=content_type,
        status=status,
        using=using)
846151
def get_inline_instances(self, request, *args, **kwargs):
        
        inlines = super(PlaceholderEditorAdmin, self).get_inline_instances(request, *args, **kwargs)

        extra_inline_instances = []
        inlinetypes = self.get_extra_inlines()
        for InlineType in inlinetypes:
            inline_instance = InlineType(self.model, self.admin_site)
            extra_inline_instances.append(inline_instance)

        return extra_inline_instances + inlines
797774
function getInlinePlugins(text, pattern, availablePlugins) {
  var match = text.match(pattern);
  // Return null if not match to make decisions based on it
  if (!match) return null;
  // Capture group [1] for plugins will be empty if no plugins specified
  if (!match[1]) return [];

  var inlinePlugins = match[1].replace(/\s/g, '').split(',');

  var validInlinePlugins = inlinePlugins.filter(function (plugin) {
    // Remove not registered plugins
    return availablePlugins.indexOf(plugin) > -1;
  });

  return validInlinePlugins;
}
402415
def generic_lazy_ref_formatter(view, context, model, name):
    
    return generic_ref_formatter(view, context, model, name, True)
267242
def _render_uncached_items(self, items, result):
        
        for contentitem in items:
            # Render the item.
            # Allow derived classes to skip it.
            try:
                output = self.render_item(contentitem)
            except PluginNotFound as ex:
                result.store_exception(contentitem, ex)
                logger.debug("- item #%s has no matching plugin: %s", contentitem.pk, str(ex))
                continue
            except SkipItem:
                result.set_skipped(contentitem)
                continue

            # Try caching it.
            self._try_cache_output(contentitem, output, result=result)
            if self.edit_mode:
                output.html = markers.wrap_contentitem_output(output.html, contentitem)

            result.store_output(contentitem, output)
1197040
function generateDirective(originalName) {
    var template = args.t || args.template || "html";
    var name = originalName.split("/").pop();
    var obj = {
        name: name,
        original_name: originalName,
        template_extension: template,
    };
    var gen = {
        json: templates.generator.config(),
        js: templates.generator.js(),
        scss: templates.generator.scss(),
    };

    gen[template] = templates.generator[template]();

    return Object.keys(gen).reduce(function (files, ext) {
        files[originalName + "/" + name + "." + ext] = replaceText(gen[ext], obj);
        return files;
    }, {});
}
234010
def merge_output(self, result, items, template_name):
        
        html_output, media = self.get_html_output(result, items)

        if not template_name:
            merged_html = mark_safe(u''.join(html_output))
        else:
            context = {
                'contentitems': list(zip(items, html_output)),
                'parent_object': result.parent_object,  # Can be None
                'edit_mode': self.edit_mode,
            }

            context = PluginContext(self.request, context)
            merged_html = render_to_string(template_name, context.flatten())

        return ContentItemOutput(merged_html, media, cacheable=result.all_cacheable, cache_timeout=result.all_timeout)
754593
def get_plugins_by_name(self, *names):
        
        self._import_plugins()
        plugin_instances = []
        for name in names:
            if isinstance(name, six.string_types):
                try:
                    plugin_instances.append(self.plugins[name.lower()])
                except KeyError:
                    raise PluginNotFound("No plugin named '{0}'.".format(name))
            elif isinstance(name, type) and issubclass(name, ContentPlugin):
                # Will also allow classes instead of strings.
                plugin_instances.append(self.plugins[self._name_for_model[name.model]])
            else:
                raise TypeError("get_plugins_by_name() expects a plugin name or class, not: {0}".format(name))
        return plugin_instances