# coding: utf-8
"""
Django settings for romans_blog project.

Generated by 'django-admin startproject' using Django 1.8.6.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import sys

BASE_DIR = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
sys.path.insert(0, BASE_DIR)


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fvh+o&w4qo-afc#fu8fy7=1_imte!d7k1d)9q+=603@963+sk!'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1', 'localhost']

SITE_ID = 1


# Application definition

INSTALLED_APPS = [
    'filebrowser',
    'tinymce',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'adminsortable2',
    'haystack',
    'solo',
    'common_content',
    'blog',
    'pages',
    'bootstrap4_skin',
]

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'common_content.middleware.maintenance_mode_middleware',
]

ROOT_URLCONF = 'romans_blog.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'romans_blog.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGES = [
    ('en-us', 'US English'),
    ('ru', 'Русский'),
    ('uk', 'Українська'),
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Europe/Kiev'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# Media files (user images, videos, other files)

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

FILEBROWSER_ADMIN_THUMBNAIL = 'small'

# TinyMCE settings

common_content_base_url = STATIC_URL + 'common_content/'

TINYMCE_DEFAULT_CONFIG = {
    'theme': 'modern',
    'plugins': 'advlist autolink link image imagetools lists charmap print hr anchor pagebreak '
               'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media '
               'nonbreaking save table contextmenu directionality emoticons template paste textcolor '
               'spellchecker autosave noneditable',
    'toolbar1': 'django_saveandcontinue | undo redo | cut copy paste | searchreplace | styleselect removeformat | '
                'fontsizeselect | forecolor backcolor | code preview | spellchecker | fullscreen',
    'toolbar2': 'bold italic underline strikethrough | alignleft aligncenter alignright alignjustify '
                '| bullist numlist outdent indent | blockquote hr charmap nonbreaking '
                '| link anchor | image media emoticons | table | codesample | spoiler-add spoiler-remove',
    'contextmenu': 'formats | cut copy paste | link image | inserttable row cell',
    'style_formats': [
        {'title': 'Special', 'items': [
            {'title': 'Small text', 'inline': 'small'},
            {'title': 'Keyboard input', 'inline': 'kbd'},
            {'title': 'Sample output', 'inline': 'samp'},
        ]},
        {'title': 'Image', 'items': [
            {'title': 'Image Left', 'selector': 'img', 'styles': {'float': 'left', 'margin': '10px'}},
            {'title': 'Image Right', 'selector': 'img', 'styles': {'float': 'right', 'margin': '10px'}}
        ]},
    ],
    'style_formats_merge': True,
    'width': 1024,
    'height': 600,
    'spellchecker_languages': 'English (US)=en_US,Russian=ru,Ukrainian=uk',
    'spellchecker_language': 'en_US',
    'plugin_preview_width': 1024,
    'plugin_preview_height': 600,
    'image_advtab': True,
    'default_link_target': '_blank',
    'extended_valid_elements': 'span[class]',
    'spoiler_caption': '<span class="fa fa-plus-square"></span>&nbsp;Click to show',
    'pagebreak_separator': '<!-- ***Blog Cut*** -->',
    'external_plugins': {
        'spoiler': '../../../common_content/js/spoiler/plugin.min.js',
        'django_saveandcontinue': '../../../common_content/js/django_saveandcontinue/plugin.min.js',
        'codesample': '../../../common_content/js/codesample/plugin.min.js',
        'preview': '../../../common_content/js/preview/plugin.min.js'
    },
    'codesample_languages': [
        {'text': 'Python', 'value': 'python'},
        {'text': 'HTML/XML', 'value': 'markup'},
        {'text': 'Django/Jinja2', 'value': 'django'},
        {'text': 'CSS', 'value': 'css'},
        {'text': 'JavaScript', 'value': 'javascript'},
        {'text': 'C++', 'value': 'cpp'},
        {'text': 'C', 'value': 'c'},
        {'text': 'C#', 'value': 'csharp'},
        {'text': 'Windows BAT', 'value': 'batch'},
        {'text': 'Bash', 'value': 'bash'},
        {'text': 'YAML', 'value': 'yaml'},
        {'text': 'SQL', 'value': 'sql'},
        {'text': 'reStructuredText', 'value': 'rest'},
        {'text': 'Plain Text', 'value': 'none'},
    ],
    'content_css': [common_content_base_url + 'css/prism.css'],
}
TINYMCE_SPELLCHECKER = True
TINYMCE_ADDITIONAL_JS_URLS = [
    common_content_base_url + 'js/prism.min.js',
    common_content_base_url + 'js/prism-django.min.js'
]

# Skin-specific settings

CURRENT_SKIN = 'bootstrap4_skin'
BLOG_POSTS_PAGINATE_BY = 5
TINYMCE_DEFAULT_CONFIG['image_class_list'] = [
    {'title': 'Responsive', 'value': 'img-fluid'},
    {'title': 'Rounded', 'value': 'img-fluid rounded'},
    {'title': 'Thumbnail', 'value': 'img-fluid img-thumbnail'},
]
TINYMCE_DEFAULT_CONFIG['table_class_list'] = [
    {'title': 'Simple', 'value': 'table'},
    {'title': 'Bordered', 'value': 'table table-bordered'},
    {'title': 'Striped', 'value': 'table table-striped'},
    {'title': 'Small', 'value': 'table table-sm'},
]
TINYMCE_DEFAULT_CONFIG['table_row_class_list'] = [
    {'title': 'None', 'value': ''},
    {'title': 'Green', 'value': 'table-success'},
    {'title': 'Red', 'value': 'table-danger'},
    {'title': 'Blue', 'value': 'table-primary'},
]
TINYMCE_DEFAULT_CONFIG['content_css'] += [
    STATIC_URL + 'bootstrap4_skin/css/bootstrap.min.css',
    STATIC_URL + 'bootstrap4_skin/css/font-awesome-all.min.css',
    STATIC_URL + 'bootstrap4_skin/css/styles.css',
]
DEFAULT_LOGO = STATIC_URL + 'bootstrap4_skin/img/favicon.png'
DEFAULT_FEATURED_IMAGE = STATIC_URL + 'bootstrap4_skin/img/featured/home.jpg'

# Haystack search settings

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
        'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
    },
}

# Enable this if your server has enough power to update index on every save
# HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
