Permalink
Browse files

Changed AssassinPanel to call the fileserver controller instead of in…

…dependent file handling
  • Loading branch information...
tsjamm committed Mar 9, 2013
1 parent 09ca8ae commit 5285520ddf827768b3470fe6b8c8fd08c983ecc9
Showing with 10 additions and 48 deletions.
  1. +1 −1 assassinPanel/index_style.css
  2. +1 −0 config/routes.txt
  3. +3 −45 controllers/assassinPanel.js
  4. +5 −2 controllers/fileserver.js
@@ -83,7 +83,7 @@ width: 71%;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
-margin-bottom: 10px;
+margin-bottom: 30px;
padding: 20px;
box-shadow: 0px 0px 130px 0px white;
border-radius: 70px;
View
@@ -9,3 +9,4 @@ GET /favicon.ico proxy
GET /proxy/getURL proxy
GET /reg/[a-zA-Z0-9]*/test testReg
GET /assassinPanel/[a-zA-Z0-9_./]* assassinPanel
+GET /[a-zA-Z0-9_./]* fileserver
@@ -6,58 +6,16 @@
*/
-var url = require('url');
-var fs = require('fs');
-var logger = require('../system/logger');
-var respond = require('./respond');
+var fileserver = require('./fileserver');
+
-var filetypemap = {};
-ReadFileTypeList();
-function ReadFileTypeList()
-{
- var data = fs.readFileSync('./config/filetypelist.txt');
- if(data == null)
- {
- logger.write('Error in Reading filetypelist.txt:\n');
- }
- else
- {
- var listentries = data.toString().split('\n');
-
- for(row in listentries)
- {
- row = listentries[row];
- filetypemap[row.split('\t')[0].split('.')[1]] = row.split('\t')[1];
- }
- }
-}
function invoke(req,res)
{
//First need to check of user validation credentials.
//If valid user, then show home page
//else redirect to login index page
- var reqDetails = url.parse(req.url);
- logger.write("Request Details To AssassinPanel: "+JSON.stringify(reqDetails));
- var filepath =reqDetails.pathname;
- if(filepath=='/assassinPanel/')
- filepath = '/assassinPanel/index.html';
- fs.readFile("."+filepath,function(err,data){
- if(err)
- {
- respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL');
- logger.write('Error in Reading File or Missing File from AssassinPanel:\n'+err+'\n');
- }
- else
- {
- var extension = filepath.split('.').pop();
- logger.write('File Extension is = '+extension);
- var contenttype = filetypemap[extension];
- respond.createResponse(res,200,contenttype,data);
- logger.write('Written File Contents to Response with content-type: '+contenttype+'\n');
-
- }
- });
+ fileserver.serveFile(req,res,'assassinPanel');
}
exports.invoke = invoke;
@@ -27,14 +27,17 @@ function ReadFileTypeList()
}
-function serveFile(req,res)
+function serveFile(req,res,defaultDir)
{
var reqDetails = url.parse(req.url);
logger.write("Request Details: "+JSON.stringify(reqDetails));
var filepath =reqDetails.pathname;
if(filepath=='/')
filepath = '/index.html';
- fs.readFile("./public"+filepath,function(err,data){
+ //if(defaultDir==null ||defaultDir==undefined)
+ // defaultDir='/public';
+ //fs.readFile("."+defaultDir+filepath,function(err,data){
+ fs.readFile("."+filepath,function(err,data){
if(err)
{
respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL');

0 comments on commit 5285520

Please sign in to comment.