예제 #1
0
import logging
import os.path

from deform.widget import MappingWidget, default_resource_registry
from pyramid.threadlocal import get_current_request

from eea.corpus. async import get_assigned_job
from eea.corpus.corpus import corpus_base_path
from eea.corpus.processing.utils import (component_phash_id,
                                         get_pipeline_for_component)

logger = logging.getLogger('eea.corpus')

default_resource_registry.set_js_resources(
    'phrase-widget', None, 'eea.corpus:static/phrase-widget.js')


class PhraseFinderWidget(MappingWidget):
    """ Mapping widget with custom template

    Template customizations:

        * frame color based on phrase model status
        * the reload button is disabled/enabled based on live phrase model
          status
        * there is an AJAX js script that queries job status and updates the
          widget status indicators (frame color, reload preview button)
    """

    template = 'phrase_form'
    requirements = (('phrase-widget', None), )
예제 #2
0
    def _add_options(self, kw):
        options = dict(self.default_options)
        from datetime import datetime
        uniqueid = hash(datetime.now())
        options['autosave']['uniqueid'] = uniqueid
        options_overrides = dict(kw.get('options', self.options or {}))
        options.update(options_overrides)
        kw['simplemde_options'] = json.dumps(options)
        return kw


default_resource_registry.set_css_resources(
    'simplemde',
    None,
    'deform_markdown:static/css/simplemde.min.css')


default_resource_registry.set_js_resources(
    'simplemde',
    None,
    'deform_markdown:static/scripts/simplemde.min.js')


def includeme(config):  # pragma: no cover
    """Pyramid integration: register static view for widget resources."""
    year = 86400 * 365
    config.add_static_view('deformmarkdownstatic',
                           'deform_markdown:static',
                           cache_max_age=year)
예제 #3
0
파일: widget.py 프로젝트: ecreall/pontus
    def __call__(self, node, value):
        if self.min is not None:
            if len(value) < self.min:
                min_err = self.translationStringFactory(
                              self.min_message.format(min=self.min))
                raise Invalid(node, min_err)

        if self.max is not None:
            if len(value) > self.max:
                max_err = self.translationStringFactory(
                              self.max_message.format(max=self.max))
                raise Invalid(node, max_err)


default_resource_registry.set_js_resources(
    'tinymce', None,
    'deform:static/tinymce/tinymce.min.js',
    'pontus:static/js/preventdelete/preventdelete.js')

default_resource_registry.set_js_resources('select2creation', None,
               'pontus:static/select2/dist/js/select2.js')


default_resource_registry.set_css_resources('select2creation', None,
               'pontus:static/select2/dist/css/select2.min.css',
               'pontus:static/css/select2.css')


default_resource_registry.set_js_resources('ajaxselect2', None, 
               'pontus:static/select2/dist/js/select2.js', 
               'pontus:static/js/select2_ajax_extension.js')
예제 #4
0

class EmojiInputWidget(deform.widget.TextInputWidget):
    template = 'novaideo:views/templates/emoji_input.pt'
    requirements = (('emoji', None), ('jquery.maskedinput', None))

    def get_emoji_form(self, cstruct=None):
        return get_emoji_form(get_current_request(),
                              emoji_class='emoji-input-widget',
                              is_grouped=getattr(self, 'is_grouped', True),
                              add_preview=getattr(self, 'add_preview', False),
                              items=self.items,
                              selected_items=[cstruct])


default_resource_registry.set_js_resources(
    'emoji', None, 'novaideo:static/js/emoji_input.js')

default_resource_registry.set_js_resources(
    'ajax_checkbox', None, 'novaideo:static/js/ajax_checkbox_choice.js')

default_resource_registry.set_js_resources(
    'stylepicker', None, 'novaideo:static/bgrins-spectrum/spectrum.js',
    'novaideo:static/js/style_picker.js')

default_resource_registry.set_css_resources(
    'stylepicker', None, 'novaideo:static/bgrins-spectrum/spectrum.css')

default_resource_registry.set_js_resources(
    'bootstrap_icon', None, 'novaideo:static/js/bootstrap_iconpicker.js',
    'novaideo:static/bootstrap-iconpicker/bootstrap-iconpicker/js/bootstrap-iconpicker.min.js'
)
예제 #5
0
파일: widget.py 프로젝트: jean/nova-ideo
    template = 'novaideo:views/templates/dragdrop_sequence/sequence.pt'
    item_template = 'novaideo:views/templates/dragdrop_sequence/sequence_item.pt'


class DragDropSelect2Widget(Select2Widget):
    template = 'novaideo:views/templates/dragdrop_sequence/select2.pt'
    requirements = (('deform', None), ('select2dragdrop', None))


class DragDropMappingWidget(deform.widget.MappingWidget):

    template = 'novaideo:views/templates/dragdrop_sequence/mapping.pt'
    item_template = 'novaideo:views/templates/dragdrop_sequence/mapping_item.pt'


default_resource_registry.set_js_resources('toucheckbox', None,
               'novaideo:static/js/toucheckbox.js'  )

default_resource_registry.set_js_resources('addnewidea', None, 
                         'novaideo:static/js/add_new_idea.js'  )

default_resource_registry.set_js_resources('select2search', None, 
           'pontus:static/select2/dist/js/select2.min.js',
           'novaideo:static/select2_search/select2_search.js'  )

default_resource_registry.set_css_resources('select2search', None, 
              'pontus:static/select2/dist/css/select2.min.css',
              'novaideo:static/select2_search/select2_search.css'  )

default_resource_registry.set_js_resources('select2dragdrop', None, 
                'pontus:static/select2/dist/js/select2.min.js',
                'novaideo:static/js/dragdrop_select.js'  )
예제 #6
0
파일: widget.py 프로젝트: ecreall/nova-ideo
    requirements = (('ajax_checkbox', None),)


class EmojiInputWidget(deform.widget.TextInputWidget):
    template = 'novaideo:views/templates/emoji_input.pt'
    requirements = (('emoji', None), ('jquery.maskedinput', None))

    def get_emoji_form(self, cstruct=None):
        return get_emoji_form(
          get_current_request(), emoji_class='emoji-input-widget',
          is_grouped=getattr(self, 'is_grouped', True),
          add_preview=getattr(self, 'add_preview', False),
          items=self.items, selected_items=[cstruct])


default_resource_registry.set_js_resources('emoji', None,
               'novaideo:static/js/emoji_input.js')

default_resource_registry.set_js_resources('ajax_checkbox', None,
               'novaideo:static/js/ajax_checkbox_choice.js')

default_resource_registry.set_js_resources('stylepicker', None,
               'novaideo:static/bgrins-spectrum/spectrum.js',
               'novaideo:static/js/style_picker.js')

default_resource_registry.set_css_resources('stylepicker', None,
              'novaideo:static/bgrins-spectrum/spectrum.css')

default_resource_registry.set_js_resources('bootstrap_icon', None,
           'novaideo:static/js/bootstrap_iconpicker.js',
           'novaideo:static/bootstrap-iconpicker/bootstrap-iconpicker/js/bootstrap-iconpicker.min.js')
예제 #7
0
# Copyright (c) 2014 by Ecreall under licence AGPL terms
# available on http://www.gnu.org/licenses/agpl.html

# licence: AGPL
# author: Amen Souissi

import deform
from deform.widget import default_resource_registry


class SearchFormWidget(deform.widget.FormWidget):
    template = 'novaideo:views/novaideo_view_manager/templates/search_form.pt'


class SearchTextInputWidget(deform.widget.TextInputWidget):
    template = 'novaideo:views/novaideo_view_manager/templates/search_textinput.pt'
    requirements = (('live_search', None), )


default_resource_registry.set_js_resources(
    'live_search', None, 'novaideo:static/js/live_search.js')

default_resource_registry.set_css_resources(
    'live_search', None, 'pontus:static/select2/dist/css/select2.min.css')
예제 #8
0
        if isinstance(cstruct, (dict, PersistentDict)):
            cstruct = json.dumps(dict(cstruct))

        readonly = kw.get('readonly', self.readonly)
        template = readonly and self.readonly_template or self.template
        values = self.get_template_values(field, cstruct, kw)
        return field.renderer(template, **values)

    def deserialize(self, field, pstruct):
        if pstruct is null:
            return null
        if self.strip:
            pstruct = pstruct.strip()
        if not pstruct:
            return null
        return json.loads(pstruct)


default_resource_registry.set_js_resources(
    'treepy', None,
    'deform_treepy:static/js/treepy.js',
    'deform_treepy:static/js/treepy_langs.js',
    'deform_treepy:static/vakata-jstree/dist/jstree.js',
    'pontus:static/select2/dist/js/select2.js')

default_resource_registry.set_css_resources(
    'treepy', None,
    'deform_treepy:static/vakata-jstree/dist/themes/default/style.min.css',
    'deform_treepy:static/css/treepy.css',
    'pontus:static/select2/dist/css/select2.min.css')
예제 #9
0
파일: widget.py 프로젝트: ecreall/nova-ideo
# Copyright (c) 2014 by Ecreall under licence AGPL terms 
# available on http://www.gnu.org/licenses/agpl.html

# licence: AGPL
# author: Amen Souissi

import deform
from deform.widget import default_resource_registry


class SearchFormWidget(deform.widget.FormWidget):
    template = 'novaideo:views/novaideo_view_manager/templates/search_form.pt'


class SearchTextInputWidget(deform.widget.TextInputWidget):
    template = 'novaideo:views/novaideo_view_manager/templates/search_textinput.pt'
    requirements = (('live_search', None),)


default_resource_registry.set_js_resources(
    'live_search', None,
    'novaideo:static/js/live_search.js')

default_resource_registry.set_css_resources(
    'live_search', None,
    'pontus:static/select2/dist/css/select2.min.css')
예제 #10
0
# Copyright (c) 2014 by Ecreall under licence AGPL terms
# available on http://www.gnu.org/licenses/agpl.html

# licence: AGPL
# author: Amen Souissi

import deform
from deform.widget import default_resource_registry


class SearchFormWidget(deform.widget.FormWidget):
    template = 'lac:views/lac_view_manager/templates/search_form.pt'


class SearchTextInputWidget(deform.widget.TextInputWidget):
    template = 'lac:views/lac_view_manager/templates/search_textinput.pt'
    requirements = (('search_text', None), )


default_resource_registry.set_js_resources('search_text', None,
                                           'lac:static/js/search_text.js')

default_resource_registry.set_css_resources(
    'search_text', None, 'pontus:static/select2/dist/css/select2.min.css')
예제 #11
0
    def deserialize(self, field, pstruct):
        row = super(BootstrapIconInputWidget, self).deserialize(field, pstruct)
        if row is null:
            return null

        data = row.split(',')
        try:
            return {'icon_class': data[0],
                    'icon': data[1]}
        except:
            return data


default_resource_registry.set_js_resources('bootstrap_icon', None,
           'lac:static/bootstrap-iconpicker/bootstrap-iconpicker/js/iconset/iconset-all.min.js',
           'lac:static/bootstrap-iconpicker/bootstrap-iconpicker/js/bootstrap-iconpicker.js',
           'lac:static/js/bootstrap_iconpicker.js')

default_resource_registry.set_css_resources('bootstrap_icon', None,
              'lac:static/bootstrap-iconpicker/bootstrap-iconpicker/css/bootstrap-iconpicker.min.css')


default_resource_registry.set_js_resources('simple_mapping', None,
               'lac:static/js/simple_mapping.js')

default_resource_registry.set_js_resources('toucheckbox', None,
               'lac:static/js/toucheckbox.js')

default_resource_registry.set_js_resources('article', None,
               'lac:static/js/article_tinymce.js')
예제 #12
0
# -*- coding: utf8 -*-
# Copyright (c) 2017 by Ecreall under licence AGPL terms
# available on http://www.gnu.org/licenses/agpl.html

# licence: AGPL
# author: Amen Souissi

import deform
from deform.widget import default_resource_registry


class YammerNotificationWidget(deform.widget.TextInputWidget):
    template = 'novaideo:connectors/yammer/views/templates/yammer_notification.pt'
    requirements = (('yammer_notification', None), )


default_resource_registry.set_js_resources(
    'yammer_notification', None,
    'novaideo:static/connectors/yammer/yammer_notification.js')
예제 #13
0
# Copyright (c) 2014 by Ecreall under licence AGPL terms 
# available on http://www.gnu.org/licenses/agpl.html 

# licence: AGPL
# author: Amen Souissi

import deform
from deform.widget import default_resource_registry


class SearchFormWidget(deform.widget.FormWidget):
    template = 'lac:views/lac_view_manager/templates/search_form.pt'


class SearchTextInputWidget(deform.widget.TextInputWidget):
    template = 'lac:views/lac_view_manager/templates/search_textinput.pt'
    requirements = (('search_text', None),)


default_resource_registry.set_js_resources('search_text', None,
           'lac:static/js/search_text.js')

default_resource_registry.set_css_resources('search_text', None,
              'pontus:static/select2/dist/css/select2.min.css')
예제 #14
0
    def __call__(self, node, value):
        if self.min is not None:
            if len(value) < self.min:
                min_err = self.translationStringFactory(
                    self.min_message.format(min=self.min))
                raise Invalid(node, min_err)

        if self.max is not None:
            if len(value) > self.max:
                max_err = self.translationStringFactory(
                    self.max_message.format(max=self.max))
                raise Invalid(node, max_err)


default_resource_registry.set_js_resources(
    'tinymce', None, 'deform:static/tinymce/tinymce.min.js',
    'pontus:static/js/preventdelete/preventdelete.js')

default_resource_registry.set_js_resources(
    'select2creation', None, 'pontus:static/select2/dist/js/select2.js')

default_resource_registry.set_css_resources(
    'select2creation', None, 'pontus:static/select2/dist/css/select2.min.css',
    'pontus:static/css/select2.css')

default_resource_registry.set_js_resources(
    'ajaxselect2', None, 'pontus:static/select2/dist/js/select2.js',
    'pontus:static/js/select2_ajax_extension.js')

default_resource_registry.set_css_resources(
    'ajaxselect2', None, 'pontus:static/select2/dist/css/select2.min.css',
예제 #15
0
        if isinstance(cstruct, (dict, PersistentDict)):
            cstruct = json.dumps(dict(cstruct))

        readonly = kw.get('readonly', self.readonly)
        template = readonly and self.readonly_template or self.template
        values = self.get_template_values(field, cstruct, kw)
        return field.renderer(template, **values)

    def deserialize(self, field, pstruct):
        if pstruct is null:
            return null
        if self.strip:
            pstruct = pstruct.strip()
        if not pstruct:
            return null
        return json.loads(pstruct)


default_resource_registry.set_js_resources(
    'treepy', None, 'deform_treepy:static/js/treepy.js',
    'deform_treepy:static/js/treepy_langs.js',
    'deform_treepy:static/vakata-jstree/dist/jstree.js',
    'pontus:static/select2/dist/js/select2.js')

default_resource_registry.set_css_resources(
    'treepy', None,
    'deform_treepy:static/vakata-jstree/dist/themes/default/style.min.css',
    'deform_treepy:static/css/treepy.css',
    'pontus:static/select2/dist/css/select2.min.css')
예제 #16
0
파일: widget.py 프로젝트: ecreall/nova-ideo
# -*- coding: utf8 -*-
# Copyright (c) 2017 by Ecreall under licence AGPL terms
# available on http://www.gnu.org/licenses/agpl.html

# licence: AGPL
# author: Amen Souissi

import deform
from deform.widget import default_resource_registry


class YammerNotificationWidget(deform.widget.TextInputWidget):
    template = 'novaideo:connectors/yammer/views/templates/yammer_notification.pt'
    requirements = ( ('yammer_notification', None), )


default_resource_registry.set_js_resources('yammer_notification', None,
               'novaideo:static/connectors/yammer/yammer_notification.js' )
예제 #17
0
    def deserialize(self, field, pstruct):
        row = super(BootstrapIconInputWidget, self).deserialize(field, pstruct)
        if row is null:
            return null

        data = row.split(',')
        try:
            return {'icon_class': data[0], 'icon': data[1]}
        except:
            return data


default_resource_registry.set_js_resources(
    'bootstrap_icon', None,
    'lac:static/bootstrap-iconpicker/bootstrap-iconpicker/js/iconset/iconset-all.min.js',
    'lac:static/bootstrap-iconpicker/bootstrap-iconpicker/js/bootstrap-iconpicker.js',
    'lac:static/js/bootstrap_iconpicker.js')

default_resource_registry.set_css_resources(
    'bootstrap_icon', None,
    'lac:static/bootstrap-iconpicker/bootstrap-iconpicker/css/bootstrap-iconpicker.min.css'
)

default_resource_registry.set_js_resources('simple_mapping', None,
                                           'lac:static/js/simple_mapping.js')

default_resource_registry.set_js_resources('toucheckbox', None,
                                           'lac:static/js/toucheckbox.js')

default_resource_registry.set_js_resources('article', None,