From 5f620e4c14b2245ec1382dc2e377fa037bc83703 Mon Sep 17 00:00:00 2001 From: fahimkhan Date: Tue, 20 Sep 2016 15:25:40 +0530 Subject: Subject: Replace Hogan express with ejs Description: Replace Hogan express with ejs. Added Contact and About page. --- app.js | 12 +++++++++--- package.json | 2 +- routes/routes.js | 13 ++++++++++++- views/about.html | 18 ++++++++++++++++++ views/base.html | 0 views/contact.html | 11 +++++++++++ views/index.html | 33 ++++++++++++++++++++------------- 7 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 views/about.html create mode 100644 views/base.html create mode 100644 views/contact.html diff --git a/app.js b/app.js index b577162..11f5228 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,9 @@ var express = require('express'), fs = require('fs'), os = require('os'), shelljs = require('shelljs/global'), - PythonShell = require('python-shell') + PythonShell = require('python-shell'), + ejs = require('ejs') + var app = express(); @@ -12,11 +14,14 @@ var app = express(); var scriptPath = path.join(__dirname,'scripts') //Set views property app.set('views',path.join(__dirname,'views')); -//set Template engine -app.engine('html',require('hogan-express')); + //Set it as View engine app.set('view engine','html'); +//set Template engine +app.engine('html',ejs.renderFile); + + //Set Static public folder app.use(express.static(path.join(__dirname,'public'))); @@ -29,6 +34,7 @@ app.set('host',config.host); //Create server which listen app var server = require('http').createServer(app); + //Socket.io is invoked by passing server var io = require('socket.io')(server); diff --git a/package.json b/package.json index 1f23061..1b727ad 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "author": "Fahim Khan", "license": "ISC", "dependencies": { + "ejs": "^2.5.2", "express": "^4.13.4", - "hogan-express": "^0.5.2", "python-shell": "^0.4.0", "shelljs": "^0.7.0", "socket.io": "^1.4.5" diff --git a/routes/routes.js b/routes/routes.js index 04fb6cc..e20ae07 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -1,14 +1,25 @@ -module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){ +module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){ console.log("Server started!!! "); var router = express.Router(); var pyEnv = '/usr/bin/python' + /*Home Page*/ router.get('/',function(req,res,next){ res.render('index',{host:app.get('host'),title:'Ngspice Simulator'}); }); + /*About Page*/ + router.get('/about',function(req,res,next){ + res.render('about',{title:'Ngspice Simulator'}); + }); + + /*Contact Page*/ + router.get('/contact',function(req,res,next){ + res.render('contact',{title:'Ngspice Simulator'}); + }); + io.on('connection', function (socket) { socketID = getSocketID(socket); var plot_allv_file = '/tmp/plot_allv_'+socketID.toLowerCase()+'.txt' diff --git a/views/about.html b/views/about.html new file mode 100644 index 0000000..c43a799 --- /dev/null +++ b/views/about.html @@ -0,0 +1,18 @@ + + +
++ FOSSEE (Free and Open Software in Education) project promotes the use of FOSS tools to improve the quality of education in our country. We aim to reduce dependency on proprietary software in educational institutions. We encourage the use of FOSS tools through various activities to ensure commercial software is replaced by equivalent FOSS tools. We also develop new FOSS tools and upgrade existing tools to meet requirements in academia and research. +
++ The FOSSEE project is part of the National Mission on Education through Information and Communication Technology (ICT), Ministry of Human Resources and Development, Government of India. +
+