From 1ab39a1abc9019e7076d294cfdc41016f44c3e95 Mon Sep 17 00:00:00 2001 From: Meutel Date: Thu, 23 Jan 2014 20:48:33 +0100 Subject: [PATCH] Send headers to outputter HTML outputter with links --- lib/outputter/outputter.js | 17 +++++++++++++++-- lib/router/router.js | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/outputter/outputter.js b/lib/outputter/outputter.js index eac5594..d1884ac 100644 --- a/lib/outputter/outputter.js +++ b/lib/outputter/outputter.js @@ -15,6 +15,7 @@ function Outputter() { * Output stream. */ this.out = null; + this.headers = {}; }; Outputter.prototype = { // @@ -48,7 +49,8 @@ Outputter.prototype = { /** * Set target stream and start outputting. */ - outputTo: function(stream) { + outputTo: function(headers, stream) { + this.headers = headers; this.out = stream; } @@ -130,7 +132,7 @@ HtmlOutputter.prototype = Object.create(Outputter.prototype, { } else { this.buffer.push(resource); if (!this.colStarted) { - this.out.write(''); + this.out.write('

Data

'); this.colStarted = true; } else this.out.write(''); @@ -161,6 +163,17 @@ HtmlOutputter.prototype = Object.create(Outputter.prototype, { //end collection this.out.write('
'); } + // links + var links = this.headers.Link; + if (links) { + this.out.write('

Links

') + } this.out.write(''); logger.debug('Action ended'); this.out.end(); diff --git a/lib/router/router.js b/lib/router/router.js index d881bdc..9c415ec 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -134,7 +134,7 @@ Router.prototype = { }); // start outputter - outputter.outputTo(resp); + outputter.outputTo(headers, resp); // start action action.doAction();