Skip to content

Commit 7a22d2a

Browse files
committed
new event + improvement handle static files
1 parent 80d2a43 commit 7a22d2a

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Framework supports a backward compatibility.
3535
- added: @{console} (.log, .info, etc.) into views
3636
- added: framework.on('controller-render-head', function(controller) {})
3737
- added: framework.on('controller-render-meta', function(controller) {})
38+
- added: framework.on('init')
3839

3940
- updated: (IMPORTANT) all models are loaded after is the framework loaded
4041
- updated: Utils.request(), timeout is possible to add as cookie, headers or encoding

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ function Framework() {
284284
this._length_request_middleware = 0;
285285
this._length_files = 0;
286286

287+
this.isVirtualDirectory = false;
287288
this.isCoffee = false;
288289
this.isWindows = os.platform().substring(0, 3).toLowerCase() === 'win';
289290
}
@@ -2245,6 +2246,15 @@ Framework.prototype.responseFile = function(req, res, filename, downloadName, he
22452246

22462247
if (!fs.existsSync(filename)) {
22472248

2249+
if (!self.isVirtualDirectory) {
2250+
2251+
if (!self.config.debug)
2252+
self.temporary.path[key] = null;
2253+
2254+
self.response404(req, res);
2255+
return self;
2256+
}
2257+
22482258
// virtual directory App
22492259
var tmpname = self.isWindows ? filename.replace(self.config['directory-public'].replace(/\//g, '\\'), self.config['directory-public-virtual'].replace(/\//g, '\\')) : filename.replace(self.config['directory-public'], self.config['directory-public-virtual']);
22502260
var notfound = true;
@@ -3303,6 +3313,8 @@ Framework.prototype.initialize = function(http, debug, options) {
33033313

33043314
self.clear();
33053315
self.cache.init();
3316+
self.isVirtualDirectory = fs.existsSync(utils.combine(self.config['directory-public-virtual']));
3317+
self.emit('init');
33063318
self.load();
33073319

33083320
if (options.https) {

minify/total.js/index.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/public/file.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TEST

test/views/fromURL.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@{config.name}

0 commit comments

Comments
 (0)