New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding template, suggessted fix for @Earl-Brown #990
Changes from 3 commits
582df12
b751709
94df296
9b8165f
1607b3e
2b62a91
99b50f0
11b5154
34dbe11
f67a805
06b0c7a
08822f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
/*! | ||
* Connect - directory | ||
* Copyright(c) 2011 Sencha Inc. | ||
|
@@ -56,6 +55,7 @@ var mediaType = { | |
* - `hidden` display hidden (dot) files. Defaults to false. | ||
* - `icons` display icons. Defaults to false. | ||
* - `filter` Apply this filter function to files. Defaults to false. | ||
* - `template` Optional path to html template. Defaults to __dirname + '/../public/directory.html' | ||
* | ||
* @param {String} root | ||
* @param {Object} options | ||
|
@@ -72,7 +72,8 @@ exports = module.exports = function directory(root, options){ | |
, icons = options.icons | ||
, view = options.view || 'tiles' | ||
, filter = options.filter | ||
, root = normalize(root + sep); | ||
, root = normalize(root + sep) | ||
, template = options.template || __dirname + '/../public/directory.html';; | ||
|
||
return function directory(req, res, next) { | ||
if ('GET' != req.method && 'HEAD' != req.method) return next(); | ||
|
@@ -110,7 +111,7 @@ exports = module.exports = function directory(root, options){ | |
|
||
// not acceptable | ||
if (!type) return next(utils.error(406)); | ||
exports[mediaType[type]](req, res, files, next, originalDir, showUp, icons, path, view); | ||
exports[mediaType[type]](req, res, files, next, originalDir, showUp, icons, path, view, template); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. holy balls this is getting so long haha There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonathanong, don't worry, I changed it in the commit I actually pushed to |
||
}); | ||
}); | ||
}; | ||
|
@@ -120,8 +121,8 @@ exports = module.exports = function directory(root, options){ | |
* Respond with text/html. | ||
*/ | ||
|
||
exports.html = function(req, res, files, next, dir, showUp, icons, path, view){ | ||
fs.readFile(__dirname + '/../public/directory.html', 'utf8', function(err, str){ | ||
exports.html = function(req, res, files, next, dir, showUp, icons, path, view, template){ | ||
fs.readFile(template, 'utf8', function(err, str){ | ||
if (err) return next(err); | ||
fs.readFile(__dirname + '/../public/style.css', 'utf8', function(err, style){ | ||
if (err) return next(err); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extraneous semi-colon on this line.