Skip to content

Commit a03798a

Browse files
committed
Initial Commit
0 parents  commit a03798a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5891
-0
lines changed

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2016 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
# Mac OS X internals
22+
.DS_Store
23+
24+
# Bower and NPM libraries
25+
bower_components
26+
node_modules
27+
28+
# Build files
29+
build
30+
MANIFEST
31+
site
32+
33+
# Distribution files
34+
dist
35+
mkdocs_material.egg-info

Gulpfile.js

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
/*
2+
* Copyright (c) 2016 Martin Donath <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to
6+
* deal in the Software without restriction, including without limitation the
7+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
* sell copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
* IN THE SOFTWARE.
21+
*/
22+
23+
/* ----------------------------------------------------------------------------
24+
* Imports
25+
* ------------------------------------------------------------------------- */
26+
27+
var gulp = require('gulp');
28+
var addsrc = require('gulp-add-src');
29+
var args = require('yargs').argv;
30+
var autoprefix = require('autoprefixer');
31+
var child = require('child_process');
32+
var clean = require('del');
33+
var collect = require('gulp-rev-collector');
34+
var compact = require('gulp-remove-empty-lines');
35+
var concat = require('gulp-concat');
36+
var ignore = require('gulp-ignore');
37+
var gulpif = require('gulp-if');
38+
var mincss = require('gulp-cssnano');
39+
var minhtml = require('gulp-htmlmin');
40+
var minimage = require('gulp-image-optimization');
41+
var modernizr = require('gulp-modernizr');
42+
var mqpacker = require('css-mqpacker');
43+
var notifier = require('node-notifier');
44+
var plumber = require('gulp-plumber');
45+
var postcss = require('gulp-postcss');
46+
var rev = require('gulp-rev');
47+
var sass = require('gulp-sass');
48+
var sourcemaps = require('gulp-sourcemaps');
49+
var uglify = require('gulp-uglify');
50+
var util = require('gulp-util');
51+
var vinyl = require('vinyl-paths');
52+
53+
/* ----------------------------------------------------------------------------
54+
* Locals
55+
* ------------------------------------------------------------------------- */
56+
57+
/* MkDocs server */
58+
var server = null;
59+
60+
/* ----------------------------------------------------------------------------
61+
* Overrides
62+
* ------------------------------------------------------------------------- */
63+
64+
/*
65+
* Override gulp.src() for nicer error handling.
66+
*/
67+
var src = gulp.src;
68+
gulp.src = function() {
69+
return src.apply(gulp, arguments)
70+
.pipe(
71+
plumber(function(error) {
72+
util.log(util.colors.red(
73+
'Error (' + error.plugin + '): ' + error.message
74+
));
75+
notifier.notify({
76+
title: 'Error (' + error.plugin + ')',
77+
message: error.message.split('\n')[0]
78+
});
79+
this.emit('end');
80+
}));
81+
};
82+
83+
/* ----------------------------------------------------------------------------
84+
* Asset pipeline
85+
* ------------------------------------------------------------------------- */
86+
87+
/*
88+
* Build stylesheets from SASS source.
89+
*/
90+
gulp.task('assets:stylesheets', function() {
91+
return gulp.src('src/assets/stylesheets/*.scss')
92+
.pipe(gulpif(args.sourcemaps, sourcemaps.init()))
93+
.pipe(
94+
sass({
95+
includePaths: [
96+
'bower_components/bourbon/app/assets/stylesheets/',
97+
'bower_components/quantum-colors/',
98+
'bower_components/quantum-shadows/'
99+
]
100+
}))
101+
.pipe(
102+
postcss([
103+
autoprefix(),
104+
mqpacker
105+
]))
106+
.pipe(gulpif(args.sourcemaps, sourcemaps.write()))
107+
.pipe(gulpif(args.production, mincss()))
108+
.pipe(gulp.dest('material/assets/stylesheets/'));
109+
});
110+
111+
/*
112+
* Build javascripts from Bower components and source.
113+
*/
114+
gulp.task('assets:javascripts', function() {
115+
return gulp.src([
116+
117+
/* Bower components */
118+
'bower_components/classlist/classList.js',
119+
'bower_components/fastclick/lib/fastclick.js',
120+
'bower_components/pegasus/dist/pegasus.js',
121+
'bower_components/lunr.js/lunr.js',
122+
123+
/* Application javascripts */
124+
'src/assets/javascripts/application.js',
125+
'src/assets/javascripts/standalone.js'
126+
]).pipe(gulpif(args.sourcemaps, sourcemaps.init()))
127+
.pipe(concat('application.js'))
128+
.pipe(gulpif(args.sourcemaps, sourcemaps.write()))
129+
.pipe(gulpif(args.production, uglify()))
130+
.pipe(gulp.dest('material/assets/javascripts/'));
131+
});
132+
133+
/*
134+
* Create a customized modernizr build.
135+
*/
136+
gulp.task('assets:modernizr', [
137+
'assets:stylesheets',
138+
'assets:javascripts'
139+
], function() {
140+
return gulp.src([
141+
'material/assets/stylesheets/application.css',
142+
'material/assets/javascripts/application.js'
143+
]).pipe(
144+
modernizr({
145+
options: [
146+
'addTest', /* Add custom tests */
147+
'fnBind', /* Use function.bind */
148+
'html5printshiv', /* HTML5 support for IE */
149+
'setClasses', /* Add CSS classes to root tag */
150+
'testProp' /* Test for properties */
151+
]
152+
}))
153+
.pipe(addsrc.append('bower_components/respond/dest/respond.src.js'))
154+
.pipe(concat('modernizr.js'))
155+
.pipe(gulpif(args.production, uglify()))
156+
.pipe(gulp.dest('material/assets/javascripts'));
157+
});
158+
159+
/*
160+
* Copy static assets like images and webfonts.
161+
*/
162+
gulp.task('assets:static', function() {
163+
return gulp.src('src/assets/{fonts,images}/*.{jpg,png,gif}')
164+
.pipe(gulpif(args.production,
165+
minimage({
166+
optimizationLevel: 5,
167+
progressive: true,
168+
interlaced: true
169+
})))
170+
.pipe(addsrc.append('src/assets/{fonts,images}/*.{ico,eot,svg,ttf,woff}'))
171+
.pipe(gulp.dest('material/assets/'));
172+
});
173+
174+
/*
175+
* Minify views.
176+
*/
177+
gulp.task('assets:views', args.production ? [
178+
'assets:modernizr',
179+
'assets:revisions:clean',
180+
'assets:revisions'
181+
] : [], function() {
182+
return gulp.src([
183+
'src/*.html'
184+
]).pipe(
185+
minhtml({
186+
collapseBooleanAttributes: true,
187+
removeComments: true,
188+
removeScriptTypeAttributes: true,
189+
removeStyleLinkTypeAttributes: true
190+
}))
191+
.pipe(compact())
192+
.pipe(gulpif(args.production,
193+
addsrc.append([
194+
'material/manifest.json',
195+
'material/**/*.css'
196+
])))
197+
.pipe(gulpif(args.production, collect()))
198+
.pipe(ignore.exclude(/manifest\.json$/))
199+
.pipe(gulp.dest('material'));
200+
});
201+
202+
/*
203+
* Clean outdated revisions.
204+
*/
205+
gulp.task('assets:revisions:clean', function() {
206+
return gulp.src(['material/**/*.{ico,css,js,png,jpg,gif}'])
207+
.pipe(ignore.include(/-[a-f0-9]{8,}\.(ico|css|js|png|jpg|gif)$/))
208+
.pipe(vinyl(clean));
209+
});
210+
211+
/*
212+
* Revision assets after build.
213+
*/
214+
gulp.task('assets:revisions', [
215+
'assets:revisions:clean',
216+
'assets:stylesheets',
217+
'assets:javascripts',
218+
'assets:static'
219+
], function() {
220+
return gulp.src(['material/**/*.{ico,css,js,png,jpg,gif}'])
221+
.pipe(ignore.exclude(/-[a-f0-9]{8,}\.(css|js|png|jpg|gif)$/))
222+
.pipe(rev())
223+
.pipe(gulp.dest('material'))
224+
.pipe(rev.manifest('manifest.json'))
225+
.pipe(gulp.dest('material'));
226+
});
227+
228+
/*
229+
* Build assets.
230+
*/
231+
gulp.task('assets:build', [
232+
'assets:stylesheets',
233+
'assets:javascripts',
234+
'assets:modernizr',
235+
'assets:static',
236+
'assets:views'
237+
]);
238+
239+
/*
240+
* Watch assets for changes and rebuild on the fly.
241+
*/
242+
gulp.task('assets:watch', function() {
243+
244+
/* Rebuild stylesheets */
245+
gulp.watch([
246+
'src/assets/stylesheets/**/*.scss'
247+
], ['assets:stylesheets']);
248+
249+
/* Rebuild javascripts */
250+
gulp.watch([
251+
'src/assets/javascripts/**/*.js',
252+
'bower.json'
253+
], ['assets:javascripts']);
254+
255+
/* Copy static assets */
256+
gulp.watch([
257+
'src/assets/{fonts,images}/*'
258+
], ['assets:static']);
259+
260+
/* Minify views */
261+
gulp.watch([
262+
'src/*.html'
263+
], ['assets:views']);
264+
});
265+
266+
/* ----------------------------------------------------------------------------
267+
* Application server
268+
* ------------------------------------------------------------------------- */
269+
270+
/*
271+
* Build documentation.
272+
*/
273+
gulp.task('mkdocs:build', [
274+
'assets:build'
275+
], function() {
276+
return child.spawnSync('mkdocs', ['build']);
277+
});
278+
279+
/*
280+
* Restart MkDocs server.
281+
*/
282+
gulp.task('mkdocs:serve', function() {
283+
if (server)
284+
server.kill();
285+
286+
/* Spawn MkDocs server */
287+
server = child.spawn('mkdocs', ['serve', '-a', '0.0.0.0:8000']);
288+
289+
/* Pretty print server log output */
290+
server.stdout.on('data', function(data) {
291+
var lines = data.toString().split('\n')
292+
for (var l in lines)
293+
if (lines[l].length)
294+
util.log(lines[l]);
295+
});
296+
297+
/* Print errors to stdout */
298+
server.stderr.on('data', function(data) {
299+
process.stdout.write(data.toString());
300+
});
301+
});
302+
303+
/* ----------------------------------------------------------------------------
304+
* Interface
305+
* ------------------------------------------------------------------------- */
306+
307+
/*
308+
* Build assets and documentation.
309+
*/
310+
gulp.task('build', [
311+
'assets:build'
312+
].concat(args.mkdocs
313+
? 'mkdocs:build'
314+
: []));
315+
316+
/*
317+
* Start asset and MkDocs watchdogs.
318+
*/
319+
gulp.task('watch', [
320+
'assets:build',
321+
], function() {
322+
return gulp.start([
323+
'assets:watch'
324+
].concat(args.mkdocs
325+
? 'mkdocs:serve'
326+
: []));
327+
});
328+
329+
/*
330+
* Build assets by default.
331+
*/
332+
gulp.task('default', ['build']);

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2016 Martin Donath <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to
5+
deal in the Software without restriction, including without limitation the
6+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
sell copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
IN THE SOFTWARE.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
recursive-include material *.ico *.js *.css *.html *.eot *.svg *.ttf *.woff
2+
recursive-exclude site *

0 commit comments

Comments
 (0)