Skip to content

Commit

Permalink
v6.13.3. Bugfix. Improvement.
Browse files Browse the repository at this point in the history
- v6.13.3 November 28, 2012
	- Reduced the extension not rendering warning to a notice
	- Fixed the `include` template helper
	- `DocPad::getFileAtPath` now does fuzzy finding
	- `FilesCollection::fuzzyFindOne` now also fuzzy matches against the
url and accepts `sorting` and `paging` arguments
  • Loading branch information
balupton committed Nov 28, 2012
1 parent 63d51a0 commit ca28738
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
6 changes: 6 additions & 0 deletions History.md
@@ -1,5 +1,11 @@
## History

- v6.13.3 November 28, 2012
- Reduced the extension not rendering warning to a notice
- Fixed the `include` template helper
- `DocPad::getFileAtPath` now does fuzzy finding
- `FilesCollection::fuzzyFindOne` now also fuzzy matches against the url and accepts `sorting` and `paging` arguments

- v6.13.2 November 27, 2012
- Reduced the extension not rendering error to a warning

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "docpad",
"version": "6.13.2",
"version": "6.13.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",
"installUrl": "http://docpad.org/install",
Expand Down
34 changes: 19 additions & 15 deletions src/lib/collections/files.coffee
Expand Up @@ -17,21 +17,25 @@ class FilesCollection extends QueryCollection

# Fuzzy Find One
# Useful for layout searching
fuzzyFindOne: (data) ->
file = @findOne(id: data)
return file if file

file = @findOne(relativePath: data)
return file if file

file = @findOne(relativeBase: data)
return file if file

file = @findOne(relativePath: $startsWith: data)
return file if file

file = @findOne(fullPath: $startsWith: data)
return file
fuzzyFindOne: (data,sorting,paging) ->
# Prepare
queries = [
{id: data}
{relativePath: data}
{relativeBase: data}
{url: data}
{relativePath: $startsWith: data}
{fullPath: $startsWith: data}
{url: $startsWith: data}
]

# Try the queries
for query in queries
file = @findOne(query,sorting,paging)
return file if file

# Didn't find a file
return null

# Export
module.exports = FilesCollection
5 changes: 2 additions & 3 deletions src/lib/docpad.coffee
Expand Up @@ -300,8 +300,7 @@ class DocPad extends EventEmitterEnhanced

# Get another file's model based on a relative path
getFileAtPath: (path,sorting,paging) ->
query = $or: [{relativePath: path}, {fullPath: path}]
result = @getDatabase().findOne(query,sorting,paging)
result = @getDatabase().fuzzyFindOne(path,sorting,paging)
return result


Expand Down Expand Up @@ -397,6 +396,7 @@ class DocPad extends EventEmitterEnhanced
# Prepare
userTemplateData or= {}
docpad = @
locale = @getLocale()

# Set the initial docpad template data
@initialTemplateData ?=
Expand Down Expand Up @@ -474,7 +474,6 @@ class DocPad extends EventEmitterEnhanced
if result
return result.get('contentRendered') or result.get('content')
else
locale = @getLocale()
err = new Error(util.format(locale.includeFailed, subRelativePath))
throw err

Expand Down

0 comments on commit ca28738

Please sign in to comment.