File: settings.py

package info (click to toggle)
django-pipeline 1.6.14-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 780 kB
  • sloc: python: 2,756; makefile: 119
file content (202 lines) | stat: -rw-r--r-- 5,677 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import glob
import os
import distutils.spawn


def local_path(path):
    return os.path.join(os.path.dirname(__file__), path)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'TEST_NAME': ':memory:'
    }
}

DEBUG = False

SITE_ID = 1

INSTALLED_APPS = [
    'django.contrib.contenttypes',
    'django.contrib.sites',
    'django.contrib.sessions',
    'django.contrib.staticfiles',
    'django.contrib.auth',
    'django.contrib.admin',
    'pipeline',
    'tests.tests'
]

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware'
)

ROOT_URLCONF = 'tests.urls'

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware'
)

MEDIA_URL = '/media/'

MEDIA_ROOT = local_path('media')

STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
STATIC_ROOT = local_path('static/')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    ('pipeline', local_path('assets/')),
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

SECRET_KEY = "django-pipeline"

PIPELINE = {
    'PIPELINE_ENABLED': True,
    'JS_COMPRESSOR': None,
    'CSS_COMPRESSOR': None,
    'STYLESHEETS': {
        'screen': {
            'source_filenames': (
                'pipeline/css/first.css',
                'pipeline/css/second.css',
                'pipeline/css/urls.css'
            ),
            'output_filename': 'screen.css'
        }
    },
    'JAVASCRIPT': {
        'scripts': {
            'source_filenames': (
                'pipeline/js/first.js',
                'pipeline/js/second.js',
                'pipeline/js/application.js',
                'pipeline/templates/**/*.jst'
            ),
            'output_filename': 'scripts.js'
        },
        'scripts_async': {
            'source_filenames': (
                'pipeline/js/first.js',
                'pipeline/js/second.js',
                'pipeline/js/application.js',
                'pipeline/templates/**/*.jst'
            ),
            'output_filename': 'scripts_async.js',
            'extra_context': {
                'async': True,
            }
        },
        'scripts_defer': {
            'source_filenames': (
                'pipeline/js/first.js',
                'pipeline/js/second.js',
                'pipeline/js/application.js',
                'pipeline/templates/**/*.jst'
            ),
            'output_filename': 'scripts_defer.js',
            'extra_context': {
                'defer': True,
            }
        },
        'scripts_async_defer': {
            'source_filenames': (
                'pipeline/js/first.js',
                'pipeline/js/second.js',
                'pipeline/js/application.js',
                'pipeline/templates/**/*.jst'
            ),
            'output_filename': 'scripts_async_defer.js',
            'extra_context': {
                'async': True,
                'defer': True,
            }
        }
    }
}

NODE_MODULES_PATH = local_path('../node_modules')
NODE_BIN_PATH = os.path.join(NODE_MODULES_PATH, '.bin')
NODE_EXE_PATH = distutils.spawn.find_executable('node')
JAVA_EXE_PATH = distutils.spawn.find_executable('java')
CSSTIDY_EXE_PATH = distutils.spawn.find_executable('csstidy')
HAS_NODE = bool(NODE_EXE_PATH)
HAS_JAVA = bool(JAVA_EXE_PATH)
HAS_CSSTIDY = bool(CSSTIDY_EXE_PATH)

if HAS_NODE:
    def node_exe_path(command):
        exe_ext = '.cmd' if os.name == 'nt' else ''
        return os.path.join(NODE_BIN_PATH, "%s%s" % (command, exe_ext))

    PIPELINE.update({
        'SASS_BINARY': node_exe_path('node-sass'),
        'COFFEE_SCRIPT_BINARY': node_exe_path('coffee'),
        'COFFEE_SCRIPT_ARGUMENTS': ['--no-header'],
        'LESS_BINARY': node_exe_path('lessc'),
        'BABEL_BINARY': node_exe_path('babel'),
        'BABEL_ARGUMENTS': ['--presets', 'es2015'],
        'STYLUS_BINARY': node_exe_path('stylus'),
        'LIVE_SCRIPT_BINARY': node_exe_path('lsc'),
        'LIVE_SCRIPT_ARGUMENTS': ['--no-header'],
        'YUGLIFY_BINARY': node_exe_path('yuglify'),
        'UGLIFYJS_BINARY': node_exe_path('uglifyjs'),
        'CSSMIN_BINARY': node_exe_path('cssmin'),
    })

if HAS_NODE and HAS_JAVA:
    PIPELINE.update({
        'CLOSURE_BINARY': [
            JAVA_EXE_PATH, '-jar',
            os.path.join(NODE_MODULES_PATH, 'google-closure-compiler', 'compiler.jar')],
        'YUI_BINARY': [
            JAVA_EXE_PATH, '-jar',
            glob.glob(os.path.join(NODE_MODULES_PATH, 'yuicompressor', 'build', '*.jar'))[0]]
    })

if HAS_CSSTIDY:
    PIPELINE.update({'CSSTIDY_BINARY': CSSTIDY_EXE_PATH})

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'APP_DIRS': True,
        'DIRS': [local_path('templates')],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
            ]
        }
    },
    {
        'BACKEND': 'django.template.backends.jinja2.Jinja2',
        'APP_DIRS': True,
        'DIRS': [local_path('templates')],
        'OPTIONS': {
            'extensions': ['pipeline.jinja2.PipelineExtension']
        }
    }
]

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'pipeline.templatetags.pipeline': {
            'handlers': ['console'],
            'level': 'ERROR',
        },
    },
}