Skip to content

Commit

Permalink
Fixed error page fetching, added new file attributes.
Browse files Browse the repository at this point in the history
New file attributes are:
- relativeOutPath
- relativeOutDirPath
  • Loading branch information
balupton committed Jul 19, 2012
1 parent b52226c commit db588a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/docpad.coffee
Expand Up @@ -2684,7 +2684,7 @@ class DocPad extends EventEmitterEnhanced
return res.send(500) unless database

# Serve the document to the user
document = database.findOne(relativePath: '404.html')
document = database.findOne(relativeOutPath: '404.html')
docpad.serveDocument({document,req,res,next,statusCode:404})

# 500 Middleware
Expand All @@ -2693,7 +2693,7 @@ class DocPad extends EventEmitterEnhanced
return res.send(500) unless database

# Serve the document to the user
document = database.findOne(relativePath: '404.html')
document = database.findOne(relativeOutPath: '500.html')
docpad.serveDocument({document,req,res,next,statusCode:500,err})

# Start the Server
Expand Down
9 changes: 5 additions & 4 deletions src/lib/models/document.coffee
Expand Up @@ -336,12 +336,13 @@ class DocumentModel extends FileModel
changes.filenameRendered = filenameRendered

# Figure out the rendered url
if !url and filenameRendered
if filenameRendered
if relativeDirPath
url = "/#{relativeDirPath}/#{filenameRendered}"
relativeOutPath = "#{relativeDirPath}/#{filenameRendered}"
else
url = "/#{filenameRendered}"
changes.url = url
relativeOutPath = "#{filenameRendered}"
changes.relativeOutPath = relativeOutPath
changes.url = url = "/#{relativeOutPath}" unless url

# Set name if it doesn't exist already
if !name and filenameRendered?
Expand Down
13 changes: 11 additions & 2 deletions src/lib/models/file.coffee
Expand Up @@ -60,12 +60,18 @@ class FileModel extends Model
# The full directory path of our source file
fullDirPath: null

# The final rendered path of our file
# The output path of our file
outPath: null

# The final rendered path of our file's directory
# The output path of our file's directory
outDirPath: null

# The relative output path of our file
relativeOutPath: null

# The relative output path of our file's directory
relativeOutDirPath: null

# The relative path of our source file (with extensions)
relativePath: null

Expand Down Expand Up @@ -447,6 +453,7 @@ class FileModel extends Model
# Fetch
{opts,next} = @getActionArgs(opts,next)
relativePath = @get('relativePath') or null
relativeDirPath = @get('relativeDirPath') or null
relativeBase = @get('relativeBase') or null
filename = @get('filename') or null
outPath = @get('outPath') or null
Expand All @@ -467,6 +474,8 @@ class FileModel extends Model

# Create the outPath if we have a outpute directory
if @outDirPath? and relativePath?
changes.relativeOutDirPath = relativeOutDirPath = relativeDirPath if relativeDirPath?
changes.relativeOutPath = relativeOutPath = relativePath
changes.outPath = outPath = pathUtil.join(@outDirPath,relativePath)
if outPath
changes.outDirPath = outDirPath = pathUtil.dirname(outPath)
Expand Down

0 comments on commit db588a5

Please sign in to comment.