<commit_before># -*- coding: utf-8 -*-

# Copyright (c) 2012-2016 CoNWeT Lab., Universidad Politécnica de Madrid

# This file is part of Wirecloud.

# Wirecloud is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Wirecloud is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with Wirecloud.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from copy import deepcopy
from hashlib import sha1
import json

from django.conf import settings
from django.utils.translation import get_language, ugettext_lazy as _

import wirecloud.platform
from wirecloud.platform.core.catalogue_manager import WirecloudCatalogueManager
from wirecloud.platform.themes import get_active_theme_name
from wirecloud.platform.plugins import build_url_template, get_active_features_info, WirecloudPlugin


WORKSPACE_CSS = (
    'css/workspace/wallet.scss',
    'css/workspace/dragboard.scss',
    'css/workspace/dragboard_cursor.scss',
    'css/workspace/iwidget.scss',
    'css/workspace/empty_workspace_message.css',
    'css/workspace/share_window_menu.scss',
    'css/upgrade_window_menu.scss',
)

CLASSIC_CORE_CSS = (
    'css/mac_search.css',
    'css/layout_field.css',
    'css/mac_field.scss',
    'css/mac_selection_dialog.css',
)

CATALOGUE_CSS = (
    'css/catalogue/emptyCatalogueBox.css',
    'css/catalogue/resource.scss',
    'css/catalogue/resource_details.scss',
    'css/catalogue/search_interface.scss',
    'css/catalogue/upload_window_menu.scss',
)

WIRING_EDITOR_FILES = (
    'js/wirecloud/ui/WiringEditor.js',
    'js/wirecloud/ui/WiringEditor/Behaviour.js',
    'js/wirecloud/ui/WiringEditor/BehaviourPrefs.js',
    'js/wirecloud/ui/WiringEditor/BehaviourLogManager.js',
    'js/wirecloud/ui/WiringEditor/BehaviourEngine.js',
    'js/wirecloud/ui/WiringEditor/Endpoint.js',
    'js/wirecloud/ui/WiringEditor/SourceEndpoint.js',
    'js/wirecloud/ui/WiringEditor/TargetEndpoint.js',
    'js/wirecloud/ui/WiringEditor/EndpointGroup.js',
    'js/wirecloud/ui/WiringEditor/Component.js',
    'js/wirecloud/ui/WiringEditor/ComponentPrefs.js',
    'js/wirecloud/ui/WiringEditor/ComponentGroup.js',
    'js/wirecloud/ui/WiringEditor/ComponentShowcase.js',
    'js/wirecloud/ui/WiringEditor/ComponentDraggable.js',
    'js/wirecloud/ui/WiringEditor/ComponentDraggablePrefs.js',
    'js/wirecloud/ui/WiringEditor/Connection.js',
    'js/wirecloud/ui/WiringEditor/ConnectionPrefs.js',
    'js/wirecloud/ui/WiringEditor/ConnectionHandle.js',
    'js/wirecloud/ui/WiringEditor/ConnectionEngine.js',
    'js/wirecloud/ui/WiringEditor/KeywordSuggestion.js',
)

TUTORIAL_FILES = (
    'js/wirecloud/ui/Tutorial.js',
    'js/wirecloud/ui/Tutorial/Utils.js',
    'js/wirecloud/ui/TutorialCatalogue.js',
    'js/wirecloud/ui/TutorialSubMenu.js',
    'js/wirecloud/ui/Tutorial/PopUp.js',
    'js/wirecloud/ui/Tutorial/SimpleDescription.js',
    'js/wirecloud/ui/Tutorial/UserAction.js',
    'js/wirecloud/ui/Tutorial/FormAction.js',
    'js/wirecloud/ui/Tutorial/AutoAction.js',
    'js/wirecloud/Tutorials/BasicConcepts.js',
    'js/wirecloud/Tutorials/BehaviourOrientedWiring.js',
)

SHIM_FILES = (
    'js/wirecloud/shims/string.js',
    'js/wirecloud/shims/classList.js',
)

STYLED_ELEMENTS_FILES = (
    # 'js/StyledElements/Utils.js', Added on bootstrap.html
    # 'js/StyledElements/ObjectWithEvents.js', Added as common file
    'js/StyledElements/StyledElements.js',
    'js/StyledElements/InputElement.js',
    'js/StyledElements/CommandQueue.js',
    'js/StyledElements/Container.js',
    'js/StyledElements/Addon.js',
    'js/StyledElements/Accordion.js',
    'js/StyledElements/Expander.js',
    'js/StyledElements/Fragment.js',
    'js/StyledElements/PaginatedSource.js',
    'js/StyledElements/GUIBuilder.js',
    'js/StyledElements/Tooltip.js',
    'js/StyledElements/Button.js',
    'js/StyledElements/SVGPlainButton.js',
    'js/StyledElements/FileButton.js',
    'js/StyledElements/PopupMenuBase.js',
    'js/StyledElements/PopupMenu.js',
    'js/StyledElements/DynamicMenuItems.js',
    'js/StyledElements/MenuItem.js',
    'js/StyledElements/Separator.js',
    'js/StyledElements/SubMenuItem.js',
    'js/StyledElements/PopupButton.js',
    'js/StyledElements/StaticPaginatedSource.js',
    'js/StyledElements/FileField.js',
    'js/StyledElements/NumericField.js',
    'js/StyledElements/TextField.js',
    'js/StyledElements/TextArea.js',
    'js/StyledElements/List.js',
    'js/StyledElements/PasswordField.js',
    'js/StyledElements/Select.js',
    'js/StyledElements/ToggleButton.js',
    'js/StyledElements/Pills.js',
    'js/StyledElements/Tab.js',
    'js/StyledElements/Notebook.js',
    'js/StyledElements/Alternative.js',
    'js/StyledElements/Alternatives.js',
    'js/StyledElements/HorizontalLayout.js',
    'js/StyledElements/VerticalLayout.js',
    'js/StyledElements/BorderLayout.js',
    'js/StyledElements/ModelTable.js',
    'js/StyledElements/EditableElement.js',
    'js/StyledElements/HiddenField.js',
    'js/StyledElements/ButtonsGroup.js',
    'js/StyledElements/CheckBox.js',
    'js/StyledElements/RadioButton.js',
    'js/StyledElements/InputInterface.js',
    'js/StyledElements/TextInputInterface.js',
    'js/StyledElements/InputInterfaces.js',
    'js/wirecloud/ui/ParametrizableValueInputInterface.js',
    'js/wirecloud/ui/ParametrizedTextInputInterface.js',
    'js/wirecloud/ui/LayoutInputInterface.js',
    'js/StyledElements/VersionInputInterface.js',
    'js/StyledElements/InputInterfaceFactory.js',
    'js/StyledElements/DefaultInputInterfaceFactory.js',
    'js/StyledElements/Form.js',
    'js/StyledElements/PaginationInterface.js',
    'js/StyledElements/Popover.js',
    'js/StyledElements/Panel.js',
    'js/StyledElements/OffCanvasLayout.js',
    'js/StyledElements/Alert.js',
    'js/StyledElements/Typeahead.js',
)

PLATFORM_CORE_CSS = (
    'css/wirecloud_core.scss',
    'css/icons.css',
    'css/window_menu.scss',
    'css/windowmenues/logwindowmenu.scss',
)

BASE_CSS = (
    'css/font-awesome.css',
    'css/font-awesome-backwards.css',
    'css/base/utils.scss',
    'css/base/body.scss',
    'css/base/fade.css',
    'css/base/code.scss',
    'css/base/z-depth.scss',
    'css/workspace/ioperator.css',
)

WIRING_EDITOR_CSS = (
    'css/wiring/wiring_layout.scss',
    'css/wiring/wiring_components.scss',
    'css/wiring/wiring_connections.scss',
    'css/wiring/wiring_behaviours.scss',
)

TUTORIAL_CSS = (
    'css/tutorial.scss',
)


STYLED_ELEMENTS_CSS = (
    'css/styled_elements_core.css',
    'css/styledelements/styled_addon.scss',
    'css/styledelements/styled_alternatives.scss',
    'css/styledelements/styled_container.css',
    'css/styledelements/styled_button.scss',
    'css/styledelements/styled_checkbox.css',
    'css/styledelements/styled_pills.scss',
    'css/styledelements/styled_notebook.scss',
    'css/styledelements/styled_form.css',
    'css/styledelements/styled_pagination.scss',
    'css/styledelements/styled_panel.scss',
    'css/styledelements/styled_numeric_field.scss',
    'css/styledelements/styled_text_field.scss',
    'css/styledelements/styled_text_area.scss',
    'css/styledelements/styled_password_field.scss',
    'css/styledelements/styled_select.scss',
    'css/styledelements/styled_border_layout.css',
    'css/styledelements/styled_horizontal_and_vertical_layout.scss',
    'css/styledelements/styled_file_field.scss',
    'css/styledelements/styled_table.scss',
    'css/styledelements/styled_label_badge.scss',
    'css/styledelements/styled_alert.scss',
    'css/styledelements/styled_rating.scss',
    'css/styledelements/styled_popup_menu.scss',
    'css/styledelements/styled_popover.scss',
    'css/styledelements/styled_tooltip.css',
    'css/styledelements/styled_expander.scss',
    'css/styledelements/styled_offcanvas_layout.scss',
    'css/styledelements/styled_thumbnail.scss',
)


def get_version_hash():
    return sha1(json.dumps(get_active_features_info(), ensure_ascii=False, sort_keys=True).encode('utf8')).hexdigest()


class WirecloudCorePlugin(WirecloudPlugin):

    features = {
        'Wirecloud': wirecloud.platform.__version__,
        'ApplicationMashup': '1.0',
        'StyledElements': '0.6.3',
        'FullscreenWidget': '0.5',
        'DashboardManagement': '1.0',
    }

    def get_platform_context_definitions(self):
        return {
            'language': {
                'label': _('Language'),
                'description': _('Current language used in the platform'),
            },
            'username': {
                'label': _('Username'),
                'description': _('User name of the current logged user'),
            },
            'fullname': {
                'label': _('Full name'),
                'description': _('Full name of the logged user'),
            },
            'isanonymous': {
                'label': _('Is Anonymous'),
                'description': _('Boolean. Designates whether current user is logged in the system.'),
            },
            'isstaff': {
                'label': _('Is Staff'),
                'description': _('Boolean. Designates whether current user can access the admin site.'),
            },
            'issuperuser': {
                'label': _('Is Superuser'),
                'description': _('Boolean. Designates whether current user is a super user.'),
            },
            'mode': {<commit_msg>Bump styledelements version<commit_after># -*- coding: utf-8 -*-

# Copyright (c) 2012-2016 CoNWeT Lab., Universidad Politécnica de Madrid

# This file is part of Wirecloud.

# Wirecloud is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Wirecloud is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with Wirecloud.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from copy import deepcopy
from hashlib import sha1
import json

from django.conf import settings
from django.utils.translation import get_language, ugettext_lazy as _

import wirecloud.platform
from wirecloud.platform.core.catalogue_manager import WirecloudCatalogueManager
from wirecloud.platform.themes import get_active_theme_name
from wirecloud.platform.plugins import build_url_template, get_active_features_info, WirecloudPlugin


WORKSPACE_CSS = (
    'css/workspace/wallet.scss',
    'css/workspace/dragboard.scss',
    'css/workspace/dragboard_cursor.scss',
    'css/workspace/iwidget.scss',
    'css/workspace/empty_workspace_message.css',
    'css/workspace/share_window_menu.scss',
    'css/upgrade_window_menu.scss',
)

CLASSIC_CORE_CSS = (
    'css/mac_search.css',
    'css/layout_field.css',
    'css/mac_field.scss',
    'css/mac_selection_dialog.css',
)

CATALOGUE_CSS = (
    'css/catalogue/emptyCatalogueBox.css',
    'css/catalogue/resource.scss',
    'css/catalogue/resource_details.scss',
    'css/catalogue/search_interface.scss',
    'css/catalogue/upload_window_menu.scss',
)

WIRING_EDITOR_FILES = (
    'js/wirecloud/ui/WiringEditor.js',
    'js/wirecloud/ui/WiringEditor/Behaviour.js',
    'js/wirecloud/ui/WiringEditor/BehaviourPrefs.js',
    'js/wirecloud/ui/WiringEditor/BehaviourLogManager.js',
    'js/wirecloud/ui/WiringEditor/BehaviourEngine.js',
    'js/wirecloud/ui/WiringEditor/Endpoint.js',
    'js/wirecloud/ui/WiringEditor/SourceEndpoint.js',
    'js/wirecloud/ui/WiringEditor/TargetEndpoint.js',
    'js/wirecloud/ui/WiringEditor/EndpointGroup.js',
    'js/wirecloud/ui/WiringEditor/Component.js',
    'js/wirecloud/ui/WiringEditor/ComponentPrefs.js',
    'js/wirecloud/ui/WiringEditor/ComponentGroup.js',
    'js/wirecloud/ui/WiringEditor/ComponentShowcase.js',
    'js/wirecloud/ui/WiringEditor/ComponentDraggable.js',
    'js/wirecloud/ui/WiringEditor/ComponentDraggablePrefs.js',
    'js/wirecloud/ui/WiringEditor/Connection.js',
    'js/wirecloud/ui/WiringEditor/ConnectionPrefs.js',
    'js/wirecloud/ui/WiringEditor/ConnectionHandle.js',
    'js/wirecloud/ui/WiringEditor/ConnectionEngine.js',
    'js/wirecloud/ui/WiringEditor/KeywordSuggestion.js',
)

TUTORIAL_FILES = (
    'js/wirecloud/ui/Tutorial.js',
    'js/wirecloud/ui/Tutorial/Utils.js',
    'js/wirecloud/ui/TutorialCatalogue.js',
    'js/wirecloud/ui/TutorialSubMenu.js',
    'js/wirecloud/ui/Tutorial/PopUp.js',
    'js/wirecloud/ui/Tutorial/SimpleDescription.js',
    'js/wirecloud/ui/Tutorial/UserAction.js',
    'js/wirecloud/ui/Tutorial/FormAction.js',
    'js/wirecloud/ui/Tutorial/AutoAction.js',
    'js/wirecloud/Tutorials/BasicConcepts.js',
    'js/wirecloud/Tutorials/BehaviourOrientedWiring.js',
)

SHIM_FILES = (
    'js/wirecloud/shims/string.js',
    'js/wirecloud/shims/classList.js',
)

STYLED_ELEMENTS_FILES = (
    # 'js/StyledElements/Utils.js', Added on bootstrap.html
    # 'js/StyledElements/ObjectWithEvents.js', Added as common file
    'js/StyledElements/StyledElements.js',
    'js/StyledElements/InputElement.js',
    'js/StyledElements/CommandQueue.js',
    'js/StyledElements/Container.js',
    'js/StyledElements/Addon.js',
    'js/StyledElements/Accordion.js',
    'js/StyledElements/Expander.js',
    'js/StyledElements/Fragment.js',
    'js/StyledElements/PaginatedSource.js',
    'js/StyledElements/GUIBuilder.js',
    'js/StyledElements/Tooltip.js',
    'js/StyledElements/Button.js',
    'js/StyledElements/SVGPlainButton.js',
    'js/StyledElements/FileButton.js',
    'js/StyledElements/PopupMenuBase.js',
    'js/StyledElements/PopupMenu.js',
    'js/StyledElements/DynamicMenuItems.js',
    'js/StyledElements/MenuItem.js',
    'js/StyledElements/Separator.js',
    'js/StyledElements/SubMenuItem.js',
    'js/StyledElements/PopupButton.js',
    'js/StyledElements/StaticPaginatedSource.js',
    'js/StyledElements/FileField.js',
    'js/StyledElements/NumericField.js',
    'js/StyledElements/TextField.js',
    'js/StyledElements/TextArea.js',
    'js/StyledElements/List.js',
    'js/StyledElements/PasswordField.js',
    'js/StyledElements/Select.js',
    'js/StyledElements/ToggleButton.js',
    'js/StyledElements/Pills.js',
    'js/StyledElements/Tab.js',
    'js/StyledElements/Notebook.js',
    'js/StyledElements/Alternative.js',
    'js/StyledElements/Alternatives.js',
    'js/StyledElements/HorizontalLayout.js',
    'js/StyledElements/VerticalLayout.js',
    'js/StyledElements/BorderLayout.js',
    'js/StyledElements/ModelTable.js',
    'js/StyledElements/EditableElement.js',
    'js/StyledElements/HiddenField.js',
    'js/StyledElements/ButtonsGroup.js',
    'js/StyledElements/CheckBox.js',
    'js/StyledElements/RadioButton.js',
    'js/StyledElements/InputInterface.js',
    'js/StyledElements/TextInputInterface.js',
    'js/StyledElements/InputInterfaces.js',
    'js/wirecloud/ui/ParametrizableValueInputInterface.js',
    'js/wirecloud/ui/ParametrizedTextInputInterface.js',
    'js/wirecloud/ui/LayoutInputInterface.js',
    'js/StyledElements/VersionInputInterface.js',
    'js/StyledElements/InputInterfaceFactory.js',
    'js/StyledElements/DefaultInputInterfaceFactory.js',
    'js/StyledElements/Form.js',
    'js/StyledElements/PaginationInterface.js',
    'js/StyledElements/Popover.js',
    'js/StyledElements/Panel.js',
    'js/StyledElements/OffCanvasLayout.js',
    'js/StyledElements/Alert.js',
    'js/StyledElements/Typeahead.js',
)

PLATFORM_CORE_CSS = (
    'css/wirecloud_core.scss',
    'css/icons.css',
    'css/window_menu.scss',
    'css/windowmenues/logwindowmenu.scss',
)

BASE_CSS = (
    'css/font-awesome.css',
    'css/font-awesome-backwards.css',
    'css/base/utils.scss',
    'css/base/body.scss',
    'css/base/fade.css',
    'css/base/code.scss',
    'css/base/z-depth.scss',
    'css/workspace/ioperator.css',
)

WIRING_EDITOR_CSS = (
    'css/wiring/wiring_layout.scss',
    'css/wiring/wiring_components.scss',
    'css/wiring/wiring_connections.scss',
    'css/wiring/wiring_behaviours.scss',
)

TUTORIAL_CSS = (
    'css/tutorial.scss',
)


STYLED_ELEMENTS_CSS = (
    'css/styled_elements_core.css',
    'css/styledelements/styled_addon.scss',
    'css/styledelements/styled_alternatives.scss',
    'css/styledelements/styled_container.css',
    'css/styledelements/styled_button.scss',
    'css/styledelements/styled_checkbox.css',
    'css/styledelements/styled_pills.scss',
    'css/styledelements/styled_notebook.scss',
    'css/styledelements/styled_form.css',
    'css/styledelements/styled_pagination.scss',
    'css/styledelements/styled_panel.scss',
    'css/styledelements/styled_numeric_field.scss',
    'css/styledelements/styled_text_field.scss',
    'css/styledelements/styled_text_area.scss',
    'css/styledelements/styled_password_field.scss',
    'css/styledelements/styled_select.scss',
    'css/styledelements/styled_border_layout.css',
    'css/styledelements/styled_horizontal_and_vertical_layout.scss',
    'css/styledelements/styled_file_field.scss',
    'css/styledelements/styled_table.scss',
    'css/styledelements/styled_label_badge.scss',
    'css/styledelements/styled_alert.scss',
    'css/styledelements/styled_rating.scss',
    'css/styledelements/styled_popup_menu.scss',
    'css/styledelements/styled_popover.scss',
    'css/styledelements/styled_tooltip.css',
    'css/styledelements/styled_expander.scss',
    'css/styledelements/styled_offcanvas_layout.scss',
    'css/styledelements/styled_thumbnail.scss',
)


def get_version_hash():
    return sha1(json.dumps(get_active_features_info(), ensure_ascii=False, sort_keys=True).encode('utf8')).hexdigest()


class WirecloudCorePlugin(WirecloudPlugin):

    features = {
        'Wirecloud': wirecloud.platform.__version__,
        'ApplicationMashup': '1.0',
        'StyledElements': '0.7',
        'FullscreenWidget': '0.5',
        'DashboardManagement': '1.0',
    }

    def get_platform_context_definitions(self):
        return {
            'language': {
                'label': _('Language'),
                'description': _('Current language used in the platform'),
            },
            'username': {
                'label': _('Username'),
                'description': _('User name of the current logged user'),
            },
            'fullname': {
                'label': _('Full name'),
                'description': _('Full name of the logged user'),
            },
            'isanonymous': {
                'label': _('Is Anonymous'),
                'description': _('Boolean. Designates whether current user is logged in the system.'),
            },
            'isstaff': {
                'label': _('Is Staff'),
                'description': _('Boolean. Designates whether current user can access the admin site.'),
            },
            'issuperuser': {
                'label': _('Is Superuser'),
                'description': _('Boolean. Designates whether current user is a super user.'),
            },
            'mode': {
{'fraction_non_alphanumeric': 0.13307926829268293, 'fraction_numerical': 0.002184959349593496, 'mean_word_length': 3.5876456876456877, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4809042', 'n_tokens_mistral': 6949, 'n_tokens_neox': 6736, 'n_words': 866}