joosy 1.2.0.alpha.33 → 1.2.0.alpha.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bower.json +1 -1
  3. data/package.json +1 -1
  4. data/tasks/joosy.coffee +84 -35
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df2bca35b74d9c14728fd7262d3b7a96e7db37dc
4
- data.tar.gz: 33b20930a8c3afbf402dfed6a4708073c9d8d669
3
+ metadata.gz: e781a0e6f7a0255ee66c756961ad0943b0624d13
4
+ data.tar.gz: 5eec16f1b2513fa0076581c246b923bda1457cf6
5
5
  SHA512:
6
- metadata.gz: d7ccfaa7b808f9bec3ffa834548ae1918e4f6ab380056670e23c2b14d5edd52b2f2bb849cb93694dee50c6492e656bc3cba5cd89d3b31b06e182a3c940a705ff
7
- data.tar.gz: 9e80a44f31ee9e465710101b7abbf936f4e901e5db384b5b8d49fadf533812124c9540abb1eab78f7b896667cd900bd60ef1dd9e17af121d1e7f1c564c3b97d3
6
+ metadata.gz: 03cab6c257006474cd4672f4748c1cd34873c6996fce3dd64e7f6a8a2447f36f5341f52e61205267045631a6996c0381714a2633112120c67a3f87016157b53a
7
+ data.tar.gz: 52c3043ccdc1fcd8c3adc57bb7dee72e375307e8c4665b9f2c1cf92facb1a7c66fbb4fa51cae2406cebfe8316d7f1c829fe46eb6b90ad95a733632b57a246ace
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joosy",
3
- "version": "1.2.0-alpha.33",
3
+ "version": "1.2.0-alpha.34",
4
4
  "main": "lib/joosy.js",
5
5
  "ignore": [
6
6
  "bin",
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.33",
7
+ "version": "1.2.0-alpha.34",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "homepage": "http://joosy.ws/",
10
10
  "repository": {
@@ -5,29 +5,49 @@ module.exports = (grunt) ->
5
5
  connect = require 'connect'
6
6
  Mincer = require 'mincer'
7
7
 
8
+ paths =
9
+ haml: Path.join('source', 'haml')
10
+ javascript: Path.join('source', 'javascript')
11
+ stylesheets: Path.join('source', 'stylesheets')
12
+ public: 'public'
13
+
8
14
  grunt.joosy =
9
15
  helpers:
10
- list: (task, config, entry) ->
11
- entries = grunt.config.get(config) || {}
12
-
13
- return if entry
14
- task.requiresConfig "#{config}.#{entry}"
16
+ normalizeFiles: (config, target) ->
17
+ entries = grunt.config.get(config) || {}
18
+ entries = if target
19
+ grunt.config.requires "#{config}.#{target}"
15
20
  [ entries[entry] ]
16
21
  else
17
22
  Object.values entries
18
23
 
24
+ entries
25
+
26
+ expandFiles: (root, entry) ->
27
+ root = Path.join(root, entry.cwd) if entry.cwd?
28
+ files = grunt.file.expand({cwd: Path.join(process.cwd(), root)}, entry.src)
29
+
30
+ return {
31
+ cwd: root,
32
+ list: files.map (file) ->
33
+ src: file
34
+ extname: Path.extname file
35
+ filename: Path.basename file, Path.extname(file)
36
+ dirname: Path.dirname file
37
+ }
38
+
19
39
  assets:
20
40
  instance: (environment='development') ->
21
41
  Mincer.logger.use console
22
42
  Mincer.StylusEngine.registerConfigurator (stylus) ->
23
- stylus.options.paths.push Path.join(process.cwd(), 'public')
43
+ stylus.options.paths.push Path.join(process.cwd(), paths.public)
24
44
  stylus.define '$environment', environment
25
45
  stylus.define '$config', grunt.config.get('joosy.config') || {}
26
46
  stylus.use require('nib')()
27
47
 
28
48
  assets = new Mincer.Environment(process.cwd())
29
- assets.appendPath 'source/javascript'
30
- assets.appendPath 'source/stylesheets'
49
+ assets.appendPath paths.javascript
50
+ assets.appendPath paths.stylesheets
31
51
  assets.appendPath 'vendor'
32
52
  assets.appendPath 'components'
33
53
  assets.appendPath 'node_modules/joosy/src'
@@ -52,14 +72,14 @@ module.exports = (grunt) ->
52
72
  callbacks.success?() if deepness == 0
53
73
 
54
74
  haml:
55
- compile: (file, partials='source/haml', environment='development') ->
75
+ compile: (file, partials=paths.haml, environment='development') ->
56
76
  HAMLC = require 'haml-coffee'
57
77
 
58
78
  HAMLC.compile(grunt.file.read file)(
59
79
  environment: environment
60
80
  config: grunt.config.get('joosy.config') || {}
61
81
  partial: (location) ->
62
- grunt.joosy.haml.compile(partials+'/'+location, environment)
82
+ grunt.joosy.haml.compile(Path.join(partials,location), environment)
63
83
  )
64
84
 
65
85
  server:
@@ -93,32 +113,42 @@ module.exports = (grunt) ->
93
113
  console.log "=> Serving assets from #{path}"
94
114
 
95
115
  serveHAML: (server, map) ->
96
- return unless map?
116
+ serve = (urls, template, partials) ->
117
+ urls = [urls] unless Object.isArray(urls)
118
+
119
+ for url in urls
120
+ do (url) ->
121
+ server.use url, (req, res, next) ->
122
+ if req.originalUrl == url
123
+ res.end grunt.joosy.haml.compile(template, partials)
124
+ console.log "Served #{url} (#{template})"
125
+ else
126
+ next()
127
+ console.log "=> Serving #{template} from #{urls.join(', ')}"
97
128
 
98
- for _, entry of map
99
- do (_, entry) ->
100
- paths = entry.path
101
- paths = [paths] unless Object.isArray(paths)
102
-
103
- for path in paths
104
- do (path) ->
105
- server.use path, (req, res, next) ->
106
- if req.originalUrl == path
107
- res.end grunt.joosy.haml.compile("source/haml/"+entry.src, entry.partials)
108
- console.log "Served #{path} (#{entry.src})"
109
- else
110
- next()
111
- console.log "=> Serving #{entry.src} from #{paths.join(', ')}"
129
+ for entry in map
130
+ do (entry) ->
131
+ unless entry.expand
132
+ serve(entry.url, Path.join(paths.haml, entry.src), entry.partials)
133
+ else
134
+ files = grunt.joosy.helpers.expandFiles(paths.haml, entry)
135
+
136
+ for file in files.list
137
+ serve(
138
+ entry.url(file),
139
+ Path.join(files.cwd, file.src),
140
+ entry.partials
141
+ )
112
142
 
113
143
  serveStatic: (server, compress=false) ->
114
144
  Gzippo = require 'gzippo'
115
145
 
116
146
  unless compress
117
- server.use connect.static('public')
147
+ server.use connect.static(paths.public)
118
148
  else
119
- server.use Gzippo.staticGzip('public')
149
+ server.use Gzippo.staticGzip(paths.public)
120
150
 
121
- console.log "=> Serving static from /public"
151
+ console.log "=> Serving static from /#{paths.public}"
122
152
 
123
153
  bower: -> require('bower')
124
154
 
@@ -144,7 +174,7 @@ module.exports = (grunt) ->
144
174
 
145
175
  grunt.joosy.server.start 4000, (server) ->
146
176
  grunt.joosy.server.serveAssets server
147
- grunt.joosy.server.serveHAML server, grunt.config.get('joosy.haml')
177
+ grunt.joosy.server.serveHAML server, grunt.joosy.helpers.normalizeFiles('joosy.haml')
148
178
  grunt.joosy.server.serveProxied server, grunt.config.get('joosy.server.proxy')
149
179
  grunt.joosy.server.serveStatic server
150
180
 
@@ -156,16 +186,35 @@ module.exports = (grunt) ->
156
186
 
157
187
  grunt.registerTask 'joosy:compile', ['joosy:assets', 'joosy:haml']
158
188
 
159
- grunt.registerTask 'joosy:assets', ->
189
+ grunt.registerTask 'joosy:assets', (target) ->
160
190
  complete = @async()
161
- assets = grunt.joosy.helpers.list(@, 'joosy.assets', @args[0])
191
+ assets = grunt.joosy.helpers.normalizeFiles('joosy.assets', target)
162
192
 
163
193
  grunt.joosy.assets.compile 'production', assets,
164
194
  error: (asset, msg) -> grunt.fail.fatal msg
165
195
  compiled: (asset, dest) -> grunt.log.ok "Compiled #{dest}"
166
196
  success: complete
167
197
 
168
- grunt.registerTask 'joosy:haml', ->
169
- for _, entry of grunt.joosy.helpers.list(@, 'joosy.haml', @args[0])
170
- grunt.file.write entry.dest, grunt.joosy.haml.compile("source/haml/#{entry.src}", entry.partials, 'production')
171
- grunt.log.ok "Compiled #{entry.dest}"
198
+ grunt.registerTask 'joosy:haml', (target) ->
199
+ for _, entry of grunt.joosy.helpers.normalizeFiles('joosy.haml', target)
200
+ unless entry.expand
201
+ grunt.file.write entry.dest, grunt.joosy.haml.compile(
202
+ Path.join(paths.haml, entry.src),
203
+ entry.partials,
204
+ 'production'
205
+ )
206
+
207
+ grunt.log.ok "Compiled #{entry.dest}"
208
+ else
209
+ files = grunt.joosy.helpers.expandFiles(paths.haml, entry)
210
+
211
+ for file in files.list
212
+ destination = Path.join entry.dest, file.dirname, file.filename+(entry.ext || '.html')
213
+
214
+ grunt.file.write destination, grunt.joosy.haml.compile(
215
+ Path.join(files.cwd, file.src),
216
+ entry.partials,
217
+ 'production'
218
+ )
219
+
220
+ grunt.log.ok "Compiled #{destination}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joosy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.alpha.33
4
+ version: 1.2.0.alpha.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Staal
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-07-08 00:00:00.000000000 Z
14
+ date: 2013-07-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sprockets