Skip to content

Commit

Permalink
continued setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bvallelunga committed Apr 19, 2014
1 parent dc73f43 commit 58e82ac
Show file tree
Hide file tree
Showing 29 changed files with 757 additions and 26 deletions.
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"general": {
"production": false,
"port": 3000,
"company": "Imprint",
"delimeter": {
"web": " · ",
Expand Down
31 changes: 31 additions & 0 deletions lib/core/extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var sprintf = require("sprintf-js").vsprintf;

module.exports = function() {
JSON.cycle = function(data) {
return JSON.parse(JSON.stringify(data));
}

String.prototype.__defineGetter__("capitalize", function() {
return $.map(this.split(" "), function(value) {
return value.charAt(0).toUpperCase() + value.slice(1);
}).join(" ");
});

String.prototype.sprintf = function(arguments) {
return sprintf(this, arguments);
};

Array.prototype.__defineGetter__("empty", function() {
return this.length == 0;
});

Array.prototype.end = function(index) {
return (this.length-1) == index;
};

/* Piler Library Breaks When Setting This Getter
Object.prototype.__defineGetter__("empty", function() {
return Object.keys(this).length == 0;
});
*/
}
74 changes: 74 additions & 0 deletions lib/core/filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
var moment = require("moment-range");
var inflect = require('i')();

module.exports = function(ejs) {
ejs.filters.capitalize = function(str) {
return $.map(str.split(" "), function(data) {
return data.charAt(0).toUpperCase() + data.slice(1);
}).join(" ");
};

ejs.filters.pluralize = function(str, pluralize) {
return (pluralize != false) ? inflect.pluralize(str) : str;
};

ejs.filters.header = function(str) {
if(str.length <= 3) {
return str.toUpperCase();
} else {
return $.map(str.split("_"), function(data) {
return data.charAt(0).toUpperCase() + data.slice(1);
}).join(" ");
}
};

ejs.filters.urlencode = function(str) {
return encodeURI(str);
}

ejs.filters.link = function(str, shorten) {
str = str.replace("http://", "").replace("https://", "");

if(shorten) {
return str.slice(0, shorten) + ((str.length >= shorten) ? "..." : "");
} else {
return str;
}
};

ejs.filters.format = function(input, format) {
switch(typeof input) {
case "number":
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

case "boolean":
if(input) {
return "<span class='" + config.icons.checked + " green'></span>" ;
} else {
return "<span class='" + config.icons.unchecked + "'></span>" ;
}

case "object":
if(input === null || input === undefined) {
return "";
} else if(input instanceof Date) {
return moment(input).format(format || "MMM Do YYYY");
} else {
return $.map(input, function(data, index) {
return "<strong>" + index + "</strong>: " + data;
}).join("<br>");
}

default:
return input;
}
};

ejs.filters.duration = function(date) {
return moment.duration(date - new Date()).humanize(true);
}

ejs.filters.random = function(array) {
return array[Math.floor(Math.random() * array.length)];
}
}
4 changes: 4 additions & 0 deletions lib/core/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
filters: require("./filters"),
extensions: require("./extensions")
}
231 changes: 231 additions & 0 deletions lib/debugger/edt.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
/*
NOTE: open source - copied theme from developer toolbar community
*/

/* make standalone page show express-debug by default and disable show/hide buttons */
.express-debug.standalone #EDT #EDT-close { display: none; }
.express-debug.standalone #EDT-show { display: none; }
.express-debug.standalone #EDT { display: block; }

/* core styling */
.express-debug { position: static !important; }

.express-debug * {
font-size: inherit;
font-style: inherit;
font-weight: inherit;
color: inherit;
background: none repeat transparent;
font-family: Consolas, Monaco, monospace, sans-serif;
vertical-align: baseline;
margin: 0;
padding: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
opacity: 1;
}
.express-debug a { cursor: pointer !important; }

/* SHOW/HIDE buttons */
#EDT-show {
position: fixed;
top: inherit;
bottom: 0;
right: 0;
z-index: 100000000000000;
border-right: none;
padding: 10px 10px 6px 12px;
font-size: 20px;
cursor: pointer;
color: #4c4c4c !important;
border: solid 1px #bfbfbf !important;
background: -webkit-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
background: -moz-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
background: -ms-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
background: -o-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
border-top-left-radius: 3px;
-moz-border-top-left-radius: 3px;
opacity: .8;
}
#EDT-show:hover, #EDT-show:focus {
opacity: 1;
}

#EDT #EDT-close {
font-weight: bold;
display: block;
float: right;
margin-right: 20px;
border-left: 1px solid #717171;
border-right: 1px solid #717171;
}

/* main layout */
#EDT {
display: none;
font-size: 14px;
z-index: 100000000000000;
position: fixed;
top: 0;
right: 0;
left: 0;
opacity: 1;
background: #fff;
height: 100%;
overflow-x: hidden;
}

#EDT td, #EDT th { vertical-align: top; }

#EDT #EDT-main {
background-color: rgba(255,255,255,0.95);
margin-top: 34px;
padding: 20px 20px 20px 20px;
width: 100%;
min-height: 100%;
opacity: 1;
}


#EDT .tab { display: none; }
#EDT .tab.active { display: block; }

#EDT h2, #EDT h4, #EDT-menu { font-size: 18px }
#EDT h2 { font-weight: bold; color: #CCC; margin-bottom: 14px; }
#EDT h4 {
display: inline-block;
padding-left: 20px;
font-weight: bold;
color: #000;
margin-bottom: 12px;
}

#EDT-menu {
width: 100%;
text-align: center;
position: fixed;
top: 0;
color: #4c4c4c !important;
border-bottom: solid 1px #bfbfbf !important;
background: -webkit-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
background: -moz-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
background: -ms-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
background: -o-linear-gradient(#fcfcfc 0%, #eeeeee 100%) !important;
line-height: 32px;
outline: none;
opacity: 1;
}

#EDT-menu span.text, #EDT-menu a {
display: inline-block;
padding: 5px 10px 0 10px;
}

#EDT-menu div.sep {
border-left: 1px solid #717171;
height: 37px;
vertical-align: top;
width: 1px;
display: inline-block;
}

#EDT-menu > div.sep,
#EDT-menu > span.text,
#EDT-menu ul div.sep:first-child {
display: none;
}

#EDT-menu ul, #EDT-menu li, #EDT-menu a {
display: inline-block;
list-style: none;
color: #555;
text-decoration: none;
}

#EDT-menu a:hover, #EDT-menu a:focus, #EDT-menu a.active {
color: #000;
outline: none;
}
#EDT-menu a:hover, #EDT-menu a:focus {
text-decoration: underline;
}

#EDT h4 span { padding-left: 20px; font-weight: normal; font-size: 14px; }

#EDT .edt-nav li {
display: block;
list-style: none;
padding: 5px;
}
#EDT .edt-nav a {
text-decoration: none;
font-size: 16px;
line-height: 26px;
}

#EDT .edt-nav a:hover {
text-decoration: underline;
}

#EDT .profile th:nth-child(1) { width: 10%; min-width: 130px}
#EDT .profile th:nth-child(2) { width: 18%; min-width: 100px}
#EDT .profile th:nth-child(4) { width: 10%; min-width: 100px}

#EDT table.profile, #EDT table.object {
border: 1px solid #DDD;
width: 100%;
border-collapse: collapse;
margin-bottom: 12px;
}
#EDT table.object { table-layout:fixed; }

#EDT th { font-weight: bold; }
#EDT .object tr:nth-child(2n), #EDT table.profile tr:nth-child(2n) { background-color: rgba(0, 0, 0, 0.03); }

#EDT .object th,
#EDT .profile th,
#EDT .object td,
#EDT .profile td { padding: 8px; word-wrap: break-word; color: #000; text-align: left; }

#EDT .object th:first-child { min-width: 126px; width: 13%; }
#EDT .object th.arr:first-child { width: 60px; min-width: 60px; }

#EDT .object .collapse, #EDT .object .expand { cursor: pointer; }
#EDT .object .indicator { text-align: right; font-size: 16px; color: #000; }
#EDT .collapse .indicator:after { content: '(-)'; }
#EDT .expand .indicator:after { content: '(+)'; }

#EDT table .right { text-align: right; }

/* value output styling */
#EDT .string { color: #179900 }
#EDT .string:before, #EDT .string:after { content: '"'; color: #000; }
#EDT .number { color: #af2b2b; font-weight: bold; }
#EDT .boolean { color: #00F; }
#EDT .undefined { font-style: italic; }
#EDT .undefined, #EDT .null { color: #a500a0; }
#EDT .date { color: #179900; }
#EDT .date:before { content: 'Date("'; color: #000; }
#EDT .date:after { content: '")'; color: #000; }
#EDT .exceeded { color: #666; font-style: italic; }
/* template code and functions */
#EDT pre { background-color: #F5F5F5; color: #444; border: 1px solid #DDD; padding: 8px; word-wrap: break-word;}
#EDT pre.fn { display: none; margin-top: 6px; }
#EDT .showFn, #EDT .hideFn { cursor: pointer; }
#EDT .showFn:before, #EDT .showFn:after, #EDT .hideFn:before, #EDT .hideFn:after { color: #666; font-weight: bold; }
#EDT .showFn:before, #EDT .hideFn:before { content: 'fn () { '; }
#EDT .showFn:after { content: ' } (+)'; }
#EDT .hideFn:after { content: ' } (-)'; }

/* fix text selection when trying to use expand/collapse */
#EDT .indicator, #EDT.showFn, #EDT.hideFn {
-webkit-user-select: none;-moz-user-select: none;-khtml-user-select: none;-ms-user-select: none;user-select: none;
}

@media print {
.express-debug,
.express-debug * {
display: none;
}
}
8 changes: 8 additions & 0 deletions lib/debugger/edt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
NOTE: open source - copied theme from developer toolbar community
*/

$(document).on("click", "#EDT-show, #EDT-close", function() {
$("#EDT-main .object .object tbody").hide();
$("body").css("overflow", (($("body").css("overflow") == "hidden") ? "" : "hidden"));
});
35 changes: 35 additions & 0 deletions lib/error/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
exports.report = function(error) {
try {
if(typeof error == "object") {
if((Array.isArray(error) && !error.empty) || !$.isEmptyObject(error)) {
console.error(error);
}
} else if(error) {
console.error(error.code);

console.error(error);
}
} catch(error) {
return exports.report(error);
}
}

exports.capture = function(data, callback) {
/* True Means It Is On Init */
if(data == true) {
/* Return Blank Function */
return function() {};
} else {
/*
var data is now seen as
error. Now check if it
contains an error.
*/
if(typeof callback == "function") {
exports.report(data);
return callback();
} else {
return exports.report(data);
}
}
}
1 change: 1 addition & 0 deletions lib/geoip/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('geoip-lite').lookup;
Loading

0 comments on commit 58e82ac

Please sign in to comment.