Skip to content

Commit

Permalink
v6.6.3. Bugfix.
Browse files Browse the repository at this point in the history
- v6.6.3 September 3, 2012
	- Fixed `date` and `name` always being their automatic values
  • Loading branch information
balupton committed Sep 3, 2012
1 parent 067b5cc commit 008ca18
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 44 deletions.
3 changes: 3 additions & 0 deletions History.md
@@ -1,5 +1,8 @@
## History

- v6.6.3 September 3, 2012
- Fixed `date` and `name` always being their automatic values

- v6.6.0-6.6.2 August 28, 2012
- Added `docpad-debug` executable for easier debugging
- Will now ask if you would like to subscribe to our newsletter when running on the development environment
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "docpad",
"version": "6.6.2",
"version": "6.6.3",
"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": [
Expand Down
21 changes: 7 additions & 14 deletions src/lib/models/document.coffee
Expand Up @@ -21,10 +21,6 @@ class DocumentModel extends FileModel
# Model Type
type: 'document'

# The parsed file meta data (header)
# Is a Backbone.Model instance
meta: null


# ---------------------------------
# Attributes
Expand Down Expand Up @@ -83,13 +79,9 @@ class DocumentModel extends FileModel
# Functions

# Initialize
initialize: (data,options) ->
initialize: (attrs,opts) ->
# Prepare
{@layouts,meta} = options

# Apply meta
@meta = new Model()
@meta.set(meta) if meta
{@layouts,meta} = opts

# Forward
super
Expand Down Expand Up @@ -314,9 +306,9 @@ class DocumentModel extends FileModel
relativeDirPath = @get('relativeDirPath')
extensions = @get('extensions')
outExtension = @get('outExtension')
url = meta.get('url')
name = meta.get('name')
outPath = meta.get('outPath')
url = meta.get('url') or null
name = meta.get('name') or null
outPath = meta.get('outPath') or null
outFilename = null

# Use our eve's rendered extension if it exists
Expand All @@ -338,7 +330,8 @@ class DocumentModel extends FileModel
else
relativeOutPath = "#{outFilename}"
changes.relativeOutPath = relativeOutPath
changes.url = url = "/#{relativeOutPath}" unless url
unless url
changes.url = url = "/#{relativeOutPath}"

# Set name if it doesn't exist already
if !name and outFilename?
Expand Down
33 changes: 24 additions & 9 deletions src/lib/models/file.coffee
Expand Up @@ -28,6 +28,10 @@ class FileModel extends Model
# The contents of the file, stored as a Buffer
data: null

# The parsed file meta data (header)
# Is a Backbone.Model instance
meta: null


# ---------------------------------
# Attributes
Expand Down Expand Up @@ -149,7 +153,7 @@ class FileModel extends Model
# Initialize
initialize: (attrs,opts) ->
# Prepare
{outDirPath,stat,data} = opts
{outDirPath,stat,data,meta} = opts
if attrs.data?
data = attrs.data
delete attrs.data
Expand All @@ -163,7 +167,13 @@ class FileModel extends Model
extensions: []
urls: []
id: @cid
},{silent:true})
})

# Meta
@meta = new Model()
if meta
@meta.set(meta)
@set(meta)

# Super
super
Expand Down Expand Up @@ -233,10 +243,10 @@ class FileModel extends Model
file.log('debug', "Loaded the file: #{filePath}")
next()
handlePath = ->
file.set({fullPath},{silent:true})
file.set({fullPath})
file.readFile(fullPath, complete)
handleData = ->
file.set({fullPath:null},{silent:true})
file.set({fullPath:null})
file.parseData data, (err) =>
return next(err) if err
file.normalize (err) =>
Expand Down Expand Up @@ -404,16 +414,18 @@ class FileModel extends Model
# next(err)
normalize: (opts={},next) ->
# Prepare
{opts,next} = @getActionArgs(opts,next)
changes = {}

# Fetch
{opts,next} = @getActionArgs(opts,next)
meta = @getMeta()
basename = @get('basename')
filename = @get('filename')
fullPath = @get('fullPath')
extensions = @get('extensions')
relativePath = @get('relativePath')
mtime = @get('mtime')
date = meta.get('date') or null

# Filename
if fullPath
Expand Down Expand Up @@ -459,7 +471,7 @@ class FileModel extends Model
changes.id = id = relativePath

# Date
if mtime
if !date and mtime
changes.date = date = mtime

# Apply
Expand All @@ -474,28 +486,31 @@ class FileModel extends Model
# next(err)
contextualize: (opts={},next) ->
# Prepare
{opts,next} = @getActionArgs(opts,next)
changes = {}

# Fetch
{opts,next} = @getActionArgs(opts,next)
meta = @getMeta()
relativePath = @get('relativePath')
relativeDirPath = @get('relativeDirPath')
relativeBase = @get('relativeBase')
filename = @get('filename')
outPath = @get('outPath')
outDirPath = @get('outDirPath')
name = meta.get('name') or null
slug = meta.get('slug') or null

# Create the URL for the file
if relativePath
url = "/#{relativePath}"
@setUrl(url)

# Create a slug for the file
if relativeBase
if !slug and relativeBase
changes.slug = slug = balUtil.generateSlugSync(relativeBase)

# Set name if it doesn't exist already
if filename
if !name and filename
changes.name = name = filename

# Create the outPath if we have a outpute directory
Expand Down

0 comments on commit 008ca18

Please sign in to comment.