This repository has been archived by the owner on Aug 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
181 lines (167 loc) · 4.89 KB
/
Gruntfile.coffee
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
module.exports = (grunt) ->
# Load grunt tasks automatically
require('load-grunt-tasks')(grunt)
# Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt)
grunt.initConfig
cfg:
dist: '_site'
pkg: grunt.file.readJSON('package.json')
clean:
dist: ['<%= cfg.dist %>']
sass:
options:
sourcemap: 'none'
style: 'compressed'
dist:
expand: true,
cwd: 'assets/css'
src: ['*.scss']
dest: '<%= cfg.dist %>/assets/css'
ext: '.css'
coffee:
dist:
expand: true,
cwd: 'assets/js',
src: ['*.coffee'],
dest: '<%= cfg.dist %>/assets/js',
ext: '.js'
uglify:
dist:
expand: true,
cwd: '<%= cfg.dist %>/assets/js',
src: '*.js',
dest: '<%= cfg.dist %>/assets/js'
haml:
dist:
expand: true,
cwd: '.'
src: ['*.haml']
dest: '<%= cfg.dist %>'
ext: '.html'
copy:
assets:
expand: true
cwd: 'assets/'
src: ['**', '!css/*.scss', '!js/*.coffee']
dest: '<%= cfg.dist %>/assets'
shower:
files: [
{
src: 'vendor/shower/core/shower.min.js'
dest: '<%= cfg.dist %>/assets/js/shower-core.min.js'
},
{
src: 'vendor/shower/ribbon/styles/screen.css'
dest: '<%= cfg.dist %>/assets/css/shower-ribbon.screen.css'
}
{
src: 'vendor/shower/bright/styles/screen.css'
dest: '<%= cfg.dist %>/assets/css/shower-bright.screen.css'
}
{
expand: true
cwd: 'vendor/shower/bright/fonts/'
src: '**'
dest: '<%= cfg.dist %>/assets/fonts/'
filter: 'isFile'
}
{
expand: true
cwd: 'vendor/shower/ribbon/fonts/'
src: '**'
dest: '<%= cfg.dist %>/assets/fonts/'
filter: 'isFile'
}
]
watch:
options: {
livereload: true,
},
css:
files: ['assets/css/*.scss']
tasks: ['sass']
js:
files: ['assets/js/*.coffee']
tasks: ['coffee', 'uglify']
html:
files: ['*.haml']
tasks: ['haml']
assets:
files: ['assets/**/*', '!assets/css/*.scss', '!assets/js/*.coffee']
tasks: ['copy:assets']
shower:
files: [
'vendor/shower/core/shower.min.js'
'vendor/shower/bright/fonts/*'
'vendor/shower/bright/styles/screen.css'
'vendor/shower/ribbon/fonts/*'
'vendor/shower/ribbon/styles/screen.css]'
]
tasks: ['copy:shower']
connect:
server:
options:
livereload: true
port: 4000
base: '<%= cfg.dist %>'
grunt.registerTask 'generate',
'Generate a slide using "grunt generate:my-slide"', (slide) ->
if arguments.length == 0
grunt.log.error "no arg given"
else
fs = require('fs')
for file in [
"assets/css/#{slide}.css.scss"
"assets/js/#{slide}.js.coffee"
]
fs.writeFileSync(file, '')
grunt.log.writeln "successfully create #{file}"
fs.writeFileSync "#{slide}.html.haml", """
!!!5
%html{lang: 'en'}
%head
%title Your slide title
%meta{charset: 'utf-8'}
%meta{name: 'viewport', content: 'width=792, user-scalable=no'}
%meta{'http-equiv' => 'x-ua-compatible', content: 'ie=edge'}
%link{rel: 'stylesheet', href: 'assets/css/shower-ribbon.screen.css'}
%link{rel: 'stylesheet', href: 'assets/css/#{slide}.css'}
%body.list
%header.caption
%h1 Your slide title
%p Your name or date
%section.slide
%div
%h2 Your slide title
%p Add your content here...
%p.badge
%a{href: 'https://github.com/shower/shower'} Fork me on Github
/
To hide progress bar from entire presentation
just remove “progress” element.
.progress
%div
%script{src: 'assets/js/shower-core.min.js'}
%script{src: 'assets/js/#{slide}.js'}
"""
grunt.log.writeln "successfully create #{slide}.html.haml"
grunt.registerTask 'destroy',
'Destroy a slide using "grunt destroy:my-slide"', (slide) ->
if arguments.length == 0
grunt.log.error "no arg given"
else
fs = require('fs')
for file in [
"#{slide}.html.haml"
"assets/css/#{slide}.css.scss"
"assets/js/#{slide}.js.coffee"
]
if fs.existsSync(file)
fs.unlinkSync(file)
grunt.log.writeln "successfully deleted #{file}"
grunt.registerTask 'build', 'Build all slides',
['clean', 'copy', 'sass', 'coffee', 'uglify', 'haml']
grunt.registerTask 'serve', 'Serve, watch and live-reload all slides',
['build', 'connect', 'watch']
grunt.registerTask 'default', 'build'