# -*- coding: utf-8 -*-
import copy
import os

INSTALLED_ADDONS = [
    # <INSTALLED_ADDONS>  # Warning: text inside the INSTALLED_ADDONS tags is auto-generated. Manual changes will be overwritten.
    'aldryn-addons',
    'aldryn-django',
    'aldryn-sso',
    'aldryn-django-cms',
    'aldryn-forms',
    'djangocms-history',
    'djangocms-link',
    'djangocms-picture',
    'djangocms-text-ckeditor',
    'django-filer',
    # </INSTALLED_ADDONS>
]

import aldryn_addons.settings

aldryn_addons.settings.load(locals())

# all django settings can be altered here

INSTALLED_APPS.extend([
    'project',
    'fontawesome',
    'haystack',
    'aldryn_search',
    'spurl',
    'image_cropping',
])

MIDDLEWARE_CLASSES.extend([
    # add your own middlewares here
])

TEMPLATES[0]['OPTIONS']['context_processors'] += [
    'project.context_processors.search_form',
]

THUMBNAIL_PROCESSORS = ('image_cropping.thumbnail_processors.crop_corners',) + THUMBNAIL_PROCESSORS

MAILCHIMP_USERNAME = 'developer@baker-street.ch'
MAILCHIMP_API_KEY = '3dfe69aed0e309452384b4c6b25ad616-us17'
MAILCHIMP_LIST_ID = '31720924bf'

# ALDRYN_SEARCH_DEFAULT_LANGUAGE = 'de'
ALDRYN_SEARCH_INDEX_BASE_CLASS = 'project.search.SearchIndex'

HAYSTACK_CUSTOM_HIGHLIGHTER = 'project.search.Highlighter'
HAYSTACK_DEFAULT_OPERATOR = 'OR'
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
        'PATH': os.path.join(BASE_DIR, 'whoosh', 'index', 'de'),
    },
}

HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter', ]

CMS_TEMPLATE_INHERITANCE = False

CMS_TEMPLATES = (
    ('project/content.html', 'Content'),
    ('project/list.html', 'Liste'),
    ('project/contact.html', 'Kontakt'),
    ('project/timetable.html', 'Zeitplan'),
)

CMS_PLACEHOLDER_CONF = {
    None: {
        'plugins': ['SectionPlugin'],
    },
    'contact': {
        'plugins': ['SectionTextPlugin', 'JourneyCalculatorPlugin'],
    },
    'timetable': {
        'plugins': ['TimetablePlugin'],
    },
    'social_media': {
        'plugins': ['SocialMediaListPlugin'],
    },
}

CMS_PLUGIN_CACHE = False

CKEDITOR_SETTINGS.update({
    'autoParagraph': False,
    'format_tags': 'p',
    'contentsCss': ['/static/css/main.css'],
    'forcePasteAsPlainText': True,
    'bodyId': 'admin_editor',
    'enterMode': 2,
    'shiftEnterMode': 2,
    'forceEnterMode': True,
    'toolbarLocation': 'bottom',
    'removePlugins': 'contextmenu,liststyle,tabletools',
    'keystrokes': [
        [1114188, None],  # Link
        [2228345, None],
        [3342457, None],
    ],
    'bodyClass': 'section__text',
    'toolbar_CMS': [
        ['Undo', 'Redo', '-', 'Bold', 'Italic', 'Underline', '-', 'RemoveFormat', '-', 'cmsplugins']
    ],
})

CKEDITOR_SETTINGS_BASE = copy.deepcopy(CKEDITOR_SETTINGS)
CKEDITOR_SETTINGS_BASE.update({
    'autoGrow_onStartup': True,
    'autoGrow_minHeight': 100,
    'autoGrow_maxHeight': 650,
    'extraPlugins': 'autogrow',
    'bodyClass': '',
})

CKEDITOR_SETTINGS_INPUT = copy.deepcopy(CKEDITOR_SETTINGS_BASE)
CKEDITOR_SETTINGS_INPUT.update({
    'keystrokes': [
        [1114188, None],  # Link
        [1114178, None],  # Bold
        [1114185, None],  # Italic
        [1114197, None],  # Unterline
        [2228345, None],
        [3342457, None],
    ],
    'toolbar_HTMLField': [
        ['Undo', 'Redo'],
    ],
    'bodyClass': 'section__text',
    'height': 100,
})

CKEDITOR_SETTINGS_SECTION_TITLE = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_SECTION_TITLE['bodyClass'] = 'h2'

CKEDITOR_SETTINGS_SLIDER_TITLE = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_SLIDER_TITLE['bodyClass'] = 'slider__text__item__title'

CKEDITOR_SETTINGS_SLIDER_TEXT = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_SLIDER_TEXT['bodyClass'] = 'slider__text__item__text'

CKEDITOR_SETTINGS_TEXT_SLIDER_TEXT = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_TEXT_SLIDER_TEXT['bodyClass'] = 'text_slider__text'

CKEDITOR_SETTINGS_QUOTE_CONTENT = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_QUOTE_CONTENT['bodyClass'] = 'quote__content'

CKEDITOR_SETTINGS_QUOTE_SOURCE = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_QUOTE_SOURCE['bodyClass'] = 'quote__source'

CKEDITOR_SETTINGS_HIGHLIGHT_LIST_ITEM_TITLE = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_HIGHLIGHT_LIST_ITEM_TITLE['bodyClass'] = 'highlight_list__item__title'

CKEDITOR_SETTINGS_HIGHLIGHT_LIST_ITEM_TEXT = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_HIGHLIGHT_LIST_ITEM_TEXT['bodyClass'] = 'highlight_list__item__text'

CKEDITOR_SETTINGS_TIMETABLE_ITEM_TITLE = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_TIMETABLE_ITEM_TITLE['bodyClass'] = 'h2 timetable__item__title'

CKEDITOR_SETTINGS_TIMETABLE_ITEM_TEXT = copy.deepcopy(CKEDITOR_SETTINGS_INPUT)
CKEDITOR_SETTINGS_TIMETABLE_ITEM_TEXT['bodyClass'] = 'section__text timetable__item__text'
