Created
December 23, 2013 18:26
-
-
Save mostafiz57/8102160 to your computer and use it in GitHub Desktop.
routes.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// require the native http module, as well as director. | |
// | |
var couchdb = require('./Libraries/couchdb'); | |
var url = require('url'); | |
var http = require('http'), | |
Plates = require('plates'), | |
fs = require('fs'), | |
util = require('util'); | |
var winston = require('winston'); | |
var connect = require('connect'); | |
var http = require('http'), | |
director = require('director'); | |
var map = Plates.Map(); | |
var connect = require('connect'); | |
var flatiron = require('flatiron'); | |
exports.setLogging = function(logger) { | |
winston = logger; | |
} | |
exports.getContent = function() { | |
couchdb.getContent(this.req, this.res, Plates, __dirname); | |
} | |
exports.getAllDigitalPrint = function() { | |
console.log("getAllDigitalPrint ... at router"); | |
couchdb.getAllDigitalPrint(this.req, this.res); | |
} | |
exports.saveDigitalPrint = function() { | |
console.log("saveDigitalPrint ... at router"); | |
couchdb.saveDigitalPrint(this.req, this.res); | |
} | |
exports.saveDigitalPrintReport = function() { | |
console.log("saveDigitalPrintReport ... at router"); | |
couchdb.saveDigitalPrintReport(this.req, this.res); | |
} | |
exports.getAllDigitalPrintReport = function() { | |
console.log("getAllDigitalPrintReport ... at router"); | |
couchdb.getAllDigitalPrintReport(this.req, this.res); | |
} | |
exports.getDigitalPrintImage = function() { | |
console.log("getAllDigitalPrintReport ... at router"); | |
couchdb.getDigitalPrintImage(this.req, this.res); | |
} | |
exports.dpm = function(Pageid) { | |
console.log("getAllDigitalPrintReport ... at router"); | |
couchdb.landingPage(this.req, this.res, Plates); | |
} | |
exports.landingPage = function(Pageid) { | |
var callbackFunc = (typeof this.req.query.jsoncallback !== 'undefined') ? this.req.query.jsoncallback : ''; | |
var renderedContent = { | |
pageContent: '', | |
headContent: '', | |
jsContent: '', | |
preContent: '', | |
gaugesPanel: '', | |
postContent: '' | |
}; | |
var directoryPath = '/views/partials/'; | |
var pageContentPath = directoryPath+'DigitalPrintContent.html'; | |
var jsContentPath = directoryPath+'DigitalPrintJsFunctions.js'; | |
var preContentPath = directoryPath+'DigitalPrintPreContent.htm'; | |
var inkLevelPopUpContentPath = directoryPath+'InkLevelPopUp.html'; | |
var pageContent = fs.readFileSync(__dirname + pageContentPath, "utf-8"); | |
var jsContent = fs.readFileSync(__dirname + jsContentPath, "utf-8"); | |
var preContent = fs.readFileSync(__dirname + preContentPath, "utf-8"); | |
var inkLevelPopUpContent = fs.readFileSync(__dirname + inkLevelPopUpContentPath, "utf-8"); | |
renderedContent.pageContent = pageContent; | |
renderedContent.jsContent = jsContent; | |
renderedContent.preContent = preContent + inkLevelPopUpContent; | |
//add the printbar popup template to precontent | |
var directoryTemplatePath = '/views/template/'; | |
var TemplateFile = directoryTemplatePath + 'printBar.html'; | |
var TemplateContent = fs.readFileSync(__dirname +TemplateFile, 'utf8'); | |
var printBarNo = RegExp('__PRINTBAR_NO__', 'g'); | |
TemplateContent = TemplateContent.toString(); | |
for (var inCount = 1; inCount <= 7; inCount++) { | |
var html = TemplateContent.replace(printBarNo, inCount); | |
renderedContent.pageContent += html; | |
} | |
//this.res.writeHead(200, {'Content-Type': 'text/html'}); | |
//this.res.end(JSON.stringify(renderedContent)); | |
this.res.writeHead(200, {'Content-Type': 'application/javascript'}); | |
this.res.end(callbackFunc + '(' + JSON.stringify(renderedContent) + ');'); | |
} | |
exports.landingPageView = function(Pageid) { | |
//this.res.writeHead(200, {'Content-Type': 'text/html'}); | |
//this.res.end(JSON.stringify(renderedContent)); | |
} | |
exports.printJob = function(Pageid) { | |
var path = '/views/printJob.html'; | |
var template = fs.readFileSync(__dirname + path, "utf-8"); | |
var rendered = Plates.bind(template); | |
this.res.writeHead(200, {'Content-Type': 'text/html'}); | |
this.res.end(rendered); | |
} | |
exports.jobPage = function() { | |
var callbackFunc = (typeof this.req.query.jsoncallback !== 'undefined') ? this.req.query.jsoncallback : ''; | |
var renderedContent = { | |
pageContent: '', | |
jsContent: '', | |
cssContent: '' | |
}; | |
var directoryPath = '/views/partials/'; | |
var pageContentPath = directoryPath+'jobHtmlContent.html'; | |
var jsContentPath = directoryPath+'jobJsContent.js'; | |
var cssContentPath = directoryPath+'jobCssContent.html'; | |
var pageContent = fs.readFileSync(__dirname + pageContentPath, "utf-8"); | |
var jsContent = fs.readFileSync(__dirname + jsContentPath, "utf-8"); | |
var cssContent = fs.readFileSync(__dirname + cssContentPath, "utf-8"); | |
renderedContent.pageContent = pageContent; | |
renderedContent.jsContent = jsContent; | |
// renderedContent.cssContent = cssContent; | |
renderedContent.preContent = cssContent; | |
//this.res.writeHead(200, {'Content-Type': 'text/html'}); | |
//this.res.end(JSON.stringify(renderedContent)); | |
this.res.writeHead(200, {'Content-Type': 'application/javascript'}); | |
this.res.end(callbackFunc + '(' + JSON.stringify(renderedContent) + ');'); | |
} | |
exports.removeJob = function(){ | |
console.log("removeJob ..."); | |
couchdb.removeJob(this.req, this.res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just use for router.js