From 05c529eafa3dee261a19cbcf38958f975444b9cc Mon Sep 17 00:00:00 2001 From: "tom.cat" Date: Tue, 8 Mar 2016 18:43:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B1=B0=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=8A=A4=ED=85=8C=ED=8B=B1=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asset/static/css/datatables/css/demo_page.css | 144 +- .../fonts/glyphicons-halflings-regular.2svg | 288 ---- .../js/easypie/jquery.easypiechart.min.js | 4 +- asset/static/js/validator/validator.js | 711 ++++----- asset/template/index.html | 1349 +++++++++++++++++ asset/template/index.tpl | 1337 ---------------- asset/template/layout/header.html | 23 + asset/template/layout/sidebar.html | 117 ++ asset/template/{lorem.tpl => lorem.html} | 0 .../template/{page_404.tpl => page_404.html} | 0 .../template/{page_500.tpl => page_500.html} | 0 main.go | 22 +- route/index.go | 2 +- 13 files changed, 1932 insertions(+), 2065 deletions(-) delete mode 100755 asset/static/fonts/glyphicons-halflings-regular.2svg create mode 100755 asset/template/index.html delete mode 100755 asset/template/index.tpl create mode 100644 asset/template/layout/header.html create mode 100755 asset/template/layout/sidebar.html rename asset/template/{lorem.tpl => lorem.html} (100%) rename asset/template/{page_404.tpl => page_404.html} (100%) rename asset/template/{page_500.tpl => page_500.html} (100%) diff --git a/asset/static/css/datatables/css/demo_page.css b/asset/static/css/datatables/css/demo_page.css index 935ed24..6ed0bc3 100755 --- a/asset/static/css/datatables/css/demo_page.css +++ b/asset/static/css/datatables/css/demo_page.css @@ -1,127 +1,103 @@ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * General page setup */ + #dt_example { - font: 80%/1.45em "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; - margin: 0; - padding: 0; - color: #333; - background-color: #fff; + font: 80%/1.45em "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; + margin: 0; + padding: 0; + color: #333; + background-color: #fff; } - - #dt_example #container { - width: 800px; - margin: 30px auto; - padding: 0; + width: 800px; + margin: 30px auto; + padding: 0; } - - #dt_example #footer { - margin: 50px auto 0 auto; - padding: 0; + margin: 50px auto 0 auto; + padding: 0; } - #dt_example #demo { - margin: 30px auto 0 auto; + margin: 30px auto 0 auto; } - #dt_example .demo_jui { - margin: 30px auto 0 auto; + margin: 30px auto 0 auto; } - #dt_example .big { - font-size: 1.3em; - font-weight: bold; - line-height: 1.6em; - color: #4E6CA3; + font-size: 1.3em; + font-weight: bold; + line-height: 1.6em; + color: #4E6CA3; } - #dt_example .spacer { - height: 20px; - clear: both; + height: 20px; + clear: both; } - #dt_example .clear { - clear: both; + clear: both; } - #dt_example pre { - padding: 15px; - background-color: #F5F5F5; - border: 1px solid #CCCCCC; + padding: 15px; + background-color: #F5F5F5; + border: 1px solid #CCCCCC; } - #dt_example h1 { - margin-top: 2em; - font-size: 1.3em; - font-weight: normal; - line-height: 1.6em; - color: #4E6CA3; - border-bottom: 1px solid #B0BED9; - clear: both; + margin-top: 2em; + font-size: 1.3em; + font-weight: normal; + line-height: 1.6em; + color: #4E6CA3; + border-bottom: 1px solid #B0BED9; + clear: both; } - #dt_example h2 { - font-size: 1.2em; - font-weight: normal; - line-height: 1.6em; - color: #4E6CA3; - clear: both; + font-size: 1.2em; + font-weight: normal; + line-height: 1.6em; + color: #4E6CA3; + clear: both; } - #dt_example a { - color: #0063DC; - text-decoration: none; + color: #0063DC; + text-decoration: none; } - #dt_example a:hover { - text-decoration: underline; + text-decoration: underline; } - #dt_example ul { - color: #4E6CA3; + color: #4E6CA3; } - .css_right { - float: right; + float: right; } - .css_left { - float: left; + float: left; } - .demo_links { - float: left; - width: 50%; - margin-bottom: 1em; + float: left; + width: 50%; + margin-bottom: 1em; } - #demo_info { - padding: 5px; - border: 1px solid #B0BED9; - height: 100px; - width: 100%; - overflow: auto; + padding: 5px; + border: 1px solid #B0BED9; + height: 100px; + width: 100%; + overflow: auto; } - #dt_example code { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - padding: 2px 4px !important; - white-space: nowrap; - font-size: 0.9em; - - color: #D14; - background-color: #F7F7F9; - - border: 1px solid #E1E1E8; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + padding: 2px 4px !important; + white-space: nowrap; + font-size: 0.9em; + color: #D14; + background-color: #F7F7F9; + border: 1px solid #E1E1E8; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; } - #dt_example div.syntaxhighlighter code { - padding: 0 !important; + padding: 0 !important; } - diff --git a/asset/static/fonts/glyphicons-halflings-regular.2svg b/asset/static/fonts/glyphicons-halflings-regular.2svg deleted file mode 100755 index 94fb549..0000000 --- a/asset/static/fonts/glyphicons-halflings-regular.2svg +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/asset/static/js/easypie/jquery.easypiechart.min.js b/asset/static/js/easypie/jquery.easypiechart.min.js index e981757..b329abe 100755 --- a/asset/static/js/easypie/jquery.easypiechart.min.js +++ b/asset/static/js/easypie/jquery.easypiechart.min.js @@ -2,8 +2,8 @@ * easyPieChart * Lightweight plugin to render simple, animated and retina optimized pie charts * - * @license + * @license * @author Robert Fleischmann (http://robert-fleischmann.de) * @version 2.1.5 **/ -!function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery)}(this,function(a){var b=function(a,b){var c,d=document.createElement("canvas");a.appendChild(d),"undefined"!=typeof G_vmlCanvasManager&&G_vmlCanvasManager.initElement(d);var e=d.getContext("2d");d.width=d.height=b.size;var f=1;window.devicePixelRatio>1&&(f=window.devicePixelRatio,d.style.width=d.style.height=[b.size,"px"].join(""),d.width=d.height=b.size*f,e.scale(f,f)),e.translate(b.size/2,b.size/2),e.rotate((-0.5+b.rotate/180)*Math.PI);var g=(b.size-b.lineWidth)/2;b.scaleColor&&b.scaleLength&&(g-=b.scaleLength+2),Date.now=Date.now||function(){return+new Date};var h=function(a,b,c){c=Math.min(Math.max(-1,c||0),1);var d=0>=c?!0:!1;e.beginPath(),e.arc(0,0,g,0,2*Math.PI*c,d),e.strokeStyle=a,e.lineWidth=b,e.stroke()},i=function(){var a,c;e.lineWidth=1,e.fillStyle=b.scaleColor,e.save();for(var d=24;d>0;--d)d%6===0?(c=b.scaleLength,a=0):(c=.6*b.scaleLength,a=b.scaleLength-c),e.fillRect(-b.size/2+a,0,c,1),e.rotate(Math.PI/12);e.restore()},j=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1e3/60)}}(),k=function(){b.scaleColor&&i(),b.trackColor&&h(b.trackColor,b.lineWidth,1)};this.getCanvas=function(){return d},this.getCtx=function(){return e},this.clear=function(){e.clearRect(b.size/-2,b.size/-2,b.size,b.size)},this.draw=function(a){b.scaleColor||b.trackColor?e.getImageData&&e.putImageData?c?e.putImageData(c,0,0):(k(),c=e.getImageData(0,0,b.size*f,b.size*f)):(this.clear(),k()):this.clear(),e.lineCap=b.lineCap;var d;d="function"==typeof b.barColor?b.barColor(a):b.barColor,h(d,b.lineWidth,a/100)}.bind(this),this.animate=function(a,c){var d=Date.now();b.onStart(a,c);var e=function(){var f=Math.min(Date.now()-d,b.animate.duration),g=b.easing(this,f,a,c-a,b.animate.duration);this.draw(g),b.onStep(a,c,g),f>=b.animate.duration?b.onStop(a,c):j(e)}.bind(this);j(e)}.bind(this)},c=function(a,c){var d={barColor:"#ef1e25",trackColor:"#f9f9f9",scaleColor:"#dfe0e0",scaleLength:6,lineCap:"round",lineWidth:3,size:95,rotate:0,animate:{duration:1e3,enabled:!0},easing:function(a,b,c,d,e){return b/=e/2,1>b?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},onStart:function(){},onStep:function(){},onStop:function(){}};if("undefined"!=typeof b)d.renderer=b;else{if("undefined"==typeof SVGRenderer)throw new Error("Please load either the SVG- or the CanvasRenderer");d.renderer=SVGRenderer}var e={},f=0,g=function(){this.el=a,this.options=e;for(var b in d)d.hasOwnProperty(b)&&(e[b]=c&&"undefined"!=typeof c[b]?c[b]:d[b],"function"==typeof e[b]&&(e[b]=e[b].bind(this)));e.easing="string"==typeof e.easing&&"undefined"!=typeof jQuery&&jQuery.isFunction(jQuery.easing[e.easing])?jQuery.easing[e.easing]:d.easing,"number"==typeof e.animate&&(e.animate={duration:e.animate,enabled:!0}),"boolean"!=typeof e.animate||e.animate||(e.animate={duration:1e3,enabled:e.animate}),this.renderer=new e.renderer(a,e),this.renderer.draw(f),a.dataset&&a.dataset.percent?this.update(parseFloat(a.dataset.percent)):a.getAttribute&&a.getAttribute("data-percent")&&this.update(parseFloat(a.getAttribute("data-percent")))}.bind(this);this.update=function(a){return a=parseFloat(a),e.animate.enabled?this.renderer.animate(f,a):this.renderer.draw(a),f=a,this}.bind(this),this.disableAnimation=function(){return e.animate.enabled=!1,this},this.enableAnimation=function(){return e.animate.enabled=!0,this},g()};a.fn.easyPieChart=function(b){return this.each(function(){var d;a.data(this,"easyPieChart")||(d=a.extend({},b,a(this).data()),a.data(this,"easyPieChart",new c(this,d)))})}}); \ No newline at end of file +!function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jQuery)}(this,function(a){var b=function(a,b){var c,d=document.createElement("canvas");a.appendChild(d),"undefined"!=typeof G_vmlCanvasManager&&G_vmlCanvasManager.initElement(d);var e=d.getContext("2d");d.width=d.height=b.size;var f=1;window.devicePixelRatio>1&&(f=window.devicePixelRatio,d.style.width=d.style.height=[b.size,"px"].join(""),d.width=d.height=b.size*f,e.scale(f,f)),e.translate(b.size/2,b.size/2),e.rotate((-0.5+b.rotate/180)*Math.PI);var g=(b.size-b.lineWidth)/2;b.scaleColor&&b.scaleLength&&(g-=b.scaleLength+2),Date.now=Date.now||function(){return+new Date};var h=function(a,b,c){c=Math.min(Math.max(-1,c||0),1);var d=0>=c?!0:!1;e.beginPath(),e.arc(0,0,g,0,2*Math.PI*c,d),e.strokeStyle=a,e.lineWidth=b,e.stroke()},i=function(){var a,c;e.lineWidth=1,e.fillStyle=b.scaleColor,e.save();for(var d=24;d>0;--d)d%6===0?(c=b.scaleLength,a=0):(c=.6*b.scaleLength,a=b.scaleLength-c),e.fillRect(-b.size/2+a,0,c,1),e.rotate(Math.PI/12);e.restore()},j=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1e3/60)}}(),k=function(){b.scaleColor&&i(),b.trackColor&&h(b.trackColor,b.lineWidth,1)};this.getCanvas=function(){return d},this.getCtx=function(){return e},this.clear=function(){e.clearRect(b.size/-2,b.size/-2,b.size,b.size)},this.draw=function(a){b.scaleColor||b.trackColor?e.getImageData&&e.putImageData?c?e.putImageData(c,0,0):(k(),c=e.getImageData(0,0,b.size*f,b.size*f)):(this.clear(),k()):this.clear(),e.lineCap=b.lineCap;var d;d="function"==typeof b.barColor?b.barColor(a):b.barColor,h(d,b.lineWidth,a/100)}.bind(this),this.animate=function(a,c){var d=Date.now();b.onStart(a,c);var e=function(){var f=Math.min(Date.now()-d,b.animate.duration),g=b.easing(this,f,a,c-a,b.animate.duration);this.draw(g),b.onStep(a,c,g),f>=b.animate.duration?b.onStop(a,c):j(e)}.bind(this);j(e)}.bind(this)},c=function(a,c){var d={barColor:"#ef1e25",trackColor:"#f9f9f9",scaleColor:"#dfe0e0",scaleLength:6,lineCap:"round",lineWidth:3,size:95,rotate:0,animate:{duration:1e3,enabled:!0},easing:function(a,b,c,d,e){return b/=e/2,1>b?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},onStart:function(){},onStep:function(){},onStop:function(){}};if("undefined"!=typeof b)d.renderer=b;else{if("undefined"==typeof SVGRenderer)throw new Error("Please load either the SVG- or the CanvasRenderer");d.renderer=SVGRenderer}var e={},f=0,g=function(){this.el=a,this.options=e;for(var b in d)d.hasOwnProperty(b)&&(e[b]=c&&"undefined"!=typeof c[b]?c[b]:d[b],"function"==typeof e[b]&&(e[b]=e[b].bind(this)));e.easing="string"==typeof e.easing&&"undefined"!=typeof jQuery&&jQuery.isFunction(jQuery.easing[e.easing])?jQuery.easing[e.easing]:d.easing,"number"==typeof e.animate&&(e.animate={duration:e.animate,enabled:!0}),"boolean"!=typeof e.animate||e.animate||(e.animate={duration:1e3,enabled:e.animate}),this.renderer=new e.renderer(a,e),this.renderer.draw(f),a.dataset&&a.dataset.percent?this.update(parseFloat(a.dataset.percent)):a.getAttribute&&a.getAttribute("data-percent")&&this.update(parseFloat(a.getAttribute("data-percent")))}.bind(this);this.update=function(a){return a=parseFloat(a),e.animate.enabled?this.renderer.animate(f,a):this.renderer.draw(a),f=a,this}.bind(this),this.disableAnimation=function(){return e.animate.enabled=!1,this},this.enableAnimation=function(){return e.animate.enabled=!0,this},g()};a.fn.easyPieChart=function(b){return this.each(function(){var d;a.data(this,"easyPieChart")||(d=a.extend({},b,a(this).data()),a.data(this,"easyPieChart",new c(this,d)))})}}); diff --git a/asset/static/js/validator/validator.js b/asset/static/js/validator/validator.js index 7179d0e..4d6a176 100755 --- a/asset/static/js/validator/validator.js +++ b/asset/static/js/validator/validator.js @@ -1,392 +1,411 @@ /* - Validator v1.1.0 - (c) Yair Even Or - https://github.com/yairEO/validator + Validator v1.1.0 + (c) Yair Even Or + https://github.com/yairEO/validator - MIT-style license. + MIT-style license. */ var validator = (function($){ - var message, tests, checkField, validate, mark, unmark, field, minmax, defaults, - validateWords, lengthRange, lengthLimit, pattern, alertTxt, data, - email_illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\]]/, - email_filter = /^.+@.+\..{2,3}$/; + var message, tests, checkField, validate, mark, unmark, field, minmax, defaults, + validateWords, lengthRange, lengthLimit, pattern, alertTxt, data, + email_illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\]]/, + email_filter = /^.+@.+\..{2,6}$/; // exmaple email "steve@s-i.photo" - /* general text messages - */ - message = { - invalid : 'invalid input', - empty : 'please put something here', - min : 'input is too short', - max : 'input is too long', - number_min : 'too low', - number_max : 'too high', - url : 'invalid URL', - number : 'not a number', - email : 'email address is invalid', - email_repeat : 'emails do not match', - password_repeat : 'passwords do not match', - repeat : 'no match', - complete : 'input is not complete', - select : 'Please select an option' - }; - - if(!window.console){ - console={}; - console.log=console.warn=function(){ return; } - } + /* general text messages + */ + message = { + invalid : 'invalid input', + checked : 'must be checked', + empty : 'please put something here', + min : 'input is too short', + max : 'input is too long', + number_min : 'too low', + number_max : 'too high', + url : 'invalid URL', + number : 'not a number', + email : 'email address is invalid', + email_repeat : 'emails do not match', + password_repeat : 'passwords do not match', + repeat : 'no match', + complete : 'input is not complete', + select : 'Please select an option' + }; - // defaults - defaults = { alerts:true }; + if(!window.console){ + console={}; + console.log=console.warn=function(){ return; } + } - /* Tests for each type of field (including Select element) - */ - tests = { - sameAsPlaceholder : function(a){ - return $.fn.placeholder && a.attr('placeholder') !== undefined && data.val == a.prop('placeholder'); - }, - hasValue : function(a){ - if( !a ){ - alertTxt = message.empty; - return false; - } - return true; - }, - // 'linked' is a special test case for inputs which their values should be equal to each other (ex. confirm email or retype password) - linked : function(a,b){ - if( b != a ){ - // choose a specific message or a general one - alertTxt = message[data.type + '_repeat'] || message.no_match; - return false; - } - return true; - }, - email : function(a){ - if ( !email_filter.test( a ) || a.match( email_illegalChars ) ){ - alertTxt = a ? message.email : message.empty; - return false; - } - return true; - }, - text : function(a){ - // make sure there are at least X number of words, each at least 2 chars long. - // for example 'john F kenedy' should be at least 2 words and will pass validation - if( validateWords ){ - var words = a.split(' '); - // iterrate on all the words - var wordsLength = function(len){ - for( var w = words.length; w--; ) - if( words[w].length < len ) - return false; - return true; - }; + // defaults + defaults = { + alerts : true, + classes : { + item : 'item', + alert : 'alert', + bad : 'bad' + } + }; - if( words.length < validateWords || !wordsLength(2) ){ - alertTxt = message.complete; - return false; - } - return true; - } - if( lengthRange && a.length < lengthRange[0] ){ - alertTxt = message.min; - return false; - } + /* Tests for each type of field (including Select element) + */ + tests = { + sameAsPlaceholder : function(a){ + return $.fn.placeholder && a.attr('placeholder') !== undefined && data.val == a.prop('placeholder'); + }, + hasValue : function(a){ + if( !a ){ + alertTxt = message.empty; + return false; + } + return true; + }, + // 'linked' is a special test case for inputs which their values should be equal to each other (ex. confirm email or retype password) + linked : function(a,b){ + if( b != a ){ + // choose a specific message or a general one + alertTxt = message[data.type + '_repeat'] || message.no_match; + return false; + } + return true; + }, + email : function(a){ + if ( !email_filter.test( a ) || a.match( email_illegalChars ) ){ + alertTxt = a ? message.email : message.empty; + return false; + } + return true; + }, + // a "skip" will skip some of the tests (needed for keydown validation) + text : function(a, skip){ + // make sure there are at least X number of words, each at least 2 chars long. + // for example 'john F kenedy' should be at least 2 words and will pass validation + if( validateWords ){ + var words = a.split(' '); + // iterrate on all the words + var wordsLength = function(len){ + for( var w = words.length; w--; ) + if( words[w].length < len ) + return false; + return true; + }; - // check if there is max length & field length is greater than the allowed - if( lengthRange && lengthRange[1] && a.length > lengthRange[1] ){ - alertTxt = message.max; - return false; - } - // check if the field's value should obey any length limits, and if so, make sure the length of the value is as specified - if( lengthLimit && lengthLimit.length ){ - var obeyLimit = false; - while( lengthLimit.length ){ - if( lengthLimit.pop() == a.length ) - obeyLimit = true; - } - if( !obeyLimit ){ - alertTxt = message.complete; - return false; - } - } + if( words.length < validateWords || !wordsLength(2) ){ + alertTxt = message.complete; + return false; + } + return true; + } + if( !skip && lengthRange && a.length < lengthRange[0] ){ + alertTxt = message.min; + return false; + } - if( pattern ){ - var regex, jsRegex; - switch( pattern ){ - case 'alphanumeric' : - regex = /^[a-z0-9]+$/i; - break; - case 'numeric' : - regex = /^[0-9]+$/i; - break; - case 'phone' : - regex = /^\+?([0-9]|[-|' '])+$/i; - break; - default : - regex = pattern; - } - try{ - jsRegex = new RegExp(regex).test(a); - if( a && !jsRegex ) - return false; - } - catch(err){ - console.log(err, field, 'regex is invalid'); - return false; - } - } - return true; - }, - number : function(a){ - // if not not a number - if( isNaN(parseFloat(a)) && !isFinite(a) ){ - alertTxt = message.number; - return false; - } - // not enough numbers - else if( lengthRange && a.length < lengthRange[0] ){ - alertTxt = message.min; - return false; - } - // check if there is max length & field length is greater than the allowed - else if( lengthRange && lengthRange[1] && a.length > lengthRange[1] ){ - alertTxt = message.max; - return false; - } - else if( minmax[0] && (a|0) < minmax[0] ){ - alertTxt = message.number_min; - return false; - } - else if( minmax[1] && (a|0) > minmax[1] ){ - alertTxt = message.number_max; - return false; - } - return true; - }, - // Date is validated in European format (day,month,year) - date : function(a){ - var day, A = a.split(/[-./]/g), i; - // if there is native HTML5 support: - if( field[0].valueAsNumber ) - return true; + // check if there is max length & field length is greater than the allowed + if( lengthRange && lengthRange[1] && a.length > lengthRange[1] ){ + alertTxt = message.max; + return false; + } - for( i = A.length; i--; ){ - if( isNaN(parseFloat(a)) && !isFinite(a) ) - return false; - } - try{ - day = new Date(A[2], A[1]-1, A[0]); - if( day.getMonth()+1 == A[1] && day.getDate() == A[0] ) - return day; - return false; - } - catch(er){ - console.log('date test: ', err); - return false; - } - }, - url : function(a){ - // minimalistic URL validation - function testUrl(url){ - return /^(https?:\/\/)?([\w\d\-_]+\.+[A-Za-z]{2,})+\/?/.test( url ); - } - if( !testUrl( a ) ){ - console.log(a); - alertTxt = a ? message.url : message.empty; - return false; - } - return true; - }, - hidden : function(a){ - if( lengthRange && a.length < lengthRange[0] ){ - alertTxt = message.min; - return false; - } - if( pattern ){ - var regex; - if( pattern == 'alphanumeric' ){ - regex = /^[a-z0-9]+$/i; - if( !regex.test(a) ){ - return false; - } - } - } - return true; - }, - select : function(a){ - if( !tests.hasValue(a) ){ - alertTxt = message.select; - return false; - } - return true; - } - }; + // check if the field's value should obey any length limits, and if so, make sure the length of the value is as specified + if( lengthLimit && lengthLimit.length ){ + while( lengthLimit.length ){ + if( lengthLimit.pop() == a.length ){ + alertTxt = message.complete; + return false; + } + } + } - /* marks invalid fields - */ + if( pattern ){ + var regex, jsRegex; + switch( pattern ){ + case 'alphanumeric' : + regex = /^[a-zA-Z0-9]+$/i; + break; + case 'numeric' : + regex = /^[0-9]+$/i; + break; + case 'phone' : + regex = /^\+?([0-9]|[-|' '])+$/i; + break; + default : + regex = pattern; + } + try{ + jsRegex = new RegExp(regex).test(a); + if( a && !jsRegex ) + return false; + } + catch(err){ + console.log(err, field, 'regex is invalid'); + return false; + } + } + + return true; + }, + number : function(a){ + // if not not a number + if( isNaN(parseFloat(a)) && !isFinite(a) ){ + alertTxt = message.number; + return false; + } + // not enough numbers + else if( lengthRange && a.length < lengthRange[0] ){ + alertTxt = message.min; + return false; + } + // check if there is max length & field length is greater than the allowed + else if( lengthRange && lengthRange[1] && a.length > lengthRange[1] ){ + alertTxt = message.max; + return false; + } + else if( minmax[0] && (a|0) < minmax[0] ){ + alertTxt = message.number_min; + return false; + } + else if( minmax[1] && (a|0) > minmax[1] ){ + alertTxt = message.number_max; + return false; + } + return true; + }, + // Date is validated in European format (day,month,year) + date : function(a){ + var day, A = a.split(/[-./]/g), i; + // if there is native HTML5 support: + if( field[0].valueAsNumber ) + return true; + + for( i = A.length; i--; ){ + if( isNaN(parseFloat(a)) && !isFinite(a) ) + return false; + } + try{ + day = new Date(A[2], A[1]-1, A[0]); + if( day.getMonth()+1 == A[1] && day.getDate() == A[0] ) + return day; + return false; + } + catch(er){ + console.log('date test: ', err); + return false; + } + }, + url : function(a){ + // minimalistic URL validation + function testUrl(url){ + return /^(https?:\/\/)?([\w\d\-_]+\.+[A-Za-z]{2,})+\/?/.test( url ); + } + if( !testUrl( a ) ){ + alertTxt = a ? message.url : message.empty; + return false; + } + return true; + }, + hidden : function(a){ + if( lengthRange && a.length < lengthRange[0] ){ + alertTxt = message.min; + return false; + } + if( pattern ){ + var regex; + if( pattern == 'alphanumeric' ){ + regex = /^[a-z0-9]+$/i; + if( !regex.test(a) ){ + return false; + } + } + } + return true; + }, + select : function(a){ + if( !tests.hasValue(a) ){ + alertTxt = message.select; + return false; + } + return true; + } + }; + + /* marks invalid fields + */ mark = function( field, text ){ - if( !text || !field || !field.length ) - return false; + if( !text || !field || !field.length ) + return false; - // check if not already marked as a 'bad' record and add the 'alert' object. - // if already is marked as 'bad', then make sure the text is set again because i might change depending on validation - var item = field.parents('.item'), - warning; - - if( item.hasClass('bad') ){ - if( defaults.alerts ) - item.find('.alert').html(text); - } + // check if not already marked as a 'bad' record and add the 'alert' object. + // if already is marked as 'bad', then make sure the text is set again because i might change depending on validation + var item = field.closest('.' + defaults.classes.item), + warning; + + if( item.hasClass(defaults.classes.bad) ){ + if( defaults.alerts ) + item.find('.'+defaults.classes.alert).html(text); + } else if( defaults.alerts ){ - warning = $('
').html( text ); + warning = $('
').html( text ); item.append( warning ); } - - item.removeClass('bad'); - // a delay so the "alert" could be transitioned via CSS + + item.removeClass(defaults.classes.bad); + // a delay so the "alert" could be transitioned via CSS setTimeout(function(){ - item.addClass('bad'); + item.addClass(defaults.classes.bad); }, 0); - }; - /* un-marks invalid fields - */ - unmark = function( field ){ - if( !field || !field.length ){ - console.warn('no "field" argument, null or DOM object not found'); - return false; - } + }; + /* un-marks invalid fields + */ + unmark = function( field ){ + if( !field || !field.length ){ + console.warn('no "field" argument, null or DOM object not found'); + return false; + } - field.parents('.item') - .removeClass('bad') - .find('.alert').remove(); - }; + field.closest('.' + defaults.classes.item) + .removeClass(defaults.classes.bad) + .find('.'+ defaults.classes.alert).remove(); + }; - function testByType(type, value){ - if( type == 'tel' ) - pattern = pattern || 'phone'; + function testByType(type, value){ + if( type == 'tel' ) + pattern = pattern || 'phone'; - if( !type || type == 'password' || type == 'tel' ) - type = 'text'; + if( !type || type == 'password' || type == 'tel' || type == 'search' || type == 'file' ) + type = 'text'; - return tests[type](value); - } - function prepareFieldData(el){ - field = $(el); + return tests[type] ? tests[type](value, true) : true; + } - field.data( 'valid', true ); // initialize validness of field by first checking if it's even filled out of now - field.data( 'type', field.attr('type') ); // every field starts as 'valid=true' until proven otherwise - pattern = el.pattern; - } + function prepareFieldData(el){ + field = $(el); - /* Validations per-character keypress - */ - function keypress(e){ - prepareFieldData(this); + field.data( 'valid', true ); // initialize validity of field + field.data( 'type', field.attr('type') ); // every field starts as 'valid=true' until proven otherwise + pattern = field.attr('pattern'); + } - if( e.charCode ) - return testByType( data.type, String.fromCharCode(e.charCode) ); - } + /* Validations per-character keypress + */ + function keypress(e){ + prepareFieldData(this); + // String.fromCharCode(e.charCode) - /* Checks a single form field by it's type and specific (custom) attributes - */ - function checkField(){ - // skip testing fields whom their type is not HIDDEN but they are HIDDEN via CSS. - if( this.type !='hidden' && $(this).is(':hidden') ) - return true; + if( e.charCode ){ + return testByType( this.type, this.value ); + } + } - prepareFieldData(this); + /* Checks a single form field by it's type and specific (custom) attributes + */ + function checkField(){ + // skip testing fields whom their type is not HIDDEN but they are HIDDEN via CSS. + if( this.type !='hidden' && $(this).is(':hidden') ) + return true; - field.data( 'val', field[0].value.replace(/^\s+|\s+$/g, "") ); // cache the value of the field and trim it - data = field.data(); + prepareFieldData(this); - // Check if there is a specific error message for that field, if not, use the default 'invalid' message - alertTxt = message[field.prop('name')] || message.invalid; + field.data( 'val', field[0].value.replace(/^\s+|\s+$/g, "") ); // cache the value of the field and trim it + data = field.data(); - // SELECT / TEXTAREA nodes needs special treatment - if( field[0].nodeName.toLowerCase() === "select" ){ - data.type = 'select'; - } - if( field[0].nodeName.toLowerCase() === "textarea" ){ - data.type = 'text'; - } - /* Gather Custom data attributes for specific validation: - */ - validateWords = data['validateWords'] || 0; - lengthRange = data['validateLengthRange'] ? (data['validateLengthRange']+'').split(',') : [1]; - lengthLimit = data['validateLength'] ? (data['validateLength']+'').split(',') : false; - minmax = data['validateMinmax'] ? (data['validateMinmax']+'').split(',') : ''; // for type 'number', defines the minimum and/or maximum for the value as a number. + // Check if there is a specific error message for that field, if not, use the default 'invalid' message + alertTxt = message[field.prop('name')] || message.invalid; - data.valid = tests.hasValue(data.val); - // check if field has any value - if( data.valid ){ - /* Validate the field's value is different than the placeholder attribute (and attribute exists) - * this is needed when fixing the placeholders for older browsers which does not support them. - * in this case, make sure the "placeholder" jQuery plugin was even used before proceeding - */ - if( tests.sameAsPlaceholder(field) ){ - alertTxt = message.empty; - data.valid = false; - } + // Special treatment + if( field[0].nodeName.toLowerCase() === "select" ){ + data.type = 'select'; + } + else if( field[0].nodeName.toLowerCase() === "textarea" ){ + data.type = 'text'; + } + /* Gather Custom data attributes for specific validation: + */ + validateWords = data['validateWords'] || 0; + lengthRange = data['validateLengthRange'] ? (data['validateLengthRange']+'').split(',') : [1]; + lengthLimit = data['validateLength'] ? (data['validateLength']+'').split(',') : false; + minmax = data['validateMinmax'] ? (data['validateMinmax']+'').split(',') : ''; // for type 'number', defines the minimum and/or maximum for the value as a number. - // if this field is linked to another field (their values should be the same) - if( data.validateLinked ){ - var linkedTo = data['validateLinked'].indexOf('#') == 0 ? $(data['validateLinked']) : $(':input[name=' + data['validateLinked'] + ']'); - data.valid = tests.linked( data.val, linkedTo.val() ); - } - /* validate by type of field. use 'attr()' is proffered to get the actual value and not what the browsers sees for unsupported types. - */ - else if( data.valid || data.type == 'select' ) - data.valid = testByType(data.type, data.val); + data.valid = tests.hasValue(data.val); - // optional fields are only validated if they are not empty - if( field.hasClass('optional') && !data.val ) - data.valid = true; - } + if( field.hasClass('optional') && !data.valid ) + data.valid = true; - // mark / unmark the field, and set the general 'submit' flag accordingly - if( data.valid ) - unmark( field ); - else{ - mark( field, alertTxt ); - submit = false; - } - return data.valid; - } + // for checkboxes + if( field[0].type === "checkbox" ){ + data.valid = field[0].checked; + alertTxt = message.checked; + } - /* vaildates all the REQUIRED fields prior to submiting the form - */ - function checkAll( $form ){ - $form = $($form); + // check if field has any value + else if( data.valid ){ + /* Validate the field's value is different than the placeholder attribute (and attribute exists) + * this is needed when fixing the placeholders for older browsers which does not support them. + * in this case, make sure the "placeholder" jQuery plugin was even used before proceeding + */ + if( tests.sameAsPlaceholder(field) ){ + alertTxt = message.empty; + data.valid = false; + } - if( $form.length == 0 ){ - console.warn('element not found'); - return false; - } + // if this field is linked to another field (their values should be the same) + if( data.validateLinked ){ + var linkedTo = data['validateLinked'].indexOf('#') == 0 ? $(data['validateLinked']) : $(':input[name=' + data['validateLinked'] + ']'); + data.valid = tests.linked( data.val, linkedTo.val() ); + } + /* validate by type of field. use 'attr()' is proffered to get the actual value and not what the browsers sees for unsupported types. + */ + else if( data.valid || data.type == 'select' ) + data.valid = testByType(data.type, data.val); - var that = this, - submit = true, // save the scope - fieldsToCheck = $form.find(':input').filter('[required=required], .required, .optional').not('[disabled=disabled]'); + } - fieldsToCheck.each(function(){ - // use an AND operation, so if any of the fields returns 'false' then the submitted result will be also FALSE - submit = submit * checkField.apply(this); - }); + // mark / unmark the field, and set the general 'submit' flag accordingly + if( data.valid ) + unmark( field ); + else{ + mark( field, alertTxt ); + submit = false; + } - return !!submit; // casting the variable to make sure it's a boolean - } + return data.valid; + } - return { - defaults : defaults, - checkField : checkField, - keypress : keypress, - checkAll : checkAll, - mark : mark, - unmark : unmark, - message : message, - tests : tests - } -})(jQuery); \ No newline at end of file + /* vaildates all the REQUIRED fields prior to submiting the form + */ + function checkAll( $form ){ + $form = $($form); + + if( $form.length == 0 ){ + console.warn('element not found'); + return false; + } + + var that = this, + submit = true, // save the scope + // get all the input/textareas/select fields which are required or optional (meaning, they need validation only if they were filled) + fieldsToCheck = $form.find(':input').filter('[required=required], .required, .optional').not('[disabled=disabled]'); + + fieldsToCheck.each(function(){ + // use an AND operation, so if any of the fields returns 'false' then the submitted result will be also FALSE + submit = submit * checkField.apply(this); + }); + + return !!submit; // casting the variable to make sure it's a boolean + } + + return { + defaults : defaults, + checkField : checkField, + keypress : keypress, + checkAll : checkAll, + mark : mark, + unmark : unmark, + message : message, + tests : tests + } +})(jQuery); diff --git a/asset/template/index.html b/asset/template/index.html new file mode 100755 index 0000000..0947731 --- /dev/null +++ b/asset/template/index.html @@ -0,0 +1,1349 @@ + + + + + + + + + + + Gentallela Alela! | + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + +
+ + +
+
+ ... +
+
+ Welcome, +

Anthony Fernando

+
+
+ + +
+ + + + + + + + +
+
+ + + + + + + +
+ + +
+
+
+
+ Total Users +
2500
+ 4% From last Week +
+
+
+
+
+ Average Time +
123.50
+ 3% From last Week +
+
+
+
+
+ Total Males +
2,500
+ 34% From last Week +
+
+
+
+
+ Total Females +
4,567
+ 12% From last Week +
+
+
+
+
+ Total Collections +
2,315
+ 34% From last Week +
+
+
+
+
+ Total Connections +
7,325
+ 34% From last Week +
+
+ +
+ + +
+
+
+ +
+
+

Network Activities Graph title sub-title

+
+
+
+ + December 30, 2014 - January 28, 2015 +
+
+
+ +
+ +
+
+
+
+
+
+

Top Campaign Performance

+
+
+ +
+
+

Facebook Campaign

+
+
+
+
+
+
+
+

Twitter Campaign

+
+
+
+
+
+
+
+
+
+

Conventional Media

+
+
+
+
+
+
+
+

Bill boards

+
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+
+
+

App Versions

+ +
+
+
+

App Usage across versions

+
+
+ 0.1.5.2 +
+
+
+
+ 60% Complete +
+
+
+
+ 123k +
+
+
+ +
+
+ 0.1.5.3 +
+
+
+
+ 60% Complete +
+
+
+
+ 53k +
+
+
+
+
+ 0.1.5.4 +
+
+
+
+ 60% Complete +
+
+
+
+ 23k +
+
+
+
+
+ 0.1.5.5 +
+
+
+
+ 60% Complete +
+
+
+
+ 3k +
+
+
+
+
+ 0.1.5.6 +
+
+
+
+ 60% Complete +
+
+
+
+ 1k +
+
+
+ +
+
+
+ +
+
+
+

Device Usage

+ +
+
+
+ + + + + + + + + + +
+

Top 5

+
+
+

Device

+
+
+

Progress

+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+

IOS

+
30%
+

Android

+
10%
+

Blackberry

+
20%
+

Symbian

+
15%
+

Others

+
30%
+
+
+
+
+ + +
+
+
+

Quick Settings

+ +
+
+
+
+ + + +
+
+
+
+ +
+ + +
+
+
+
+

Recent Activities Sessions

+ +
+
+
+
+ + +
+
+
+
+ + +
+ + + +
+ +
+
+
+

Visitors location geo-presentation

+ +
+
+
+
+
+

125.7k Views from 60 countries

+ + + + + + + + + + + + + + + + + + + + + + + + +
United States33%
France27%
Germany16%
Spain11%
Britain10%
+
+
+
+
+
+
+ +
+
+ + + +
+
+
+

To Do List Sample tasks

+ +
+
+
+ +
+
    +
  • +

    + Schedule meeting with new client

    +
  • +
  • +

    + Create email address for new intern

    +
  • +
  • +

    + Have IT fix the network printer

    +
  • +
  • +

    + Copy backups to offsite location

    +
  • +
  • +

    + Food truck fixie locavors mcsweeney

    +
  • +
  • +

    + Food truck fixie locavors mcsweeney

    +
  • +
  • +

    + Create email address for new intern

    +
  • +
  • +

    + Have IT fix the network printer

    +
  • +
  • +

    + Copy backups to offsite location

    +
  • +
+
+
+
+
+ + + + +
+
+
+

Daily active users Sessions

+ +
+
+
+
+
+
Monday, 07:30 AM + F + C + +
+
+
+
+
+
+ + + + +
+
+
+
+

Texas +
Partly Cloudy Day +

+
+
+
+
+
+

23

+
+
+
+ + +
+
+
+

Mon

+

25

+ + + + + +
15 + km/h +
+
+
+
+
+

Tue

+

25

+ +
12 + km/h +
+
+
+
+
+

Wed

+

27

+ +
14 + km/h +
+
+
+
+
+

Thu

+

28

+ +
15 + km/h +
+
+
+
+
+

Fri

+

28

+ +
11 + km/h +
+
+
+
+
+

Sat

+

26

+ +
10 + km/h +
+
+
+
+
+
+
+ +
+ +
+ + + + + + + + + +
+ +
+ + + +
+
+

Gentelella Alela! a Bootstrap 3 template by Colorlib. | + Gentelella Alela! +

+
+
+
+ +
+ + +
+ +
+ +
+
    +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/asset/template/index.tpl b/asset/template/index.tpl deleted file mode 100755 index b032155..0000000 --- a/asset/template/index.tpl +++ /dev/null @@ -1,1337 +0,0 @@ - - - - - - - - - - - Gentallela Alela! | - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
-
- - -
- - -
-
- ... -
-
- Welcome, -

John Doe

-
-
- - -
- - - - - - - - -
-
- - - - - - - -
- - -
-
-
-
- Total Users -
2500
- 4% From last Week -
-
-
-
-
- Average Time -
123.50
- 3% From last Week -
-
-
-
-
- Total Males -
2,500
- 34% From last Week -
-
-
-
-
- Total Females -
4,567
- 12% From last Week -
-
-
-
-
- Total Collections -
2,315
- 34% From last Week -
-
-
-
-
- Total Connections -
7,325
- 34% From last Week -
-
- -
- - -
-
-
- -
-
-

Network Activities Graph title sub-title

-
-
-
- - December 30, 2014 - January 28, 2015 -
-
-
- -
- -
-
-
-
-
-
-

Top Campaign Performance

-
-
- -
-
-

Facebook Campaign

-
-
-
-
-
-
-
-

Twitter Campaign

-
-
-
-
-
-
-
-
-
-

Conventional Media

-
-
-
-
-
-
-
-

Bill boards

-
-
-
-
-
-
-
- -
- -
-
-
- -
-
- -
- - -
-
-
-

App Versions

- -
-
-
-

App Usage across versions

-
-
- 0.1.5.2 -
-
-
-
- 60% Complete -
-
-
-
- 123k -
-
-
- -
-
- 0.1.5.3 -
-
-
-
- 60% Complete -
-
-
-
- 53k -
-
-
-
-
- 0.1.5.4 -
-
-
-
- 60% Complete -
-
-
-
- 23k -
-
-
-
-
- 0.1.5.5 -
-
-
-
- 60% Complete -
-
-
-
- 3k -
-
-
-
-
- 0.1.5.6 -
-
-
-
- 60% Complete -
-
-
-
- 1k -
-
-
- -
-
-
- -
-
-
-

Device Usage

- -
-
-
- - - - - - - - - - -
-

Top 5

-
-
-

Device

-
-
-

Progress

-
-
- - - - - - - - - - - - - - - - - - - - - - - -
-

IOS

-
30%
-

Android

-
10%
-

Blackberry

-
20%
-

Symbian

-
15%
-

Others

-
30%
-
-
-
-
- - -
-
-
-

Quick Settings

- -
-
-
-
- - - -
-
-
-
- -
- - -
-
-
-
-

Recent Activities Sessions

- -
-
-
-
- - -
-
-
-
- - -
- - - -
- -
-
-
-

Visitors location geo-presentation

- -
-
-
-
-
-

125.7k Views from 60 countries

- - - - - - - - - - - - - - - - - - - - - - - - -
United States33%
France27%
Germany16%
Spain11%
Britain10%
-
-
-
-
-
-
- -
-
- - - -
-
-
-

To Do List Sample tasks

- -
-
-
- -
-
    -
  • -

    - Schedule meeting with new client

    -
  • -
  • -

    - Create email address for new intern

    -
  • -
  • -

    - Have IT fix the network printer

    -
  • -
  • -

    - Copy backups to offsite location

    -
  • -
  • -

    - Food truck fixie locavors mcsweeney

    -
  • -
  • -

    - Food truck fixie locavors mcsweeney

    -
  • -
  • -

    - Create email address for new intern

    -
  • -
  • -

    - Have IT fix the network printer

    -
  • -
  • -

    - Copy backups to offsite location

    -
  • -
-
-
-
-
- - - - -
-
-
-

Daily active users Sessions

- -
-
-
-
-
-
Monday, 07:30 AM - F - C - -
-
-
-
-
-
- - - - -
-
-
-
-

Texas -
Partly Cloudy Day -

-
-
-
-
-
-

23

-
-
-
- - -
-
-
-

Mon

-

25

- - - - - -
15 - km/h -
-
-
-
-
-

Tue

-

25

- -
12 - km/h -
-
-
-
-
-

Wed

-

27

- -
14 - km/h -
-
-
-
-
-

Thu

-

28

- -
15 - km/h -
-
-
-
-
-

Fri

-

28

- -
11 - km/h -
-
-
-
-
-

Sat

-

26

- -
10 - km/h -
-
-
-
-
-
-
- -
- -
- - - - - - - - - -
- -
- - - -
-
-

Gentelella Alela! a Bootstrap 3 template by Kimlabs. | - Gentelella Alela! -

-
-
-
- -
- - -
- -
- -
-
    -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/asset/template/layout/header.html b/asset/template/layout/header.html new file mode 100644 index 0000000..62ddd18 --- /dev/null +++ b/asset/template/layout/header.html @@ -0,0 +1,23 @@ + + + + + +Gentallela Alela! | + + + + + + + + + + + + \ No newline at end of file diff --git a/asset/template/layout/sidebar.html b/asset/template/layout/sidebar.html new file mode 100755 index 0000000..0cd0b55 --- /dev/null +++ b/asset/template/layout/sidebar.html @@ -0,0 +1,117 @@ + + + diff --git a/asset/template/lorem.tpl b/asset/template/lorem.html similarity index 100% rename from asset/template/lorem.tpl rename to asset/template/lorem.html diff --git a/asset/template/page_404.tpl b/asset/template/page_404.html similarity index 100% rename from asset/template/page_404.tpl rename to asset/template/page_404.html diff --git a/asset/template/page_500.tpl b/asset/template/page_500.html similarity index 100% rename from asset/template/page_500.tpl rename to asset/template/page_500.html diff --git a/main.go b/main.go index b992fbd..a970b07 100644 --- a/main.go +++ b/main.go @@ -16,8 +16,8 @@ package main import ( "github.com/gin-gonic/gin" - "github.com/golang/glog" - "github.com/zalando-techmonkeys/gin-glog" + "github.com/Sirupsen/logrus" + "github.com/gin-gonic/contrib/ginrus" "runtime" "time" "flag" @@ -25,6 +25,7 @@ import ( "amuz.es/go/mnemonics/util" "net/http" "github.com/flosch/pongo2" + "os" ) var argIp = flag.String("listen_ip", "", "IP to listen on, defaults to all IPs") @@ -34,16 +35,22 @@ var maxProcs = flag.Int("max_procs", 0, "max number of CPUs that can be used sim func main() { flag.Parse() setMaxProcs() - r := gin.Default() + r := gin.New() - r.Use(ginglog.Logger(3 * time.Second)) + + r.Use(ginrus.Ginrus(logrus.StandardLogger(), time.RFC3339, true)) r.Use(gin.Recovery()) r.NoRoute(func(c *gin.Context) { - c.HTML(http.StatusOK, "page_404.tpl", pongo2.Context{}) + c.HTML(http.StatusOK, "page_404.html", pongo2.Context{}) }) + + logger := logrus.New() + logger.Level = logrus.ErrorLevel + logger.SetOutput(os.Stderr) + r.Use(ginrus.Ginrus(logger, time.RFC3339, false)) r.StaticFS("/static", route.Static("")) r.GET("/api", route.Api) @@ -58,7 +65,8 @@ func main() { r.HTMLRender = util.Default() r.GET("/", route.Index) - glog.Info("bootstrapped application") + logger.Error("bootstrapped application") + r.Run() // listen and server on 0.0.0.0:8080 } @@ -76,6 +84,6 @@ func setMaxProcs() { // Check if the setting was successful. actualNumProcs := runtime.GOMAXPROCS(0) if actualNumProcs != numProcs { - glog.Warningf("Specified max procs of %v but using %v", numProcs, actualNumProcs) + logger.Warningf("Specified max procs of %v but using %v", numProcs, actualNumProcs) } } diff --git a/route/index.go b/route/index.go index a6e63fa..d952f67 100644 --- a/route/index.go +++ b/route/index.go @@ -8,5 +8,5 @@ import ( ) func Index(c *gin.Context) { - c.HTML(http.StatusOK, "index.tpl", pongo2.Context{}) + c.HTML(http.StatusOK, "index.html", pongo2.Context{}) }