Skip to content
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

Closed
wants to merge 12 commits into from
11 changes: 6 additions & 5 deletions lib/middleware/directory.js
@@ -1,4 +1,3 @@

/*!
* Connect - directory
* Copyright(c) 2011 Sencha Inc.
Expand Down Expand Up @@ -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
Expand All @@ -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';;
Copy link
Contributor

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.


return function directory(req, res, next) {
if ('GET' != req.method && 'HEAD' != req.method) return next();
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holy balls this is getting so long haha

Copy link
Contributor

Choose a reason for hiding this comment

The 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 connect: 99b9feb#diff-ae1a8892811e2198325c36af7cb4389dR37 😃

});
});
};
Expand All @@ -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);
Expand Down