Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

v6.6.6. Improvement.

- v6.6.6 September 24, 2012
	- Further improved file text/binary detection
  • Loading branch information...
commit d1016ad4c2f7f5fe78e4482146ff911b3ef3c99d 1 parent de59b71
@balupton balupton authored
View
3  History.md
@@ -1,5 +1,8 @@
## History
+- v6.6.6 September 24, 2012
+ - Further improved file text/binary detection
+
- v6.6.5 September 18, 2012
- Further improved file encoding detection
- Closes [#266: Images are broken](https://github.com/bevry/docpad/issues/266)
View
4 package.json
@@ -1,6 +1,6 @@
{
"name": "docpad",
- "version": "6.6.5",
+ "version": "6.6.6",
"description": "DocPad is a language agnostic document management system. This means you write your website as documents, in whatever language you wish, and DocPad will handle the compiling, templates and layouts for you. For static documents it will generate static files, for dynamic documents it'll re-render them on each request. You can utilise DocPad by itself, or use it as a module your own custom system. It's pretty cool, and well worth checking out. We love it.",
"homepage": "https://github.com/bevry/docpad",
"keywords": [
@@ -58,7 +58,7 @@
"npm": ">=1.1.0"
},
"dependencies": {
- "bal-util": ">=1.13.6 <1.14",
+ "bal-util": ">=1.13.7 <1.14",
"express": "2.5.x",
"mime": "1.2.x",
"query-engine": ">=1.2.3 <1.3",
View
5 src/lib/models/document.coffee
@@ -203,9 +203,10 @@ class DocumentModel extends FileModel
file = @
fileOutPath = @get('outPath')
contentRendered = @get('contentRendered')
+ encoding = @get('encoding')
# Log
- file.log 'debug', "Writing the rendered file: #{fileOutPath}"
+ file.log 'debug', "Writing the rendered file: #{fileOutPath} #{encoding}"
# Write data
balUtil.writeFile fileOutPath, contentRendered, (err) ->
@@ -213,7 +214,7 @@ class DocumentModel extends FileModel
return next(err) if err
# Log
- file.log 'debug', "Wrote the rendered file: #{fileOutPath}"
+ file.log 'debug', "Wrote the rendered file: #{fileOutPath} #{encoding}"
# Next
return next()
View
27 src/lib/models/file.coffee
@@ -313,17 +313,30 @@ class FileModel extends Model
# next(err)
parseData: (data,next) ->
# Prepare
- encoding = 'utf8'
+ fullPath = @get('fullPath')
+ encoding = @get('encoding')
# Extract content from data
if data instanceof Buffer
- encoding = balUtil.getEncodingSync(data)
- if encoding is 'binary'
- source = ''
- else
+ # Detect encoding
+ unless encoding
+ isText = balUtil.isTextSync(fullPath,data)
+ if isText
+ encoding = 'utf8'
+ else
+ encoding = 'binary'
+
+ # Fetch source with encoding
+ if encoding is 'utf8'
source = data.toString(encoding)
+ else
+ source = ''
+
+ # Data is a string
else if balUtil.isString(data)
source = data
+
+ # Data is invalid
else
source = ''
@@ -518,7 +531,7 @@ class FileModel extends Model
encoding = @get('encoding')
# Log
- file.log 'debug', "Writing the file: #{fileOutPath}"
+ file.log 'debug', "Writing the file: #{fileOutPath} #{encoding}"
# Write data
balUtil.writeFile fileOutPath, content, encoding, (err) ->
@@ -526,7 +539,7 @@ class FileModel extends Model
return next(err) if err
# Log
- file.log 'debug', "Wrote the file: #{fileOutPath}"
+ file.log 'debug', "Wrote the file: #{fileOutPath} #{encoding}"
# Next
next()
Please sign in to comment.
Something went wrong with that request. Please try again.