diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 07e6e47..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/node_modules diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 03cffcc..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright (c) Kris Zhang - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 33356fd..0000000 --- a/README.md +++ /dev/null @@ -1,468 +0,0 @@ -WebSvr -============== -A simple web server, implement with filter and handler. - - -Features --------------- -- Filter (Middleware): A request will try to match all the filters first. -- Handler: When a request matched a handler, it will returned, only one handler will be executed. -- Session: By config sessionDir, you can store session in files, with JSON format -- File: Support uploading files -- Cache: Cahce template in release mode - -Install --------------- - - npm install websvr - - -Start --------------- -It's simple to start the websvr. - - //import WebSvr module - var WebSvr = require("websvr"); - - //Start the WebSvr, runnting at parent folder, default port is 8054, directory browser enabled; - //Trying at: http://localhost:8054 - var webSvr = WebSvr({ - home: "./web" - , listDir: true - , debug: true - , sessionTimeout: 60 * 1000 - }); - - -Filter (HttpModule) --------------- -Session based authentication, basically useage: - - /* - Session support; - */ - webSvr.filter(function(req, res) { - //Link to next filter - req.filter.next(); - }, {session:true}); - - - /* - * filter equal to use - */ - webSvr.use('/home', function(req, res) { - //do sth. - req.filter.next(); - }); - - -Filter all the requests that begin with "test/", check the user permission in session, except the "index.htm" and "login.do". - - /* - Session Filter: protect web/* folder => (validation by session); - */ - webSvr.filter(function(req, res) { - //It's not index.htm/login.do, do the session validation - if (req.url.indexOf("login.htm") < 0 && req.url.indexOf("login.do") < 0 && req.url !== '/') { - var val = req.session.get("username"); - - console.log("session username:", val); - !val && res.end("You must login, first!"); - - //Link to next filter - req.filter.next(); - } else { - req.filter.next(); - } - }, { session: true }); - -Handler (HttpHandler, Servlet) --------------- -Handle Login and put the username in session - - /* - Handler: login.do => (validate the username & password) - username: admin - password: 12345678 - webSvr.url equal to webSvr.get/webSvr.post/webSvr.handle - */ - webSvr.url("login.do", function(req, res) { - var qs = req.body; - console.log(qs); - if (qs.username == "admin" && qs.password == "12345678") { - //Add username in session - var session = req.session.set("username", qs.username); - console.log(session); - res.redirect("setting.htm"); - } else { - res.writeHead(401); - res.end("Wrong username/password"); - } - }, 'qs'); - -Note: --------------- -Filter and Handler doesn't have the same match rules when you sending a request - -Filter : Match any section in the request url, for example - - websvr.filter(".svr", cb); - -The result is - - request: "domain.com/admin/root/login.svr" match: true - -Handler : Match from the begining (ignore the first '/'), etc: - - websvr.handle("root/login", cb) //equal to - websvr.handle("/root/login", cb) - -etc: - - request: "domain.com/root/login.svr" match: true - request: "domain.com/admin/root/login.svr" match: false - -You can use regular expression to match any part of url in Handler. - -Cookies --------------- - - //get cookie value by key - req.cookies[key]; - - -Template --------------- -Render template with params, using doT template engine - - res.render([view, model]); - -View is optional, it will get the location of template from req.url - - res.render({json: true}); - -View is a relative path, relative to web home - - //means related to Setting.home - res.render("list.tmpl", {json: true}); - -View is a absolute path, relative to web root - - //means related to Setting.root - res.render("/list.tmpl", {json: true}); - -Render raw HTML views - - res.renderRaw(viewContent, model); - -You can change template engine, - - webSvr.engine(engineFunc); - -for example: - - webSvr.engine(require("doT").compile); - webSvr.engine(require("jade").compile); - -You can define some default properties in model, for example header/footer, this parameters will be overridden if they have the same key in your custom model. - - webSvr.model({ - title : "WebSvr Page" - , username: "WebSvr" - }); - -You can use template and render it by using websvr.render(tmplPath, model, callback), tmplPath relative to webSvr.home; - - //pre-defined model - var model = {}; - webSvr.model(model); - - //render a template using model, callbak argument is result html - webSvr.render("header.tmpl", {categoryList: category.categoryList}, function(html) { - //store rendered html to header - model.header = html; - console.log(model); - }); - -Include file, you can using "#include" to include a file during rendering a template, in order to make the process easier, the file will fetched from the cache pool so the first refresh will not work when you first start the server; - -###Be ware: include file: relative to web home, not the template file itself.### - - - -
- -Cache templates, by default, server will cache the templates(include the "include file" in the templates), turn it off via: - - var webSvr = WebSvr({ - templateCache: false - }); - -Clear the cached templates - - webSvr.clear() - - - -Enable template engine and '', using: res.render()/res.render(model)/res.render(tmplPath, model), etc - -webSvr.url(['login.htm', 'setting.htm'], function(req, res) { - res.render(); -}); - - -It also support include file in include files, but you need to refresh more times after the first running. - - -Settings --------------- -Return configuration of current WebSvr instance - - webSvr.settings - -Settings API: - - var Settings = { - //home folder of web - home: "../" - - //http start - //default port of http - , port: 8054 - - //default port of https - , httpsPort: 8443 - , httpsKey: "" - , httpsCert: "" - - //list files in directory - , listDir: false - //enable client-side cache(304) - , cache: true - //enable debug information output - , debug: true - //enable cache of template/include file (when enabled templates will not be refreshed before restart) - , templateCache: true - - //default pages, only one is supported - , defaultPage: "index.html" - //404 template/static file - , 404: "404.tmpl" - //show errors to user(displayed in response) - , showError: true - - /* - Session timeout, in milliseconds. - */ - , sessionTimeout: 1440000 - - //session file stored here - , sessionDir: os.tmpDir() - - //session domain, e.g. ".google.com" - , sessionDomain: "" - - //tempary upload file stored here - , uploadDir: os.tmpDir() - }; - -Response --------------- -Extension on reponse object - -Ouput file, filepath relative to the root - - res.sendRootFile(filePath, [callback]); - -Ouput file, filepath relative to the home (web dir) - - res.sendFile(filePath); - res.sendHomeFile(filePath); - -Reidrect request - - res.redirect(url); - -Return request object - - res.req - -Set Content-Type - - res.type('xml'); - -Set/Remove Cookie - - //Set Cookie - res.cookie(name, value [, {domain: string, path: string, expires: date, secure, httponly }]) - //Remove Cookie - res.cookie(name, null); - - -Change default charset - - res.charset = 'utf-8' - - -WebSvr APIs --------------- -Mapping url to file, webSvr.url equal to webSvr.handle - - webSvr.url("sitetest", ["svr/sitetest.js"]); - -Mapping url to string - - webSvr.url("hello", "Hello WebSvr!") - -Handle post - - webSvr.post("post.htm", function(req, res) { - res.end('Received : ' + req.body); - }); - - //Equal to - webSvr.handle("post.htm", function(req, res) { - res.end('Received : ' + req.body); - }, {post: true}); - -Post type - - post: true/"json"/"qs" - -Handle session - - webSvr.session("session required url", function(req, res) { - console.log(req.session); - res.end(); - }); - - -Handle upload file, it's a specfic filter - - webSvr.file("upload.do", function(req, res) { - res.writeHead(200, {"Content-Type": "text/plain"}); - //Upload file is stored in req.files - //form fields is stored in req.body - res.write(JSON.stringify(req.body)); - res.end(JSON.stringify(req.files)); - }); - -Valid File beofre receing it - - /* - * Valid request before receiving - */ - webSvr.file("upload.do", function(req, res) { - res.writeHead(200, {"Content-Type": "text/plain"}); - res.send(req.files); - }).before(function(req, res) { - if ((req.headers['content-length'] || 0) > 245760) { - res.send('Posting is too large, should less than 240K') - } else { - return true - } - }); - -Multi-Mapping in Handler or Filter - - webSvr.handle(["about", "help", "welcome"], function(req, res) { - res.writeFile(req.url + ".shtml"); - }, {post: true}); - -Pickup parameters from url expression - - webSvr.handle("/verify/:id", function(req, res) { - var id = req.params.id; - }); - -Parse parameters in url - - * expression = /home/:key/:pager - * /home/JavaScript => { id: 'JavaScript', pager: '' } - * /key/JavaScript => false - - var params = webSvr.parseUrl(expression, reqUrl); - -Send API - - webSvr.send([type or statusCode, ] content); - -Send JSON - - webSvr.send('json', { a: 1, b: 2 }); - -Send String - - webSvr.send(401, 'No permission'); - - -Multi-instance support --------------- -Start a https server, make sure that the port will no conflict with others. - - var httpsSvr = new WebSvr({ - home: "./" - - //disable http server - , port: null - - //enable https server - , httpsPort: 8443 - , httpsKey: require("fs").readFileSync("svr/cert/privatekey.pem") - , httpsCert: require("fs").readFileSync("svr/cert/certificate.pem") - - }).start(); - -Do you want to re-use the filters & handlers? - - httpsSvr.filters = webSvr.filters; - httpsSvr.handlers = webSvr.handlers; - - -Store session in redis --------------- -Install: npm install websvr-redis - - var RedisStore = require('websvr-redis'); - - RedisStore.start({ - port: 6379 - , host: 'ourjs.org' - , auth: 'your-password-if-needed' - , select: 0 - }); - - httpsSvr.sessionStore = RedisStore; - - -Clear expired sessions, only 1 refresh timer is needed - - setInterval(RedisStore.clear, 1000000); - - - - -Lincenses ----- -MIT, see our license file - - - - - - - - - - - -Demo Sites ----- -1. ourjs: url [ourjs.com](http://ourjs.com) -2. icalc: url [icalc.cn](http://icalc.cn), source code [github](https://github.com/newghost/websvr-icalc/) - - -Websvr -==== -基于NodeJS的一个极简Web服务器, 专为ARM设计。 -假设嵌入式设备需要保持长时间稳定运行,当遇到问题时也可自动重启并恢复此前用户的Session会话。 diff --git a/fonts/copse-regular-webfont.eot b/fonts/copse-regular-webfont.eot new file mode 100644 index 0000000..af1f5e6 Binary files /dev/null and b/fonts/copse-regular-webfont.eot differ diff --git a/fonts/copse-regular-webfont.svg b/fonts/copse-regular-webfont.svg new file mode 100644 index 0000000..1e920b5 --- /dev/null +++ b/fonts/copse-regular-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2010 Daniel Rhatigansparkyultrasparkyorg with Reserved Font Name Copse +Designer : Daniel Rhatigan +Foundry : Daniel Rhatigan + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/copse-regular-webfont.ttf b/fonts/copse-regular-webfont.ttf new file mode 100644 index 0000000..434b208 Binary files /dev/null and b/fonts/copse-regular-webfont.ttf differ diff --git a/fonts/copse-regular-webfont.woff b/fonts/copse-regular-webfont.woff new file mode 100644 index 0000000..a9a0450 Binary files /dev/null and b/fonts/copse-regular-webfont.woff differ diff --git a/fonts/quattrocentosans-bold-webfont.eot b/fonts/quattrocentosans-bold-webfont.eot new file mode 100644 index 0000000..c041ed9 Binary files /dev/null and b/fonts/quattrocentosans-bold-webfont.eot differ diff --git a/fonts/quattrocentosans-bold-webfont.svg b/fonts/quattrocentosans-bold-webfont.svg new file mode 100644 index 0000000..fb162e9 --- /dev/null +++ b/fonts/quattrocentosans-bold-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-bold-webfont.ttf b/fonts/quattrocentosans-bold-webfont.ttf new file mode 100644 index 0000000..7389c87 Binary files /dev/null and b/fonts/quattrocentosans-bold-webfont.ttf differ diff --git a/fonts/quattrocentosans-bold-webfont.woff b/fonts/quattrocentosans-bold-webfont.woff new file mode 100644 index 0000000..fc14168 Binary files /dev/null and b/fonts/quattrocentosans-bold-webfont.woff differ diff --git a/fonts/quattrocentosans-bolditalic-webfont.eot b/fonts/quattrocentosans-bolditalic-webfont.eot new file mode 100644 index 0000000..7c1aa7a Binary files /dev/null and b/fonts/quattrocentosans-bolditalic-webfont.eot differ diff --git a/fonts/quattrocentosans-bolditalic-webfont.svg b/fonts/quattrocentosans-bolditalic-webfont.svg new file mode 100644 index 0000000..9070a8b --- /dev/null +++ b/fonts/quattrocentosans-bolditalic-webfont.svg @@ -0,0 +1,248 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-bolditalic-webfont.ttf b/fonts/quattrocentosans-bolditalic-webfont.ttf new file mode 100644 index 0000000..9766a17 Binary files /dev/null and b/fonts/quattrocentosans-bolditalic-webfont.ttf differ diff --git a/fonts/quattrocentosans-bolditalic-webfont.woff b/fonts/quattrocentosans-bolditalic-webfont.woff new file mode 100644 index 0000000..c436da0 Binary files /dev/null and b/fonts/quattrocentosans-bolditalic-webfont.woff differ diff --git a/fonts/quattrocentosans-italic-webfont.eot b/fonts/quattrocentosans-italic-webfont.eot new file mode 100644 index 0000000..379b383 Binary files /dev/null and b/fonts/quattrocentosans-italic-webfont.eot differ diff --git a/fonts/quattrocentosans-italic-webfont.svg b/fonts/quattrocentosans-italic-webfont.svg new file mode 100644 index 0000000..b613779 --- /dev/null +++ b/fonts/quattrocentosans-italic-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-italic-webfont.ttf b/fonts/quattrocentosans-italic-webfont.ttf new file mode 100644 index 0000000..c7ba47a Binary files /dev/null and b/fonts/quattrocentosans-italic-webfont.ttf differ diff --git a/fonts/quattrocentosans-italic-webfont.woff b/fonts/quattrocentosans-italic-webfont.woff new file mode 100644 index 0000000..3798881 Binary files /dev/null and b/fonts/quattrocentosans-italic-webfont.woff differ diff --git a/fonts/quattrocentosans-regular-webfont.eot b/fonts/quattrocentosans-regular-webfont.eot new file mode 100644 index 0000000..346db6f Binary files /dev/null and b/fonts/quattrocentosans-regular-webfont.eot differ diff --git a/fonts/quattrocentosans-regular-webfont.svg b/fonts/quattrocentosans-regular-webfont.svg new file mode 100644 index 0000000..3470924 --- /dev/null +++ b/fonts/quattrocentosans-regular-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-regular-webfont.ttf b/fonts/quattrocentosans-regular-webfont.ttf new file mode 100644 index 0000000..e414670 Binary files /dev/null and b/fonts/quattrocentosans-regular-webfont.ttf differ diff --git a/fonts/quattrocentosans-regular-webfont.woff b/fonts/quattrocentosans-regular-webfont.woff new file mode 100644 index 0000000..09ed324 Binary files /dev/null and b/fonts/quattrocentosans-regular-webfont.woff differ diff --git a/images/background.png b/images/background.png new file mode 100644 index 0000000..b63b420 Binary files /dev/null and b/images/background.png differ diff --git a/images/body-background.png b/images/body-background.png new file mode 100644 index 0000000..d6a152f Binary files /dev/null and b/images/body-background.png differ diff --git a/images/bullet.png b/images/bullet.png new file mode 100644 index 0000000..2b7dc9a Binary files /dev/null and b/images/bullet.png differ diff --git a/images/hr.gif b/images/hr.gif new file mode 100644 index 0000000..a64b56c Binary files /dev/null and b/images/hr.gif differ diff --git a/images/octocat-logo.png b/images/octocat-logo.png new file mode 100644 index 0000000..28a3ad1 Binary files /dev/null and b/images/octocat-logo.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..625c126 --- /dev/null +++ b/index.html @@ -0,0 +1,189 @@ + + + + + + Node-websvr by newghost + + + + + + + + + + +
+

Node-websvr

+

+
+ + + +
+ +
+

WebSvr

+ +

Lincense: MIT, GPL

+ +

Description:

+ +

A simple web server based on node.js

+ +

Version: 0.024

+ +
    +
  • Filter: A request will try to match all the filters first, and then pass to the Handler
  • +
  • Handler: When a request matched a handler, it will returned, only one handler will be executed
  • +
  • Session: Stored in file, with JSON format
  • +
  • File: Support uploading files
  • +

Start

+ +

Edit in SiteTest.js or Create a new Site.js and added to MakeFile.list

+ +
//Start the WebSVr, runnting at parent folder, default port is 8054, directory browser enabled;
+//Trying at: http://localhost:8054
+var webSvr = new WebSvr({
+  root: "../",
+  listDir: true,
+  https: true,
+  httpsPort: 8443
+});
+
+webSvr.start();
+
+ +

Filter

+ +

Session based authentication (session stored in files), all the request under "test/" will parse the post data and session by default, except the "index.htm" and "login.do"

+ +
/*
+General filter: parse the post data / session before all request
+  parse:   parse the post data and stored in req.body;
+  session: init the session and stored in req.session; 
+*/
+webSvr.filter(function(req, res){
+  //TODO: Add greeting words in filter
+  //res.write("Hello WebSvr!<br/>");
+
+  //Link to next filter
+  req.filter.next(req, res);
+}, {parse:true, session:true});
+
+/*
+Session Filter: protect test/* folder => (validate by session);
+*/
+webSvr.filter(/test\/[\w\.]+/, function(req, res) {
+  //It's not index.htm/login.do, do the session validation
+  if (req.url.indexOf("index.htm") < 0 && req.url.indexOf("login.do") < 0) {
+    !req.session.get("username") && res.end("You must login, first!");
+  }
+
+  //Link to next filter
+  req.filter.next(req, res);
+});
+
+ +

Handler

+ +

Handle Login and put the username in Session

+ +
/*
+Handler: login.do => (validate the username & password)
+  username: admin
+  password: 12345678
+*/
+webSvr.session(/login.do/, function(req, res) {
+  var querystring = require("querystring");
+
+  //TODO: Add an parameter to auto-complete querystring.parse(req.body);
+  var qs = querystring.parse(req.body);
+  if (qs.username == "admin" && qs.password == "12345678") {
+    //Put key/value pair in session
+    //TODO: Support put JSON object directly
+    req.session.set("username", qs.username, function(session) {
+      //TODO: Add req.redirect / req.forward functionalities;
+      res.writeHead(200, {"Content-Type": "text/html"});
+      res.writeFile("/test/setting.htm");
+    });
+  }else{
+    res.writeHead(401);
+    res.end("Wrong username/password");
+  }
+});
+
+ +

File

+ +

Receive upload file (it's a specfic filter)

+ +
/*
+Uploader: upload.do => (receive handler)
+*/
+webSvr.file(/upload.do/, function(req, res) {
+  res.writeHead(200, {"Content-Type": "text/plain"});
+  //Upload file is stored in req.files
+  //form fields is stored in req.body
+  res.write(JSON.stringify(req.body));
+  res.end(JSON.stringify(req.files));
+});
+
+ +

Other APIs

+ +

Redirect

+ +
/*
+Redirect: redirect request, try at: http://localhost:8054/redirect
+*/
+webSvr.url("redirect", function(req, res){
+  res.redirect("/svr/websvr.all.js");
+});
+
+ +

Url Mapping

+ +
//Mapping "combine" to tool/Combine.js, trying at: http://localhost:8054/combine
+webSvr.url(/combine/, ["svr/tool/Combine.js"]);
+//Mapping "hello" to a string, trying at http://localhost:8054/hello
+webSvr.url(/hello/, "Hello WebSvr!");
+
+ +

Post Data

+ +
//Mapping "post" and parse the post in the request, trying at: http://localhost:8054/post.htm
+webSvr.post(/post.htm/, function(req, res) {
+  res.writeHead(200, {"Content-Type": "text/html"});
+  //Need session support
+  res.write("You username is " + req.session.get("username"));
+  res.write('<form action="" method="post"><input name="input" /></form><br/>');
+  res.end('Received : ' + req.body);
+}, {session: true});
+
+
+ +
+ + + + \ No newline at end of file diff --git a/javascripts/main.js b/javascripts/main.js new file mode 100644 index 0000000..c57e54c --- /dev/null +++ b/javascripts/main.js @@ -0,0 +1,53 @@ +var sectionHeight = function() { + var total = $(window).height(), + $section = $('section').css('height','auto'); + + if ($section.outerHeight(true) < total) { + var margin = $section.outerHeight(true) - $section.height(); + $section.height(total - margin - 20); + } else { + $section.css('height','auto'); + } +} + +$(window).resize(sectionHeight); + +$(document).ready(function(){ + $("section h1, section h2").each(function(){ + $("nav ul").append("
  • " + $(this).text() + "
  • "); + $(this).attr("id",$(this).text().toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g,'')); + $("nav ul li:first-child a").parent().addClass("active"); + }); + + $("nav ul li").on("click", "a", function(event) { + var position = $($(this).attr("href")).offset().top - 190; + $("html, body").animate({scrollTop: position}, 400); + $("nav ul li a").parent().removeClass("active"); + $(this).parent().addClass("active"); + event.preventDefault(); + }); + + sectionHeight(); + + $('img').load(sectionHeight); +}); + +fixScale = function(doc) { + + var addEvent = 'addEventListener', + type = 'gesturestart', + qsa = 'querySelectorAll', + scales = [1, 1], + meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; + + function fix() { + meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; + doc.removeEventListener(type, fix, true); + } + + if ((meta = meta[meta.length - 1]) && addEvent in doc) { + fix(); + scales = [.25, 1.6]; + doc[addEvent](type, fix, true); + } +}; \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index 3952422..0000000 --- a/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "websvr", - "description": "A simple web server, implement http module(filter) and handler(servlet), autorecover persistent session", - "version": "0.1.41", - "author": "Kris Zhang ", - "dependencies": { - "dot": "1.1.3", - "formidable": "1.0.14", - "mime": "1.2.9" - }, - "keywords": [ - "web", - "server", - "https", - "filter", - "handler" - ], - "repository": "git://github.com/newghost/websvr.git", - "main": "./websvr/websvr.js" -} diff --git a/params.json b/params.json new file mode 100644 index 0000000..6611509 --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"body":"WebSvr\r\n==============\r\nLincense: MIT, GPL\r\n\r\nDescription:\r\n--------------\r\nA simple web server based on node.js\r\n\r\nVersion: 0.024\r\n--------------\r\n- Filter: A request will try to match all the filters first, and then pass to the Handler\r\n- Handler: When a request matched a handler, it will returned, only one handler will be executed\r\n- Session: Stored in file, with JSON format\r\n- File: Support uploading files\r\n\r\nStart\r\n--------------\r\nEdit in SiteTest.js or Create a new Site.js and added to MakeFile.list\r\n\r\n //Start the WebSVr, runnting at parent folder, default port is 8054, directory browser enabled;\r\n //Trying at: http://localhost:8054\r\n var webSvr = new WebSvr({\r\n root: \"../\",\r\n listDir: true,\r\n https: true,\r\n httpsPort: 8443\r\n });\r\n\r\n webSvr.start();\r\n\r\nFilter\r\n--------------\r\nSession based authentication (session stored in files), all the request under \"test/\" will parse the post data and session by default, except the \"index.htm\" and \"login.do\"\r\n\r\n /*\r\n General filter: parse the post data / session before all request\r\n parse: parse the post data and stored in req.body;\r\n session: init the session and stored in req.session; \r\n */\r\n webSvr.filter(function(req, res){\r\n //TODO: Add greeting words in filter\r\n //res.write(\"Hello WebSvr!
    \");\r\n\r\n //Link to next filter\r\n req.filter.next(req, res);\r\n }, {parse:true, session:true});\r\n\r\n /*\r\n Session Filter: protect test/* folder => (validate by session);\r\n */\r\n webSvr.filter(/test\\/[\\w\\.]+/, function(req, res) {\r\n //It's not index.htm/login.do, do the session validation\r\n if (req.url.indexOf(\"index.htm\") < 0 && req.url.indexOf(\"login.do\") < 0) {\r\n !req.session.get(\"username\") && res.end(\"You must login, first!\");\r\n }\r\n\r\n //Link to next filter\r\n req.filter.next(req, res);\r\n });\r\n\r\n\r\nHandler\r\n--------------\r\nHandle Login and put the username in Session\r\n\r\n /*\r\n Handler: login.do => (validate the username & password)\r\n username: admin\r\n password: 12345678\r\n */\r\n webSvr.session(/login.do/, function(req, res) {\r\n var querystring = require(\"querystring\");\r\n\r\n //TODO: Add an parameter to auto-complete querystring.parse(req.body);\r\n var qs = querystring.parse(req.body);\r\n if (qs.username == \"admin\" && qs.password == \"12345678\") {\r\n //Put key/value pair in session\r\n //TODO: Support put JSON object directly\r\n req.session.set(\"username\", qs.username, function(session) {\r\n //TODO: Add req.redirect / req.forward functionalities;\r\n res.writeHead(200, {\"Content-Type\": \"text/html\"});\r\n res.writeFile(\"/test/setting.htm\");\r\n });\r\n }else{\r\n res.writeHead(401);\r\n res.end(\"Wrong username/password\");\r\n }\r\n });\r\n\r\nFile\r\n--------------\r\nReceive upload file (it's a specfic filter)\r\n\r\n /*\r\n Uploader: upload.do => (receive handler)\r\n */\r\n webSvr.file(/upload.do/, function(req, res) {\r\n res.writeHead(200, {\"Content-Type\": \"text/plain\"});\r\n //Upload file is stored in req.files\r\n //form fields is stored in req.body\r\n res.write(JSON.stringify(req.body));\r\n res.end(JSON.stringify(req.files));\r\n });\r\n\r\n\r\nOther APIs\r\n--------------\r\nRedirect\r\n\r\n /*\r\n Redirect: redirect request, try at: http://localhost:8054/redirect\r\n */\r\n webSvr.url(\"redirect\", function(req, res){\r\n res.redirect(\"/svr/websvr.all.js\");\r\n });\r\n\r\nUrl Mapping\r\n\r\n //Mapping \"combine\" to tool/Combine.js, trying at: http://localhost:8054/combine\r\n webSvr.url(/combine/, [\"svr/tool/Combine.js\"]);\r\n //Mapping \"hello\" to a string, trying at http://localhost:8054/hello\r\n webSvr.url(/hello/, \"Hello WebSvr!\");\r\n\r\nPost Data\r\n\r\n //Mapping \"post\" and parse the post in the request, trying at: http://localhost:8054/post.htm\r\n webSvr.post(/post.htm/, function(req, res) {\r\n res.writeHead(200, {\"Content-Type\": \"text/html\"});\r\n //Need session support\r\n res.write(\"You username is \" + req.session.get(\"username\"));\r\n res.write('

    ');\r\n res.end('Received : ' + req.body);\r\n }, {session: true});","name":"Node-websvr","note":"Don't delete this file! It's used internally to help with page regeneration.","tagline":"","google":""} \ No newline at end of file diff --git a/stylesheets/normalize.css b/stylesheets/normalize.css new file mode 100644 index 0000000..bc2ba93 --- /dev/null +++ b/stylesheets/normalize.css @@ -0,0 +1,459 @@ +/* normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */ +/* ============================================================================= + HTML5 display definitions + ========================================================================== */ +/* + * Corrects block display not defined in IE6/7/8/9 & FF3 + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects inline-block display not defined in IE6/7/8/9 & FF3 + */ +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying 'audio' without controls + */ +audio:not([controls]) { + display: none; +} + +/* + * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 + * Known issue: no IE6 support + */ +[hidden] { + display: none; +} + +/* ============================================================================= + Base + ========================================================================== */ +/* + * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units + * http://clagnut.com/blog/348/#c790 + * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom + * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ + */ +html { + font-size: 100%; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -ms-text-size-adjust: 100%; + /* 2 */ +} + +/* + * Addresses font-family inconsistency between 'textarea' and other form elements. + */ +html, +button, +input, +select, +textarea { + font-family: sans-serif; +} + +/* + * Addresses margins handled incorrectly in IE6/7 + */ +body { + margin: 0; +} + +/* ============================================================================= + Links + ========================================================================== */ +/* + * Addresses outline displayed oddly in Chrome + */ +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers + * people.opera.com/patrickl/experiments/keyboard/test + */ +a:hover, +a:active { + outline: 0; +} + +/* ============================================================================= + Typography + ========================================================================== */ +/* + * Addresses font sizes and margins set differently in IE6/7 + * Addresses font sizes within 'section' and 'article' in FF4+, Chrome, S5 + */ +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.75em; + margin: 2.33em 0; +} + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome + */ +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to 'bolder' in FF3+, S4/5, Chrome +*/ +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome + */ +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9 + */ +mark { + background: #ff0; + color: #000; +} + +/* + * Addresses margins set differently in IE6/7 + */ +p, +pre { + margin: 1em 0; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ +pre, +code, +kbd, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * 1. Addresses CSS quotes not supported in IE6/7 + * 2. Addresses quote property not supported in S4 + */ +/* 1 */ +q { + quotes: none; +} + +/* 2 */ +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents sub and sup affecting line-height in all browsers + * gist.github.com/413930 + */ +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ============================================================================= + Lists + ========================================================================== */ +/* + * Addresses margins set differently in IE6/7 + */ +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +/* + * Addresses paddings set differently in IE6/7 + */ +menu, +ol, +ul { + padding: 0 0 0 40px; +} + +/* + * Corrects list images handled incorrectly in IE7 + */ +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + +/* ============================================================================= + Embedded content + ========================================================================== */ +/* + * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 + * 2. Improves image quality when scaled in IE7 + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ +img { + border: 0; + /* 1 */ + -ms-interpolation-mode: bicubic; + /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9 + */ +svg:not(:root) { + overflow: hidden; +} + +/* ============================================================================= + Figures + ========================================================================== */ +/* + * Addresses margin not present in IE6/7/8/9, S5, O11 + */ +figure { + margin: 0; +} + +/* ============================================================================= + Forms + ========================================================================== */ +/* + * Corrects margin displayed oddly in IE6/7 + */ +form { + margin: 0; +} + +/* + * Define consistent border, margin, and padding + */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9 + * 2. Corrects text not wrapping in FF3 + * 3. Corrects alignment displayed oddly in IE6/7 + */ +legend { + border: 0; + /* 1 */ + padding: 0; + white-space: normal; + /* 2 */ + *margin-left: -7px; + /* 3 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers + * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome + * 3. Improves appearance and consistency in all browsers + */ +button, +input, +select, +textarea { + font-size: 100%; + /* 1 */ + margin: 0; + /* 2 */ + vertical-align: baseline; + /* 3 */ + *vertical-align: middle; + /* 3 */ +} + +/* + * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet + */ +button, +input { + line-height: normal; + /* 1 */ +} + +/* + * 1. Improves usability and consistency of cursor style between image-type 'input' and others + * 2. Corrects inability to style clickable 'input' types in iOS + * 3. Removes inner spacing in IE7 without affecting normal text inputs + * Known issue: inner spacing remains in IE6 + */ +button, +input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + /* 1 */ + -webkit-appearance: button; + /* 2 */ + *overflow: visible; + /* 3 */ +} + +/* + * Re-set default cursor for disabled elements + */ +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9 + * 2. Removes excess padding in IE8/9 + * 3. Removes excess padding in IE7 + Known issue: excess padding remains in IE6 + */ +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + /* 1 */ + padding: 0; + /* 2 */ + *height: 13px; + /* 3 */ + *width: 13px; + /* 3 */ +} + +/* + * 1. Addresses appearance set to searchfield in S5, Chrome + * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) + */ +input[type="search"] { + -webkit-appearance: textfield; + /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in S5, Chrome on OS X + */ +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in FF3+ + * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ + */ +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9 + * 2. Improves readability and alignment in all browsers + */ +textarea { + overflow: auto; + /* 1 */ + vertical-align: top; + /* 2 */ +} + +/* ============================================================================= + Tables + ========================================================================== */ +/* + * Remove most spacing between table cells + */ +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..62fd970 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,70 @@ +.highlight .hll { background-color: #404040 } +.highlight { color: #d0d0d0 } +.highlight .c { color: #999999; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .g { color: #d0d0d0 } /* Generic */ +.highlight .k { color: #6ab825; font-weight: normal } /* Keyword */ +.highlight .l { color: #d0d0d0 } /* Literal */ +.highlight .n { color: #d0d0d0 } /* Name */ +.highlight .o { color: #d0d0d0 } /* Operator */ +.highlight .x { color: #d0d0d0 } /* Other */ +.highlight .p { color: #d0d0d0 } /* Punctuation */ +.highlight .cm { color: #999999; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #cd2828; font-weight: normal } /* Comment.Preproc */ +.highlight .c1 { color: #999999; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #e50808; font-weight: normal; background-color: #520000 } /* Comment.Special */ +.highlight .gd { color: #d22323 } /* Generic.Deleted */ +.highlight .ge { color: #d0d0d0; font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #d22323 } /* Generic.Error */ +.highlight .gh { color: #ffffff; font-weight: normal } /* Generic.Heading */ +.highlight .gi { color: #589819 } /* Generic.Inserted */ +.highlight .go { color: #cccccc } /* Generic.Output */ +.highlight .gp { color: #aaaaaa } /* Generic.Prompt */ +.highlight .gs { color: #d0d0d0; font-weight: normal } /* Generic.Strong */ +.highlight .gu { color: #ffffff; text-decoration: underline } /* Generic.Subheading */ +.highlight .gt { color: #d22323 } /* Generic.Traceback */ +.highlight .kc { color: #6ab825; font-weight: normal } /* Keyword.Constant */ +.highlight .kd { color: #6ab825; font-weight: normal } /* Keyword.Declaration */ +.highlight .kn { color: #6ab825; font-weight: normal } /* Keyword.Namespace */ +.highlight .kp { color: #6ab825 } /* Keyword.Pseudo */ +.highlight .kr { color: #6ab825; font-weight: normal } /* Keyword.Reserved */ +.highlight .kt { color: #6ab825; font-weight: normal } /* Keyword.Type */ +.highlight .ld { color: #d0d0d0 } /* Literal.Date */ +.highlight .m { color: #3677a9 } /* Literal.Number */ +.highlight .s { color: #ff8 } /* Literal.String */ +.highlight .na { color: #bbbbbb } /* Name.Attribute */ +.highlight .nb { color: #24909d } /* Name.Builtin */ +.highlight .nc { color: #447fcf; text-decoration: underline } /* Name.Class */ +.highlight .no { color: #40ffff } /* Name.Constant */ +.highlight .nd { color: #ffa500 } /* Name.Decorator */ +.highlight .ni { color: #d0d0d0 } /* Name.Entity */ +.highlight .ne { color: #bbbbbb } /* Name.Exception */ +.highlight .nf { color: #447fcf } /* Name.Function */ +.highlight .nl { color: #d0d0d0 } /* Name.Label */ +.highlight .nn { color: #447fcf; text-decoration: underline } /* Name.Namespace */ +.highlight .nx { color: #d0d0d0 } /* Name.Other */ +.highlight .py { color: #d0d0d0 } /* Name.Property */ +.highlight .nt { color: #6ab825;} /* Name.Tag */ +.highlight .nv { color: #40ffff } /* Name.Variable */ +.highlight .ow { color: #6ab825; font-weight: normal } /* Operator.Word */ +.highlight .w { color: #666666 } /* Text.Whitespace */ +.highlight .mf { color: #3677a9 } /* Literal.Number.Float */ +.highlight .mh { color: #3677a9 } /* Literal.Number.Hex */ +.highlight .mi { color: #3677a9 } /* Literal.Number.Integer */ +.highlight .mo { color: #3677a9 } /* Literal.Number.Oct */ +.highlight .sb { color: #ff8 } /* Literal.String.Backtick */ +.highlight .sc { color: #ff8 } /* Literal.String.Char */ +.highlight .sd { color: #ff8 } /* Literal.String.Doc */ +.highlight .s2 { color: #ff8 } /* Literal.String.Double */ +.highlight .se { color: #ff8 } /* Literal.String.Escape */ +.highlight .sh { color: #ff8 } /* Literal.String.Heredoc */ +.highlight .si { color: #ff8 } /* Literal.String.Interpol */ +.highlight .sx { color: #ffa500 } /* Literal.String.Other */ +.highlight .sr { color: #ff8 } /* Literal.String.Regex */ +.highlight .s1 { color: #ff8 } /* Literal.String.Single */ +.highlight .ss { color: #ff8 } /* Literal.String.Symbol */ +.highlight .bp { color: #24909d } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #40ffff } /* Name.Variable.Class */ +.highlight .vg { color: #40ffff } /* Name.Variable.Global */ +.highlight .vi { color: #40ffff } /* Name.Variable.Instance */ +.highlight .il { color: #3677a9 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/stylesheets/styles.css b/stylesheets/styles.css new file mode 100644 index 0000000..033edc7 --- /dev/null +++ b/stylesheets/styles.css @@ -0,0 +1,1010 @@ +/* +Leap Day for Github Pages +by Matt Graham +*/ +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-bold-webfont.eot"); + src: url("../fonts/quattrocentosans-bold-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-bold-webfont.woff") format("woff"), url("../fonts/quattrocentosans-bold-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-bold-webfont.svg#QuattrocentoSansBold") format("svg"); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-bolditalic-webfont.eot"); + src: url("../fonts/quattrocentosans-bolditalic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-bolditalic-webfont.woff") format("woff"), url("../fonts/quattrocentosans-bolditalic-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-bolditalic-webfont.svg#QuattrocentoSansBoldItalic") format("svg"); + font-weight: bold; + font-style: italic; +} + +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-italic-webfont.eot"); + src: url("../fonts/quattrocentosans-italic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-italic-webfont.woff") format("woff"), url("../fonts/quattrocentosans-italic-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-italic-webfont.svg#QuattrocentoSansItalic") format("svg"); + font-weight: normal; + font-style: italic; +} + +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-regular-webfont.eot"); + src: url("../fonts/quattrocentosans-regular-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-regular-webfont.woff") format("woff"), url("../fonts/quattrocentosans-regular-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-regular-webfont.svg#QuattrocentoSansRegular") format("svg"); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'Copse'; + src: url("../fonts/copse-regular-webfont.eot"); + src: url("../fonts/copse-regular-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/copse-regular-webfont.woff") format("woff"), url("../fonts/copse-regular-webfont.ttf") format("truetype"), url("../fonts/copse-regular-webfont.svg#CopseRegular") format("svg"); + font-weight: normal; + font-style: normal; +} + +/* normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */ +/* ============================================================================= + HTML5 display definitions + ========================================================================== */ +/* + * Corrects block display not defined in IE6/7/8/9 & FF3 + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects inline-block display not defined in IE6/7/8/9 & FF3 + */ +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying 'audio' without controls + */ +audio:not([controls]) { + display: none; +} + +/* + * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 + * Known issue: no IE6 support + */ +[hidden] { + display: none; +} + +/* ============================================================================= + Base + ========================================================================== */ +/* + * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units + * http://clagnut.com/blog/348/#c790 + * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom + * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ + */ +html { + font-size: 100%; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -ms-text-size-adjust: 100%; + /* 2 */ +} + +/* + * Addresses font-family inconsistency between 'textarea' and other form elements. + */ +html, +button, +input, +select, +textarea { + font-family: sans-serif; +} + +/* + * Addresses margins handled incorrectly in IE6/7 + */ +body { + margin: 0; +} + +/* ============================================================================= + Links + ========================================================================== */ +/* + * Addresses outline displayed oddly in Chrome + */ +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers + * people.opera.com/patrickl/experiments/keyboard/test + */ +a:hover, +a:active { + outline: 0; +} + +/* ============================================================================= + Typography + ========================================================================== */ +/* + * Addresses font sizes and margins set differently in IE6/7 + * Addresses font sizes within 'section' and 'article' in FF4+, Chrome, S5 + */ +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.75em; + margin: 2.33em 0; +} + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome + */ +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to 'bolder' in FF3+, S4/5, Chrome +*/ +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome + */ +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9 + */ +mark { + background: #ff0; + color: #000; +} + +/* + * Addresses margins set differently in IE6/7 + */ +p, +pre { + margin: 1em 0; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ +pre, +code, +kbd, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * 1. Addresses CSS quotes not supported in IE6/7 + * 2. Addresses quote property not supported in S4 + */ +/* 1 */ +q { + quotes: none; +} + +/* 2 */ +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents sub and sup affecting line-height in all browsers + * gist.github.com/413930 + */ +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ============================================================================= + Lists + ========================================================================== */ +/* + * Addresses margins set differently in IE6/7 + */ +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +/* + * Addresses paddings set differently in IE6/7 + */ +menu, +ol, +ul { + padding: 0 0 0 40px; +} + +/* + * Corrects list images handled incorrectly in IE7 + */ +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + +/* ============================================================================= + Embedded content + ========================================================================== */ +/* + * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 + * 2. Improves image quality when scaled in IE7 + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ +img { + border: 0; + /* 1 */ + -ms-interpolation-mode: bicubic; + /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9 + */ +svg:not(:root) { + overflow: hidden; +} + +/* ============================================================================= + Figures + ========================================================================== */ +/* + * Addresses margin not present in IE6/7/8/9, S5, O11 + */ +figure { + margin: 0; +} + +/* ============================================================================= + Forms + ========================================================================== */ +/* + * Corrects margin displayed oddly in IE6/7 + */ +form { + margin: 0; +} + +/* + * Define consistent border, margin, and padding + */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9 + * 2. Corrects text not wrapping in FF3 + * 3. Corrects alignment displayed oddly in IE6/7 + */ +legend { + border: 0; + /* 1 */ + padding: 0; + white-space: normal; + /* 2 */ + *margin-left: -7px; + /* 3 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers + * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome + * 3. Improves appearance and consistency in all browsers + */ +button, +input, +select, +textarea { + font-size: 100%; + /* 1 */ + margin: 0; + /* 2 */ + vertical-align: baseline; + /* 3 */ + *vertical-align: middle; + /* 3 */ +} + +/* + * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet + */ +button, +input { + line-height: normal; + /* 1 */ +} + +/* + * 1. Improves usability and consistency of cursor style between image-type 'input' and others + * 2. Corrects inability to style clickable 'input' types in iOS + * 3. Removes inner spacing in IE7 without affecting normal text inputs + * Known issue: inner spacing remains in IE6 + */ +button, +input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + /* 1 */ + -webkit-appearance: button; + /* 2 */ + *overflow: visible; + /* 3 */ +} + +/* + * Re-set default cursor for disabled elements + */ +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9 + * 2. Removes excess padding in IE8/9 + * 3. Removes excess padding in IE7 + Known issue: excess padding remains in IE6 + */ +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + /* 1 */ + padding: 0; + /* 2 */ + *height: 13px; + /* 3 */ + *width: 13px; + /* 3 */ +} + +/* + * 1. Addresses appearance set to searchfield in S5, Chrome + * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) + */ +input[type="search"] { + -webkit-appearance: textfield; + /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in S5, Chrome on OS X + */ +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in FF3+ + * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ + */ +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9 + * 2. Improves readability and alignment in all browsers + */ +textarea { + overflow: auto; + /* 1 */ + vertical-align: top; + /* 2 */ +} + +/* ============================================================================= + Tables + ========================================================================== */ +/* + * Remove most spacing between table cells + */ +table { + border-collapse: collapse; + border-spacing: 0; +} + +body { + font: 14px/22px "Quattrocento Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #666; + font-weight: 300; + margin: 0px; + padding: 0px 0 20px 0px; + background: url(../images/body-background.png) #eae6d1; +} + +h1, h2, h3, h4, h5, h6 { + color: #333; + margin: 0 0 10px; +} + +p, ul, ol, table, pre, dl { + margin: 0 0 20px; +} + +h1, h2, h3 { + line-height: 1.1; +} + +h1 { + font-size: 28px; +} + +h2 { + font-size: 24px; + color: #393939; +} + +h3, h4, h5, h6 { + color: #666666; +} + +h3 { + font-size: 18px; + line-height: 24px; +} + +a { + color: #3399cc; + font-weight: 400; + text-decoration: none; +} + +a small { + font-size: 11px; + color: #666; + margin-top: -0.6em; + display: block; +} + +ul { + list-style-image: url("../images/bullet.png"); +} + +strong { + font-weight: bold; + color: #333; +} + +.wrapper { + width: 650px; + margin: 0 auto; + position: relative; +} + +section img { + max-width: 100%; +} + +blockquote { + border-left: 1px solid #ffcc00; + margin: 0; + padding: 0 0 0 20px; + font-style: italic; +} + +code { + font-family: "Lucida Sans", Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + font-size: 13px; + color: #efefef; + text-shadow: 0px 1px 0px #000; + margin: 0 4px; + padding: 2px 6px; + background: #333; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; +} + +pre { + padding: 8px 15px; + background: #333333; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -o-border-radius: 3px; + -ms-border-radius: 3px; + -khtml-border-radius: 3px; + border-radius: 3px; + border: 1px solid #c7c7c7; + overflow: auto; + overflow-y: hidden; +} +pre code { + margin: 0px; + padding: 0px; +} + +table { + width: 100%; + border-collapse: collapse; +} + +th { + text-align: left; + padding: 5px 10px; + border-bottom: 1px solid #e5e5e5; + color: #444; +} + +td { + text-align: left; + padding: 5px 10px; + border-bottom: 1px solid #e5e5e5; + border-right: 1px solid #ffcc00; +} +td:first-child { + border-left: 1px solid #ffcc00; +} + +hr { + border: 0; + outline: none; + height: 11px; + background: transparent url("../images/hr.gif") center center repeat-x; + margin: 0 0 20px; +} + +dt { + color: #444; + font-weight: 700; +} + +header { + padding: 25px 20px 40px 20px; + margin: 0; + position: fixed; + top: 0; + left: 0; + right: 0; + width: 100%; + text-align: center; + background: url(../images/background.png) #4276b6; + -moz-box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + -webkit-box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + -o-box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + z-index: 99; + -webkit-font-smoothing: antialiased; + min-height: 76px; +} +header h1 { + font: 40px/48px "Copse", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #f3f3f3; + text-shadow: 0px 2px 0px #235796; + margin: 0px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; +} +header p { + color: #d8d8d8; + text-shadow: rgba(0, 0, 0, 0.2) 0 1px 0; + font-size: 18px; + margin: 0px; +} + +#banner { + z-index: 100; + left: 0; + right: 50%; + height: 50px; + margin-right: -382px; + position: fixed; + top: 115px; + background: #ffcc00; + border: 1px solid #f0b500; + -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + -o-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + -moz-border-radius: 0px 2px 2px 0px; + -webkit-border-radius: 0px 2px 2px 0px; + -o-border-radius: 0px 2px 2px 0px; + -ms-border-radius: 0px 2px 2px 0px; + -khtml-border-radius: 0px 2px 2px 0px; + border-radius: 0px 2px 2px 0px; + padding-right: 10px; +} +#banner .button { + border: 1px solid #dba500; + background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffe788), color-stop(100%, #ffce38)); + background: -webkit-linear-gradient(#ffe788, #ffce38); + background: -moz-linear-gradient(#ffe788, #ffce38); + background: -o-linear-gradient(#ffe788, #ffce38); + background: -ms-linear-gradient(#ffe788, #ffce38); + background: linear-gradient(#ffe788, #ffce38); + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; + -moz-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + -webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + -o-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + background-color: #FFE788; + margin-left: 5px; + padding: 10px 12px; + margin-top: 6px; + line-height: 14px; + font-size: 14px; + color: #333; + font-weight: bold; + display: inline-block; + text-align: center; +} +#banner .button:hover { + background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffe788), color-stop(100%, #ffe788)); + background: -webkit-linear-gradient(#ffe788, #ffe788); + background: -moz-linear-gradient(#ffe788, #ffe788); + background: -o-linear-gradient(#ffe788, #ffe788); + background: -ms-linear-gradient(#ffe788, #ffe788); + background: linear-gradient(#ffe788, #ffe788); + background-color: #ffeca0; +} +#banner .fork { + position: fixed; + left: 50%; + margin-left: -325px; + padding: 10px 12px; + margin-top: 6px; + line-height: 14px; + font-size: 14px; + background-color: #FFE788; +} +#banner .downloads { + float: right; + margin: 0 45px 0 0; +} +#banner .downloads span { + float: left; + line-height: 52px; + font-size: 90%; + color: #9d7f0d; + text-transform: uppercase; + text-shadow: rgba(255, 255, 255, 0.2) 0 1px 0; +} +#banner ul { + list-style: none; + height: 40px; + padding: 0; + float: left; + margin-left: 10px; +} +#banner ul li { + display: inline; +} +#banner ul li a.button { + background-color: #FFE788; +} +#banner #logo { + position: absolute; + height: 36px; + width: 36px; + right: 7px; + top: 7px; + display: block; + background: url(../images/octocat-logo.png); +} + +section { + width: 590px; + padding: 30px 30px 50px 30px; + margin: 20px 0; + margin-top: 190px; + position: relative; + background: #fbfbfb; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -o-border-radius: 3px; + -ms-border-radius: 3px; + -khtml-border-radius: 3px; + border-radius: 3px; + border: 1px solid #cbcbcb; + -moz-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); + -webkit-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); + -o-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); +} + +small { + font-size: 12px; +} + +nav { + width: 230px; + position: fixed; + top: 220px; + left: 50%; + margin-left: -580px; + text-align: right; +} +nav ul { + list-style: none; + list-style-image: none; + font-size: 14px; + line-height: 24px; +} +nav ul li { + padding: 5px 0px; + line-height: 16px; +} +nav ul li.tag-h1 { + font-size: 1.2em; +} +nav ul li.tag-h1 a { + font-weight: bold; + color: #333; +} +nav ul li.tag-h2 + .tag-h1 { + margin-top: 10px; +} +nav ul a { + color: #666; +} +nav ul a:hover { + color: #999; +} + +footer { + width: 180px; + position: fixed; + left: 50%; + margin-left: -530px; + bottom: 20px; + text-align: right; + line-height: 16px; +} + +@media print, screen and (max-width: 1060px) { + div.wrapper { + width: auto; + margin: 0; + } + + nav { + display: none; + } + + header, section, footer { + float: none; + } + header h1, section h1, footer h1 { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + } + + #banner { + width: 100%; + } + #banner .downloads { + margin-right: 60px; + } + #banner #logo { + margin-right: 15px; + } + + section { + border: 1px solid #e5e5e5; + border-width: 1px 0; + padding: 20px auto; + margin: 190px auto 20px; + max-width: 600px; + } + + footer { + text-align: center; + margin: 20px auto; + position: relative; + left: auto; + bottom: auto; + width: auto; + } +} +@media print, screen and (max-width: 720px) { + body { + word-wrap: break-word; + } + + header { + padding: 20px 20px; + margin: 0; + } + header h1 { + font-size: 32px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + } + header p { + display: none; + } + + #banner { + top: 80px; + } + #banner .fork { + float: left; + display: inline-block; + margin-left: 0px; + position: fixed; + left: 20px; + } + + section { + margin-top: 130px; + margin-bottom: 0px; + width: auto; + } + + header ul, header p.view { + position: static; + } +} +@media print, screen and (max-width: 480px) { + header { + position: relative; + padding: 5px 0px; + min-height: 0px; + } + header h1 { + font-size: 24px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + } + + section { + margin-top: 5px; + } + + #banner { + display: none; + } + + header ul { + display: none; + } +} +@media print { + body { + padding: 0.4in; + font-size: 12pt; + color: #444; + } +} +@media print, screen and (max-height: 680px) { + footer { + text-align: center; + margin: 20px auto; + position: relative; + left: auto; + bottom: auto; + width: auto; + } +} +@media print, screen and (max-height: 480px) { + nav { + display: none; + } + + footer { + text-align: center; + margin: 20px auto; + position: relative; + left: auto; + bottom: auto; + width: auto; + } +} diff --git a/website/start.sh b/website/start.sh deleted file mode 100755 index 3fe9516..0000000 --- a/website/start.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -echo start sitetest - -#change current dir, in order to call it from anywhere. -cd $(dirname $0) - -while true; do - node svr/sitetest.js - - echo *************************************** - echo Server stop working, restarting... - echo *************************************** - - #wait 2 seconds - sleep 2 -done \ No newline at end of file diff --git a/website/svr/cert/certificate.pem b/website/svr/cert/certificate.pem deleted file mode 100644 index f660f7d..0000000 --- a/website/svr/cert/certificate.pem +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICpTCCAg4CCQCISrlY6+bq+DANBgkqhkiG9w0BAQUFADCBljELMAkGA1UEBhMC -Q04xETAPBgNVBAgMCFNoYW5naGFpMREwDwYDVQQHDAhTaGFuZ2hhaTEQMA4GA1UE -CgwHRW5sb2dpYzEfMB0GA1UECwwWUmVzZWFyY2ggJiBEZXZlbG9wbWVudDESMBAG -A1UEAwwJbG9jYWxob3N0MRowGAYJKoZIhvcNAQkBFgtjMnVAbGl2ZS5jbjAeFw0x -MjEwMjgwNzU1MTZaFw0xMjExMjcwNzU1MTZaMIGWMQswCQYDVQQGEwJDTjERMA8G -A1UECAwIU2hhbmdoYWkxETAPBgNVBAcMCFNoYW5naGFpMRAwDgYDVQQKDAdFbmxv -Z2ljMR8wHQYDVQQLDBZSZXNlYXJjaCAmIERldmVsb3BtZW50MRIwEAYDVQQDDAls -b2NhbGhvc3QxGjAYBgkqhkiG9w0BCQEWC2MydUBsaXZlLmNuMIGfMA0GCSqGSIb3 -DQEBAQUAA4GNADCBiQKBgQCgWDgMTdIEafBqczxi4BpFOL741bf3nttkJxS5eMbj -bQvfDX9LHkNpqZFx3jDWecmjBhUY+B2Q1PmiBnwuRLIBaYsg3jT2nWp0fphzBcJ5 -JsPF3S9GjeWrzYZIuK+YRyCarlmzbjn4omidm/4wAtXuXxQYiouTMe9hyuLnxb6s -mQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAB/dirZrcdB4aGUTlSGWt+LmFuz/Xl6x -iWkfjwvQP7h4oCGoSUjoB9vqy5hIkCKxI+PWhW76S7YpJNXHIdjrC7BRyYVIlAmp -Efm4GUlBAdSYo222my1xTF8SaEx1debDfzq2Ho8xeozpnKae4x62MoA+Fp2kphsq -tLTB8YxbjIQy ------END CERTIFICATE----- diff --git a/website/svr/cert/privatekey.pem b/website/svr/cert/privatekey.pem deleted file mode 100644 index 5f7786a..0000000 --- a/website/svr/cert/privatekey.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQCgWDgMTdIEafBqczxi4BpFOL741bf3nttkJxS5eMbjbQvfDX9L -HkNpqZFx3jDWecmjBhUY+B2Q1PmiBnwuRLIBaYsg3jT2nWp0fphzBcJ5JsPF3S9G -jeWrzYZIuK+YRyCarlmzbjn4omidm/4wAtXuXxQYiouTMe9hyuLnxb6smQIDAQAB -AoGAWDpSlMqZPh6A0EIaPxmqut4PjuIiORlrBL/QUoHXhjpxZsmJem7rjw9j3XDy -FIGs5owpPbUAp7nYpkPFPrxD6U3qVwZk/C7K2Lx2vWYlJ9vf8TTWAvIt6yyNuq5x -ocFosz346viky3K5QkyvmT9y3UuQS65GKj8Hv5S9xSolAhUCQQDSGzabd9c1kgex -EH96Fu/EWIE2G2U3f5/MRalAPlCIrVkBo1YjNoO8QDIb61mW0KdunQrtxrOoKDJp -Opxwpkj7AkEAw15qkHWd2yfU4yw7cFWsWOLojs3pyLdSX+7++vT3gLL8y2otbyKi -mWlrQJDgCnbXywUyRJtMGmLrn9X0y5IUewJBAJxGlYVpy+8SoRn4dXjwGoLmeaUv -F0gCa29a2RrpvqkKlst7HBSw9adN8HeHxGlC5WaG9JwLUZHf5C8U40t+w4UCQClz -keaeneSO2fNtQhs+gjfFxRPviofEpZynJ8B1U0IiN9Ks74Dh91/XZyMm2fI+buCr -dJPr40TB8j5SdgLvNpsCQFaYxoFde72QZHBQKYMsOmKldhcSuQKeZ/oppuhjgYqp -9qrtIyQ2MTchc8Yu27WCU975F0UGWQTsNG0BqVtGLik= ------END RSA PRIVATE KEY----- diff --git a/website/svr/sitetest.js b/website/svr/sitetest.js deleted file mode 100644 index e508047..0000000 --- a/website/svr/sitetest.js +++ /dev/null @@ -1,224 +0,0 @@ -//import WebSvr module -var WebSvr = require("../../websvr/websvr"); - - -//Start the WebSvr, runnting at parent folder, default port is 8054, directory browser enabled; -//Trying at: http://localhost:8054 -var webSvr = WebSvr({ - home: "./web" - , listDir: true - , debug: true - , sessionTimeout: 1200 * 1000 -}); - - -/* -Session support; -*/ -webSvr.filter(function(req, res) { - //Link to next filter - req.filter.next(); -}, {session: true}); - - -/* -Session Filter: protect web/* folder => (validation by session); -*/ -webSvr.filter(function(req, res) { - //Not index.htm/login.do, do the session validation - if (req.url.indexOf("login.htm") < 0 && req.url.indexOf("login.do") < 0 && req.url !== '/') { - var val = req.session.get("username"); - - console.log("session username:", val); - !val && res.end("You must login, first!"); - - //Link to next filter - req.filter.next(); - } else { - req.filter.next(); - } -}, { session: true }); - - -/* -Handler: login.do => (validate the username & password) - username: admin - password: 12345678 -webSvr.url equal to webSvr.get/webSvr.post/webSvr.handle -*/ -webSvr.url("login.do", function(req, res) { - var qs = req.body; - console.log(qs); - if (qs.username == "admin" && qs.password == "12345678") { - //Add username in session - var session = req.session.set("username", qs.username); - console.log(session); - res.redirect("setting.htm"); - } else { - res.writeHead(401); - res.end("Wrong username/password"); - } -}, 'qs'); - - -/* -Uploader: upload.do => (receive handler) -*/ -webSvr.file("upload.do", function(req, res) { - res.writeHead(200, {"Content-Type": "text/plain"}); - //Upload file is stored in req.files - //form fields is stored in req.body - res.write(JSON.stringify(req.body)); - res.end(JSON.stringify(req.files)); -}).before(function(req, res) { - if ((req.headers['content-length'] || 0) > 245760) { - res.send('Posting is too large, should less than 240K') - } else { - return true - } -}); - - -/* -Redirect: redirect request, try at: http://localhost:8054/redirect -*/ -webSvr.url("redirect", function(req, res) { - res.redirect("/svr/websvr.all.js"); -}); - - -/* -Template: define default template params -*/ -webSvr.model({ - title : "WebSvr Page" - , username: "WebSvr" -}); - - -/* -Enable template engine and '', using: res.render()/res.render(model)/res.render(tmplPath, model) -*/ -webSvr.url(['login.htm', 'setting.htm'], function(req, res) { - //Default template engine - webSvr.engine(require("doT").compile); - res.render(); -}); - - -/* -Template: render template with params -*/ -webSvr.url("template.node", function(req, res) { - webSvr.engine(require("dot").compile); - - res.writeHead(200, {"Content-Type": "text/html"}); - //render template with session: { "username" : "admin" } - var session = req.session.get(); - res.render(session); -}); - - -/* -Template: render template with jade -*/ -webSvr.url("template.jade", function(req, res) { - webSvr.engine(require("jade").compile); - - res.writeHead(200, {"Content-Type": "text/html"}); - res.render({ - pageTitle: "Testing Jade", - maintainer: { - name: 'Forbes Lindesay', - twitter: '@ForbesLindesay', - blog: 'forbeslindesay.co.uk' - } - }); -}); - - -/* -Simple redirect API: -*/ -webSvr - //Mapping "sitest" to tool/Combine.js, trying at: http://localhost:8054/combine - .url("sitetest", ["svr/sitetest.js"]) - //Mapping "hello" to a string, trying at http://localhost:8054/hello - .url("hello", "Hello WebSvr!") - //Mapping "post" and parse the post in the request, trying at: http://localhost:8054/post.htm - .url("post.htm", function(req, res) { - res.writeHead(200, {"Content-Type": "text/html"}); - //With session support: "{session: true}" - res.write("You username is " + req.session.get("username")); - res.write('

    '); - res.end('Received : ' + req.body); - }, {session: true, post: true}); - - -webSvr.post('post_qs', function(req, res) { - res.end('Received : ' + JSON.stringify(req.body)); -}); - - -webSvr.post('post_json', function(req, res) { - res.end('Received : ' + JSON.stringify(req.body)); -}, 'json'); - - - -/* -* HTTPS server -* session stored in files£ºsupport for hot restart -*/ -var httpsSvr = WebSvr({ - home: "./web" - - //disable http server - , port: null - - //enable https server - , httpsPort: 8443 - , httpsKey: require("fs").readFileSync("svr/cert/privatekey.pem") - , httpsCert: require("fs").readFileSync("svr/cert/certificate.pem") - - //, defaultPage: "index.htm" - , listDir: true - - //Change the default locations of tmp session and upload files - //session file stored here - , sessionDir: "tmp/session/" - //tempary upload file stored here - , uploadDir: "tmp/upload/" - - //5 minutes - , sessionTimeout: 2 * 3600 * 1000 - -}); - -httpsSvr.model({ title: 'HTTPS PAGE', username: 'HTTPS' }); - -httpsSvr.filters = webSvr.filters; -httpsSvr.handlers = webSvr.handlers; - - - -/* -* Store your session in redis -* Requires: npm install websvr-redis -*/ -/* -var RedisStore = require('websvr-redis'); - -RedisStore.start({ - port: 6379 - , host: 'ourjs.org' - , auth: 'your-password-if-needed' - , select: 0 -}); - -httpsSvr.sessionStore = RedisStore; - - -//Clear expired session, only 1 refresh timer is needed -setInterval(RedisStore.clear, 1000000); -*/ \ No newline at end of file diff --git a/website/tmp/session/readme.txt b/website/tmp/session/readme.txt deleted file mode 100644 index 0b4b98a..0000000 --- a/website/tmp/session/readme.txt +++ /dev/null @@ -1 +0,0 @@ -Temporary session here. \ No newline at end of file diff --git a/website/tmp/upload/readme.txt b/website/tmp/upload/readme.txt deleted file mode 100644 index 9cf689f..0000000 --- a/website/tmp/upload/readme.txt +++ /dev/null @@ -1 +0,0 @@ -Temporary upload files here. \ No newline at end of file diff --git a/website/web/header.xml b/website/web/header.xml deleted file mode 100644 index 0bfc6be..0000000 --- a/website/web/header.xml +++ /dev/null @@ -1,3 +0,0 @@ -
    -
    Hello: {{=it.username}}, this is global header, you can override it in your custom model.
    -
    \ No newline at end of file diff --git a/website/web/login.htm b/website/web/login.htm deleted file mode 100644 index 6f408a8..0000000 --- a/website/web/login.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - {{=it.title}} - - - - -

    WebSvr configuration login:

    -
    -
      -
    • - - - admin -
    • -
    • - - - 12345678 -
    • -
    • - - -
    • -
    -
    - -
    - -

    Post querystring Testing:

    -
    -
      -
    • - - - admin -
    • -
    • - - - 12345678 -
    • -
    • - - -
    • -
    -
    - - - diff --git a/website/web/setting.htm b/website/web/setting.htm deleted file mode 100644 index 2d4a074..0000000 --- a/website/web/setting.htm +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - {{=it.title}} - - - -
    -
    - - -
    -
    - - - diff --git a/website/web/template.jade b/website/web/template.jade deleted file mode 100644 index ce66dc0..0000000 --- a/website/web/template.jade +++ /dev/null @@ -1,16 +0,0 @@ -doctype 5 -html(lang="en") - head - title= pageTitle - script(type='text/javascript'). - if (foo) bar(1 + 5) - body - h1 Jade - node template engine - #container.col - if youAreUsingJade - p You are amazing - else - p Get on it! - p. - Jade is a terse and simple templating language with a - strong focus on performance and powerful features. \ No newline at end of file diff --git a/website/web/template.node b/website/web/template.node deleted file mode 100644 index 1015ab4..0000000 --- a/website/web/template.node +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Login - - - -
    -
    - - -
    -
    - - - diff --git a/websvr/test/lib/MIME.types b/websvr/test/lib/MIME.types deleted file mode 100644 index 739a544..0000000 --- a/websvr/test/lib/MIME.types +++ /dev/null @@ -1,105 +0,0 @@ -var MIMETYPES = module.exports = { - "js": "application/javascript", - "json": "application/json", - "doc": "application/msword", - "pdf": "application/pdf", - "7z": "application/x-7z-compressed", - "torrent": "application/x-bittorrent", - "bz": "application/x-bzip", - "bz2": "application/x-bzip2", - "boz": "application/x-bzip2", - "application": "application/x-ms-application", - "rar": "application/x-rar-compressed", - "sh": "application/x-sh", - "swf": "application/x-shockwave-flash", - "xap": "application/x-silverlight-app", - "tar": "application/x-tar", - "der": "application/x-x509-ca-cert", - "crt": "application/x-x509-ca-cert", - "xhtml": "application/xhtml+xml", - "xht": "application/xhtml+xml", - "xml": "application/xml", - "xsl": "application/xml", - "dtd": "application/xml-dtd", - "xop": "application/xop+xml", - "xslt": "application/xslt+xml", - "xspf": "application/xspf+xml", - "zip": "application/zip", - "adp": "audio/adpcm", - "au": "audio/basic", - "snd": "audio/basic", - "mid": "audio/midi", - "midi": "audio/midi", - "kar": "audio/midi", - "rmi": "audio/midi", - "mp4a": "audio/mp4", - "mpga": "audio/mpeg", - "mp2": "audio/mpeg", - "mp2a": "audio/mpeg", - "mp3": "audio/mpeg", - "m2a": "audio/mpeg", - "m3a": "audio/mpeg", - "oga": "audio/ogg", - "ogg": "audio/ogg", - "weba": "audio/webm", - "wav": "audio/x-wav", - "bmp": "image/bmp", - "cgm": "image/cgm", - "gif": "image/gif", - "jpeg": "image/jpeg", - "jpg": "image/jpeg", - "png": "image/png", - "btif": "image/prs.btif", - "svg": "image/svg+xml", - "svgz": "image/svg+xml", - "tiff": "image/tiff", - "tif": "image/tiff", - "psd": "image/vnd.adobe.photoshop", - "mdi": "image/vnd.ms-modi", - "ico": "image/x-icon", - "eml": "message/rfc822", - "mime": "message/rfc822", - "css": "text/css", - "csv": "text/csv", - "html": "text/html", - "htm": "text/html", - "txt": "text/plain", - "text": "text/plain", - "conf": "text/plain", - "def": "text/plain", - "list": "text/plain", - "log": "text/plain", - "wml": "text/vnd.wap.wml", - "wmls": "text/vnd.wap.wmlscript", - "3gp": "video/3gpp", - "3g2": "video/3gpp2", - "h261": "video/h261", - "h263": "video/h263", - "h264": "video/h264", - "jpgv": "video/jpeg", - "jpm": "video/jpm", - "jpgm": "video/jpm", - "mp4": "video/mp4", - "mp4v": "video/mp4", - "mpg4": "video/mp4", - "mpeg": "video/mpeg", - "mpg": "video/mpeg", - "mpe": "video/mpeg", - "m1v": "video/mpeg", - "m2v": "video/mpeg", - "ogv": "video/ogg", - "qt": "video/quicktime", - "mov": "video/quicktime", - "webm": "video/webm", - "f4v": "video/x-f4v", - "fli": "video/x-fli", - "flv": "video/x-flv", - "m4v": "video/x-m4v", - "asf": "video/x-ms-asf", - "asx": "video/x-ms-asf", - "wm": "video/x-ms-wm", - "wmv": "video/x-ms-wmv", - "wmx": "video/x-ms-wmx", - "wvx": "video/x-ms-wvx", - "avi": "video/x-msvideo", -}; \ No newline at end of file diff --git a/websvr/test/lib/MIMETYPES.js b/websvr/test/lib/MIMETYPES.js deleted file mode 100644 index 85422a6..0000000 --- a/websvr/test/lib/MIMETYPES.js +++ /dev/null @@ -1,901 +0,0 @@ -var MIMETYPES = module.exports = { - "123": "application/vnd.lotus-1-2-3", - "ez": "application/andrew-inset", - "aw": "application/applixware", - "atom": "application/atom+xml", - "atomcat": "application/atomcat+xml", - "atomsvc": "application/atomsvc+xml", - "ccxml": "application/ccxml+xml", - "cdmia": "application/cdmi-capability", - "cdmic": "application/cdmi-container", - "cdmid": "application/cdmi-domain", - "cdmio": "application/cdmi-object", - "cdmiq": "application/cdmi-queue", - "cu": "application/cu-seeme", - "davmount": "application/davmount+xml", - "dssc": "application/dssc+der", - "xdssc": "application/dssc+xml", - "ecma": "application/ecmascript", - "emma": "application/emma+xml", - "epub": "application/epub+zip", - "exi": "application/exi", - "pfr": "application/font-tdpfr", - "stk": "application/hyperstudio", - "ink": "application/inkml+xml", - "inkml": "application/inkml+xml", - "ipfix": "application/ipfix", - "jar": "application/java-archive", - "ser": "application/java-serialized-object", - "class": "application/java-vm", - "js": "application/javascript", - "json": "application/json", - "lostxml": "application/lost+xml", - "hqx": "application/mac-binhex40", - "cpt": "application/mac-compactpro", - "mads": "application/mads+xml", - "mrc": "application/marc", - "mrcx": "application/marcxml+xml", - "ma": "application/mathematica", - "nb": "application/mathematica", - "mb": "application/mathematica", - "mathml": "application/mathml+xml", - "mbox": "application/mbox", - "mscml": "application/mediaservercontrol+xml", - "meta4": "application/metalink4+xml", - "mets": "application/mets+xml", - "mods": "application/mods+xml", - "m21": "application/mp21", - "mp21": "application/mp21", - "mp4s": "application/mp4", - "doc": "application/msword", - "dot": "application/msword", - "mxf": "application/mxf", - "bin": "application/octet-stream", - "dms": "application/octet-stream", - "lha": "application/octet-stream", - "lrf": "application/octet-stream", - "lzh": "application/octet-stream", - "so": "application/octet-stream", - "iso": "application/octet-stream", - "dmg": "application/octet-stream", - "dist": "application/octet-stream", - "distz": "application/octet-stream", - "pkg": "application/octet-stream", - "bpk": "application/octet-stream", - "dump": "application/octet-stream", - "elc": "application/octet-stream", - "deploy": "application/octet-stream", - "oda": "application/oda", - "opf": "application/oebps-package+xml", - "ogx": "application/ogg", - "onetoc": "application/onenote", - "onetoc2": "application/onenote", - "onetmp": "application/onenote", - "onepkg": "application/onenote", - "oxps": "application/oxps", - "xer": "application/patch-ops-error+xml", - "pdf": "application/pdf", - "pgp": "application/pgp-encrypted", - "asc": "application/pgp-signature", - "sig": "application/pgp-signature", - "prf": "application/pics-rules", - "p10": "application/pkcs10", - "p7m": "application/pkcs7-mime", - "p7c": "application/pkcs7-mime", - "p7s": "application/pkcs7-signature", - "p8": "application/pkcs8", - "ac": "application/pkix-attr-cert", - "cer": "application/pkix-cert", - "crl": "application/pkix-crl", - "pkipath": "application/pkix-pkipath", - "pki": "application/pkixcmp", - "pls": "application/pls+xml", - "ai": "application/postscript", - "eps": "application/postscript", - "ps": "application/postscript", - "cww": "application/prs.cww", - "pskcxml": "application/pskc+xml", - "rdf": "application/rdf+xml", - "rif": "application/reginfo+xml", - "rnc": "application/relax-ng-compact-syntax", - "rl": "application/resource-lists+xml", - "rld": "application/resource-lists-diff+xml", - "rs": "application/rls-services+xml", - "gbr": "application/rpki-ghostbusters", - "mft": "application/rpki-manifest", - "roa": "application/rpki-roa", - "rsd": "application/rsd+xml", - "rss": "application/rss+xml", - "rtf": "application/rtf", - "sbml": "application/sbml+xml", - "scq": "application/scvp-cv-request", - "scs": "application/scvp-cv-response", - "spq": "application/scvp-vp-request", - "spp": "application/scvp-vp-response", - "sdp": "application/sdp", - "setpay": "application/set-payment-initiation", - "setreg": "application/set-registration-initiation", - "shf": "application/shf+xml", - "smi": "application/smil+xml", - "smil": "application/smil+xml", - "rq": "application/sparql-query", - "srx": "application/sparql-results+xml", - "gram": "application/srgs", - "grxml": "application/srgs+xml", - "sru": "application/sru+xml", - "ssml": "application/ssml+xml", - "tei": "application/tei+xml", - "teicorpus": "application/tei+xml", - "tfi": "application/thraud+xml", - "tsd": "application/timestamped-data", - "plb": "application/vnd.3gpp.pic-bw-large", - "psb": "application/vnd.3gpp.pic-bw-small", - "pvb": "application/vnd.3gpp.pic-bw-var", - "tcap": "application/vnd.3gpp2.tcap", - "pwn": "application/vnd.3m.post-it-notes", - "aso": "application/vnd.accpac.simply.aso", - "imp": "application/vnd.accpac.simply.imp", - "acu": "application/vnd.acucobol", - "atc": "application/vnd.acucorp", - "acutc": "application/vnd.acucorp", - "air": "application/vnd.adobe.air-application-installer-package+zip", - "fxp": "application/vnd.adobe.fxp", - "fxpl": "application/vnd.adobe.fxp", - "xdp": "application/vnd.adobe.xdp+xml", - "xfdf": "application/vnd.adobe.xfdf", - "ahead": "application/vnd.ahead.space", - "azf": "application/vnd.airzip.filesecure.azf", - "azs": "application/vnd.airzip.filesecure.azs", - "azw": "application/vnd.amazon.ebook", - "acc": "application/vnd.americandynamics.acc", - "ami": "application/vnd.amiga.ami", - "apk": "application/vnd.android.package-archive", - "cii": "application/vnd.anser-web-certificate-issue-initiation", - "fti": "application/vnd.anser-web-funds-transfer-initiation", - "atx": "application/vnd.antix.game-component", - "mpkg": "application/vnd.apple.installer+xml", - "m3u8": "application/vnd.apple.mpegurl", - "swi": "application/vnd.aristanetworks.swi", - "iota": "application/vnd.astraea-software.iota", - "aep": "application/vnd.audiograph", - "mpm": "application/vnd.blueice.multipass", - "bmi": "application/vnd.bmi", - "rep": "application/vnd.businessobjects", - "cdxml": "application/vnd.chemdraw+xml", - "mmd": "application/vnd.chipnuts.karaoke-mmd", - "cdy": "application/vnd.cinderella", - "cla": "application/vnd.claymore", - "rp9": "application/vnd.cloanto.rp9", - "c4g": "application/vnd.clonk.c4group", - "c4d": "application/vnd.clonk.c4group", - "c4f": "application/vnd.clonk.c4group", - "c4p": "application/vnd.clonk.c4group", - "c4u": "application/vnd.clonk.c4group", - "c11amc": "application/vnd.cluetrust.cartomobile-config", - "c11amz": "application/vnd.cluetrust.cartomobile-config-pkg", - "csp": "application/vnd.commonspace", - "cdbcmsg": "application/vnd.contact.cmsg", - "cmc": "application/vnd.cosmocaller", - "clkx": "application/vnd.crick.clicker", - "clkk": "application/vnd.crick.clicker.keyboard", - "clkp": "application/vnd.crick.clicker.palette", - "clkt": "application/vnd.crick.clicker.template", - "clkw": "application/vnd.crick.clicker.wordbank", - "wbs": "application/vnd.criticaltools.wbs+xml", - "pml": "application/vnd.ctc-posml", - "ppd": "application/vnd.cups-ppd", - "car": "application/vnd.curl.car", - "pcurl": "application/vnd.curl.pcurl", - "rdz": "application/vnd.data-vision.rdz", - "uvf": "application/vnd.dece.data", - "uvvf": "application/vnd.dece.data", - "uvd": "application/vnd.dece.data", - "uvvd": "application/vnd.dece.data", - "uvt": "application/vnd.dece.ttml+xml", - "uvvt": "application/vnd.dece.ttml+xml", - "uvx": "application/vnd.dece.unspecified", - "uvvx": "application/vnd.dece.unspecified", - "uvz": "application/vnd.dece.zip", - "uvvz": "application/vnd.dece.zip", - "fe_launch": "application/vnd.denovo.fcselayout-link", - "dna": "application/vnd.dna", - "mlp": "application/vnd.dolby.mlp", - "dpg": "application/vnd.dpgraph", - "dfac": "application/vnd.dreamfactory", - "ait": "application/vnd.dvb.ait", - "svc": "application/vnd.dvb.service", - "geo": "application/vnd.dynageo", - "mag": "application/vnd.ecowin.chart", - "nml": "application/vnd.enliven", - "esf": "application/vnd.epson.esf", - "msf": "application/vnd.epson.msf", - "qam": "application/vnd.epson.quickanime", - "slt": "application/vnd.epson.salt", - "ssf": "application/vnd.epson.ssf", - "es3": "application/vnd.eszigno3+xml", - "et3": "application/vnd.eszigno3+xml", - "ez2": "application/vnd.ezpix-album", - "ez3": "application/vnd.ezpix-package", - "fdf": "application/vnd.fdf", - "mseed": "application/vnd.fdsn.mseed", - "seed": "application/vnd.fdsn.seed", - "dataless": "application/vnd.fdsn.seed", - "gph": "application/vnd.flographit", - "ftc": "application/vnd.fluxtime.clip", - "fm": "application/vnd.framemaker", - "frame": "application/vnd.framemaker", - "maker": "application/vnd.framemaker", - "book": "application/vnd.framemaker", - "fnc": "application/vnd.frogans.fnc", - "ltf": "application/vnd.frogans.ltf", - "fsc": "application/vnd.fsc.weblaunch", - "oas": "application/vnd.fujitsu.oasys", - "oa2": "application/vnd.fujitsu.oasys2", - "oa3": "application/vnd.fujitsu.oasys3", - "fg5": "application/vnd.fujitsu.oasysgp", - "bh2": "application/vnd.fujitsu.oasysprs", - "ddd": "application/vnd.fujixerox.ddd", - "xdw": "application/vnd.fujixerox.docuworks", - "xbd": "application/vnd.fujixerox.docuworks.binder", - "fzs": "application/vnd.fuzzysheet", - "txd": "application/vnd.genomatix.tuxedo", - "ggb": "application/vnd.geogebra.file", - "ggt": "application/vnd.geogebra.tool", - "gex": "application/vnd.geometry-explorer", - "gre": "application/vnd.geometry-explorer", - "gxt": "application/vnd.geonext", - "g2w": "application/vnd.geoplan", - "g3w": "application/vnd.geospace", - "gmx": "application/vnd.gmx", - "kml": "application/vnd.google-earth.kml+xml", - "kmz": "application/vnd.google-earth.kmz", - "gqf": "application/vnd.grafeq", - "gqs": "application/vnd.grafeq", - "gac": "application/vnd.groove-account", - "ghf": "application/vnd.groove-help", - "gim": "application/vnd.groove-identity-message", - "grv": "application/vnd.groove-injector", - "gtm": "application/vnd.groove-tool-message", - "tpl": "application/vnd.groove-tool-template", - "vcg": "application/vnd.groove-vcard", - "hal": "application/vnd.hal+xml", - "zmm": "application/vnd.handheld-entertainment+xml", - "hbci": "application/vnd.hbci", - "les": "application/vnd.hhe.lesson-player", - "hpgl": "application/vnd.hp-hpgl", - "hpid": "application/vnd.hp-hpid", - "hps": "application/vnd.hp-hps", - "jlt": "application/vnd.hp-jlyt", - "pcl": "application/vnd.hp-pcl", - "pclxl": "application/vnd.hp-pclxl", - "sfd-hdstx": "application/vnd.hydrostatix.sof-data", - "x3d": "application/vnd.hzn-3d-crossword", - "mpy": "application/vnd.ibm.minipay", - "afp": "application/vnd.ibm.modcap", - "listafp": "application/vnd.ibm.modcap", - "list3820": "application/vnd.ibm.modcap", - "irm": "application/vnd.ibm.rights-management", - "sc": "application/vnd.ibm.secure-container", - "icc": "application/vnd.iccprofile", - "icm": "application/vnd.iccprofile", - "igl": "application/vnd.igloader", - "ivp": "application/vnd.immervision-ivp", - "ivu": "application/vnd.immervision-ivu", - "igm": "application/vnd.insors.igm", - "xpw": "application/vnd.intercon.formnet", - "xpx": "application/vnd.intercon.formnet", - "i2g": "application/vnd.intergeo", - "qbo": "application/vnd.intu.qbo", - "qfx": "application/vnd.intu.qfx", - "rcprofile": "application/vnd.ipunplugged.rcprofile", - "irp": "application/vnd.irepository.package+xml", - "xpr": "application/vnd.is-xpr", - "fcs": "application/vnd.isac.fcs", - "jam": "application/vnd.jam", - "rms": "application/vnd.jcp.javame.midlet-rms", - "jisp": "application/vnd.jisp", - "joda": "application/vnd.joost.joda-archive", - "ktz": "application/vnd.kahootz", - "ktr": "application/vnd.kahootz", - "karbon": "application/vnd.kde.karbon", - "chrt": "application/vnd.kde.kchart", - "kfo": "application/vnd.kde.kformula", - "flw": "application/vnd.kde.kivio", - "kon": "application/vnd.kde.kontour", - "kpr": "application/vnd.kde.kpresenter", - "kpt": "application/vnd.kde.kpresenter", - "ksp": "application/vnd.kde.kspread", - "kwd": "application/vnd.kde.kword", - "kwt": "application/vnd.kde.kword", - "htke": "application/vnd.kenameaapp", - "kia": "application/vnd.kidspiration", - "kne": "application/vnd.kinar", - "knp": "application/vnd.kinar", - "skp": "application/vnd.koan", - "skd": "application/vnd.koan", - "skt": "application/vnd.koan", - "skm": "application/vnd.koan", - "sse": "application/vnd.kodak-descriptor", - "lasxml": "application/vnd.las.las+xml", - "lbd": "application/vnd.llamagraphics.life-balance.desktop", - "lbe": "application/vnd.llamagraphics.life-balance.exchange+xml", - "apr": "application/vnd.lotus-approach", - "pre": "application/vnd.lotus-freelance", - "nsf": "application/vnd.lotus-notes", - "org": "application/vnd.lotus-organizer", - "scm": "application/vnd.lotus-screencam", - "lwp": "application/vnd.lotus-wordpro", - "portpkg": "application/vnd.macports.portpkg", - "mcd": "application/vnd.mcd", - "mc1": "application/vnd.medcalcdata", - "cdkey": "application/vnd.mediastation.cdkey", - "mwf": "application/vnd.mfer", - "mfm": "application/vnd.mfmp", - "flo": "application/vnd.micrografx.flo", - "igx": "application/vnd.micrografx.igx", - "mif": "application/vnd.mif", - "daf": "application/vnd.mobius.daf", - "dis": "application/vnd.mobius.dis", - "mbk": "application/vnd.mobius.mbk", - "mqy": "application/vnd.mobius.mqy", - "msl": "application/vnd.mobius.msl", - "plc": "application/vnd.mobius.plc", - "txf": "application/vnd.mobius.txf", - "mpn": "application/vnd.mophun.application", - "mpc": "application/vnd.mophun.certificate", - "xul": "application/vnd.mozilla.xul+xml", - "cil": "application/vnd.ms-artgalry", - "cab": "application/vnd.ms-cab-compressed", - "xls": "application/vnd.ms-excel", - "xlm": "application/vnd.ms-excel", - "xla": "application/vnd.ms-excel", - "xlc": "application/vnd.ms-excel", - "xlt": "application/vnd.ms-excel", - "xlw": "application/vnd.ms-excel", - "xlam": "application/vnd.ms-excel.addin.macroenabled.12", - "xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12", - "xlsm": "application/vnd.ms-excel.sheet.macroenabled.12", - "xltm": "application/vnd.ms-excel.template.macroenabled.12", - "eot": "application/vnd.ms-fontobject", - "chm": "application/vnd.ms-htmlhelp", - "ims": "application/vnd.ms-ims", - "lrm": "application/vnd.ms-lrm", - "thmx": "application/vnd.ms-officetheme", - "cat": "application/vnd.ms-pki.seccat", - "stl": "application/vnd.ms-pki.stl", - "ppt": "application/vnd.ms-powerpoint", - "pps": "application/vnd.ms-powerpoint", - "pot": "application/vnd.ms-powerpoint", - "ppam": "application/vnd.ms-powerpoint.addin.macroenabled.12", - "pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12", - "sldm": "application/vnd.ms-powerpoint.slide.macroenabled.12", - "ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12", - "potm": "application/vnd.ms-powerpoint.template.macroenabled.12", - "mpp": "application/vnd.ms-project", - "mpt": "application/vnd.ms-project", - "docm": "application/vnd.ms-word.document.macroenabled.12", - "dotm": "application/vnd.ms-word.template.macroenabled.12", - "wps": "application/vnd.ms-works", - "wks": "application/vnd.ms-works", - "wcm": "application/vnd.ms-works", - "wdb": "application/vnd.ms-works", - "wpl": "application/vnd.ms-wpl", - "xps": "application/vnd.ms-xpsdocument", - "mseq": "application/vnd.mseq", - "mus": "application/vnd.musician", - "msty": "application/vnd.muvee.style", - "taglet": "application/vnd.mynfc", - "nlu": "application/vnd.neurolanguage.nlu", - "nnd": "application/vnd.noblenet-directory", - "nns": "application/vnd.noblenet-sealer", - "nnw": "application/vnd.noblenet-web", - "ngdat": "application/vnd.nokia.n-gage.data", - "n-gage": "application/vnd.nokia.n-gage.symbian.install", - "rpst": "application/vnd.nokia.radio-preset", - "rpss": "application/vnd.nokia.radio-presets", - "edm": "application/vnd.novadigm.edm", - "edx": "application/vnd.novadigm.edx", - "ext": "application/vnd.novadigm.ext", - "odc": "application/vnd.oasis.opendocument.chart", - "otc": "application/vnd.oasis.opendocument.chart-template", - "odb": "application/vnd.oasis.opendocument.database", - "odf": "application/vnd.oasis.opendocument.formula", - "odft": "application/vnd.oasis.opendocument.formula-template", - "odg": "application/vnd.oasis.opendocument.graphics", - "otg": "application/vnd.oasis.opendocument.graphics-template", - "odi": "application/vnd.oasis.opendocument.image", - "oti": "application/vnd.oasis.opendocument.image-template", - "odp": "application/vnd.oasis.opendocument.presentation", - "otp": "application/vnd.oasis.opendocument.presentation-template", - "ods": "application/vnd.oasis.opendocument.spreadsheet", - "ots": "application/vnd.oasis.opendocument.spreadsheet-template", - "odt": "application/vnd.oasis.opendocument.text", - "odm": "application/vnd.oasis.opendocument.text-master", - "ott": "application/vnd.oasis.opendocument.text-template", - "oth": "application/vnd.oasis.opendocument.text-web", - "xo": "application/vnd.olpc-sugar", - "dd2": "application/vnd.oma.dd2+xml", - "oxt": "application/vnd.openofficeorg.extension", - "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", - "sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide", - "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow", - "potx": "application/vnd.openxmlformats-officedocument.presentationml.template", - "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template", - "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template", - "mgp": "application/vnd.osgeo.mapguide.package", - "dp": "application/vnd.osgi.dp", - "pdb": "application/vnd.palm", - "pqa": "application/vnd.palm", - "oprc": "application/vnd.palm", - "paw": "application/vnd.pawaafile", - "str": "application/vnd.pg.format", - "ei6": "application/vnd.pg.osasli", - "efif": "application/vnd.picsel", - "wg": "application/vnd.pmi.widget", - "plf": "application/vnd.pocketlearn", - "pbd": "application/vnd.powerbuilder6", - "box": "application/vnd.previewsystems.box", - "mgz": "application/vnd.proteus.magazine", - "qps": "application/vnd.publishare-delta-tree", - "ptid": "application/vnd.pvi.ptid1", - "qxd": "application/vnd.quark.quarkxpress", - "qxt": "application/vnd.quark.quarkxpress", - "qwd": "application/vnd.quark.quarkxpress", - "qwt": "application/vnd.quark.quarkxpress", - "qxl": "application/vnd.quark.quarkxpress", - "qxb": "application/vnd.quark.quarkxpress", - "bed": "application/vnd.realvnc.bed", - "mxl": "application/vnd.recordare.musicxml", - "musicxml": "application/vnd.recordare.musicxml+xml", - "cryptonote": "application/vnd.rig.cryptonote", - "cod": "application/vnd.rim.cod", - "rm": "application/vnd.rn-realmedia", - "link66": "application/vnd.route66.link66+xml", - "st": "application/vnd.sailingtracker.track", - "see": "application/vnd.seemail", - "sema": "application/vnd.sema", - "semd": "application/vnd.semd", - "semf": "application/vnd.semf", - "ifm": "application/vnd.shana.informed.formdata", - "itp": "application/vnd.shana.informed.formtemplate", - "iif": "application/vnd.shana.informed.interchange", - "ipk": "application/vnd.shana.informed.package", - "twd": "application/vnd.simtech-mindmapper", - "twds": "application/vnd.simtech-mindmapper", - "mmf": "application/vnd.smaf", - "teacher": "application/vnd.smart.teacher", - "sdkm": "application/vnd.solent.sdkm+xml", - "sdkd": "application/vnd.solent.sdkm+xml", - "dxp": "application/vnd.spotfire.dxp", - "sfs": "application/vnd.spotfire.sfs", - "sdc": "application/vnd.stardivision.calc", - "sda": "application/vnd.stardivision.draw", - "sdd": "application/vnd.stardivision.impress", - "smf": "application/vnd.stardivision.math", - "sdw": "application/vnd.stardivision.writer", - "vor": "application/vnd.stardivision.writer", - "sgl": "application/vnd.stardivision.writer-global", - "smzip": "application/vnd.stepmania.package", - "sm": "application/vnd.stepmania.stepchart", - "sxc": "application/vnd.sun.xml.calc", - "stc": "application/vnd.sun.xml.calc.template", - "sxd": "application/vnd.sun.xml.draw", - "std": "application/vnd.sun.xml.draw.template", - "sxi": "application/vnd.sun.xml.impress", - "sti": "application/vnd.sun.xml.impress.template", - "sxm": "application/vnd.sun.xml.math", - "sxw": "application/vnd.sun.xml.writer", - "sxg": "application/vnd.sun.xml.writer.global", - "stw": "application/vnd.sun.xml.writer.template", - "sus": "application/vnd.sus-calendar", - "susp": "application/vnd.sus-calendar", - "svd": "application/vnd.svd", - "sis": "application/vnd.symbian.install", - "sisx": "application/vnd.symbian.install", - "xsm": "application/vnd.syncml+xml", - "bdm": "application/vnd.syncml.dm+wbxml", - "xdm": "application/vnd.syncml.dm+xml", - "tao": "application/vnd.tao.intent-module-archive", - "pcap": "application/vnd.tcpdump.pcap", - "cap": "application/vnd.tcpdump.pcap", - "dmp": "application/vnd.tcpdump.pcap", - "tmo": "application/vnd.tmobile-livetv", - "tpt": "application/vnd.trid.tpt", - "mxs": "application/vnd.triscape.mxs", - "tra": "application/vnd.trueapp", - "ufd": "application/vnd.ufdl", - "ufdl": "application/vnd.ufdl", - "utz": "application/vnd.uiq.theme", - "umj": "application/vnd.umajin", - "unityweb": "application/vnd.unity", - "uoml": "application/vnd.uoml+xml", - "vcx": "application/vnd.vcx", - "vsd": "application/vnd.visio", - "vst": "application/vnd.visio", - "vss": "application/vnd.visio", - "vsw": "application/vnd.visio", - "vis": "application/vnd.visionary", - "vsf": "application/vnd.vsf", - "wbxml": "application/vnd.wap.wbxml", - "wmlc": "application/vnd.wap.wmlc", - "wmlsc": "application/vnd.wap.wmlscriptc", - "wtb": "application/vnd.webturbo", - "nbp": "application/vnd.wolfram.player", - "wpd": "application/vnd.wordperfect", - "wqd": "application/vnd.wqd", - "stf": "application/vnd.wt.stf", - "xar": "application/vnd.xara", - "xfdl": "application/vnd.xfdl", - "hvd": "application/vnd.yamaha.hv-dic", - "hvs": "application/vnd.yamaha.hv-script", - "hvp": "application/vnd.yamaha.hv-voice", - "osf": "application/vnd.yamaha.openscoreformat", - "osfpvg": "application/vnd.yamaha.openscoreformat.osfpvg+xml", - "saf": "application/vnd.yamaha.smaf-audio", - "spf": "application/vnd.yamaha.smaf-phrase", - "cmp": "application/vnd.yellowriver-custom-menu", - "zir": "application/vnd.zul", - "zirz": "application/vnd.zul", - "zaz": "application/vnd.zzazz.deck+xml", - "vxml": "application/voicexml+xml", - "wgt": "application/widget", - "hlp": "application/winhlp", - "wsdl": "application/wsdl+xml", - "wspolicy": "application/wspolicy+xml", - "7z": "application/x-7z-compressed", - "abw": "application/x-abiword", - "ace": "application/x-ace-compressed", - "aab": "application/x-authorware-bin", - "x32": "application/x-authorware-bin", - "u32": "application/x-authorware-bin", - "vox": "application/x-authorware-bin", - "aam": "application/x-authorware-map", - "aas": "application/x-authorware-seg", - "bcpio": "application/x-bcpio", - "torrent": "application/x-bittorrent", - "bz": "application/x-bzip", - "bz2": "application/x-bzip2", - "boz": "application/x-bzip2", - "vcd": "application/x-cdlink", - "chat": "application/x-chat", - "pgn": "application/x-chess-pgn", - "cpio": "application/x-cpio", - "csh": "application/x-csh", - "deb": "application/x-debian-package", - "udeb": "application/x-debian-package", - "dir": "application/x-director", - "dcr": "application/x-director", - "dxr": "application/x-director", - "cst": "application/x-director", - "cct": "application/x-director", - "cxt": "application/x-director", - "w3d": "application/x-director", - "fgd": "application/x-director", - "swa": "application/x-director", - "wad": "application/x-doom", - "ncx": "application/x-dtbncx+xml", - "dtb": "application/x-dtbook+xml", - "res": "application/x-dtbresource+xml", - "dvi": "application/x-dvi", - "bdf": "application/x-font-bdf", - "gsf": "application/x-font-ghostscript", - "psf": "application/x-font-linux-psf", - "otf": "application/x-font-otf", - "pcf": "application/x-font-pcf", - "snf": "application/x-font-snf", - "ttf": "application/x-font-ttf", - "ttc": "application/x-font-ttf", - "pfa": "application/x-font-type1", - "pfb": "application/x-font-type1", - "pfm": "application/x-font-type1", - "afm": "application/x-font-type1", - "woff": "application/x-font-woff", - "spl": "application/x-futuresplash", - "gnumeric": "application/x-gnumeric", - "gtar": "application/x-gtar", - "hdf": "application/x-hdf", - "jnlp": "application/x-java-jnlp-file", - "latex": "application/x-latex", - "prc": "application/x-mobipocket-ebook", - "mobi": "application/x-mobipocket-ebook", - "application": "application/x-ms-application", - "wmd": "application/x-ms-wmd", - "wmz": "application/x-ms-wmz", - "xbap": "application/x-ms-xbap", - "mdb": "application/x-msaccess", - "obd": "application/x-msbinder", - "crd": "application/x-mscardfile", - "clp": "application/x-msclip", - "exe": "application/x-msdownload", - "dll": "application/x-msdownload", - "com": "application/x-msdownload", - "bat": "application/x-msdownload", - "msi": "application/x-msdownload", - "mvb": "application/x-msmediaview", - "m13": "application/x-msmediaview", - "m14": "application/x-msmediaview", - "wmf": "application/x-msmetafile", - "mny": "application/x-msmoney", - "pub": "application/x-mspublisher", - "scd": "application/x-msschedule", - "trm": "application/x-msterminal", - "wri": "application/x-mswrite", - "nc": "application/x-netcdf", - "cdf": "application/x-netcdf", - "p12": "application/x-pkcs12", - "pfx": "application/x-pkcs12", - "p7b": "application/x-pkcs7-certificates", - "spc": "application/x-pkcs7-certificates", - "p7r": "application/x-pkcs7-certreqresp", - "rar": "application/x-rar-compressed", - "sh": "application/x-sh", - "shar": "application/x-shar", - "swf": "application/x-shockwave-flash", - "xap": "application/x-silverlight-app", - "sit": "application/x-stuffit", - "sitx": "application/x-stuffitx", - "sv4cpio": "application/x-sv4cpio", - "sv4crc": "application/x-sv4crc", - "tar": "application/x-tar", - "tcl": "application/x-tcl", - "tex": "application/x-tex", - "tfm": "application/x-tex-tfm", - "texinfo": "application/x-texinfo", - "texi": "application/x-texinfo", - "ustar": "application/x-ustar", - "src": "application/x-wais-source", - "der": "application/x-x509-ca-cert", - "crt": "application/x-x509-ca-cert", - "fig": "application/x-xfig", - "xpi": "application/x-xpinstall", - "xdf": "application/xcap-diff+xml", - "xenc": "application/xenc+xml", - "xhtml": "application/xhtml+xml", - "xht": "application/xhtml+xml", - "xml": "application/xml", - "xsl": "application/xml", - "dtd": "application/xml-dtd", - "xop": "application/xop+xml", - "xslt": "application/xslt+xml", - "xspf": "application/xspf+xml", - "mxml": "application/xv+xml", - "xhvml": "application/xv+xml", - "xvml": "application/xv+xml", - "xvm": "application/xv+xml", - "yang": "application/yang", - "yin": "application/yin+xml", - "zip": "application/zip", - "adp": "audio/adpcm", - "au": "audio/basic", - "snd": "audio/basic", - "mid": "audio/midi", - "midi": "audio/midi", - "kar": "audio/midi", - "rmi": "audio/midi", - "mp4a": "audio/mp4", - "mpga": "audio/mpeg", - "mp2": "audio/mpeg", - "mp2a": "audio/mpeg", - "mp3": "audio/mpeg", - "m2a": "audio/mpeg", - "m3a": "audio/mpeg", - "oga": "audio/ogg", - "ogg": "audio/ogg", - "spx": "audio/ogg", - "uva": "audio/vnd.dece.audio", - "uvva": "audio/vnd.dece.audio", - "eol": "audio/vnd.digital-winds", - "dra": "audio/vnd.dra", - "dts": "audio/vnd.dts", - "dtshd": "audio/vnd.dts.hd", - "lvp": "audio/vnd.lucent.voice", - "pya": "audio/vnd.ms-playready.media.pya", - "ecelp4800": "audio/vnd.nuera.ecelp4800", - "ecelp7470": "audio/vnd.nuera.ecelp7470", - "ecelp9600": "audio/vnd.nuera.ecelp9600", - "rip": "audio/vnd.rip", - "weba": "audio/webm", - "aac": "audio/x-aac", - "aif": "audio/x-aiff", - "aiff": "audio/x-aiff", - "aifc": "audio/x-aiff", - "m3u": "audio/x-mpegurl", - "wax": "audio/x-ms-wax", - "wma": "audio/x-ms-wma", - "ram": "audio/x-pn-realaudio", - "ra": "audio/x-pn-realaudio", - "rmp": "audio/x-pn-realaudio-plugin", - "wav": "audio/x-wav", - "cdx": "chemical/x-cdx", - "cif": "chemical/x-cif", - "cmdf": "chemical/x-cmdf", - "cml": "chemical/x-cml", - "csml": "chemical/x-csml", - "xyz": "chemical/x-xyz", - "bmp": "image/bmp", - "cgm": "image/cgm", - "g3": "image/g3fax", - "gif": "image/gif", - "ief": "image/ief", - "jpeg": "image/jpeg", - "jpg": "image/jpeg", - "jpe": "image/jpeg", - "ktx": "image/ktx", - "png": "image/png", - "btif": "image/prs.btif", - "svg": "image/svg+xml", - "svgz": "image/svg+xml", - "tiff": "image/tiff", - "tif": "image/tiff", - "psd": "image/vnd.adobe.photoshop", - "uvi": "image/vnd.dece.graphic", - "uvvi": "image/vnd.dece.graphic", - "uvg": "image/vnd.dece.graphic", - "uvvg": "image/vnd.dece.graphic", - "sub": "text/vnd.dvb.subtitle", - "djvu": "image/vnd.djvu", - "djv": "image/vnd.djvu", - "dwg": "image/vnd.dwg", - "dxf": "image/vnd.dxf", - "fbs": "image/vnd.fastbidsheet", - "fpx": "image/vnd.fpx", - "fst": "image/vnd.fst", - "mmr": "image/vnd.fujixerox.edmics-mmr", - "rlc": "image/vnd.fujixerox.edmics-rlc", - "mdi": "image/vnd.ms-modi", - "npx": "image/vnd.net-fpx", - "wbmp": "image/vnd.wap.wbmp", - "xif": "image/vnd.xiff", - "webp": "image/webp", - "ras": "image/x-cmu-raster", - "cmx": "image/x-cmx", - "fh": "image/x-freehand", - "fhc": "image/x-freehand", - "fh4": "image/x-freehand", - "fh5": "image/x-freehand", - "fh7": "image/x-freehand", - "ico": "image/x-icon", - "pcx": "image/x-pcx", - "pic": "image/x-pict", - "pct": "image/x-pict", - "pnm": "image/x-portable-anymap", - "pbm": "image/x-portable-bitmap", - "pgm": "image/x-portable-graymap", - "ppm": "image/x-portable-pixmap", - "rgb": "image/x-rgb", - "xbm": "image/x-xbitmap", - "xpm": "image/x-xpixmap", - "xwd": "image/x-xwindowdump", - "eml": "message/rfc822", - "mime": "message/rfc822", - "igs": "model/iges", - "iges": "model/iges", - "msh": "model/mesh", - "mesh": "model/mesh", - "silo": "model/mesh", - "dae": "model/vnd.collada+xml", - "dwf": "model/vnd.dwf", - "gdl": "model/vnd.gdl", - "gtw": "model/vnd.gtw", - "mts": "model/vnd.mts", - "vtu": "model/vnd.vtu", - "wrl": "model/vrml", - "vrml": "model/vrml", - "ics": "text/calendar", - "ifb": "text/calendar", - "css": "text/css", - "csv": "text/csv", - "html": "text/html", - "htm": "text/html", - "n3": "text/n3", - "txt": "text/plain", - "text": "text/plain", - "conf": "text/plain", - "def": "text/plain", - "list": "text/plain", - "log": "text/plain", - "in": "text/plain", - "dsc": "text/prs.lines.tag", - "rtx": "text/richtext", - "sgml": "text/sgml", - "sgm": "text/sgml", - "tsv": "text/tab-separated-values", - "t": "text/troff", - "tr": "text/troff", - "roff": "text/troff", - "man": "text/troff", - "me": "text/troff", - "ms": "text/troff", - "ttl": "text/turtle", - "uri": "text/uri-list", - "uris": "text/uri-list", - "urls": "text/uri-list", - "vcard": "text/vcard", - "curl": "text/vnd.curl", - "dcurl": "text/vnd.curl.dcurl", - "scurl": "text/vnd.curl.scurl", - "mcurl": "text/vnd.curl.mcurl", - "fly": "text/vnd.fly", - "flx": "text/vnd.fmi.flexstor", - "gv": "text/vnd.graphviz", - "3dml": "text/vnd.in3d.3dml", - "spot": "text/vnd.in3d.spot", - "jad": "text/vnd.sun.j2me.app-descriptor", - "wml": "text/vnd.wap.wml", - "wmls": "text/vnd.wap.wmlscript", - "s": "text/x-asm", - "asm": "text/x-asm", - "c": "text/x-c", - "cc": "text/x-c", - "cxx": "text/x-c", - "cpp": "text/x-c", - "h": "text/x-c", - "hh": "text/x-c", - "dic": "text/x-c", - "f": "text/x-fortran", - "for": "text/x-fortran", - "f77": "text/x-fortran", - "f90": "text/x-fortran", - "p": "text/x-pascal", - "pas": "text/x-pascal", - "java": "text/x-java-source", - "etx": "text/x-setext", - "uu": "text/x-uuencode", - "vcs": "text/x-vcalendar", - "vcf": "text/x-vcard", - "3gp": "video/3gpp", - "3g2": "video/3gpp2", - "h261": "video/h261", - "h263": "video/h263", - "h264": "video/h264", - "jpgv": "video/jpeg", - "jpm": "video/jpm", - "jpgm": "video/jpm", - "mj2": "video/mj2", - "mjp2": "video/mj2", - "mp4": "video/mp4", - "mp4v": "video/mp4", - "mpg4": "video/mp4", - "mpeg": "video/mpeg", - "mpg": "video/mpeg", - "mpe": "video/mpeg", - "m1v": "video/mpeg", - "m2v": "video/mpeg", - "ogv": "video/ogg", - "qt": "video/quicktime", - "mov": "video/quicktime", - "uvh": "video/vnd.dece.hd", - "uvvh": "video/vnd.dece.hd", - "uvm": "video/vnd.dece.mobile", - "uvvm": "video/vnd.dece.mobile", - "uvp": "video/vnd.dece.pd", - "uvvp": "video/vnd.dece.pd", - "uvs": "video/vnd.dece.sd", - "uvvs": "video/vnd.dece.sd", - "uvv": "video/vnd.dece.video", - "uvvv": "video/vnd.dece.video", - "dvb": "video/vnd.dvb.file", - "fvt": "video/vnd.fvt", - "mxu": "video/vnd.mpegurl", - "m4u": "video/vnd.mpegurl", - "pyv": "video/vnd.ms-playready.media.pyv", - "uvu": "video/vnd.uvvu.mp4", - "uvvu": "video/vnd.uvvu.mp4", - "viv": "video/vnd.vivo", - "webm": "video/webm", - "f4v": "video/x-f4v", - "fli": "video/x-fli", - "flv": "video/x-flv", - "m4v": "video/x-m4v", - "asf": "video/x-ms-asf", - "asx": "video/x-ms-asf", - "wm": "video/x-ms-wm", - "wmv": "video/x-ms-wmv", - "wmx": "video/x-ms-wmx", - "wvx": "video/x-ms-wvx", - "avi": "video/x-msvideo", - "movie": "video/x-sgi-movie", - "ice": "x-conference/x-cooltalk" -}; \ No newline at end of file diff --git a/websvr/test/lib/mime.js b/websvr/test/lib/mime.js deleted file mode 100644 index 28dcbfe..0000000 --- a/websvr/test/lib/mime.js +++ /dev/null @@ -1,93 +0,0 @@ -var path = require('path'), - fs = require('fs'); - -var mime = module.exports = { - // Map of extension to mime type - types: Object.create(null), - - // Map of mime type to extension - extensions :Object.create(null), - - /** - * Define mimetype -> extension mappings. Each key is a mime-type that maps - * to an array of extensions associated with the type. The first extension is - * used as the default extension for the type. - * - * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); - * - * @param map (Object) type definitions - */ - define: function(map) { - for (var type in map) { - var exts = map[type]; - - for (var i = 0; i < exts.length; i++) { - mime.types[exts[i]] = type; - } - - // Default extension is the first one we encounter - if (!mime.extensions[type]) { - mime.extensions[type] = exts[0]; - } - } - }, - - /** - * Load an Apache2-style ".types" file - * - * This may be called multiple times (it's expected). Where files declare - * overlapping types/extensions, the last file wins. - * - * @param file (String) path of file to load. - */ - load: function(file) { - // Read file and split into lines - var map = {}, - content = fs.readFileSync(file, 'ascii'), - lines = content.split(/[\r\n]+/); - - lines.forEach(function(line, lineno) { - // Clean up whitespace/comments, and split into fields - var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); - map[fields.shift()] = fields; - }); - - mime.define(map); - }, - - /** - * Lookup a mime type based on extension - */ - lookup: function(path, fallback) { - var ext = path.replace(/.*[\.\/]/, '').toLowerCase(); - - return mime.types[ext] || fallback || mime.default_type - }, - - /** - * Return file extension associated with a mime type - */ - extension: function(mimeType) { - return mime.extensions[mimeType]; - }, - - /** - * Lookup a charset based on mime type. - */ - charsets: { - lookup: function (mimeType, fallback) { - // Assume text types are utf8. Modify mime logic as needed. - return (/^text\//).test(mimeType) ? 'UTF-8' : fallback; - } - } -}; - -// Load our local copy of -// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types -mime.load(path.join(__dirname, 'types/mime.types')); - -// Overlay enhancements submitted by the node.js community -mime.load(path.join(__dirname, 'types/node.types')); - -// Set the default type -mime.default_type = mime.types.bin; diff --git a/websvr/test/lib/test.js b/websvr/test/lib/test.js deleted file mode 100644 index 6678a12..0000000 --- a/websvr/test/lib/test.js +++ /dev/null @@ -1,22 +0,0 @@ -//Test method -var os = require("os"); - -var test = module.exports = function(msg, func, repeat) { - - var t1 = new Date(), - m1 = os.freemem(); - - repeat = repeat || 1000000; - - for (var i = 0; i < repeat; i++) { - func(); - } - - var t2 = new Date(), - m2 = os.freemem(); - - console.log("\r\n" + msg); - console.log(" time used:", t2 - t1); - console.log(" memo used:", m1 - m2); - -}; \ No newline at end of file diff --git a/websvr/test/lib/types.js b/websvr/test/lib/types.js deleted file mode 100644 index ddb92ee..0000000 --- a/websvr/test/lib/types.js +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env node -/* -Pickup mime type from mime.types files (node-mime); -*/ -var fs = require("fs"), - types = "./types/mime.types"; - -//remove the space/tab/comments -var readLines = function(trunk) { - var lines = []; - - //format the EOL, keep the same with (win & linux) - var body = trunk.toString().replace('\r', ''); - - //remove comments: /* comthing */ - //body = body.replace(/\/\*.*\*\//g, ''); - body.split('\n').forEach(function(line) { - lines.push(line.trim()); - }); - - return lines; -}; - -var pickup = function(lines) { - - var result = {}; - - lines.forEach(function(line, idx) { - // - if (line[0] != '#') { - - //pickup values in attribute - var pair = line.split(/[ \t]+/), - l = pair.length; - - if (l > 1 && pair[0]) { - for (var i = 1; i < l; i++) { - pair[i] && ( result[pair[i]] = pair[0] ); - } - }; - } - }); - - fs.writeFileSync("MIMETYPES.js", "var MIMETYPES = module.exports = " + JSON.stringify(result, null, ' ') + ';'); -}; - -fs.readFile(types, function(err, trunk) { - if (err) throw err; - - var lines = readLines(trunk); - pickup(lines); -}); \ No newline at end of file diff --git a/websvr/test/lib/types/mime.types b/websvr/test/lib/types/mime.types deleted file mode 100644 index cf9dbe8..0000000 --- a/websvr/test/lib/types/mime.types +++ /dev/null @@ -1,1510 +0,0 @@ -# This file maps Internet media types to unique file extension(s). -# Although created for httpd, this file is used by many software systems -# and has been placed in the public domain for unlimited redisribution. -# -# The table below contains both registered and (common) unregistered types. -# A type that has no unique extension can be ignored -- they are listed -# here to guide configurations toward known types and to make it easier to -# identify "new" types. File extensions are also commonly used to indicate -# content languages and encodings, so choose them carefully. -# -# Internet media types should be registered as described in RFC 4288. -# The registry is at . -# -# MIME type (lowercased) Extensions -# ============================================ ========== -# application/1d-interleaved-parityfec -# application/3gpp-ims+xml -# application/activemessage -application/andrew-inset ez -# application/applefile -application/applixware aw -application/atom+xml atom -application/atomcat+xml atomcat -# application/atomicmail -application/atomsvc+xml atomsvc -# application/auth-policy+xml -# application/batch-smtp -# application/beep+xml -# application/calendar+xml -# application/cals-1840 -# application/ccmp+xml -application/ccxml+xml ccxml -application/cdmi-capability cdmia -application/cdmi-container cdmic -application/cdmi-domain cdmid -application/cdmi-object cdmio -application/cdmi-queue cdmiq -# application/cea-2018+xml -# application/cellml+xml -# application/cfw -# application/cnrp+xml -# application/commonground -# application/conference-info+xml -# application/cpl+xml -# application/csta+xml -# application/cstadata+xml -application/cu-seeme cu -# application/cybercash -application/davmount+xml davmount -# application/dca-rft -# application/dec-dx -# application/dialog-info+xml -# application/dicom -# application/dns -# application/dskpp+xml -application/dssc+der dssc -application/dssc+xml xdssc -# application/dvcs -application/ecmascript ecma -# application/edi-consent -# application/edi-x12 -# application/edifact -application/emma+xml emma -# application/epp+xml -application/epub+zip epub -# application/eshop -# application/example -application/exi exi -# application/fastinfoset -# application/fastsoap -# application/fits -application/font-tdpfr pfr -# application/framework-attributes+xml -# application/h224 -# application/held+xml -# application/http -application/hyperstudio stk -# application/ibe-key-request+xml -# application/ibe-pkg-reply+xml -# application/ibe-pp-data -# application/iges -# application/im-iscomposing+xml -# application/index -# application/index.cmd -# application/index.obj -# application/index.response -# application/index.vnd -application/inkml+xml ink inkml -# application/iotp -application/ipfix ipfix -# application/ipp -# application/isup -application/java-archive jar -application/java-serialized-object ser -application/java-vm class -application/javascript js -application/json json -# application/kpml-request+xml -# application/kpml-response+xml -application/lost+xml lostxml -application/mac-binhex40 hqx -application/mac-compactpro cpt -# application/macwriteii -application/mads+xml mads -application/marc mrc -application/marcxml+xml mrcx -application/mathematica ma nb mb -# application/mathml-content+xml -# application/mathml-presentation+xml -application/mathml+xml mathml -# application/mbms-associated-procedure-description+xml -# application/mbms-deregister+xml -# application/mbms-envelope+xml -# application/mbms-msk+xml -# application/mbms-msk-response+xml -# application/mbms-protection-description+xml -# application/mbms-reception-report+xml -# application/mbms-register+xml -# application/mbms-register-response+xml -# application/mbms-user-service-description+xml -application/mbox mbox -# application/media_control+xml -application/mediaservercontrol+xml mscml -application/metalink4+xml meta4 -application/mets+xml mets -# application/mikey -application/mods+xml mods -# application/moss-keys -# application/moss-signature -# application/mosskey-data -# application/mosskey-request -application/mp21 m21 mp21 -application/mp4 mp4s -# application/mpeg4-generic -# application/mpeg4-iod -# application/mpeg4-iod-xmt -# application/msc-ivr+xml -# application/msc-mixer+xml -application/msword doc dot -application/mxf mxf -# application/nasdata -# application/news-checkgroups -# application/news-groupinfo -# application/news-transmission -# application/nss -# application/ocsp-request -# application/ocsp-response -application/octet-stream bin dms lha lrf lzh so iso dmg dist distz pkg bpk dump elc deploy -application/oda oda -application/oebps-package+xml opf -application/ogg ogx -application/onenote onetoc onetoc2 onetmp onepkg -application/oxps oxps -# application/parityfec -application/patch-ops-error+xml xer -application/pdf pdf -application/pgp-encrypted pgp -# application/pgp-keys -application/pgp-signature asc sig -application/pics-rules prf -# application/pidf+xml -# application/pidf-diff+xml -application/pkcs10 p10 -application/pkcs7-mime p7m p7c -application/pkcs7-signature p7s -application/pkcs8 p8 -application/pkix-attr-cert ac -application/pkix-cert cer -application/pkix-crl crl -application/pkix-pkipath pkipath -application/pkixcmp pki -application/pls+xml pls -# application/poc-settings+xml -application/postscript ai eps ps -# application/prs.alvestrand.titrax-sheet -application/prs.cww cww -# application/prs.nprend -# application/prs.plucker -# application/prs.rdf-xml-crypt -# application/prs.xsf+xml -application/pskc+xml pskcxml -# application/qsig -application/rdf+xml rdf -application/reginfo+xml rif -application/relax-ng-compact-syntax rnc -# application/remote-printing -application/resource-lists+xml rl -application/resource-lists-diff+xml rld -# application/riscos -# application/rlmi+xml -application/rls-services+xml rs -application/rpki-ghostbusters gbr -application/rpki-manifest mft -application/rpki-roa roa -# application/rpki-updown -application/rsd+xml rsd -application/rss+xml rss -application/rtf rtf -# application/rtx -# application/samlassertion+xml -# application/samlmetadata+xml -application/sbml+xml sbml -application/scvp-cv-request scq -application/scvp-cv-response scs -application/scvp-vp-request spq -application/scvp-vp-response spp -application/sdp sdp -# application/set-payment -application/set-payment-initiation setpay -# application/set-registration -application/set-registration-initiation setreg -# application/sgml -# application/sgml-open-catalog -application/shf+xml shf -# application/sieve -# application/simple-filter+xml -# application/simple-message-summary -# application/simplesymbolcontainer -# application/slate -# application/smil -application/smil+xml smi smil -# application/soap+fastinfoset -# application/soap+xml -application/sparql-query rq -application/sparql-results+xml srx -# application/spirits-event+xml -application/srgs gram -application/srgs+xml grxml -application/sru+xml sru -application/ssml+xml ssml -# application/tamp-apex-update -# application/tamp-apex-update-confirm -# application/tamp-community-update -# application/tamp-community-update-confirm -# application/tamp-error -# application/tamp-sequence-adjust -# application/tamp-sequence-adjust-confirm -# application/tamp-status-query -# application/tamp-status-response -# application/tamp-update -# application/tamp-update-confirm -application/tei+xml tei teicorpus -application/thraud+xml tfi -# application/timestamp-query -# application/timestamp-reply -application/timestamped-data tsd -# application/tve-trigger -# application/ulpfec -# application/vcard+xml -# application/vemmi -# application/vividence.scriptfile -# application/vnd.3gpp.bsf+xml -application/vnd.3gpp.pic-bw-large plb -application/vnd.3gpp.pic-bw-small psb -application/vnd.3gpp.pic-bw-var pvb -# application/vnd.3gpp.sms -# application/vnd.3gpp2.bcmcsinfo+xml -# application/vnd.3gpp2.sms -application/vnd.3gpp2.tcap tcap -application/vnd.3m.post-it-notes pwn -application/vnd.accpac.simply.aso aso -application/vnd.accpac.simply.imp imp -application/vnd.acucobol acu -application/vnd.acucorp atc acutc -application/vnd.adobe.air-application-installer-package+zip air -application/vnd.adobe.fxp fxp fxpl -# application/vnd.adobe.partial-upload -application/vnd.adobe.xdp+xml xdp -application/vnd.adobe.xfdf xfdf -# application/vnd.aether.imp -# application/vnd.ah-barcode -application/vnd.ahead.space ahead -application/vnd.airzip.filesecure.azf azf -application/vnd.airzip.filesecure.azs azs -application/vnd.amazon.ebook azw -application/vnd.americandynamics.acc acc -application/vnd.amiga.ami ami -# application/vnd.amundsen.maze+xml -application/vnd.android.package-archive apk -application/vnd.anser-web-certificate-issue-initiation cii -application/vnd.anser-web-funds-transfer-initiation fti -application/vnd.antix.game-component atx -application/vnd.apple.installer+xml mpkg -application/vnd.apple.mpegurl m3u8 -# application/vnd.arastra.swi -application/vnd.aristanetworks.swi swi -application/vnd.astraea-software.iota iota -application/vnd.audiograph aep -# application/vnd.autopackage -# application/vnd.avistar+xml -application/vnd.blueice.multipass mpm -# application/vnd.bluetooth.ep.oob -application/vnd.bmi bmi -application/vnd.businessobjects rep -# application/vnd.cab-jscript -# application/vnd.canon-cpdl -# application/vnd.canon-lips -# application/vnd.cendio.thinlinc.clientconf -application/vnd.chemdraw+xml cdxml -application/vnd.chipnuts.karaoke-mmd mmd -application/vnd.cinderella cdy -# application/vnd.cirpack.isdn-ext -application/vnd.claymore cla -application/vnd.cloanto.rp9 rp9 -application/vnd.clonk.c4group c4g c4d c4f c4p c4u -application/vnd.cluetrust.cartomobile-config c11amc -application/vnd.cluetrust.cartomobile-config-pkg c11amz -# application/vnd.collection+json -# application/vnd.commerce-battelle -application/vnd.commonspace csp -application/vnd.contact.cmsg cdbcmsg -application/vnd.cosmocaller cmc -application/vnd.crick.clicker clkx -application/vnd.crick.clicker.keyboard clkk -application/vnd.crick.clicker.palette clkp -application/vnd.crick.clicker.template clkt -application/vnd.crick.clicker.wordbank clkw -application/vnd.criticaltools.wbs+xml wbs -application/vnd.ctc-posml pml -# application/vnd.ctct.ws+xml -# application/vnd.cups-pdf -# application/vnd.cups-postscript -application/vnd.cups-ppd ppd -# application/vnd.cups-raster -# application/vnd.cups-raw -# application/vnd.curl -application/vnd.curl.car car -application/vnd.curl.pcurl pcurl -# application/vnd.cybank -application/vnd.data-vision.rdz rdz -application/vnd.dece.data uvf uvvf uvd uvvd -application/vnd.dece.ttml+xml uvt uvvt -application/vnd.dece.unspecified uvx uvvx -application/vnd.dece.zip uvz uvvz -application/vnd.denovo.fcselayout-link fe_launch -# application/vnd.dir-bi.plate-dl-nosuffix -application/vnd.dna dna -application/vnd.dolby.mlp mlp -# application/vnd.dolby.mobile.1 -# application/vnd.dolby.mobile.2 -application/vnd.dpgraph dpg -application/vnd.dreamfactory dfac -application/vnd.dvb.ait ait -# application/vnd.dvb.dvbj -# application/vnd.dvb.esgcontainer -# application/vnd.dvb.ipdcdftnotifaccess -# application/vnd.dvb.ipdcesgaccess -# application/vnd.dvb.ipdcesgaccess2 -# application/vnd.dvb.ipdcesgpdd -# application/vnd.dvb.ipdcroaming -# application/vnd.dvb.iptv.alfec-base -# application/vnd.dvb.iptv.alfec-enhancement -# application/vnd.dvb.notif-aggregate-root+xml -# application/vnd.dvb.notif-container+xml -# application/vnd.dvb.notif-generic+xml -# application/vnd.dvb.notif-ia-msglist+xml -# application/vnd.dvb.notif-ia-registration-request+xml -# application/vnd.dvb.notif-ia-registration-response+xml -# application/vnd.dvb.notif-init+xml -# application/vnd.dvb.pfr -application/vnd.dvb.service svc -# application/vnd.dxr -application/vnd.dynageo geo -# application/vnd.easykaraoke.cdgdownload -# application/vnd.ecdis-update -application/vnd.ecowin.chart mag -# application/vnd.ecowin.filerequest -# application/vnd.ecowin.fileupdate -# application/vnd.ecowin.series -# application/vnd.ecowin.seriesrequest -# application/vnd.ecowin.seriesupdate -# application/vnd.emclient.accessrequest+xml -application/vnd.enliven nml -# application/vnd.eprints.data+xml -application/vnd.epson.esf esf -application/vnd.epson.msf msf -application/vnd.epson.quickanime qam -application/vnd.epson.salt slt -application/vnd.epson.ssf ssf -# application/vnd.ericsson.quickcall -application/vnd.eszigno3+xml es3 et3 -# application/vnd.etsi.aoc+xml -# application/vnd.etsi.cug+xml -# application/vnd.etsi.iptvcommand+xml -# application/vnd.etsi.iptvdiscovery+xml -# application/vnd.etsi.iptvprofile+xml -# application/vnd.etsi.iptvsad-bc+xml -# application/vnd.etsi.iptvsad-cod+xml -# application/vnd.etsi.iptvsad-npvr+xml -# application/vnd.etsi.iptvservice+xml -# application/vnd.etsi.iptvsync+xml -# application/vnd.etsi.iptvueprofile+xml -# application/vnd.etsi.mcid+xml -# application/vnd.etsi.overload-control-policy-dataset+xml -# application/vnd.etsi.sci+xml -# application/vnd.etsi.simservs+xml -# application/vnd.etsi.tsl+xml -# application/vnd.etsi.tsl.der -# application/vnd.eudora.data -application/vnd.ezpix-album ez2 -application/vnd.ezpix-package ez3 -# application/vnd.f-secure.mobile -application/vnd.fdf fdf -application/vnd.fdsn.mseed mseed -application/vnd.fdsn.seed seed dataless -# application/vnd.ffsns -# application/vnd.fints -application/vnd.flographit gph -application/vnd.fluxtime.clip ftc -# application/vnd.font-fontforge-sfd -application/vnd.framemaker fm frame maker book -application/vnd.frogans.fnc fnc -application/vnd.frogans.ltf ltf -application/vnd.fsc.weblaunch fsc -application/vnd.fujitsu.oasys oas -application/vnd.fujitsu.oasys2 oa2 -application/vnd.fujitsu.oasys3 oa3 -application/vnd.fujitsu.oasysgp fg5 -application/vnd.fujitsu.oasysprs bh2 -# application/vnd.fujixerox.art-ex -# application/vnd.fujixerox.art4 -# application/vnd.fujixerox.hbpl -application/vnd.fujixerox.ddd ddd -application/vnd.fujixerox.docuworks xdw -application/vnd.fujixerox.docuworks.binder xbd -# application/vnd.fut-misnet -application/vnd.fuzzysheet fzs -application/vnd.genomatix.tuxedo txd -# application/vnd.geocube+xml -application/vnd.geogebra.file ggb -application/vnd.geogebra.tool ggt -application/vnd.geometry-explorer gex gre -application/vnd.geonext gxt -application/vnd.geoplan g2w -application/vnd.geospace g3w -# application/vnd.globalplatform.card-content-mgt -# application/vnd.globalplatform.card-content-mgt-response -application/vnd.gmx gmx -application/vnd.google-earth.kml+xml kml -application/vnd.google-earth.kmz kmz -application/vnd.grafeq gqf gqs -# application/vnd.gridmp -application/vnd.groove-account gac -application/vnd.groove-help ghf -application/vnd.groove-identity-message gim -application/vnd.groove-injector grv -application/vnd.groove-tool-message gtm -application/vnd.groove-tool-template tpl -application/vnd.groove-vcard vcg -# application/vnd.hal+json -application/vnd.hal+xml hal -application/vnd.handheld-entertainment+xml zmm -application/vnd.hbci hbci -# application/vnd.hcl-bireports -application/vnd.hhe.lesson-player les -application/vnd.hp-hpgl hpgl -application/vnd.hp-hpid hpid -application/vnd.hp-hps hps -application/vnd.hp-jlyt jlt -application/vnd.hp-pcl pcl -application/vnd.hp-pclxl pclxl -# application/vnd.httphone -application/vnd.hydrostatix.sof-data sfd-hdstx -application/vnd.hzn-3d-crossword x3d -# application/vnd.ibm.afplinedata -# application/vnd.ibm.electronic-media -application/vnd.ibm.minipay mpy -application/vnd.ibm.modcap afp listafp list3820 -application/vnd.ibm.rights-management irm -application/vnd.ibm.secure-container sc -application/vnd.iccprofile icc icm -application/vnd.igloader igl -application/vnd.immervision-ivp ivp -application/vnd.immervision-ivu ivu -# application/vnd.informedcontrol.rms+xml -# application/vnd.informix-visionary -# application/vnd.infotech.project -# application/vnd.infotech.project+xml -application/vnd.insors.igm igm -application/vnd.intercon.formnet xpw xpx -application/vnd.intergeo i2g -# application/vnd.intertrust.digibox -# application/vnd.intertrust.nncp -application/vnd.intu.qbo qbo -application/vnd.intu.qfx qfx -# application/vnd.iptc.g2.conceptitem+xml -# application/vnd.iptc.g2.knowledgeitem+xml -# application/vnd.iptc.g2.newsitem+xml -# application/vnd.iptc.g2.packageitem+xml -application/vnd.ipunplugged.rcprofile rcprofile -application/vnd.irepository.package+xml irp -application/vnd.is-xpr xpr -application/vnd.isac.fcs fcs -application/vnd.jam jam -# application/vnd.japannet-directory-service -# application/vnd.japannet-jpnstore-wakeup -# application/vnd.japannet-payment-wakeup -# application/vnd.japannet-registration -# application/vnd.japannet-registration-wakeup -# application/vnd.japannet-setstore-wakeup -# application/vnd.japannet-verification -# application/vnd.japannet-verification-wakeup -application/vnd.jcp.javame.midlet-rms rms -application/vnd.jisp jisp -application/vnd.joost.joda-archive joda -application/vnd.kahootz ktz ktr -application/vnd.kde.karbon karbon -application/vnd.kde.kchart chrt -application/vnd.kde.kformula kfo -application/vnd.kde.kivio flw -application/vnd.kde.kontour kon -application/vnd.kde.kpresenter kpr kpt -application/vnd.kde.kspread ksp -application/vnd.kde.kword kwd kwt -application/vnd.kenameaapp htke -application/vnd.kidspiration kia -application/vnd.kinar kne knp -application/vnd.koan skp skd skt skm -application/vnd.kodak-descriptor sse -application/vnd.las.las+xml lasxml -# application/vnd.liberty-request+xml -application/vnd.llamagraphics.life-balance.desktop lbd -application/vnd.llamagraphics.life-balance.exchange+xml lbe -application/vnd.lotus-1-2-3 123 -application/vnd.lotus-approach apr -application/vnd.lotus-freelance pre -application/vnd.lotus-notes nsf -application/vnd.lotus-organizer org -application/vnd.lotus-screencam scm -application/vnd.lotus-wordpro lwp -application/vnd.macports.portpkg portpkg -# application/vnd.marlin.drm.actiontoken+xml -# application/vnd.marlin.drm.conftoken+xml -# application/vnd.marlin.drm.license+xml -# application/vnd.marlin.drm.mdcf -application/vnd.mcd mcd -application/vnd.medcalcdata mc1 -application/vnd.mediastation.cdkey cdkey -# application/vnd.meridian-slingshot -application/vnd.mfer mwf -application/vnd.mfmp mfm -application/vnd.micrografx.flo flo -application/vnd.micrografx.igx igx -application/vnd.mif mif -# application/vnd.minisoft-hp3000-save -# application/vnd.mitsubishi.misty-guard.trustweb -application/vnd.mobius.daf daf -application/vnd.mobius.dis dis -application/vnd.mobius.mbk mbk -application/vnd.mobius.mqy mqy -application/vnd.mobius.msl msl -application/vnd.mobius.plc plc -application/vnd.mobius.txf txf -application/vnd.mophun.application mpn -application/vnd.mophun.certificate mpc -# application/vnd.motorola.flexsuite -# application/vnd.motorola.flexsuite.adsi -# application/vnd.motorola.flexsuite.fis -# application/vnd.motorola.flexsuite.gotap -# application/vnd.motorola.flexsuite.kmr -# application/vnd.motorola.flexsuite.ttc -# application/vnd.motorola.flexsuite.wem -# application/vnd.motorola.iprm -application/vnd.mozilla.xul+xml xul -application/vnd.ms-artgalry cil -# application/vnd.ms-asf -application/vnd.ms-cab-compressed cab -application/vnd.ms-excel xls xlm xla xlc xlt xlw -application/vnd.ms-excel.addin.macroenabled.12 xlam -application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb -application/vnd.ms-excel.sheet.macroenabled.12 xlsm -application/vnd.ms-excel.template.macroenabled.12 xltm -application/vnd.ms-fontobject eot -application/vnd.ms-htmlhelp chm -application/vnd.ms-ims ims -application/vnd.ms-lrm lrm -# application/vnd.ms-office.activex+xml -application/vnd.ms-officetheme thmx -application/vnd.ms-pki.seccat cat -application/vnd.ms-pki.stl stl -# application/vnd.ms-playready.initiator+xml -application/vnd.ms-powerpoint ppt pps pot -application/vnd.ms-powerpoint.addin.macroenabled.12 ppam -application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm -application/vnd.ms-powerpoint.slide.macroenabled.12 sldm -application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm -application/vnd.ms-powerpoint.template.macroenabled.12 potm -application/vnd.ms-project mpp mpt -# application/vnd.ms-tnef -# application/vnd.ms-wmdrm.lic-chlg-req -# application/vnd.ms-wmdrm.lic-resp -# application/vnd.ms-wmdrm.meter-chlg-req -# application/vnd.ms-wmdrm.meter-resp -application/vnd.ms-word.document.macroenabled.12 docm -application/vnd.ms-word.template.macroenabled.12 dotm -application/vnd.ms-works wps wks wcm wdb -application/vnd.ms-wpl wpl -application/vnd.ms-xpsdocument xps -application/vnd.mseq mseq -# application/vnd.msign -# application/vnd.multiad.creator -# application/vnd.multiad.creator.cif -# application/vnd.music-niff -application/vnd.musician mus -application/vnd.muvee.style msty -application/vnd.mynfc taglet -# application/vnd.ncd.control -# application/vnd.ncd.reference -# application/vnd.nervana -# application/vnd.netfpx -application/vnd.neurolanguage.nlu nlu -application/vnd.noblenet-directory nnd -application/vnd.noblenet-sealer nns -application/vnd.noblenet-web nnw -# application/vnd.nokia.catalogs -# application/vnd.nokia.conml+wbxml -# application/vnd.nokia.conml+xml -# application/vnd.nokia.isds-radio-presets -# application/vnd.nokia.iptv.config+xml -# application/vnd.nokia.landmark+wbxml -# application/vnd.nokia.landmark+xml -# application/vnd.nokia.landmarkcollection+xml -# application/vnd.nokia.n-gage.ac+xml -application/vnd.nokia.n-gage.data ngdat -application/vnd.nokia.n-gage.symbian.install n-gage -# application/vnd.nokia.ncd -# application/vnd.nokia.pcd+wbxml -# application/vnd.nokia.pcd+xml -application/vnd.nokia.radio-preset rpst -application/vnd.nokia.radio-presets rpss -application/vnd.novadigm.edm edm -application/vnd.novadigm.edx edx -application/vnd.novadigm.ext ext -# application/vnd.ntt-local.file-transfer -# application/vnd.ntt-local.sip-ta_remote -# application/vnd.ntt-local.sip-ta_tcp_stream -application/vnd.oasis.opendocument.chart odc -application/vnd.oasis.opendocument.chart-template otc -application/vnd.oasis.opendocument.database odb -application/vnd.oasis.opendocument.formula odf -application/vnd.oasis.opendocument.formula-template odft -application/vnd.oasis.opendocument.graphics odg -application/vnd.oasis.opendocument.graphics-template otg -application/vnd.oasis.opendocument.image odi -application/vnd.oasis.opendocument.image-template oti -application/vnd.oasis.opendocument.presentation odp -application/vnd.oasis.opendocument.presentation-template otp -application/vnd.oasis.opendocument.spreadsheet ods -application/vnd.oasis.opendocument.spreadsheet-template ots -application/vnd.oasis.opendocument.text odt -application/vnd.oasis.opendocument.text-master odm -application/vnd.oasis.opendocument.text-template ott -application/vnd.oasis.opendocument.text-web oth -# application/vnd.obn -# application/vnd.oftn.l10n+json -# application/vnd.oipf.contentaccessdownload+xml -# application/vnd.oipf.contentaccessstreaming+xml -# application/vnd.oipf.cspg-hexbinary -# application/vnd.oipf.dae.svg+xml -# application/vnd.oipf.dae.xhtml+xml -# application/vnd.oipf.mippvcontrolmessage+xml -# application/vnd.oipf.pae.gem -# application/vnd.oipf.spdiscovery+xml -# application/vnd.oipf.spdlist+xml -# application/vnd.oipf.ueprofile+xml -# application/vnd.oipf.userprofile+xml -application/vnd.olpc-sugar xo -# application/vnd.oma-scws-config -# application/vnd.oma-scws-http-request -# application/vnd.oma-scws-http-response -# application/vnd.oma.bcast.associated-procedure-parameter+xml -# application/vnd.oma.bcast.drm-trigger+xml -# application/vnd.oma.bcast.imd+xml -# application/vnd.oma.bcast.ltkm -# application/vnd.oma.bcast.notification+xml -# application/vnd.oma.bcast.provisioningtrigger -# application/vnd.oma.bcast.sgboot -# application/vnd.oma.bcast.sgdd+xml -# application/vnd.oma.bcast.sgdu -# application/vnd.oma.bcast.simple-symbol-container -# application/vnd.oma.bcast.smartcard-trigger+xml -# application/vnd.oma.bcast.sprov+xml -# application/vnd.oma.bcast.stkm -# application/vnd.oma.cab-address-book+xml -# application/vnd.oma.cab-feature-handler+xml -# application/vnd.oma.cab-pcc+xml -# application/vnd.oma.cab-user-prefs+xml -# application/vnd.oma.dcd -# application/vnd.oma.dcdc -application/vnd.oma.dd2+xml dd2 -# application/vnd.oma.drm.risd+xml -# application/vnd.oma.group-usage-list+xml -# application/vnd.oma.pal+xml -# application/vnd.oma.poc.detailed-progress-report+xml -# application/vnd.oma.poc.final-report+xml -# application/vnd.oma.poc.groups+xml -# application/vnd.oma.poc.invocation-descriptor+xml -# application/vnd.oma.poc.optimized-progress-report+xml -# application/vnd.oma.push -# application/vnd.oma.scidm.messages+xml -# application/vnd.oma.xcap-directory+xml -# application/vnd.omads-email+xml -# application/vnd.omads-file+xml -# application/vnd.omads-folder+xml -# application/vnd.omaloc-supl-init -application/vnd.openofficeorg.extension oxt -# application/vnd.openxmlformats-officedocument.custom-properties+xml -# application/vnd.openxmlformats-officedocument.customxmlproperties+xml -# application/vnd.openxmlformats-officedocument.drawing+xml -# application/vnd.openxmlformats-officedocument.drawingml.chart+xml -# application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml -# application/vnd.openxmlformats-officedocument.extended-properties+xml -# application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml -# application/vnd.openxmlformats-officedocument.presentationml.comments+xml -# application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml -# application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml -# application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml -application/vnd.openxmlformats-officedocument.presentationml.presentation pptx -# application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml -# application/vnd.openxmlformats-officedocument.presentationml.presprops+xml -application/vnd.openxmlformats-officedocument.presentationml.slide sldx -# application/vnd.openxmlformats-officedocument.presentationml.slide+xml -# application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml -# application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml -application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx -# application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml -# application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml -# application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml -# application/vnd.openxmlformats-officedocument.presentationml.tags+xml -application/vnd.openxmlformats-officedocument.presentationml.template potx -# application/vnd.openxmlformats-officedocument.presentationml.template.main+xml -# application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml -application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx -# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml -application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx -# application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml -# application/vnd.openxmlformats-officedocument.theme+xml -# application/vnd.openxmlformats-officedocument.themeoverride+xml -# application/vnd.openxmlformats-officedocument.vmldrawing -# application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml -application/vnd.openxmlformats-officedocument.wordprocessingml.document docx -# application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml -application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx -# application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml -# application/vnd.openxmlformats-package.core-properties+xml -# application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml -# application/vnd.openxmlformats-package.relationships+xml -# application/vnd.quobject-quoxdocument -# application/vnd.osa.netdeploy -application/vnd.osgeo.mapguide.package mgp -# application/vnd.osgi.bundle -application/vnd.osgi.dp dp -# application/vnd.otps.ct-kip+xml -application/vnd.palm pdb pqa oprc -# application/vnd.paos.xml -application/vnd.pawaafile paw -application/vnd.pg.format str -application/vnd.pg.osasli ei6 -# application/vnd.piaccess.application-licence -application/vnd.picsel efif -application/vnd.pmi.widget wg -# application/vnd.poc.group-advertisement+xml -application/vnd.pocketlearn plf -application/vnd.powerbuilder6 pbd -# application/vnd.powerbuilder6-s -# application/vnd.powerbuilder7 -# application/vnd.powerbuilder7-s -# application/vnd.powerbuilder75 -# application/vnd.powerbuilder75-s -# application/vnd.preminet -application/vnd.previewsystems.box box -application/vnd.proteus.magazine mgz -application/vnd.publishare-delta-tree qps -application/vnd.pvi.ptid1 ptid -# application/vnd.pwg-multiplexed -# application/vnd.pwg-xhtml-print+xml -# application/vnd.qualcomm.brew-app-res -application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb -# application/vnd.radisys.moml+xml -# application/vnd.radisys.msml+xml -# application/vnd.radisys.msml-audit+xml -# application/vnd.radisys.msml-audit-conf+xml -# application/vnd.radisys.msml-audit-conn+xml -# application/vnd.radisys.msml-audit-dialog+xml -# application/vnd.radisys.msml-audit-stream+xml -# application/vnd.radisys.msml-conf+xml -# application/vnd.radisys.msml-dialog+xml -# application/vnd.radisys.msml-dialog-base+xml -# application/vnd.radisys.msml-dialog-fax-detect+xml -# application/vnd.radisys.msml-dialog-fax-sendrecv+xml -# application/vnd.radisys.msml-dialog-group+xml -# application/vnd.radisys.msml-dialog-speech+xml -# application/vnd.radisys.msml-dialog-transform+xml -# application/vnd.rainstor.data -# application/vnd.rapid -application/vnd.realvnc.bed bed -application/vnd.recordare.musicxml mxl -application/vnd.recordare.musicxml+xml musicxml -# application/vnd.renlearn.rlprint -application/vnd.rig.cryptonote cryptonote -application/vnd.rim.cod cod -application/vnd.rn-realmedia rm -application/vnd.route66.link66+xml link66 -# application/vnd.ruckus.download -# application/vnd.s3sms -application/vnd.sailingtracker.track st -# application/vnd.sbm.cid -# application/vnd.sbm.mid2 -# application/vnd.scribus -# application/vnd.sealed.3df -# application/vnd.sealed.csf -# application/vnd.sealed.doc -# application/vnd.sealed.eml -# application/vnd.sealed.mht -# application/vnd.sealed.net -# application/vnd.sealed.ppt -# application/vnd.sealed.tiff -# application/vnd.sealed.xls -# application/vnd.sealedmedia.softseal.html -# application/vnd.sealedmedia.softseal.pdf -application/vnd.seemail see -application/vnd.sema sema -application/vnd.semd semd -application/vnd.semf semf -application/vnd.shana.informed.formdata ifm -application/vnd.shana.informed.formtemplate itp -application/vnd.shana.informed.interchange iif -application/vnd.shana.informed.package ipk -application/vnd.simtech-mindmapper twd twds -application/vnd.smaf mmf -# application/vnd.smart.notebook -application/vnd.smart.teacher teacher -# application/vnd.software602.filler.form+xml -# application/vnd.software602.filler.form-xml-zip -application/vnd.solent.sdkm+xml sdkm sdkd -application/vnd.spotfire.dxp dxp -application/vnd.spotfire.sfs sfs -# application/vnd.sss-cod -# application/vnd.sss-dtf -# application/vnd.sss-ntf -application/vnd.stardivision.calc sdc -application/vnd.stardivision.draw sda -application/vnd.stardivision.impress sdd -application/vnd.stardivision.math smf -application/vnd.stardivision.writer sdw vor -application/vnd.stardivision.writer-global sgl -application/vnd.stepmania.package smzip -application/vnd.stepmania.stepchart sm -# application/vnd.street-stream -application/vnd.sun.xml.calc sxc -application/vnd.sun.xml.calc.template stc -application/vnd.sun.xml.draw sxd -application/vnd.sun.xml.draw.template std -application/vnd.sun.xml.impress sxi -application/vnd.sun.xml.impress.template sti -application/vnd.sun.xml.math sxm -application/vnd.sun.xml.writer sxw -application/vnd.sun.xml.writer.global sxg -application/vnd.sun.xml.writer.template stw -# application/vnd.sun.wadl+xml -application/vnd.sus-calendar sus susp -application/vnd.svd svd -# application/vnd.swiftview-ics -application/vnd.symbian.install sis sisx -application/vnd.syncml+xml xsm -application/vnd.syncml.dm+wbxml bdm -application/vnd.syncml.dm+xml xdm -# application/vnd.syncml.dm.notification -# application/vnd.syncml.ds.notification -application/vnd.tao.intent-module-archive tao -application/vnd.tcpdump.pcap pcap cap dmp -application/vnd.tmobile-livetv tmo -application/vnd.trid.tpt tpt -application/vnd.triscape.mxs mxs -application/vnd.trueapp tra -# application/vnd.truedoc -# application/vnd.ubisoft.webplayer -application/vnd.ufdl ufd ufdl -application/vnd.uiq.theme utz -application/vnd.umajin umj -application/vnd.unity unityweb -application/vnd.uoml+xml uoml -# application/vnd.uplanet.alert -# application/vnd.uplanet.alert-wbxml -# application/vnd.uplanet.bearer-choice -# application/vnd.uplanet.bearer-choice-wbxml -# application/vnd.uplanet.cacheop -# application/vnd.uplanet.cacheop-wbxml -# application/vnd.uplanet.channel -# application/vnd.uplanet.channel-wbxml -# application/vnd.uplanet.list -# application/vnd.uplanet.list-wbxml -# application/vnd.uplanet.listcmd -# application/vnd.uplanet.listcmd-wbxml -# application/vnd.uplanet.signal -application/vnd.vcx vcx -# application/vnd.vd-study -# application/vnd.vectorworks -# application/vnd.verimatrix.vcas -# application/vnd.vidsoft.vidconference -application/vnd.visio vsd vst vss vsw -application/vnd.visionary vis -# application/vnd.vividence.scriptfile -application/vnd.vsf vsf -# application/vnd.wap.sic -# application/vnd.wap.slc -application/vnd.wap.wbxml wbxml -application/vnd.wap.wmlc wmlc -application/vnd.wap.wmlscriptc wmlsc -application/vnd.webturbo wtb -# application/vnd.wfa.wsc -# application/vnd.wmc -# application/vnd.wmf.bootstrap -# application/vnd.wolfram.mathematica -# application/vnd.wolfram.mathematica.package -application/vnd.wolfram.player nbp -application/vnd.wordperfect wpd -application/vnd.wqd wqd -# application/vnd.wrq-hp3000-labelled -application/vnd.wt.stf stf -# application/vnd.wv.csp+wbxml -# application/vnd.wv.csp+xml -# application/vnd.wv.ssp+xml -application/vnd.xara xar -application/vnd.xfdl xfdl -# application/vnd.xfdl.webform -# application/vnd.xmi+xml -# application/vnd.xmpie.cpkg -# application/vnd.xmpie.dpkg -# application/vnd.xmpie.plan -# application/vnd.xmpie.ppkg -# application/vnd.xmpie.xlim -application/vnd.yamaha.hv-dic hvd -application/vnd.yamaha.hv-script hvs -application/vnd.yamaha.hv-voice hvp -application/vnd.yamaha.openscoreformat osf -application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg -# application/vnd.yamaha.remote-setup -application/vnd.yamaha.smaf-audio saf -application/vnd.yamaha.smaf-phrase spf -# application/vnd.yamaha.through-ngn -# application/vnd.yamaha.tunnel-udpencap -application/vnd.yellowriver-custom-menu cmp -application/vnd.zul zir zirz -application/vnd.zzazz.deck+xml zaz -application/voicexml+xml vxml -# application/vq-rtcpxr -# application/watcherinfo+xml -# application/whoispp-query -# application/whoispp-response -application/widget wgt -application/winhlp hlp -# application/wita -# application/wordperfect5.1 -application/wsdl+xml wsdl -application/wspolicy+xml wspolicy -application/x-7z-compressed 7z -application/x-abiword abw -application/x-ace-compressed ace -application/x-authorware-bin aab x32 u32 vox -application/x-authorware-map aam -application/x-authorware-seg aas -application/x-bcpio bcpio -application/x-bittorrent torrent -application/x-bzip bz -application/x-bzip2 bz2 boz -application/x-cdlink vcd -application/x-chat chat -application/x-chess-pgn pgn -# application/x-compress -application/x-cpio cpio -application/x-csh csh -application/x-debian-package deb udeb -application/x-director dir dcr dxr cst cct cxt w3d fgd swa -application/x-doom wad -application/x-dtbncx+xml ncx -application/x-dtbook+xml dtb -application/x-dtbresource+xml res -application/x-dvi dvi -application/x-font-bdf bdf -# application/x-font-dos -# application/x-font-framemaker -application/x-font-ghostscript gsf -# application/x-font-libgrx -application/x-font-linux-psf psf -application/x-font-otf otf -application/x-font-pcf pcf -application/x-font-snf snf -# application/x-font-speedo -# application/x-font-sunos-news -application/x-font-ttf ttf ttc -application/x-font-type1 pfa pfb pfm afm -application/x-font-woff woff -# application/x-font-vfont -application/x-futuresplash spl -application/x-gnumeric gnumeric -application/x-gtar gtar -# application/x-gzip -application/x-hdf hdf -application/x-java-jnlp-file jnlp -application/x-latex latex -application/x-mobipocket-ebook prc mobi -application/x-ms-application application -application/x-ms-wmd wmd -application/x-ms-wmz wmz -application/x-ms-xbap xbap -application/x-msaccess mdb -application/x-msbinder obd -application/x-mscardfile crd -application/x-msclip clp -application/x-msdownload exe dll com bat msi -application/x-msmediaview mvb m13 m14 -application/x-msmetafile wmf -application/x-msmoney mny -application/x-mspublisher pub -application/x-msschedule scd -application/x-msterminal trm -application/x-mswrite wri -application/x-netcdf nc cdf -application/x-pkcs12 p12 pfx -application/x-pkcs7-certificates p7b spc -application/x-pkcs7-certreqresp p7r -application/x-rar-compressed rar -application/x-sh sh -application/x-shar shar -application/x-shockwave-flash swf -application/x-silverlight-app xap -application/x-stuffit sit -application/x-stuffitx sitx -application/x-sv4cpio sv4cpio -application/x-sv4crc sv4crc -application/x-tar tar -application/x-tcl tcl -application/x-tex tex -application/x-tex-tfm tfm -application/x-texinfo texinfo texi -application/x-ustar ustar -application/x-wais-source src -application/x-x509-ca-cert der crt -application/x-xfig fig -application/x-xpinstall xpi -# application/x400-bp -# application/xcap-att+xml -# application/xcap-caps+xml -application/xcap-diff+xml xdf -# application/xcap-el+xml -# application/xcap-error+xml -# application/xcap-ns+xml -# application/xcon-conference-info-diff+xml -# application/xcon-conference-info+xml -application/xenc+xml xenc -application/xhtml+xml xhtml xht -# application/xhtml-voice+xml -application/xml xml xsl -application/xml-dtd dtd -# application/xml-external-parsed-entity -# application/xmpp+xml -application/xop+xml xop -application/xslt+xml xslt -application/xspf+xml xspf -application/xv+xml mxml xhvml xvml xvm -application/yang yang -application/yin+xml yin -application/zip zip -# audio/1d-interleaved-parityfec -# audio/32kadpcm -# audio/3gpp -# audio/3gpp2 -# audio/ac3 -audio/adpcm adp -# audio/amr -# audio/amr-wb -# audio/amr-wb+ -# audio/asc -# audio/atrac-advanced-lossless -# audio/atrac-x -# audio/atrac3 -audio/basic au snd -# audio/bv16 -# audio/bv32 -# audio/clearmode -# audio/cn -# audio/dat12 -# audio/dls -# audio/dsr-es201108 -# audio/dsr-es202050 -# audio/dsr-es202211 -# audio/dsr-es202212 -# audio/dv -# audio/dvi4 -# audio/eac3 -# audio/evrc -# audio/evrc-qcp -# audio/evrc0 -# audio/evrc1 -# audio/evrcb -# audio/evrcb0 -# audio/evrcb1 -# audio/evrcwb -# audio/evrcwb0 -# audio/evrcwb1 -# audio/example -# audio/fwdred -# audio/g719 -# audio/g722 -# audio/g7221 -# audio/g723 -# audio/g726-16 -# audio/g726-24 -# audio/g726-32 -# audio/g726-40 -# audio/g728 -# audio/g729 -# audio/g7291 -# audio/g729d -# audio/g729e -# audio/gsm -# audio/gsm-efr -# audio/gsm-hr-08 -# audio/ilbc -# audio/ip-mr_v2.5 -# audio/l16 -# audio/l20 -# audio/l24 -# audio/l8 -# audio/lpc -audio/midi mid midi kar rmi -# audio/mobile-xmf -audio/mp4 mp4a -# audio/mp4a-latm -# audio/mpa -# audio/mpa-robust -audio/mpeg mpga mp2 mp2a mp3 m2a m3a -# audio/mpeg4-generic -audio/ogg oga ogg spx -# audio/parityfec -# audio/pcma -# audio/pcma-wb -# audio/pcmu-wb -# audio/pcmu -# audio/prs.sid -# audio/qcelp -# audio/red -# audio/rtp-enc-aescm128 -# audio/rtp-midi -# audio/rtx -# audio/smv -# audio/smv0 -# audio/smv-qcp -# audio/sp-midi -# audio/speex -# audio/t140c -# audio/t38 -# audio/telephone-event -# audio/tone -# audio/uemclip -# audio/ulpfec -# audio/vdvi -# audio/vmr-wb -# audio/vnd.3gpp.iufp -# audio/vnd.4sb -# audio/vnd.audiokoz -# audio/vnd.celp -# audio/vnd.cisco.nse -# audio/vnd.cmles.radio-events -# audio/vnd.cns.anp1 -# audio/vnd.cns.inf1 -audio/vnd.dece.audio uva uvva -audio/vnd.digital-winds eol -# audio/vnd.dlna.adts -# audio/vnd.dolby.heaac.1 -# audio/vnd.dolby.heaac.2 -# audio/vnd.dolby.mlp -# audio/vnd.dolby.mps -# audio/vnd.dolby.pl2 -# audio/vnd.dolby.pl2x -# audio/vnd.dolby.pl2z -# audio/vnd.dolby.pulse.1 -audio/vnd.dra dra -audio/vnd.dts dts -audio/vnd.dts.hd dtshd -# audio/vnd.dvb.file dvb -# audio/vnd.everad.plj -# audio/vnd.hns.audio -audio/vnd.lucent.voice lvp -audio/vnd.ms-playready.media.pya pya -# audio/vnd.nokia.mobile-xmf -# audio/vnd.nortel.vbk -audio/vnd.nuera.ecelp4800 ecelp4800 -audio/vnd.nuera.ecelp7470 ecelp7470 -audio/vnd.nuera.ecelp9600 ecelp9600 -# audio/vnd.octel.sbc -# audio/vnd.qcelp -# audio/vnd.rhetorex.32kadpcm -audio/vnd.rip rip -# audio/vnd.sealedmedia.softseal.mpeg -# audio/vnd.vmx.cvsd -# audio/vorbis -# audio/vorbis-config -audio/webm weba -audio/x-aac aac -audio/x-aiff aif aiff aifc -audio/x-mpegurl m3u -audio/x-ms-wax wax -audio/x-ms-wma wma -audio/x-pn-realaudio ram ra -audio/x-pn-realaudio-plugin rmp -audio/x-wav wav -chemical/x-cdx cdx -chemical/x-cif cif -chemical/x-cmdf cmdf -chemical/x-cml cml -chemical/x-csml csml -# chemical/x-pdb -chemical/x-xyz xyz -image/bmp bmp -image/cgm cgm -# image/example -# image/fits -image/g3fax g3 -image/gif gif -image/ief ief -# image/jp2 -image/jpeg jpeg jpg jpe -# image/jpm -# image/jpx -image/ktx ktx -# image/naplps -image/png png -image/prs.btif btif -# image/prs.pti -image/svg+xml svg svgz -# image/t38 -image/tiff tiff tif -# image/tiff-fx -image/vnd.adobe.photoshop psd -# image/vnd.cns.inf2 -image/vnd.dece.graphic uvi uvvi uvg uvvg -image/vnd.dvb.subtitle sub -image/vnd.djvu djvu djv -image/vnd.dwg dwg -image/vnd.dxf dxf -image/vnd.fastbidsheet fbs -image/vnd.fpx fpx -image/vnd.fst fst -image/vnd.fujixerox.edmics-mmr mmr -image/vnd.fujixerox.edmics-rlc rlc -# image/vnd.globalgraphics.pgb -# image/vnd.microsoft.icon -# image/vnd.mix -image/vnd.ms-modi mdi -image/vnd.net-fpx npx -# image/vnd.radiance -# image/vnd.sealed.png -# image/vnd.sealedmedia.softseal.gif -# image/vnd.sealedmedia.softseal.jpg -# image/vnd.svf -image/vnd.wap.wbmp wbmp -image/vnd.xiff xif -image/webp webp -image/x-cmu-raster ras -image/x-cmx cmx -image/x-freehand fh fhc fh4 fh5 fh7 -image/x-icon ico -image/x-pcx pcx -image/x-pict pic pct -image/x-portable-anymap pnm -image/x-portable-bitmap pbm -image/x-portable-graymap pgm -image/x-portable-pixmap ppm -image/x-rgb rgb -image/x-xbitmap xbm -image/x-xpixmap xpm -image/x-xwindowdump xwd -# message/cpim -# message/delivery-status -# message/disposition-notification -# message/example -# message/external-body -# message/feedback-report -# message/global -# message/global-delivery-status -# message/global-disposition-notification -# message/global-headers -# message/http -# message/imdn+xml -# message/news -# message/partial -message/rfc822 eml mime -# message/s-http -# message/sip -# message/sipfrag -# message/tracking-status -# message/vnd.si.simp -# model/example -model/iges igs iges -model/mesh msh mesh silo -model/vnd.collada+xml dae -model/vnd.dwf dwf -# model/vnd.flatland.3dml -model/vnd.gdl gdl -# model/vnd.gs-gdl -# model/vnd.gs.gdl -model/vnd.gtw gtw -# model/vnd.moml+xml -model/vnd.mts mts -# model/vnd.parasolid.transmit.binary -# model/vnd.parasolid.transmit.text -model/vnd.vtu vtu -model/vrml wrl vrml -# multipart/alternative -# multipart/appledouble -# multipart/byteranges -# multipart/digest -# multipart/encrypted -# multipart/example -# multipart/form-data -# multipart/header-set -# multipart/mixed -# multipart/parallel -# multipart/related -# multipart/report -# multipart/signed -# multipart/voice-message -# text/1d-interleaved-parityfec -text/calendar ics ifb -text/css css -text/csv csv -# text/directory -# text/dns -# text/ecmascript -# text/enriched -# text/example -# text/fwdred -text/html html htm -# text/javascript -text/n3 n3 -# text/parityfec -text/plain txt text conf def list log in -# text/prs.fallenstein.rst -text/prs.lines.tag dsc -# text/vnd.radisys.msml-basic-layout -# text/red -# text/rfc822-headers -text/richtext rtx -# text/rtf -# text/rtp-enc-aescm128 -# text/rtx -text/sgml sgml sgm -# text/t140 -text/tab-separated-values tsv -text/troff t tr roff man me ms -text/turtle ttl -# text/ulpfec -text/uri-list uri uris urls -text/vcard vcard -# text/vnd.abc -text/vnd.curl curl -text/vnd.curl.dcurl dcurl -text/vnd.curl.scurl scurl -text/vnd.curl.mcurl mcurl -# text/vnd.dmclientscript -text/vnd.dvb.subtitle sub -# text/vnd.esmertec.theme-descriptor -text/vnd.fly fly -text/vnd.fmi.flexstor flx -text/vnd.graphviz gv -text/vnd.in3d.3dml 3dml -text/vnd.in3d.spot spot -# text/vnd.iptc.newsml -# text/vnd.iptc.nitf -# text/vnd.latex-z -# text/vnd.motorola.reflex -# text/vnd.ms-mediapackage -# text/vnd.net2phone.commcenter.command -# text/vnd.si.uricatalogue -text/vnd.sun.j2me.app-descriptor jad -# text/vnd.trolltech.linguist -# text/vnd.wap.si -# text/vnd.wap.sl -text/vnd.wap.wml wml -text/vnd.wap.wmlscript wmls -text/x-asm s asm -text/x-c c cc cxx cpp h hh dic -text/x-fortran f for f77 f90 -text/x-pascal p pas -text/x-java-source java -text/x-setext etx -text/x-uuencode uu -text/x-vcalendar vcs -text/x-vcard vcf -# text/xml -# text/xml-external-parsed-entity -# video/1d-interleaved-parityfec -video/3gpp 3gp -# video/3gpp-tt -video/3gpp2 3g2 -# video/bmpeg -# video/bt656 -# video/celb -# video/dv -# video/example -video/h261 h261 -video/h263 h263 -# video/h263-1998 -# video/h263-2000 -video/h264 h264 -# video/h264-rcdo -# video/h264-svc -video/jpeg jpgv -# video/jpeg2000 -video/jpm jpm jpgm -video/mj2 mj2 mjp2 -# video/mp1s -# video/mp2p -# video/mp2t -video/mp4 mp4 mp4v mpg4 -# video/mp4v-es -video/mpeg mpeg mpg mpe m1v m2v -# video/mpeg4-generic -# video/mpv -# video/nv -video/ogg ogv -# video/parityfec -# video/pointer -video/quicktime qt mov -# video/raw -# video/rtp-enc-aescm128 -# video/rtx -# video/smpte292m -# video/ulpfec -# video/vc1 -# video/vnd.cctv -video/vnd.dece.hd uvh uvvh -video/vnd.dece.mobile uvm uvvm -# video/vnd.dece.mp4 -video/vnd.dece.pd uvp uvvp -video/vnd.dece.sd uvs uvvs -video/vnd.dece.video uvv uvvv -# video/vnd.directv.mpeg -# video/vnd.directv.mpeg-tts -# video/vnd.dlna.mpeg-tts -video/vnd.dvb.file dvb -video/vnd.fvt fvt -# video/vnd.hns.video -# video/vnd.iptvforum.1dparityfec-1010 -# video/vnd.iptvforum.1dparityfec-2005 -# video/vnd.iptvforum.2dparityfec-1010 -# video/vnd.iptvforum.2dparityfec-2005 -# video/vnd.iptvforum.ttsavc -# video/vnd.iptvforum.ttsmpeg2 -# video/vnd.motorola.video -# video/vnd.motorola.videop -video/vnd.mpegurl mxu m4u -video/vnd.ms-playready.media.pyv pyv -# video/vnd.nokia.interleaved-multimedia -# video/vnd.nokia.videovoip -# video/vnd.objectvideo -# video/vnd.sealed.mpeg1 -# video/vnd.sealed.mpeg4 -# video/vnd.sealed.swf -# video/vnd.sealedmedia.softseal.mov -video/vnd.uvvu.mp4 uvu uvvu -video/vnd.vivo viv -video/webm webm -video/x-f4v f4v -video/x-fli fli -video/x-flv flv -video/x-m4v m4v -video/x-ms-asf asf asx -video/x-ms-wm wm -video/x-ms-wmv wmv -video/x-ms-wmx wmx -video/x-ms-wvx wvx -video/x-msvideo avi -video/x-sgi-movie movie -x-conference/x-cooltalk ice diff --git a/websvr/test/lib/types/node.types b/websvr/test/lib/types/node.types deleted file mode 100644 index 69a6641..0000000 --- a/websvr/test/lib/types/node.types +++ /dev/null @@ -1,54 +0,0 @@ -# What: Google Chrome Extension -# Why: To allow apps to (work) be served with the right content type header. -# http://codereview.chromium.org/2830017 -# Added by: niftylettuce -application/x-chrome-extension crx - -# What: OTF Message Silencer -# Why: To silence the "Resource interpreted as font but transferred with MIME -# type font/otf" message that occurs in Google Chrome -# Added by: niftylettuce -font/opentype otf - -# What: HTC support -# Why: To properly render .htc files such as CSS3PIE -# Added by: niftylettuce -text/x-component htc - -# What: HTML5 application cache manifest -# Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps -# per https://developer.mozilla.org/en/offline_resources_in_firefox -# Added by: louisremi -text/cache-manifest appcache manifest - -# What: node binary buffer format -# Why: semi-standard extension w/in the node community -# Added by: tootallnate -application/octet-stream buffer - -# What: The "protected" MP-4 formats used by iTunes. -# Why: Required for streaming music to browsers (?) -# Added by: broofa -application/mp4 m4p -audio/mp4 m4a - -# What: Music playlist format (http://en.wikipedia.org/wiki/M3U) -# Why: See https://github.com/bentomas/node-mime/pull/6 -# Added by: mjrusso -application/x-mpegURL m3u8 - -# What: Video format, Part of RFC1890 -# Why: See https://github.com/bentomas/node-mime/pull/6 -# Added by: mjrusso -video/MP2T ts - -# What: The FLAC lossless codec format -# Why: Streaming and serving FLAC audio -# Added by: jacobrask -audio/flac flac - -# What: EventSource mime type -# Why: mime type of Server-Sent Events stream -# http://www.w3.org/TR/eventsource/#text-event-stream -# Added by: francois2metz -text/event-stream event-stream diff --git a/websvr/test/lib/underscore.js b/websvr/test/lib/underscore.js deleted file mode 100644 index 93df9d1..0000000 --- a/websvr/test/lib/underscore.js +++ /dev/null @@ -1,1200 +0,0 @@ -// Underscore.js 1.4.2 -// http://underscorejs.org -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore may be freely distributed under the MIT license. - -(function() { - - // Baseline setup - // -------------- - - // Establish the root object, `window` in the browser, or `global` on the server. - var root = this; - - // Save the previous value of the `_` variable. - var previousUnderscore = root._; - - // Establish the object that gets returned to break out of a loop iteration. - var breaker = {}; - - // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - - // Create quick reference variables for speed access to core prototypes. - var push = ArrayProto.push, - slice = ArrayProto.slice, - concat = ArrayProto.concat, - unshift = ArrayProto.unshift, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; - - // All **ECMAScript 5** native function implementations that we hope to use - // are declared here. - var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind; - - // Create a safe reference to the Underscore object for use below. - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - - // Export the Underscore object for **Node.js**, with - // backwards-compatibility for the old `require()` API. If we're in - // the browser, add `_` as a global object via a string identifier, - // for Closure Compiler "advanced" mode. - if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root['_'] = _; - } - - // Current version. - _.VERSION = '1.4.2'; - - // Collection Functions - // -------------------- - - // The cornerstone, an `each` implementation, aka `forEach`. - // Handles objects with the built-in `forEach`, arrays, and raw objects. - // Delegates to **ECMAScript 5**'s native `forEach` if available. - var each = _.each = _.forEach = function(obj, iterator, context) { - if (obj == null) return; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, l = obj.length; i < l; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - for (var key in obj) { - if (_.has(obj, key)) { - if (iterator.call(context, obj[key], key, obj) === breaker) return; - } - } - } - }; - - // Return the results of applying the iterator to each element. - // Delegates to **ECMAScript 5**'s native `map` if available. - _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results[results.length] = iterator.call(context, value, index, list); - }); - return results; - }; - - // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. - _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError('Reduce of empty array with no initial value'); - return memo; - }; - - // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var length = obj.length; - if (length !== +length) { - var keys = _.keys(obj); - length = keys.length; - } - each(obj, function(value, index, list) { - index = keys ? keys[--length] : --length; - if (!initial) { - memo = obj[index]; - initial = true; - } else { - memo = iterator.call(context, memo, obj[index], index, list); - } - }); - if (!initial) throw new TypeError('Reduce of empty array with no initial value'); - return memo; - }; - - // Return the first value which passes a truth test. Aliased as `detect`. - _.find = _.detect = function(obj, iterator, context) { - var result; - any(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - - // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. - // Aliased as `select`. - _.filter = _.select = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); - each(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - - // Return all the elements for which a truth test fails. - _.reject = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - each(obj, function(value, index, list) { - if (!iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - - // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. - // Aliased as `all`. - _.every = _.all = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); - each(obj, function(value, index, list) { - if (!(result = result && iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. - // Aliased as `any`. - var any = _.some = _.any = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); - each(obj, function(value, index, list) { - if (result || (result = iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if the array or object contains a given value (using `===`). - // Aliased as `include`. - _.contains = _.include = function(obj, target) { - var found = false; - if (obj == null) return found; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - found = any(obj, function(value) { - return value === target; - }); - return found; - }; - - // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - return _.map(obj, function(value) { - return (_.isFunction(method) ? method : value[method]).apply(value, args); - }); - }; - - // Convenience version of a common use case of `map`: fetching a property. - _.pluck = function(obj, key) { - return _.map(obj, function(value){ return value[key]; }); - }; - - // Convenience version of a common use case of `filter`: selecting only objects - // with specific `key:value` pairs. - _.where = function(obj, attrs) { - if (_.isEmpty(attrs)) return []; - return _.filter(obj, function(value) { - for (var key in attrs) { - if (attrs[key] !== value[key]) return false; - } - return true; - }); - }; - - // Return the maximum element or (element-based computation). - // Can't optimize arrays of integers longer than 65,535 elements. - // See: https://bugs.webkit.org/show_bug.cgi?id=80797 - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed >= result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed < result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Shuffle an array. - _.shuffle = function(obj) { - var rand; - var index = 0; - var shuffled = []; - each(obj, function(value) { - rand = _.random(index++); - shuffled[index - 1] = shuffled[rand]; - shuffled[rand] = value; - }); - return shuffled; - }; - - // An internal function to generate lookup iterators. - var lookupIterator = function(value) { - return _.isFunction(value) ? value : function(obj){ return obj[value]; }; - }; - - // Sort the object's values by a criterion produced by an iterator. - _.sortBy = function(obj, value, context) { - var iterator = lookupIterator(value); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value : value, - index : index, - criteria : iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; - } - return left.index < right.index ? -1 : 1; - }), 'value'); - }; - - // An internal function used for aggregate "group by" operations. - var group = function(obj, value, context, behavior) { - var result = {}; - var iterator = lookupIterator(value); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); - }); - return result; - }; - - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - _.groupBy = function(obj, value, context) { - return group(obj, value, context, function(result, key, value) { - (_.has(result, key) ? result[key] : (result[key] = [])).push(value); - }); - }; - - // Counts instances of an object that group by a certain criterion. Pass - // either a string attribute to count by, or a function that returns the - // criterion. - _.countBy = function(obj, value, context) { - return group(obj, value, context, function(result, key, value) { - if (!_.has(result, key)) result[key] = 0; - result[key]++; - }); - }; - - // Use a comparator function to figure out the smallest index at which - // an object should be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator, context) { - iterator = iterator == null ? _.identity : lookupIterator(iterator); - var value = iterator.call(context, obj); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; - } - return low; - }; - - // Safely convert anything iterable into a real, live array. - _.toArray = function(obj) { - if (!obj) return []; - if (obj.length === +obj.length) return slice.call(obj); - return _.values(obj); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; - }; - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. Aliased as `head` and `take`. The **guard** check - // allows it to work with `_.map`. - _.first = _.head = _.take = function(array, n, guard) { - return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; - }; - - // Returns everything but the last entry of the array. Especially useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. The **guard** check allows it to work with - // `_.map`. - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - - // Get the last element of an array. Passing **n** will return the last N - // values in the array. The **guard** check allows it to work with `_.map`. - _.last = function(array, n, guard) { - if ((n != null) && !guard) { - return slice.call(array, Math.max(array.length - n, 0)); - } else { - return array[array.length - 1]; - } - }; - - // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. - // Especially useful on the arguments object. Passing an **n** will return - // the rest N values in the array. The **guard** - // check allows it to work with `_.map`. - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.filter(array, function(value){ return !!value; }); - }; - - // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, output) { - each(input, function(value) { - if (_.isArray(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); - } else { - output.push(value); - } - }); - return output; - }; - - // Return a completely flattened version of an array. - _.flatten = function(array, shallow) { - return flatten(array, shallow, []); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // Aliased as `unique`. - _.uniq = _.unique = function(array, isSorted, iterator, context) { - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; - var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); - } - }); - return results; - }; - - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - _.union = function() { - return _.uniq(concat.apply(ArrayProto, arguments)); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. - _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.indexOf(other, item) >= 0; - }); - }); - }; - - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var args = slice.call(arguments); - var length = _.max(_.pluck(args, 'length')); - var results = new Array(length); - for (var i = 0; i < length; i++) { - results[i] = _.pluck(args, "" + i); - } - return results; - }; - - // Converts lists into objects. Pass either a single array of `[key, value]` - // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. - _.object = function(list, values) { - var result = {}; - for (var i = 0, l = list.length; i < l; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; - } - } - return result; - }; - - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i = 0, l = array.length; - if (isSorted) { - if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); - } else { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); - for (; i < l; i++) if (array[i] === item) return i; - return -1; - }; - - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. - _.lastIndexOf = function(array, item, from) { - if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); - } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; - return -1; - }; - - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; - - var len = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(len); - - while(idx < len) { - range[idx++] = start; - start += step; - } - - return range; - }; - - // Function (ahem) Functions - // ------------------ - - // Reusable constructor function for prototype setting. - var ctor = function(){}; - - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Binding with arguments is also known as `curry`. - // Delegates to **ECMAScript 5**'s native `Function.bind` if available. - // We check for `func.bind` first, to fail fast when `func` is undefined. - _.bind = function bind(func, context) { - var bound, args; - if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError; - args = slice.call(arguments, 2); - return bound = function() { - if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); - ctor.prototype = func.prototype; - var self = new ctor; - var result = func.apply(self, args.concat(slice.call(arguments))); - if (Object(result) === result) return result; - return self; - }; - }; - - // Bind all of an object's methods to that object. Useful for ensuring that - // all callbacks defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length == 0) funcs = _.functions(obj); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Memoize an expensive function by storing its results. - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. - _.throttle = function(func, wait) { - var context, args, timeout, throttling, more, result; - var whenDone = _.debounce(function(){ more = throttling = false; }, wait); - return function() { - context = this; args = arguments; - var later = function() { - timeout = null; - if (more) { - result = func.apply(context, args); - } - whenDone(); - }; - if (!timeout) timeout = setTimeout(later, wait); - if (throttling) { - more = true; - } else { - throttling = true; - result = func.apply(context, args); - } - whenDone(); - return result; - }; - }; - - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. If `immediate` is passed, trigger the function on the - // leading edge, instead of the trailing. - _.debounce = function(func, wait, immediate) { - var timeout, result; - return function() { - var context = this, args = arguments; - var later = function() { - timeout = null; - if (!immediate) result = func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) result = func.apply(context, args); - return result; - }; - }; - - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return function() { - var args = [func]; - push.apply(args, arguments); - return wrapper.apply(this, args); - }; - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - // Returns a function that will only be executed after being called N times. - _.after = function(times, func) { - if (times <= 0) return func(); - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - - // Object Functions - // ---------------- - - // Retrieve the names of an object's properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` - _.keys = nativeKeys || function(obj) { - if (obj !== Object(obj)) throw new TypeError('Invalid object'); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - var values = []; - for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); - return values; - }; - - // Convert an object into a list of `[key, value]` pairs. - _.pairs = function(obj) { - var pairs = []; - for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); - return pairs; - }; - - // Invert the keys and values of an object. The values must be serializable. - _.invert = function(obj) { - var result = {}; - for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; - return result; - }; - - // Return a sorted list of the function names available on the object. - // Aliased as `methods` - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - - // Extend a given object with all the properties in passed-in object(s). - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - }); - return obj; - }; - - // Return a copy of the object only containing the whitelisted properties. - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - - // Return a copy of the object without the blacklisted properties. - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; - } - return copy; - }; - - // Fill in a given object with default properties. - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } - }); - return obj; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - - // Internal recursive comparison function for `isEqual`. - var eq = function(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. - if (a === b) return a !== 0 || 1 / a == 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; - // Unwrap any wrapped objects. - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] == a) return bStack[length] == b; - } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); - var size = 0, result = true; - // Recursively compare objects and arrays. - if (className == '[object Array]') { - // Compare array lengths to determine if a deep comparison is necessary. - size = a.length; - result = size == b.length; - if (result) { - // Deep compare the contents, ignoring non-numeric properties. - while (size--) { - if (!(result = eq(a[size], b[size], aStack, bStack))) break; - } - } - } else { - // Objects with different constructors are not equivalent, but `Object`s - // from different frames are. - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor))) { - return false; - } - // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - return result; - }; - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - return eq(a, b, [], []); - }; - - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - _.isEmpty = function(obj) { - if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; - return true; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - - // Is a given variable an object? - _.isObject = function(obj) { - return obj === Object(obj); - }; - - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { - _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; - }; - }); - - // Define a fallback version of the method in browsers (ahem, IE), where - // there isn't any inspectable "Arguments" type. - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; - } - - // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; - } - - // Is a given object a finite number? - _.isFinite = function(obj) { - return _.isNumber(obj) && isFinite(obj); - }; - - // Is the given value `NaN`? (NaN is the only number which does not equal itself). - _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; - }; - - // Is a given value a boolean? - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return obj === void 0; - }; - - // Shortcut function for checking if an object has a given property directly - // on itself (in other words, not on a prototype). - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - - // Utility Functions - // ----------------- - - // Run Underscore.js in *noConflict* mode, returning the `_` variable to its - // previous owner. Returns a reference to the Underscore object. - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - - // Keep the identity function around for default iterators. - _.identity = function(value) { - return value; - }; - - // Run a function **n** times. - _.times = function(n, iterator, context) { - for (var i = 0; i < n; i++) iterator.call(context, i); - }; - - // Return a random integer between min and max (inclusive). - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + (0 | Math.random() * (max - min + 1)); - }; - - // List of HTML entities for escaping. - var entityMap = { - escape: { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '/': '/' - } - }; - entityMap.unescape = _.invert(entityMap.escape); - - // Regexes containing the keys and values listed immediately above. - var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') - }; - - // Functions for escaping and unescaping strings to/from HTML interpolation. - _.each(['escape', 'unescape'], function(method) { - _[method] = function(string) { - if (string == null) return ''; - return ('' + string).replace(entityRegexes[method], function(match) { - return entityMap[method][match]; - }); - }; - }); - - // If the value of the named property is a function then invoke it; - // otherwise, return it. - _.result = function(object, property) { - if (object == null) return null; - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - - // Add your own custom functions to the Underscore object. - _.mixin = function(obj) { - each(_.functions(obj), function(name){ - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); - }; - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = idCounter++; - return prefix ? prefix + id : id; - }; - - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /(.)^/; - - // Certain characters need to be escaped so that they can be put into a - // string literal. - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - _.template = function(text, data, settings) { - settings = _.defaults({}, settings, _.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = new RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); - source += - escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" : - interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" : - evaluate ? "';\n" + evaluate + "\n__p+='" : ''; - index = offset + match.length; - }); - source += "';\n"; - - // If a variable is not specified, place data values in local scope. - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; - - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; - - try { - var render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; - } - - if (data) return render(data, _); - var template = function(data) { - return render.call(this, data, _); - }; - - // Provide the compiled function source as a convenience for precompilation. - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; - - return template; - }; - - // Add a "chain" function, which will delegate to the wrapper. - _.chain = function(obj) { - return _(obj).chain(); - }; - - // OOP - // --------------- - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - - // Helper function to continue chaining intermediate results. - var result = function(obj) { - return this._chain ? _(obj).chain() : obj; - }; - - // Add all of the Underscore functions to the wrapper object. - _.mixin(_); - - // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; - return result.call(this, obj); - }; - }); - - // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result.call(this, method.apply(this._wrapped, arguments)); - }; - }); - - _.extend(_.prototype, { - - // Start chaining a wrapped Underscore object. - chain: function() { - this._chain = true; - return this; - }, - - // Extracts the result from a wrapped and chained object. - value: function() { - return this._wrapped; - } - - }); - -}).call(this); diff --git a/websvr/test/lib/uuid.js b/websvr/test/lib/uuid.js deleted file mode 100644 index f616d52..0000000 --- a/websvr/test/lib/uuid.js +++ /dev/null @@ -1,233 +0,0 @@ -/* - * UUID-js: A js library to generate and parse UUIDs, TimeUUIDs and generate - * TimeUUID based on dates for range selections. - * @see http://www.ietf.org/rfc/rfc4122.txt - **/ - -function UUIDjs() { -}; - -UUIDjs.maxFromBits = function(bits) { - return Math.pow(2, bits); -}; - -UUIDjs.limitUI04 = UUIDjs.maxFromBits(4); -UUIDjs.limitUI06 = UUIDjs.maxFromBits(6); -UUIDjs.limitUI08 = UUIDjs.maxFromBits(8); -UUIDjs.limitUI12 = UUIDjs.maxFromBits(12); -UUIDjs.limitUI14 = UUIDjs.maxFromBits(14); -UUIDjs.limitUI16 = UUIDjs.maxFromBits(16); -UUIDjs.limitUI32 = UUIDjs.maxFromBits(32); -UUIDjs.limitUI40 = UUIDjs.maxFromBits(40); -UUIDjs.limitUI48 = UUIDjs.maxFromBits(48); - -UUIDjs.randomUI04 = function() { - return Math.round(Math.random() * UUIDjs.limitUI04); -}; -UUIDjs.randomUI06 = function() { - return Math.round(Math.random() * UUIDjs.limitUI06); -}; -UUIDjs.randomUI08 = function() { - return Math.round(Math.random() * UUIDjs.limitUI08); -}; -UUIDjs.randomUI12 = function() { - return Math.round(Math.random() * UUIDjs.limitUI12); -}; -UUIDjs.randomUI14 = function() { - return Math.round(Math.random() * UUIDjs.limitUI14); -}; -UUIDjs.randomUI16 = function() { - return Math.round(Math.random() * UUIDjs.limitUI16); -}; -UUIDjs.randomUI32 = function() { - return Math.round(Math.random() * UUIDjs.limitUI32); -}; -UUIDjs.randomUI40 = function() { - return (0 | Math.random() * (1 << 30)) + (0 | Math.random() * (1 << 40 - 30)) * (1 << 30); -}; -UUIDjs.randomUI48 = function() { - return (0 | Math.random() * (1 << 30)) + (0 | Math.random() * (1 << 48 - 30)) * (1 << 30); -}; - -UUIDjs.paddedString = function(string, length, z) { - string = String(string); - z = (!z) ? '0' : z; - var i = length - string.length; - for (; i > 0; i >>>= 1, z += z) { - if (i & 1) { - string = z + string; - } - } - return string; -}; - -UUIDjs.prototype.fromParts = function(timeLow, timeMid, timeHiAndVersion, clockSeqHiAndReserved, clockSeqLow, node) { - this.version = (timeHiAndVersion >> 12) & 0xF; - this.hex = UUIDjs.paddedString(timeLow.toString(16), 8) - + '-' - + UUIDjs.paddedString(timeMid.toString(16), 4) - + '-' - + UUIDjs.paddedString(timeHiAndVersion.toString(16), 4) - + '-' - + UUIDjs.paddedString(clockSeqHiAndReserved.toString(16), 2) - + UUIDjs.paddedString(clockSeqLow.toString(16), 2) - + '-' - + UUIDjs.paddedString(node.toString(16), 12); - return this; -}; - -UUIDjs.prototype.toString = function() { - return this.hex; -}; -UUIDjs.prototype.toURN = function() { - return 'urn:uuid:' + this.hex; -}; - -UUIDjs.prototype.toBytes = function() { - var parts = this.hex.split('-'); - var ints = []; - var intPos = 0; - for (var i = 0; i < parts.length; i++) { - for (var j = 0; j < parts[i].length; j+=2) { - ints[intPos++] = parseInt(parts[i].substr(j, 2), 16); - } - } - return ints; -}; - -UUIDjs.prototype.equals = function(uuid) { - if (!(uuid instanceof UUID)) { - return false; - } - if (this.hex !== uuid.hex) { - return false; - } - return true; -}; - -UUIDjs.getTimeFieldValues = function(time) { - var ts = time - Date.UTC(1582, 9, 15); - var hm = ((ts / 0x100000000) * 10000) & 0xFFFFFFF; - return { low: ((ts & 0xFFFFFFF) * 10000) % 0x100000000, - mid: hm & 0xFFFF, hi: hm >>> 16, timestamp: ts }; -}; - -UUIDjs._create4 = function() { - return new UUIDjs().fromParts( - UUIDjs.randomUI32(), - UUIDjs.randomUI16(), - 0x4000 | UUIDjs.randomUI12(), - 0x80 | UUIDjs.randomUI06(), - UUIDjs.randomUI08(), - UUIDjs.randomUI48() - ); -}; - -UUIDjs._create1 = function() { - var now = new Date().getTime(); - var sequence = UUIDjs.randomUI14(); - var node = (UUIDjs.randomUI08() | 1) * 0x10000000000 + UUIDjs.randomUI40(); - var tick = UUIDjs.randomUI04(); - var timestamp = 0; - var timestampRatio = 1/4; - - if (now != timestamp) { - if (now < timestamp) { - sequence++; - } - timestamp = now; - tick = UUIDjs.randomUI04(); - } else if (Math.random() < timestampRatio && tick < 9984) { - tick += 1 + UUIDjs.randomUI04(); - } else { - sequence++; - } - - var tf = UUIDjs.getTimeFieldValues(timestamp); - var tl = tf.low + tick; - var thav = (tf.hi & 0xFFF) | 0x1000; - - sequence &= 0x3FFF; - var cshar = (sequence >>> 8) | 0x80; - var csl = sequence & 0xFF; - - return new UUIDjs().fromParts(tl, tf.mid, thav, cshar, csl, node); -}; - -UUIDjs.create = function(version) { - version = version || 4; - return this['_create' + version](); -}; - -UUIDjs.fromTime = function(time, last) { - last = (!last) ? false : last; - var tf = UUIDjs.getTimeFieldValues(time); - var tl = tf.low; - var thav = (tf.hi & 0xFFF) | 0x1000; // set version '0001' - if (last === false) { - return new UUIDjs().fromParts(tl, tf.mid, thav, 0, 0, 0); - } else { - return new UUIDjs().fromParts(tl, tf.mid, thav, 0x80 | UUIDjs.limitUI06, UUIDjs.limitUI08 - 1, UUIDjs.limitUI48 - 1); - } -}; - -UUIDjs.firstFromTime = function(time) { - return UUIDjs.fromTime(time, false); -}; -UUIDjs.lastFromTime = function(time) { - return UUIDjs.fromTime(time, true); -}; - -UUIDjs.fromURN = function(strId) { - var r, p = /^(?:urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(?:\})?$/i; - if ((r = p.exec(strId))) { - return new UUIDjs().fromParts(parseInt(r[1], 16), parseInt(r[2], 16), - parseInt(r[3], 16), parseInt(r[4], 16), - parseInt(r[5], 16), parseInt(r[6], 16)); - } - return null; -}; - -UUIDjs.fromBytes = function(ints) { - if (ints.length < 5) { - return null; - } - var str = ''; - var pos = 0; - var parts = [4, 2, 2, 2, 6]; - for (var i = 0; i < parts.length; i++) { - for (var j = 0; j < parts[i]; j++) { - var octet = ints[pos++].toString(16); - if (octet.length == 1) { - octet = '0' + octet; - } - str += octet; - } - if (parts[i] !== 6) { - str += '-'; - } - } - return UUIDjs.fromURN(str); -}; - -UUIDjs.fromBinary = function(binary) { - var ints = []; - for (var i = 0; i < binary.length; i++) { - ints[i] = binary.charCodeAt(i); - if (ints[i] > 255 || ints[i] < 0) { - throw new Error('Unexpected byte in binary data.'); - } - } - return UUIDjs.fromBytes(ints); -}; - -// Aliases to support legacy code. Do not use these when writing new code as -// they may be removed in future versions! -UUIDjs.new = function() { - return this.create(4); -}; -UUIDjs.newTS = function() { - return this.create(1); -}; - -module.exports = UUIDjs; diff --git a/websvr/test/testExtend.js b/websvr/test/testExtend.js deleted file mode 100644 index 05ce3bb..0000000 --- a/websvr/test/testExtend.js +++ /dev/null @@ -1,56 +0,0 @@ -var test = require("./lib/test"); - -var extend = function(tar, obj) { - if (!obj) return; - - for (var key in obj) { - tar[key] = obj[key]; - } - - return tar; -}; - -var _ = require("./lib/underscore"); - -//test method -test("Extend by _.extend:", function() { - var tar = { - a: 1, b: "2", c: "3", - e: { i: "5", j: "6" }, - f: { x: {}, y: [] } - }; - - var obj = { - b: 123, - f: { x: [1]} - }; - - _.extend(tar, obj); - //console.log(tar, obj); -}); - -test("Extend by simple func:", function() { - var tar = { - a: 1, b: "2", c: "3", - e: { i: "5", j: "6" }, - f: { x: {}, y: [] } - }; - - var obj = { - b: 123, - f: { x: [1]} - }; - - extend(tar, obj); - //console.log(tar, obj); -}); - -test("String operate by []:", function() { - var dirPath = 'www/abc/login/'; - dirPath[dirPath.length - 1] == '/'; -}); - -test("String operate by charAt:", function() { - var dirPath = 'www/abc/login/'; - dirPath.charAt(dirPath.length - 1) == '/'; -}); \ No newline at end of file diff --git a/websvr/test/testFormat.js b/websvr/test/testFormat.js deleted file mode 100644 index d27526a..0000000 --- a/websvr/test/testFormat.js +++ /dev/null @@ -1,19 +0,0 @@ -var test = require("./lib/test"); - -var qs = require("querystring"); - -var testQuery = "a=link&b=1&c=abc&f=efg" -var testString = '{a: "link", b: 1, c: "abc", f: "efg"}'; -var testObject = {a: "link", b: 1, c: "abc", f: "efg"}; - -test("Test parse/stringify querystring", function() { - var string = qs.stringify(testObject); - var obj = qs.parse(string); - //console.log(string, obj); -}); - -test("Test parse/stringify json", function() { - var string = JSON.stringify(testString); - var obj = JSON.parse(string); - //console.log(string, obj); -}); \ No newline at end of file diff --git a/websvr/test/testMIME.js b/websvr/test/testMIME.js deleted file mode 100644 index 9e0ed11..0000000 --- a/websvr/test/testMIME.js +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env node -var test = require("./lib/test"), - mime = require("./lib/mime"); - MIMETYPES = require('./lib/MIMETYPES.js'); - -var urls = [ - "http://www.github.com/appmobi/jq.html", - "stringify/appmobi.lok.mp3", - "good/soha.shtml", - "abcdefg/appmobi.look/abcdefgg.good" - ]; - -/* - It'll be sure that: - 1) The url must indicate to a file. - 2) There will be no query string. - 3) Length of extension will be less than 10. -*/ -var lookup = function(url) { - var idx = url.lastIndexOf('.') + 1, - type; - - (idx > 0 ) && (type = MIMETYPES[url.substr(idx, 10)]); - - return type || "application/octet-stream"; -}; - -test("Test mime.lookup == mime.custom", function() { - urls.forEach(function(url) { - console.log(mime.lookup(url) == lookup(url), lookup(url), mime.lookup(url), url); - }); -}, 1); - -test("Test mime.lookup", function() { - urls.forEach(function(url) { - mime.lookup(url); - }); -}); - -test("Test mime.custom", function() { - urls.forEach(function(url) { - lookup(url); - }); -}); \ No newline at end of file diff --git a/websvr/test/testSession.js b/websvr/test/testSession.js deleted file mode 100644 index 002279b..0000000 --- a/websvr/test/testSession.js +++ /dev/null @@ -1,49 +0,0 @@ -var test = require("./lib/test"); - -var create = function() { - //Time stamp, change interval is 18.641 hours, higher 6 bits will be kept, this is used for delete the old sessions - var uuid - = ((+new Date()) / 60000 | 0) //Time stamp, change interval is 1 min, 8 chars - + '-' - + ((Math.random() * 0x4000000 | 0)) //Random 1: Used for distinguish the session, max 9 chars - + ((Math.random() * 0x4000000 | 0)); //Random 2: Used for distinguish the session, max 9 chars - - //fix the length to 25 - //uuid += '0000000000'.substr(0, 25 - uuid.length); - - return uuid; -}; - -test("SessionManager.create: test length", function() { - - var max = 0, min = 1000; - for (var i = 0; i < 1000000; i ++) { - var len = create().length; - - (len > max) && (max = len); - (len < min) && (min = len); - } - - console.log("min:", min, "max:", max); - -}, 1); - -test("Test parse Int string: | 0", function() { - var rnd = "18999334.3415921676"; - rnd = rnd | 0; -}); - -test("Test parse Int string: parseInt", function() { - var rnd = "18999334.3415921676"; - rnd = parseInt(rnd); -}); - -test("Test parse Int float: | 0", function() { - var rnd = 18999334.3415921676; - rnd = rnd | 0; -}); - -test("Test parse Int float: parseInt", function() { - var rnd = 18999334.3415921676; - rnd = parseInt(rnd); -}); \ No newline at end of file diff --git a/websvr/test/testString.js b/websvr/test/testString.js deleted file mode 100644 index 05e2bf7..0000000 --- a/websvr/test/testString.js +++ /dev/null @@ -1,11 +0,0 @@ -var test = require("./lib/test"); - -var testString = "/a=link&b=1&c=abc&f=efg" - -test("Test string chartAt", function() { - testString.charAt(0) == '/' -}); - -test("Test string array", function() { - testString[0] == '/' -}); \ No newline at end of file diff --git a/websvr/test/testUUID.js b/websvr/test/testUUID.js deleted file mode 100644 index 0090799..0000000 --- a/websvr/test/testUUID.js +++ /dev/null @@ -1,206 +0,0 @@ -var UUIDjs = require("./lib/uuid"), - test = require("./lib/test"); - -var websvr = require('../websvr')().stop(); - -(function() { - // Private array of chars to use - var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); - - Math.uuid = function (len, radix) { - var chars = CHARS, uuid = [], i; - radix = radix || chars.length; - - if (len) { - // Compact form - for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix]; - } else { - // rfc4122, version 4 form - var r; - - // rfc4122 requires these characters - uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; - uuid[14] = '4'; - - // Fill in random data. At i==19 set the high bits of clock sequence as - // per rfc4122, sec. 4.1.5 - for (i = 0; i < 36; i++) { - if (!uuid[i]) { - r = 0 | Math.random()*16; - uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; - } - } - } - - return uuid.join(''); - }; - - // A more performant, but slightly bulkier, RFC4122v4 solution. We boost performance - // by minimizing calls to random() - Math.uuidFast = function() { - var chars = CHARS, uuid = new Array(36), rnd=0, r; - for (var i = 0; i < 36; i++) { - if (i==8 || i==13 || i==18 || i==23) { - uuid[i] = '-'; - } else if (i==14) { - uuid[i] = '4'; - } else { - if (rnd <= 0x02) rnd = 0x2000000 + (Math.random()*0x1000000)|0; - r = rnd & 0xf; - rnd = rnd >> 4; - uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; - } - } - return uuid.join(''); - }; - - // A more compact, but less performant, RFC4122v4 solution: - Math.uuidCompact = function() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); - }; -})(); - -//Conver to array will make it slower; -var CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -var CHARSArr = CHARS.split(''); - -var SCHARS = "0123456789ABCDEF"; -var SCHARSArr = SCHARS.split(''); - -console.log("Testing long chars:"); - -test("Math.uuid(32)", function() { - Math.uuid(32); -}); - -test("Math.uuidFast", function() { - Math.uuidFast(); -}); - -test("UUIDjs.create", function() { - UUIDjs.create(); -}); - -var createUUID = function() { - var create = function() { - return (Math.random() * 0x10000 | 0).toString(16); - }; - - var uuid = new Array(8); - for (var i = 0; i < 8; i++) { - uuid[i] = (Math.random() * 0x10000 | 0).toString(16); - } -}; - -test("createUUID", function() { - createUUID(); -}); - -test("UUID fixed array", function() { - //Using fixed size array will be more faster than "new Array()" - var uuid = new Array(32); - for (var i = 0; i < 32; i++) { - uuid[i] = CHARS[0 | Math.random() * 36]; - } - uuid = uuid.join(); -}); - -test("UUID string plus", function() { - var uuid = ""; - for (var i = 0; i < 32; i++) { - uuid += CHARS[0 | Math.random() * 36]; - } -}); - -test("UUIDArr string plus", function() { - var uuid = ""; - for (var i = 0; i < 32; i++) { - uuid += CHARSArr[0 | Math.random() * 36]; - } -}); - -test("UUIDArr fixed array", function() { - //Using fixed size array will be more faster than "new Array()" - var uuid = new Array(32); - for (var i = 0; i < 32; i++) { - uuid[i] = CHARSArr[0 | Math.random() * 36]; - } - uuid = uuid.join(); -}); - -console.log("\r\n\r\nTesting short chars:"); - -test("UUID fixed array", function() { - //Using fixed size array will be more faster than "new Array()" - var uuid = new Array(32); - for (var i = 0; i < 32; i++) { - uuid[i] = SCHARS[0 | Math.random() * 16]; - } - uuid = uuid.join(); -}); - -test("UUID string plus", function() { - var uuid = ""; - for (var i = 0; i < 32; i++) { - uuid += SCHARS[0 | Math.random() * 16]; - } -}); - -test("UUIDArr string plus", function() { - var uuid = ""; - for (var i = 0; i < 32; i++) { - uuid += SCHARSArr[0 | Math.random() * 16]; - } -}); - -test("UUIDArr fixed array", function() { - //Using fixed size array will be more faster than "new Array()" - var uuid = new Array(32); - for (var i = 0; i < 32; i++) { - uuid[i] = SCHARSArr[0 | Math.random() * 16]; - } - uuid = uuid.join(); -}); - -//interval is 4 hours -test("UUIDArr fixed array final", function() { - var suuid = (+new Date()) / 14400000; - - var uuid = new Array(32); - for (var i = 0; i < 32; i++) { - uuid[i] = SCHARSArr[0 | Math.random() * 16]; - } - - suuid += "-" + uuid.join(''); -}); - -test("Custom session id, with full Date", function() { - var uuid - = (+new Date()) //Time stamp, change interval is 0.583 hours, higher 11 bits will be kept - + '-' - + ((Math.random() * 0x40000000 | 0)) //Random 1: Used for distinguish the session - + ((Math.random() * 0x40000000 | 0)); //Random 2: Used for distinguish the session - - uuid += '0000000000'.substr(0, 25 - uuid.length); -}); - -test("Custom session id, with short Date", function() { - var uuid - = ((+new Date()) / 60000 | 0) //Time stamp, change interval is 0.583 hours, higher 11 bits will be kept - + '-' - + ((Math.random() * 0x40000000 | 0)) //Random 1: Used for distinguish the session - + ((Math.random() * 0x40000000 | 0)); //Random 2: Used for distinguish the session - - uuid += '0000000000'.substr(0, 25 - uuid.length); -}); - -test("Test default Session ID", function() { - var newID = websvr.newID(); -}); - -test("Test Session ID with appended chars", function() { - var newID = websvr.newID(3); -}); \ No newline at end of file diff --git a/websvr/websvr.js b/websvr/websvr.js deleted file mode 100644 index 7885c44..0000000 --- a/websvr/websvr.js +++ /dev/null @@ -1,1469 +0,0 @@ -/* -* Description: websvr -* Author: Kris Zhang -* Licenses: MIT -* Project url: https://github.com/newghost/websvr -*/ - -"use strict"; - -//Node libraries -var fs = require("fs"); -var path = require("path"); -var qs = require("querystring"); -var os = require("os"); - -var http = require("http"); -var https = require("https"); - -//Open source libraries -var mime = require("mime"); -var formidable = require("formidable"); - -/* -* Utility -*/ -var _ = { - //extend object to target - extend: function(tar, obj) { - if (!obj) return tar; - - for (var key in obj) { - tar[key] = obj[key]; - } - - return tar; - } -}; - -//Shortcuts -var define = Object.defineProperty; - -//Mapping -var CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'.split(''); - -/* -* Define and Export WebSvr -*/ -var WebSvr = module.exports = function(options) { - - var self = {}; - - var SessionStore; - - /*****************Web module definitions*************/ - /* - Configurations - */ - var Settings = { - //root folder of server - root: process.cwd() - - //home folder of web - , home: './' - - //http start - //default port of http - , port: 8054 - - //default port of https - , httpsPort: 8443 - , httpsKey: "" - , httpsCert: "" - - //list files in directory - , listDir: false - //enable client-side cache(304) - , cache: true - //enable debug information output - , debug: true - //enable cache of template/include file (when enabled templates will not be refreshed before restart) - , templateCache: true - //show errors to user(displayed in response) - , showError: true - - //default pages, only one is supported - , defaultPage: "index.html" - , 404: "" - - /* - Session timeout, in milliseconds. - */ - , sessionTimeout: 1440000 - - //session file stored here - , sessionDir : '' - - //session domain - , sessionDomain: '' - - , sessionLength: 36 - - //tempary upload file stored here - , uploadDir: os.tmpDir() - }; - - /* - Logger: log sth - */ - var Logger = (function() { - /* - Turn off debug when Settings.debug = false - */ - var debug = function() { - //diable console.log information - if (!Settings.debug) { - return; - } - - var d = new Date().toISOString(); - Array.prototype.splice.call(arguments, 0, 0, d); - console.log.apply(console, arguments); - }; - - var error = function() { - var d = new Date().toISOString(); - Array.prototype.splice.call(arguments, 0, 0, d); - console.error.apply(console, arguments); - }; - - return { debug: debug, error: error }; - })(); - - /* - Body parser, parse the data in request body - when parse complete, execute the callback with response data; - */ - var BodyParser = function(req, res, callback) { - - var receives = []; - - req.on('data', function(chunk) { - receives.push(chunk); - }); - - req.on('end', function() { - callback(Buffer.concat(receives).toString()); - }); - }; - - /* - Parse request with session support - */ - var SessionParser = function() { - var self = this; - - //session id - self.sid = null; - self.val = null; - }; - - SessionParser.prototype = { - init: function(req, res, cb) { - var self = this - , sidKey = "_wsid" - , sidVal - , sidStr - ; - - //Get or Create sid, sid exist in the cookie, read it - var sidVal = req.cookies[sidKey]; - - //Does session expired? - var getSession = function(session) { - var isValid = session && session.__lastAccessTime && (+new Date() - session.__lastAccessTime <= Settings.sessionTimeout); - - if (isValid) { - self.sid = sidVal; - self.val = session; - self.val.__lastAccessTime = +new Date(); - cb && cb(); - } else { - SessionStore.del(sidVal); - setSession(); - } - }; - - var setSession = function() { - self.create(); - res.cookie(sidKey, self.sid, { domain: Settings.sessionDomain, path: '/', httponly: true }); - cb && cb(); - }; - - //Sid doesn't exist, create it - if (!sidVal || sidVal.length != Settings.sessionLength) { - setSession(); - } else { - SessionStore.get(sidVal, getSession); - } - } - - /* - * newId() : [Time Stamp]-[serverID][Random Chars] //for sessionid, fixed length - * newID(n) : [Time Stamp][serverID][Random Chars(n)] //for userid - */ - , newID: function(appendLen) { - var len = CHARS.length; - var sid = (+new Date()).toString(len); - - if (appendLen) { - sid += Settings.serverID || ''; - for (var i = 0; i < appendLen; i++) { - sid += CHARS[Math.random() * len | 0]; - } - } else { - sid = sid + '-' + (Settings.serverID || ''); - for (var i = sid.length; i < Settings.sessionLength; i++ ) { - sid += CHARS[Math.random() * len | 0]; - } - } - - return sid; - } - - //Binding new sid to this session - , create: function() { - var self = this; - self.sid = self.newID(); - self.val = { __lastAccessTime: +new Date() }; - return self; - } - - , update: function() { - var self = this; - SessionStore.set(self.sid, self.val); - } - - //Set an key/value pair in session object - , set: function(key, val) { - var session = this.val; - session.__lastAccessTime = +new Date(); - session[key] = val; - return session; - } - - //Get value from session file - , get: function(key) { - var session = this.val; - session.__lastAccessTime = +new Date(); - return key ? session[key] : session; - } - }; - - - var errorRender = function(err, customErrorMsg, outFn) { - var errorMsg - = (customErrorMsg || '') - + '\n' - + err.stack || err.message || 'unknow error' - + '\n' - ; - - console.error(errorMsg); - - if (outFn) { - Settings.showError - ? outFn('
    ' + errorMsg.replace(//g, '>') + '
    ') - : outFn(); - } - } - - /* - Parser: Functions that Filter and Handler will be called - */ - var Parser = function(req, res, mapper) { - - var handle = function() { - try { - mapper.handler(req, res); - } catch(err) { - errorRender(err, 'Error ' + new Date().toISOString() + ' ' + req.url, res.end) - } - }; - - //add sesion support - var parseSession = function() { - //add sesion support - if (mapper.session && typeof req.session == "undefined") { - req.session = new SessionParser(); - req.session.init(req, res, handle); - } else { - handle(); - } - }; - - /* - parse data in request - */ - var parseBody = function() { - //need to parse the request? - if (mapper.post && typeof req.body == "undefined") { - //Must parser the request first, or the post data will lost; - BodyParser(req, res, function(data) { - var body = data; - - //handle exception - try { - mapper.post == "json" - && (body = JSON.parse(data || "{}")); - - mapper.post == "qs" - && (body = qs.parse(data || "")); - } catch(e) { - body = {}; - } - - req.body = body; - parseSession(); - }); - } else { - parseSession(); - } - }; - - /* - parse file in request, this should be at the top of the list - */ - var parseFile = function() { - if (mapper._before && !mapper._before(req, res)) { - Logger.debug('"before" function does not return true, request ended.'); - res.end('This is not a valid request'); - return - } - - //Need to parse the file in request? - if (mapper.file && typeof req.body == "undefined") { - //Must parser the request first, or the post data maybe lost; - var form = new formidable.IncomingForm(); - - form.uploadDir = Settings.uploadDir; - - form.parse(req, function(err, fields, files) { - if (err) { - Logger.debug(err); - return; - }; - - //attach the parameters and files - req.body = fields; - req.files = files; - - //in fact request will not be parsed again, because body is not undefined - parseBody(); - }); - } else { - parseBody(); - }; - }; - - /* - parse cookie in request - */ - var parseCookies = function() { - var cookie = req.headers.cookie - , cookies = {} - ; - - if (cookie) { - var cookieArr = cookie.split(';'); - - for (var i = 0; i < cookieArr.length; i++) { - var strCookie = cookieArr[i] - , idx = strCookie.indexOf('=') - ; - idx > 0 && (cookies[strCookie.substr(0, idx).trim()] = strCookie.substr(idx + 1).trim()); - } - } - - req.cookies = cookies; - parseFile(); - }; - - parseCookies(); - }; - - - /* - set: res.cookie(name, value, options) - del: res.cookie(name, null); - */ - var Cookie = function(name, value, options) { - if (arguments.length < 2) { - return Logger.debug('cookie setter ignored', name); - } - - var self = this - , cookies = self.cookies = self.cookies || [] - , setStr = name + '=' + (value || '') - ; - - options = options || {}; - - if (value === null) { - setStr += '; expires=Thu, 01 Jan 1970 00:00:00 GMT'; - } else if (options.expires) { - setStr += '; expires=' + (new Date(options.expires)).toGMTString(); - } - - options.path && (setStr += '; path=' + options.path); - options.domain && (setStr += '; domain=' + options.domain); - options.secure && (setStr += '; secure'); - options.httponly && (setStr += '; httponly'); - - cookies.push(setStr); - }; - - - /* - SessionStore Interface (MemoryStore) - - get : (sid, callback:session) - - set : (sid, session) - - del : (sid) - session object: { - sid: { - .... - __lastAccessTime: dateObject - } - } - */ - var MemoryStore = (function() { - - var list; - - //force update session in list, convert to big int - //get session in list, if undefined create new one - var get = function(sid, cb) { - !list && init(); - !list[sid] && (list[sid] = {}); - cb && cb(list[sid]); - }; - - var set = function(sid, session) { - !list && init(); - list[sid] = session; - }; - - //remove a sesson from list - var del = function(sid) { - delete list[sid]; - }; - - /* - Session clear handler - */ - var clearHandler = function() { - for (var sid in list) { - var session = list[sid]; - var isValid = session.__lastAccessTime && ((new Date() - session.__lastAccessTime) || 0 <= Settings.sessionTimeout * 2); - !isValid && del(sid); - } - }; - - var init = function() { - list = {}; - setInterval(clearHandler, Settings.sessionTimeout * 4); - }; - - return { - get : get - , set : set - , del : del - } - - })(); - - var FileStore = (function() { - - var getPath = function(sid) { - return path.join(Settings.sessionDir, sid); - }; - - var del = function(sid) { - fs.unlink(getPath(sid), function(err) { - Logger.debug("unlink session file err", err); - }); - }; - - var set = function(sid, session) { - fs.writeFile(getPath(sid), JSON.stringify(session), function(err) { - if (err) { - Logger.error(err); - } - }); - }; - - var get = function(sid, cb) { - var session = {}; - fs.readFile(getPath(sid), function(err, data) { - if (err) { - Logger.debug(err); - cb && cb(session); - return; - } - - try { - session = JSON.parse(data); - } catch (e) { - Logger.debug(e); - } - cb && cb(session); - }); - }; - - /* - Clear the sessions, you should do it manually somewhere, etc: - setInterval(websvr.SessionStore.clear, 200 * 60 * 1000) - */ - var clear = function() { - fs.readdir(Settings.sessionDir, function(err, files) { - if (err) return Logger.debug(err); - - //Delete these sessions that created very very long ago - var expire = +new Date() - Settings.sessionTimeout * 24; - - for (var i = 0; i < files.length; i++) { - var file = files[i] - , idx = file.indexOf('-') - ; - - if (file.length == Settings.sessionLength && idx > 0) { - var stamp = parseInt(file.substr(0, idx), CHARS.length); - //remove the expired session - stamp && stamp < expire && del(file); - } - } - }); - }; - - return { - get : get - , set : set - , del : del - , clear : clear - } - - })(); - - /* - Mapper: Used for Filter & Handler, - expression: required parameter - handler: required parameter - options: optional parameters - */ - var Mapper = function(expression, handler, options) { - var self = this; - - self.expression = expression; - self.handler = handler; - - typeof options == 'object' - ? self.extend(options) - : (self.post = options); - }; - - Mapper.prototype = { - /* - Does this mapper matched this request? - Filter and Handler doesn't have the same matched rules when you passing a string - Filter : Match any section of the request url, e.g., websvr.filter(".svr", cb); - Handler : Match from the begining but it can bypass '/', e.g., websvr.handle("home/login", cb) or websvr.handle("/home/login") - */ - match: function(req, isHandler) { - var self = this - , reqUrl = req.url - , expression = self.expression - ; - - //No expression? It's a general filter mapper - if (!expression) return true; - - switch (expression.constructor) { - //String handler must start with home path, but it can bypass '/' - case String: - return self.matchString(req, isHandler, expression); - case RegExp: return expression.test(reqUrl); - case Array: - for (var i = 0, l = expression.length; i < l; i++) { - if (self.matchString(req, isHandler, expression[i])) { - return true; - } - } - return false; - } - - return false; - }, - - /* - Handle string expression like: /login/:username or /userinfo/ - */ - matchString: function(req, isHandler, expression) { - var reqUrl = req.url; - - //Pure string without params - if (expression.indexOf('/:') < 0) { - var idx = reqUrl.indexOf(expression); - - /* - fix: url(['/m'], cb) & url(['/more'], cb) will match the same handler - */ - if (isHandler) { - if ((idx == 0 || idx == 1)) { - var lastChar = reqUrl.charAt(idx + expression.length) - return lastChar == '' || lastChar == '/' || lastChar == '?' - } - } else { - return idx > -1; - } - - return false; - //Handle and pickup params - } else { - var params = this.parseUrl(expression, reqUrl); - params && _.extend(req.params, params); - return params; - } - }, - - /* - * Pickup the params in the request url - * expression = /home/:key/:pager - * /home/JavaScript => { id: 'JavaScript', pager: '' } - * /key/JavaScript => false - */ - parseUrl: function(expression, reqUrl) { - //Remove the params in querystring - var idx = reqUrl.indexOf('?'); - idx > 0 && (reqUrl = reqUrl.substr(0, idx)); - - var parts = expression.split('/') - , start = expression.charAt(0) === '/' ? 0 : 1 - , urls = reqUrl.split('/') - , params = {} - ; - - for (var i = 0, l = parts.length; i < l; i++) { - var part = parts[i] - , param = urls[i + start] - ; - - if (part.charAt(0) === ':') { - var paramName = part.substr(1); - try { - params[paramName] = decodeURIComponent(param || ''); - } catch(err) { - params[paramName] = param; - } - } else if (part != param) { - return false; - } - } - - return params; - }, - - /* - Add optional parameters on current mapper - i.e: - session: boolean - file: boolean - parse: boolean - */ - extend: function(options) { - for(var key in options) { - this[key] = options[key] - } - }, - - /* - Something need to be done first: i.e: - check the file size and extension before uploading files; - check the content-length before receiving a post json - */ - before: function(func) { - func && (this._before = func) - } - }; - - /* - Http Filter: Execute all the rules that matched, - Filter will be always called before a handler. - */ - var Filter = { - //filter list - filters: [] - - /* - filter: add a new filter - expression: string/regexp [optional] - handler: function [required] - options: object [optional] - */ - , filter: function(expression, handler, options) { - //The first parameter is Function => (handler, options) - if (expression.constructor == Function) { - options = handler; - handler = expression; - expression = null; - } - - var mapper = new Mapper(expression, handler, options); - Filter.filters.push(mapper); - - return mapper; - } - - //Session: parse the session - , session: function(expression, handler, options) { - var mapper = this.filter(expression, handler, options); - mapper.session = true; - return mapper; - } - - /* - file receiver: it's a specfic filter, - this filter should be always at the top of the filter list - */ - , file: function(expression, handler, options) { - var mapper = new Mapper(expression, handler, options); - mapper.file = true; - //insert at the top of the filter list - Filter.filters.splice(0, 0, mapper); - - return mapper; - } - }; - - /* - Filter Chain - */ - var FilterChain = function(cb, req, res) { - var self = this; - - self.idx = 0; - self.cb = cb; - - self.req = req; - self.res = res; - }; - - FilterChain.prototype = { - next: function() { - var self = this - , req = self.req - , res = self.res - ; - - var mapper = Filter.filters[self.idx++]; - - //filter is complete, execute callback; - if (!mapper) return self.cb && self.cb(); - - /* - If not Matched go to next filter - If matched need to execute the req.next() in callback handler, - e.g: - webSvr.filter(/expression/, function(req, res) { - //filter actions - req.next(req, res); - }, options); - */ - if (mapper.match(req)) { - Logger.debug("filter matched", self.idx, mapper.expression, req.url); - - //filter matched, parse the request and then execute it - Parser(req, res, mapper); - } else { - //filter not matched, validate next filter - self.next(); - } - } - }; - - /* - Http Handler: Execute and returned when when first matched; - At the same time only one Handler will be called; - */ - var Handler = { - handlers: [] - /* - url: add a new handler - expression: string/regexp [required] - handler: [many types] [required] - options: object [optional] - */ - , url: function(expression, handler, options) { - if (!expression) { - Logger.debug('url expression ignored'); - } else { - var mapper = new Mapper(expression, handler, options); - Handler.handlers.push(mapper); - } - return self; - } - - , post: function(expression, handler, options) { - if (expression && handler) { - return this.url(expression, handler, options || 'qs'); - } - return self; - } - - , handle: function(req, res) { - //flag: is matched? - for(var i = 0, len = Handler.handlers.length; i < len ; i++) { - - var mapper = Handler.handlers[i]; - //This is handler match - if (mapper.match(req, true)) { - - Logger.debug("handler matched", i, mapper.expression, req.url); - - var handler = mapper.handler, - type = handler.constructor.name; - - switch(type) { - //function: treated it as custom function handler - case "Function": - Parser(req, res, mapper); - break; - - //string: treated it as content - case "String": - res.writeHead(200, { "Content-Type": "text/html" }); - res.end(handler); - break; - - //array: treated it as a file. - case "Array": - res.sendFile(handler[0]); - break; - } - return true; - } - } - - return false; - - } //end of handle - }; - - /* - ListDir: List all the files in a directory - */ - var ListDir = (function() { - - var urlFormat = function(url) { - url = url.replace(/\\/g,'/'); - url = url.replace(/ /g,'%20'); - return url; - }; - - //Align to right - var date = function(date) { - var d = date.getFullYear() - + '-' + (date.getMonth() + 1) - + '-' + (date.getDay() + 1) - + " " + date.toLocaleTimeString(); - return " ".substring(0, 20 - d.length) + d; - }; - - //Align to left - var size = function(num) { - return num + " ".substring(0, 12 - String(num).length); - }; - - //Create an anchor - var anchor = function(txt, url) { - url = url ? url : "/"; - return '' + txt + ""; - }; - - var listDir = { - //List all the files in a directory - list: function(req, res, dir) { - var url = req.url, - cur = 0, - len = 0; - - var listBegin = function() { - res.writeHead(200, {"Content-Type": "text/html"}); - res.write("

    http://" + req.headers.host + url + "


    "); - res.write("
    ");
    -          res.write(anchor("[To Parent Directory]", url.substr(0, url.lastIndexOf('/'))) + "\r\n\r\n");
    -        };
    -
    -        var listEnd = function() {
    -          res.write("

    "); - res.end("
    Count: " + len + "
    "); - }; - - listBegin(); - - fs.readdir(dir, function(err, files) { - if (err) { - listEnd(); - Logger.debug(err); - return; - } - - len = files.length; - - for(var idx = 0; idx < len; idx++) { - //Persistent the idx before make the sync process - (function(idx) { - var filePath = path.join(dir, files[idx]), - fileUrl = urlFormat(path.join(url, files[idx])); - - fs.stat(filePath, function(err, stat) { - cur++; - - if (err) { - Logger.debug(err); - }else{ - res.write( - date(stat.mtime) - + "\t" + size(stat.size) - + anchor(files[idx], fileUrl) - + "\r\n" - ); - } - - (cur == len) && listEnd(); - }); - })(idx); - } - - (len == 0) && listEnd(); - }); - } - }; - - return listDir; - }()); - - /* - * Template Engine - */ - var Template = (function() { - - //Caching of template files. - var templatePool = {} - , includeString = '/g - , includeBeginLen = 14 - , includeAfterLen = 4 - ; - - //default engine and defaultModel (e.g., define global footer/header in model) - var engineFunc = require("dot").compile - , defaultModel = null - ; - - //get a file - var getFile = function(filename, cb) { - //if template cache enabled, get from cache pool directly - var cachedTemplate = templatePool[filename] - - var updateCache = function(err, tmpl) { - if (err) { - Logger.debug(err); - cb && cb(""); - } else { - tmpl = getInclude(tmpl.toString(), cb) - templatePool[filename] = tmpl; - Logger.debug('update template cache', filename); - } - }; - - if (Settings.templateCache && cachedTemplate) { - if (cachedTemplate.indexOf(includeString) > -1) { - updateCache(null, cachedTemplate); - } else { - cb && cb(templatePool[filename]); - } - } else { - /* - * webSvr.render('/home.tmpl', model) : means related to Setting.root - * webSvr.render('home.tmpl', model) : means related to Setting.home - */ - var firstChar = filename && filename.charAt(0) - , fullpath = path.join(firstChar == '/' ? Settings.root : Settings.home, filename) - ; - - fs.readFile(fullpath, updateCache); - } - }; - - var getInclude = function(tmpl, cb) { - /* - find and update all the include files, - will get templates from cache for making the process easier - include file will be enabled at the next refresh - */ - tmpl = (tmpl || '').replace(includeRegExp, function(fileStr) { - Logger.debug('Include File:', fileStr); - var includeFile = fileStr.substring(includeBeginLen, fileStr.length - includeAfterLen); - getFile(includeFile); - return templatePool[includeFile] || fileStr; - }); - - cb && cb (tmpl) - return tmpl - }; - - return { - //render templates - render: function(tmplUrl, _model, outFn, isRawTmpl) { - var res = this - , end = outFn || res.end - , len = arguments.length - ; - - /* - format - */ - len < 1 && (tmplUrl = {}); - - if (len < 2) { - if (typeof tmplUrl == 'object') { - _model = tmplUrl; - /* - * remove the first '/' make it as related path - */ - tmplUrl = res.req.url.substr(1); - - var idx = tmplUrl.indexOf('?'); - idx > -1 && (tmplUrl = tmplUrl.substr(0, idx)); - } else { - _model = {}; - } - } - - /* - merge model - */ - var model = defaultModel - ? Object.create(defaultModel) - : {} - ; - - _.extend(model, res.model); - _.extend(model, _model); - - - /* - response - */ - var render = function(chrunk) { - var tmplFn; - - try { - tmplFn = engineFunc(chrunk); - end(tmplFn(model)); - } catch(err) { - /* - refer: https://code.google.com/p/v8/issues/detail?id=1914 - at eval (eval at (unknown source), :2:8) - */ - var errStack = err.stack || '' - , lineStr = ':' - , idx = errStack.indexOf(lineStr) - , errmsg = res.req.url + '@' + tmplUrl.substr(0, 400) - - if (idx > 0) { - errStack = errStack.substr(idx) - errStack = errStack.substr(0, errStack.indexOf(')')) - var pos = errStack.substring(lineStr.length) - pos = pos.substring(pos.indexOf(':') + 1, errStack.length - 1) - pos = parseInt(pos) - - if (pos) { - var strFn = (tmplFn || '').toString() - var errStr = strFn.substring(pos - 10, pos + 100) - errmsg += ':' + errStack + '\n ' + errStr - } - } - - errorRender(err, errmsg, end) - } - }; - - isRawTmpl - ? getInclude(tmplUrl, render) - : getFile(tmplUrl, render) - } - , renderRaw: function(rawTmpl, model, outFn) { - Template.render(rawTmpl, model, outFn, true) - } - , engine: function(_engineFunc) { - engineFunc = _engineFunc; - } - , model: function(_model) { - defaultModel = _model; - } - , clear: function() { - for (var tmpl in templatePool) { - delete templatePool[tmpl] - } - } - } - }()); - - - /*****************Web initial codes*************/ - var fileHandler = function(req, res) { - - var url = req.url - , hasQuery = url.indexOf("?") - ; - - //fs.stat can't recognize the file name with querystring; - url = hasQuery > 0 ? url.substring(0, hasQuery) : url; - - var fullPath = path.join(Settings.home, url); - - //Handle path - var handlePath = function(phyPath) { - fs.stat(phyPath, function(err, stat) { - - //Consider as file not found - if (err) return self.write404(res); - - //Is file? Open this file and send to client. - if (stat.isFile()) { - // "If-modified-since" undefined, mark it as 1970-01-01 0:0:0 - var cacheTime = new Date(req.headers["if-modified-since"] || 1); - - // The file is modified - if (Settings.cache && stat.mtime <= cacheTime) { - res.writeHead(304); - res.end(); - - // Else send "not modifed" - } else { - res.setHeader("Last-Modified", stat.mtime.toUTCString()); - writeFile(res, phyPath); - } - } - - //Is Directory? - else if (stat.isDirectory()) { - handleDefault(phyPath); - } - - //Or write the 404 pages - else { - self.write404(res); - } - - }); - }; - - //List all the files and folders. - var handleDir = function(dirPath) { - Settings.listDir - ? ListDir.list(req, res, dirPath) - : self.write403(res); - }; - - //Handle default page - var handleDefault = function(dirPath) { - var defaultPage = Settings.defaultPage; - - if (defaultPage) { - var defaultPath = path.join(dirPath, defaultPage); - - fs.exists(defaultPath, function(exists) { - //If page exists hanle it again - if (exists) { - //In order to make it as a dir path for loading static resources - if (url[url.length - 1] != '/') { - return res.redirect(url + '/'); - } - - handlePath(defaultPath); - //If page doesn't exist hanlde the dir again - } else { - handleDir(dirPath); - } - }); - } else { - handleDir(dirPath); - } - }; - - handlePath(fullPath); - }; - - var requestHandler = function(req, res) { - //Make request accessible in response object - res.req = req; - - //Response may be shutdown when do the filter, in order not to cause exception, - //Rewrite the write/writeHead functionalities of current response object - var endFn = res.end; - res.end = function() { - - //If Content-Type is undefined, using text/html as default - if (!res.headersSent) { - !res.getHeader('Content-Type') && res.setHeader('Content-Type', 'text/html; charset=' + (res.charset || 'utf-8')); - res.cookies && res.cookies.length && res.setHeader('Set-Cookie', res.cookies); - } - - //Execute old end - endFn.apply(res, arguments); - //Rewirte write/writeHead on response object - res.write = res.writeHead = res.setHeader = function() { - Logger.debug("response is already end, response.write ignored!") - }; - - //Update session when resonse.end is executed - req.session && req.session.update(); - }; - - res.sendRootFile = function(filePath) { - writeFile(res, path.join(Settings.root, filePath)); - }; - - res.sendHomeFile = res.sendFile = function(filePath) { - writeFile(res, path.join(Settings.home, filePath)); - }; - - //301/302 : move permanently - res.redirect = function(url, status) { - res.statusCode = status || 302; - res.setHeader('Location', url); - res.end(); - }; - - //set content-type - res.type = function(type) { - if(type && !res.headersSent) { - res.getHeader('Content-Type') && res.removeHeader("Content-Type"); - res.setHeader('Content-Type', (mime.lookup(type) || 'text/plain') + '; charset=' + (res.charset || 'utf-8')); - } - }; - - //Send sth - res.send = function(type, content) { - if (arguments.length < 2) { - content = type; - type = null; - } - - if (typeof content == 'object') { - content = JSON.stringify(content); - type = type || 'json'; - } - - if (type) { - typeof type == 'number' - ? (res.statusCode = 404) - : res.type(type); - } - res.end(content || ''); - }; - - res.cookie = Cookie; - - //render template objects - res.render = Template.render; - res.renderRaw = Template.renderRaw; - - //params in the matched url - req.params = {}; - //default model - res.model = {}; - - //initial httprequest - var filterChain = new FilterChain(function() { - - //if handler not match, send the request - !Handler.handle(req, res) && fileHandler(req, res); - - }, req, res); - - //Hook FilterChain object on the request - req.filter = filterChain; - - //Handle the first filter - req.filter.next(); - }; - - var writeFile = function(res, fullPath) { - fs.readFile(fullPath, function(err, data) { - if (err) { - Logger.debug(err); - return; - } - - res.type(fullPath); - res.writeHead(200); - res.end(data, "binary"); - }); - }; - - //API have function chain - //Mapper - self.parseUrl = Mapper.prototype.parseUrl; - - //Server ID - self.newID = SessionParser.prototype.newID; - - //Filter - self.use = Filter.filter; - self.filter = Filter.filter; - self.session = Filter.session; - self.file = Filter.file; - - //Handler - self.get = Handler.url; - self.url = Handler.url; - self.handle = Handler.url; - self.handler = Handler.url; - self.post = Handler.post; - self.settings = Settings; - - //Template - self.render = Template.render; - self.engine = Template.engine; - self.model = Template.model; - self.clear = Template.clear; - - //Get a full path of a request - self.getFullPath = function(filePath) { - return path.join(Settings.home, filePath); - }; - - self.write403 = function(res) { - res.writeHead(403, {"Content-Type": "text/html"}); - res.end("Access forbidden!"); - - return self; - }; - - self.write404 = function(res) { - var tmpl404 = Settings["404"]; - - res.writeHead(404, {"Content-Type": "text/html"}); - - tmpl404 - ? res.render(tmpl404, null) - : res.end("File not found!"); - - return self; - }; - - self.running = false; - - //start http server - self.start = function() { - - if (self.running) { - console.log('Already running, ignored'); - return self; - } - - //Create http server: Enable by default - if (Settings.port) { - var port = Settings.port; - - var httpSvr = self.httpSvr || http.createServer(requestHandler); - httpSvr.listen(port); - - console.log("Http server running at" - ,"home:", Settings.home - ,"port:", port - ); - - self.httpSvr = httpSvr; - } - - //Create https server: Disable by default - if ( Settings.httpsPort - && Settings.httpsKey - && Settings.httpsCert) { - - var httpsPort = Settings.httpsPort; - - var httpsSvr = self.httpsSvr || https.createServer({ - key: Settings.httpsKey, - cert: Settings.httpsCert - }, requestHandler); - - httpsSvr.listen(httpsPort); - - console.log("Https server running at" - ,"home:", Settings.home - ,"port:", httpsPort - ); - - self.httpsSvr = httpsSvr; - } - - self.running = true; - - return self; - }; - - //stop http server - self.stop = function() { - self.httpSvr && self.httpSvr.close(); - self.httpsSvr && self.httpsSvr.close(); - self.running = false; - - return self; - }; - - //init - self.init = function() { - //Update the default value of Settings - _.extend(Settings, options); - - SessionStore = Settings.sessionDir ? FileStore : MemoryStore; - - //Start by default - self.start(); - - return self; - }; - - //property: filters & handlers - define(self, 'filters', { - get: function() { - return Filter.filters - }, - set: function(filters) { - Filter.filters = filters; - } - }); - - define(self, 'handlers', { - get: function() { - return Handler.handlers; - }, - set: function(handlers) { - Handler.handlers = handlers; - } - }); - - define(self, 'sessionStore', { - get: function() { - return SessionStore; - }, - set: function(sessionStore) { - if (sessionStore && sessionStore.get && sessionStore.set && sessionStore.del) { - SessionStore = sessionStore; - } else { - Logger.debug('Your session storage do not have interface: get/set/del'); - } - } - }); - - //init - self.init(); - - return self; - -}; \ No newline at end of file