# Path: djedi/plugins/form.py
# class FormsBasePlugin(DjediPlugin):
#     ext = None
# 
#     @property
#     def forms(self):
#         return {}
# 
#     def get_editor_context(self, **context):
#         context.update(
#             {"forms": {
#                 tab: form()
#                 for tab, form in self.forms.items()
#             }}
#         )
# 
#         return context
# 
#     def save(self, data, dumps=True):
#         data = self.collect_forms_data(data)
#         return json.dumps(data) if dumps else data
# 
#     def collect_forms_data(self, data):
#         return {
#             deprefix(field): data.get(deprefix(field))
#             for tab, form in self.forms.items()
#             for field in form.base_fields.keys()
#         }
# 
# class BaseEditorForm(forms.Form):
#     def __init__(self, *args, **kwargs):
#         super(BaseEditorForm, self).__init__(*args, **kwargs)
# 
#         for field in list(self.fields.keys()):
#             self.fields[field].widget.__class__ = get_custom_render_widget(
#                 self.fields[field].widget.__class__
#             )


import json
import six
from django.utils.html import escape
from django.core.files.uploadedfile import InMemoryUploadedFile
from django import forms
from hashlib import sha1
from os import path
from .form import FormsBasePlugin, BaseEditorForm
        from PIL import Image
            from django.core.files.storage import default_storage as file_storage
            # Djedi backend and frontend run on different domains. The base64
            # part was made by running:
            # $ svgo djedi/static/djedi/placeholder.svg -o - | openssl base64 | tr -d '\n'
            # 'src': '/static/djedi/placeholder.svg',
            'src': 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTYwIDkwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIG9wYWNpdHk9Ii4yNSIgZmlsbD0iIzIwYjJhYSIgZD0iTTAgMGgxNjB2OTBIMHoiLz48L3N2Zz4K',  # noqa: E501
            'width': 160,
            'height': 90
        }

        if data:
            url = data.get('url')
            if url:
                attrs['src'] = url

            width = data.get('width') or 0
            height = data.get('height') or 0
            if width and height:
                attrs['width'] = width
                attrs['height'] = height

            attrs['alt'] = data.get('alt') or ''

            attr_id = data.get('id')
            if attr_id:
                attrs['id'] = attr_id

            attr_class = data.get('class')
            if attr_class:
                attrs['class'] = attr_class


# Path: djedi/plugins/form.py
# class FormsBasePlugin(DjediPlugin):
#     ext = None
# 
#     @property
#     def forms(self):
#         return {}
# 
#     def get_editor_context(self, **context):
#         context.update(
#             {"forms": {
#                 tab: form()
#                 for tab, form in self.forms.items()
#             }}
#         )
# 
#         return context
# 
#     def save(self, data, dumps=True):
#         data = self.collect_forms_data(data)
#         return json.dumps(data) if dumps else data
# 
#     def collect_forms_data(self, data):
#         return {
#             deprefix(field): data.get(deprefix(field))
#             for tab, form in self.forms.items()
#             for field in form.base_fields.keys()
#         }
# 
# class BaseEditorForm(forms.Form):
#     def __init__(self, *args, **kwargs):
#         super(BaseEditorForm, self).__init__(*args, **kwargs)
# 
#         for field in list(self.fields.keys()):
#             self.fields[field].widget.__class__ = get_custom_render_widget(
#                 self.fields[field].widget.__class__
#             )


# Path: djedi/plugins/img.py
import json
import six
from django.utils.html import escape
from django.core.files.uploadedfile import InMemoryUploadedFile
from django import forms
from hashlib import sha1
from os import path
from .form import FormsBasePlugin, BaseEditorForm
        from PIL import Image
            from django.core.files.storage import default_storage as file_storage

            # Djedi backend and frontend run on different domains. The base64
            # part was made by running:
            # $ svgo djedi/static/djedi/placeholder.svg -o - | openssl base64 | tr -d '\n'
            # 'src': '/static/djedi/placeholder.svg',
            'src': 'data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTYwIDkwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIG9wYWNpdHk9Ii4yNSIgZmlsbD0iIzIwYjJhYSIgZD0iTTAgMGgxNjB2OTBIMHoiLz48L3N2Zz4K',  # noqa: E501
            'width': 160,
            'height': 90
        }

        if data:
            url = data.get('url')
            if url:
                attrs['src'] = url

            width = data.get('width') or 0
            height = data.get('height') or 0
            if width and height:
                attrs['width'] = width
                attrs['height'] = height

            attrs['alt'] = data.get('alt') or ''

            attr_id = data.get('id')
            if attr_id:
                attrs['id'] = attr_id

            attr_class = data.get('class')
            if attr_class:
                attrs['class'] = attr_class


        html_attrs = (u'{0}="{1}"'.format(attr, escape(attrs[attr])) for attr in sorted(attrs.keys()))