@lazycatcloud/lzc-cli 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/lib/api.js +123 -0
- package/lib/archiver.js +128 -0
- package/lib/builder.js +183 -0
- package/lib/dev.js +300 -0
- package/lib/docker/promise.js +91 -0
- package/lib/docker-compose.js +51 -0
- package/lib/env.js +104 -0
- package/lib/generator.js +115 -0
- package/lib/key.js +112 -0
- package/lib/sdk.js +129 -0
- package/lib/utils.js +349 -0
- package/package.json +53 -0
- package/scripts/cli.js +98 -0
- package/template/_lazycat/_gitignore +1 -0
- package/template/_lazycat/debug/devforward/50x.html +30 -0
- package/template/_lazycat/debug/devforward/Dockerfile +16 -0
- package/template/_lazycat/debug/devforward/docker-compose.override.yml.in +11 -0
- package/template/_lazycat/debug/devforward/entrypoint.sh +10 -0
- package/template/_lazycat/debug/devforward/nginx.conf.template +56 -0
- package/template/_lazycat/debug/devforward/sshd_config +116 -0
- package/template/_lazycat/debug/shell/50x.html +32 -0
- package/template/_lazycat/debug/shell/Dockerfile +16 -0
- package/template/_lazycat/debug/shell/build.sh +15 -0
- package/template/_lazycat/debug/shell/docker-compose.override.yml.in +23 -0
- package/template/_lazycat/debug/shell/entrypoint.sh +10 -0
- package/template/_lazycat/debug/shell/nginx.conf.template +64 -0
- package/template/_lazycat/debug/shell/sshd_config +117 -0
- package/template/_lazycat/docker-compose.yml.in +17 -0
- package/template/_lazycat/icon.svg +1 -0
- package/template/_lazycat/screenshot.png +0 -0
- package/template/golang/.godir +1 -0
- package/template/golang/README.md +13 -0
- package/template/golang/assets/css/bootstrap-responsive.css +1088 -0
- package/template/golang/assets/css/bootstrap-responsive.min.css +9 -0
- package/template/golang/assets/css/bootstrap.css +5893 -0
- package/template/golang/assets/css/bootstrap.min.css +9 -0
- package/template/golang/assets/css/rego.css +45 -0
- package/template/golang/assets/img/glyphicons-halflings-white.png +0 -0
- package/template/golang/assets/img/glyphicons-halflings.png +0 -0
- package/template/golang/assets/js/bootstrap.js +2025 -0
- package/template/golang/assets/js/bootstrap.min.js +6 -0
- package/template/golang/assets/js/rego.js +121 -0
- package/template/golang/go.mod +3 -0
- package/template/golang/index.html +267 -0
- package/template/golang/rego.go +83 -0
- package/template/release/golang/Dockerfile +18 -0
- package/template/release/golang/build.sh +14 -0
- package/template/release/vue/Dockerfile +9 -0
- package/template/release/vue/build.sh +9 -0
- package/template/release/vue/docker-compose.yml.in +8 -0
- package/template/vue/README.md +24 -0
- package/template/vue/_dockerignore +1 -0
- package/template/vue/babel.config.js +5 -0
- package/template/vue/package.json +43 -0
- package/template/vue/public/favicon.ico +0 -0
- package/template/vue/public/index.html +33 -0
- package/template/vue/src/App.vue +39 -0
- package/template/vue/src/lzc.js +110 -0
- package/template/vue/src/main.js +19 -0
- package/template/vue/src/todo.vue +640 -0
- package/template/vue/src/top-bar.vue +100 -0
- package/template/vue/src/webdav.vue +183 -0
- package/template/vue/vue.config.js +5 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Bootstrap.js by @fat & @mdo
|
|
3
|
+
* Copyright 2012 Twitter, Inc.
|
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
|
5
|
+
*/
|
|
6
|
+
!function(e){"use strict";e(function(){e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(document).on("click.alert.data-api",t,n.prototype.close)}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(document).on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f;this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u](),f=e.Event("slide",{relatedTarget:i[0]});if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(document).on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hasClass("width");return e?"width":"height"},show:function(){var t,n,r,i;if(this.transitioning)return;t=this.dimension(),n=e.camelCase(["scroll",t].join("-")),r=this.$parent&&this.$parent.find("> .accordion-group > .in");if(r&&r.length){i=r.data("collapse");if(i&&i.transitioning)return;r.collapse("hide"),i||r.data("collapse",null)}this.$element[t](0),this.transition("addClass",e.Event("show"),"shown"),e.support.transition&&this.$element[t](this.$element[0][n])},hide:function(){var t;if(this.transitioning)return;t=this.dimension(),this.reset(this.$element[t]()),this.transition("removeClass",e.Event("hide"),"hidden"),this.$element[t](0)},reset:function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this},transition:function(t,n,r){var i=this,s=function(){n.type=="show"&&i.reset(),i.transitioning=0,i.$element.trigger(r)};this.$element.trigger(n);if(n.isDefaultPrevented())return;this.transitioning=1,this.$element[t]("in"),e.support.transition&&this.$element.hasClass("collapse")?this.$element.one(e.support.transition.end,s):s()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},e.fn.collapse=function(n){return this.each(function(){var r=e(this),i=r.data("collapse"),s=typeof n=="object"&&n;i||r.data("collapse",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.collapse.defaults={toggle:!0},e.fn.collapse.Constructor=t,e(document).on("click.collapse.data-api","[data-toggle=collapse]",function(t){var n=e(this),r,i=n.attr("data-target")||t.preventDefault()||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,""),s=e(i).data("collapse")?"toggle":n.data();n[e(i).hasClass("in")?"addClass":"removeClass"]("collapsed"),e(i).collapse(s)})}(window.jQuery),!function(e){"use strict";function r(){e(t).each(function(){i(e(this)).removeClass("open")})}function i(t){var n=t.attr("data-target"),r;return n||(n=t.attr("href"),n=n&&/#/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,"")),r=e(n),r.length||(r=t.parent()),r}var t="[data-toggle=dropdown]",n=function(t){var n=e(t).on("click.dropdown.data-api",this.toggle);e("html").on("click.dropdown.data-api",function(){n.parent().removeClass("open")})};n.prototype={constructor:n,toggle:function(t){var n=e(this),s,o;if(n.is(".disabled, :disabled"))return;return s=i(n),o=s.hasClass("open"),r(),o||(s.toggleClass("open"),n.focus()),!1},keydown:function(t){var n,r,s,o,u,a;if(!/(38|40|27)/.test(t.keyCode))return;n=e(this),t.preventDefault(),t.stopPropagation();if(n.is(".disabled, :disabled"))return;o=i(n),u=o.hasClass("open");if(!u||u&&t.keyCode==27)return n.click();r=e("[role=menu] li:not(.divider) a",o);if(!r.length)return;a=r.index(r.filter(":focus")),t.keyCode==38&&a>0&&a--,t.keyCode==40&&a<r.length-1&&a++,~a||(a=0),r.eq(a).focus()}},e.fn.dropdown=function(t){return this.each(function(){var r=e(this),i=r.data("dropdown");i||r.data("dropdown",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.dropdown.Constructor=n,e(document).on("click.dropdown.data-api touchstart.dropdown.data-api",r).on("click.dropdown touchstart.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("click.dropdown.data-api touchstart.dropdown.data-api",t,n.prototype.toggle).on("keydown.dropdown.data-api touchstart.dropdown.data-api",t+", [role=menu]",n.prototype.keydown)}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.options=n,this.$element=e(t).delegate('[data-dismiss="modal"]',"click.dismiss.modal",e.proxy(this.hide,this)),this.options.remote&&this.$element.find(".modal-body").load(this.options.remote)};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.parent().length||t.$element.appendTo(document.body),t.$element.show(),n&&t.$element[0].offsetWidth,t.$element.addClass("in").attr("aria-hidden",!1),t.enforceFocus(),n?t.$element.one(e.support.transition.end,function(){t.$element.focus().trigger("shown")}):t.$element.focus().trigger("shown")})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide"),this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1,this.escape(),e(document).off("focusin.modal"),this.$element.removeClass("in").attr("aria-hidden",!0),e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal()},enforceFocus:function(){var t=this;e(document).on("focusin.modal",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(t){t.which==27&&e.hide()}):this.isShown||this.$element.off("keyup.dismiss.modal")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end),t.hideModal()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n),t.hideModal()})},hideModal:function(e){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()):t&&t()}},e.fn.modal=function(n){return this.each(function(){var r=e(this),i=r.data("modal"),s=e.extend({},e.fn.modal.defaults,r.data(),typeof n=="object"&&n);i||r.data("modal",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},e.fn.modal.Constructor=t,e(document).on("click.modal.data-api",'[data-toggle="modal"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("modal")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data());t.preventDefault(),i.modal(s).one("hide",function(){n.focus()})})}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("tooltip",e,t)};t.prototype={constructor:t,init:function(t,n,r){var i,s;this.type=t,this.$element=e(n),this.options=this.getOptions(r),this.enabled=!0,this.options.trigger=="click"?this.$element.on("click."+this.type,this.options.selector,e.proxy(this.toggle,this)):this.options.trigger!="manual"&&(i=this.options.trigger=="hover"?"mouseenter":"focus",s=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(i+"."+this.type,this.options.selector,e.proxy(this.enter,this)),this.$element.on(s+"."+this.type,this.options.selector,e.proxy(this.leave,this))),this.options.selector?this._options=e.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(t){return t=e.extend({},e.fn[this.type].defaults,t,this.$element.data()),t.delay&&typeof t.delay=="number"&&(t.delay={show:t.delay,hide:t.delay}),t},enter:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);if(!n.options.delay||!n.options.delay.show)return n.show();clearTimeout(this.timeout),n.hoverState="in",this.timeout=setTimeout(function(){n.hoverState=="in"&&n.show()},n.options.delay.show)},leave:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(this.timeout);if(!n.options.delay||!n.options.delay.hide)return n.hide();n.hoverState="out",this.timeout=setTimeout(function(){n.hoverState=="out"&&n.hide()},n.options.delay.hide)},show:function(){var e,t,n,r,i,s,o;if(this.hasContent()&&this.enabled){e=this.tip(),this.setContent(),this.options.animation&&e.addClass("fade"),s=typeof this.options.placement=="function"?this.options.placement.call(this,e[0],this.$element[0]):this.options.placement,t=/in/.test(s),e.detach().css({top:0,left:0,display:"block"}).insertAfter(this.$element),n=this.getPosition(t),r=e[0].offsetWidth,i=e[0].offsetHeight;switch(t?s.split(" ")[1]:s){case"bottom":o={top:n.top+n.height,left:n.left+n.width/2-r/2};break;case"top":o={top:n.top-i,left:n.left+n.width/2-r/2};break;case"left":o={top:n.top+n.height/2-i/2,left:n.left-r};break;case"right":o={top:n.top+n.height/2-i/2,left:n.left+n.width}}e.offset(o).addClass(s).addClass("in")}},setContent:function(){var e=this.tip(),t=this.getTitle();e.find(".tooltip-inner")[this.options.html?"html":"text"](t),e.removeClass("fade in top bottom left right")},hide:function(){function r(){var t=setTimeout(function(){n.off(e.support.transition.end).detach()},500);n.one(e.support.transition.end,function(){clearTimeout(t),n.detach()})}var t=this,n=this.tip();return n.removeClass("in"),e.support.transition&&this.$tip.hasClass("fade")?r():n.detach(),this},fixTitle:function(){var e=this.$element;(e.attr("title")||typeof e.attr("data-original-title")!="string")&&e.attr("data-original-title",e.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(t){return e.extend({},t?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-original-title")||(typeof n.title=="function"?n.title.call(t[0]):n.title),e},tip:function(){return this.$tip=this.$tip||e(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);n[n.tip().hasClass("in")?"hide":"show"]()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}},e.fn.tooltip=function(n){return this.each(function(){var r=e(this),i=r.data("tooltip"),s=typeof n=="object"&&n;i||r.data("tooltip",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.tooltip.Constructor=t,e.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0,html:!1}}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("popover",e,t)};t.prototype=e.extend({},e.fn.tooltip.Constructor.prototype,{constructor:t,setContent:function(){var e=this.tip(),t=this.getTitle(),n=this.getContent();e.find(".popover-title")[this.options.html?"html":"text"](t),e.find(".popover-content > *")[this.options.html?"html":"text"](n),e.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-content")||(typeof n.content=="function"?n.content.call(t[0]):n.content),e},tip:function(){return this.$tip||(this.$tip=e(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}}),e.fn.popover=function(n){return this.each(function(){var r=e(this),i=r.data("popover"),s=typeof n=="object"&&n;i||r.data("popover",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.popover.Constructor=t,e.fn.popover.defaults=e.extend({},e.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(e){"use strict";function t(t,n){var r=e.proxy(this.process,this),i=e(t).is("body")?e(window):e(t),s;this.options=e.extend({},e.fn.scrollspy.defaults,n),this.$scrollElement=i.on("scroll.scroll-spy.data-api",r),this.selector=(this.options.target||(s=e(t).attr("href"))&&s.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=e("body"),this.refresh(),this.process()}t.prototype={constructor:t,refresh:function(){var t=this,n;this.offsets=e([]),this.targets=e([]),n=this.$body.find(this.selector).map(function(){var t=e(this),n=t.data("target")||t.attr("href"),r=/^#\w/.test(n)&&e(n);return r&&r.length&&[[r.position().top,n]]||null}).sort(function(e,t){return e[0]-t[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},process:function(){var e=this.$scrollElement.scrollTop()+this.options.offset,t=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,n=t-this.$scrollElement.height(),r=this.offsets,i=this.targets,s=this.activeTarget,o;if(e>=n)return s!=(o=i.last()[0])&&this.activate(o);for(o=r.length;o--;)s!=i[o]&&e>=r[o]&&(!r[o+1]||e<=r[o+1])&&this.activate(i[o])},activate:function(t){var n,r;this.activeTarget=t,e(this.selector).parent(".active").removeClass("active"),r=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',n=e(r).parent("li").addClass("active"),n.parent(".dropdown-menu").length&&(n=n.closest("li.dropdown").addClass("active")),n.trigger("activate")}},e.fn.scrollspy=function(n){return this.each(function(){var r=e(this),i=r.data("scrollspy"),s=typeof n=="object"&&n;i||r.data("scrollspy",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.scrollspy.Constructor=t,e.fn.scrollspy.defaults={offset:10},e(window).on("load",function(){e('[data-spy="scroll"]').each(function(){var t=e(this);t.scrollspy(t.data())})})}(window.jQuery),!function(e){"use strict";var t=function(t){this.element=e(t)};t.prototype={constructor:t,show:function(){var t=this.element,n=t.closest("ul:not(.dropdown-menu)"),r=t.attr("data-target"),i,s,o;r||(r=t.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,""));if(t.parent("li").hasClass("active"))return;i=n.find(".active:last a")[0],o=e.Event("show",{relatedTarget:i}),t.trigger(o);if(o.isDefaultPrevented())return;s=e(r),this.activate(t.parent("li"),n),this.activate(s,s.parent(),function(){t.trigger({type:"shown",relatedTarget:i})})},activate:function(t,n,r){function o(){i.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),t.addClass("active"),s?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu")&&t.closest("li.dropdown").addClass("active"),r&&r()}var i=n.find("> .active"),s=r&&e.support.transition&&i.hasClass("fade");s?i.one(e.support.transition.end,o):o(),i.removeClass("in")}},e.fn.tab=function(n){return this.each(function(){var r=e(this),i=r.data("tab");i||r.data("tab",i=new t(this)),typeof n=="string"&&i[n]()})},e.fn.tab.Constructor=t,e(document).on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(t){t.preventDefault(),e(this).tab("show")})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.typeahead.defaults,n),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.$menu=e(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};t.prototype={constructor:t,select:function(){var e=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(e)).change(),this.hide()},updater:function(e){return e},show:function(){var t=e.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:t.top+t.height,left:t.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(t){var n;return this.query=this.$element.val(),!this.query||this.query.length<this.options.minLength?this.shown?this.hide():this:(n=e.isFunction(this.source)?this.source(this.query,e.proxy(this.process,this)):this.source,n?this.process(n):this)},process:function(t){var n=this;return t=e.grep(t,function(e){return n.matcher(e)}),t=this.sorter(t),t.length?this.render(t.slice(0,this.options.items)).show():this.shown?this.hide():this},matcher:function(e){return~e.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(e){var t=[],n=[],r=[],i;while(i=e.shift())i.toLowerCase().indexOf(this.query.toLowerCase())?~i.indexOf(this.query)?n.push(i):r.push(i):t.push(i);return t.concat(n,r)},highlighter:function(e){var t=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return e.replace(new RegExp("("+t+")","ig"),function(e,t){return"<strong>"+t+"</strong>"})},render:function(t){var n=this;return t=e(t).map(function(t,r){return t=e(n.options.item).attr("data-value",r),t.find("a").html(n.highlighter(r)),t[0]}),t.first().addClass("active"),this.$menu.html(t),this},next:function(t){var n=this.$menu.find(".active").removeClass("active"),r=n.next();r.length||(r=e(this.$menu.find("li")[0])),r.addClass("active")},prev:function(e){var t=this.$menu.find(".active").removeClass("active"),n=t.prev();n.length||(n=this.$menu.find("li").last()),n.addClass("active")},listen:function(){this.$element.on("blur",e.proxy(this.blur,this)).on("keypress",e.proxy(this.keypress,this)).on("keyup",e.proxy(this.keyup,this)),this.eventSupported("keydown")&&this.$element.on("keydown",e.proxy(this.keydown,this)),this.$menu.on("click",e.proxy(this.click,this)).on("mouseenter","li",e.proxy(this.mouseenter,this))},eventSupported:function(e){var t=e in this.$element;return t||(this.$element.setAttribute(e,"return;"),t=typeof this.$element[e]=="function"),t},move:function(e){if(!this.shown)return;switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),this.prev();break;case 40:e.preventDefault(),this.next()}e.stopPropagation()},keydown:function(t){this.suppressKeyPressRepeat=!~e.inArray(t.keyCode,[40,38,9,13,27]),this.move(t)},keypress:function(e){if(this.suppressKeyPressRepeat)return;this.move(e)},keyup:function(e){switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}e.stopPropagation(),e.preventDefault()},blur:function(e){var t=this;setTimeout(function(){t.hide()},150)},click:function(e){e.stopPropagation(),e.preventDefault(),this.select()},mouseenter:function(t){this.$menu.find(".active").removeClass("active"),e(t.currentTarget).addClass("active")}},e.fn.typeahead=function(n){return this.each(function(){var r=e(this),i=r.data("typeahead"),s=typeof n=="object"&&n;i||r.data("typeahead",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>',minLength:1},e.fn.typeahead.Constructor=t,e(document).on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(t){var n=e(this);if(n.data("typeahead"))return;t.preventDefault(),n.typeahead(n.data())})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.options=e.extend({},e.fn.affix.defaults,n),this.$window=e(window).on("scroll.affix.data-api",e.proxy(this.checkPosition,this)).on("click.affix.data-api",e.proxy(function(){setTimeout(e.proxy(this.checkPosition,this),1)},this)),this.$element=e(t),this.checkPosition()};t.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var t=e(document).height(),n=this.$window.scrollTop(),r=this.$element.offset(),i=this.options.offset,s=i.bottom,o=i.top,u="affix affix-top affix-bottom",a;typeof i!="object"&&(s=o=i),typeof o=="function"&&(o=i.top()),typeof s=="function"&&(s=i.bottom()),a=this.unpin!=null&&n+this.unpin<=r.top?!1:s!=null&&r.top+this.$element.height()>=t-s?"bottom":o!=null&&n<=o?"top":!1;if(this.affixed===a)return;this.affixed=a,this.unpin=a=="bottom"?r.top-n:null,this.$element.removeClass(u).addClass("affix"+(a?"-"+a:""))},e.fn.affix=function(n){return this.each(function(){var r=e(this),i=r.data("affix"),s=typeof n=="object"&&n;i||r.data("affix",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.affix.Constructor=t,e.fn.affix.defaults={offset:0},e(window).on("load",function(){e('[data-spy="affix"]').each(function(){var t=e(this),n=t.data();n.offset=n.offset||{},n.offsetBottom&&(n.offset.bottom=n.offsetBottom),n.offsetTop&&(n.offset.top=n.offsetTop),t.affix(n)})})}(window.jQuery);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// jQuery form oninput wrapper
|
|
2
|
+
// Thx to Mathias Bynens https://github.com/mathiasbynens/jquery-oninput
|
|
3
|
+
jQuery.fn.input=function(a){var b=this;return a?b.bind({'input.input':function(c){b.unbind('keydown.input');a.call(this,c)},'keydown.input':function(c){a.call(this,c)}}):b.trigger('keydown.input')};
|
|
4
|
+
|
|
5
|
+
$(document).ready(function() {
|
|
6
|
+
var testRegexTimeout;
|
|
7
|
+
|
|
8
|
+
function testRegex () {
|
|
9
|
+
$.ajax({
|
|
10
|
+
type: "POST",
|
|
11
|
+
url: "/test_regexp/",
|
|
12
|
+
data: {
|
|
13
|
+
regexp: $("#regexpInput").val()
|
|
14
|
+
, testString: $("#testStringInput").val()
|
|
15
|
+
, findAllSubmatch: $("#findAllSubmatchCheckbox").is(":checked")
|
|
16
|
+
}
|
|
17
|
+
}).done(function(msg) {
|
|
18
|
+
var res = $.parseJSON(msg);
|
|
19
|
+
var allMatches = res.matches;
|
|
20
|
+
var groupsName = res.groupsName;
|
|
21
|
+
|
|
22
|
+
// We clear previous results
|
|
23
|
+
clearResults();
|
|
24
|
+
|
|
25
|
+
if (allMatches && allMatches[0] != null)
|
|
26
|
+
{
|
|
27
|
+
var l = allMatches.length;
|
|
28
|
+
|
|
29
|
+
// Match font color > green
|
|
30
|
+
$("#match").css("color", "green")
|
|
31
|
+
|
|
32
|
+
// Match groups
|
|
33
|
+
if (l > 0)
|
|
34
|
+
{
|
|
35
|
+
var match = [];
|
|
36
|
+
var matchGroupsTable = [];
|
|
37
|
+
var index = 0;
|
|
38
|
+
|
|
39
|
+
for (var i = 0; i < l; i++)
|
|
40
|
+
{
|
|
41
|
+
var matches = allMatches[i];
|
|
42
|
+
var m = matches.length;
|
|
43
|
+
|
|
44
|
+
match.push(matches[0]);
|
|
45
|
+
for (var j = 1; j < m; j++)
|
|
46
|
+
{
|
|
47
|
+
matchGroupsTable.push('<tr><td>'+(index++)+'</td><td>'+((groupsName[j-1] != "") ? groupsName[j-1] : "-")+'</td><td>'+escapeHTML(matches[j])+'</td></tr>');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
$("#match").html(escapeHTML(match.join(" ")))
|
|
52
|
+
$('#matchGroupsTable > tbody:last').append(matchGroupsTable.join());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
{
|
|
58
|
+
$("#match").html("No match !")
|
|
59
|
+
$("#match").css("color", "red")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}).error(function(error) {
|
|
63
|
+
$("#match").html(error.responseText)
|
|
64
|
+
$("#match").css("color", "red")
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function clear() {
|
|
69
|
+
$("#regexpInput").val("");
|
|
70
|
+
$("#testStringInput").val("");
|
|
71
|
+
|
|
72
|
+
// Remove placeholder
|
|
73
|
+
$("#regexpInput").attr("placeholder", "");
|
|
74
|
+
$("#testStringInput").attr("placeholder", "");
|
|
75
|
+
|
|
76
|
+
clearResults();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function clearResults() {
|
|
80
|
+
// Empty match groups table
|
|
81
|
+
$("#matchGroupsTable tbody > tr").remove();
|
|
82
|
+
|
|
83
|
+
$("#match").html("")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function escapeHTML(str) {
|
|
87
|
+
var div = document.createElement('div');
|
|
88
|
+
div.appendChild(document.createTextNode(str));
|
|
89
|
+
return div.innerHTML;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//
|
|
93
|
+
// Add Handlers
|
|
94
|
+
//
|
|
95
|
+
$("#regexpForm").submit(function() {
|
|
96
|
+
testRegex();
|
|
97
|
+
|
|
98
|
+
return false;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
$("#regexpForm").input(function() {
|
|
102
|
+
|
|
103
|
+
if (testRegexTimeout)
|
|
104
|
+
clearTimeout(testRegexTimeout)
|
|
105
|
+
|
|
106
|
+
testRegexTimeout = setTimeout(testRegex, 750)
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
$("#findAllSubmatchCheckbox").click(function() {
|
|
110
|
+
testRegex();
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
$("#clearAllFieldsButton").click(function() {
|
|
114
|
+
clear();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// Test sample regexp
|
|
119
|
+
testRegex();
|
|
120
|
+
|
|
121
|
+
});
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Rego - A Go regular expression tester</title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<meta name="description" content="Rego - A Go regular expression tester">
|
|
8
|
+
<meta name="author" content="Steve Domin">
|
|
9
|
+
|
|
10
|
+
<!-- CSS -->
|
|
11
|
+
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
|
|
12
|
+
<style type="text/css">
|
|
13
|
+
|
|
14
|
+
/* Sticky footer styles
|
|
15
|
+
-------------------------------------------------- */
|
|
16
|
+
|
|
17
|
+
html,
|
|
18
|
+
body {
|
|
19
|
+
height: 100%;
|
|
20
|
+
/* The html and body elements cannot have any padding or margin. */
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Wrapper for page content to push down footer */
|
|
24
|
+
#wrap {
|
|
25
|
+
min-height: 100%;
|
|
26
|
+
height: auto !important;
|
|
27
|
+
height: 100%;
|
|
28
|
+
/* Negative indent footer by it's height */
|
|
29
|
+
margin: 0 auto -60px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Set the fixed height of the footer here */
|
|
33
|
+
#push,
|
|
34
|
+
#footer {
|
|
35
|
+
height: 60px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#footer {
|
|
39
|
+
background-color: #f5f5f5;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Lastly, apply responsive CSS fixes as necessary */
|
|
43
|
+
@media (max-width: 767px) {
|
|
44
|
+
#footer {
|
|
45
|
+
margin-left: -20px;
|
|
46
|
+
margin-right: -20px;
|
|
47
|
+
padding-left: 20px;
|
|
48
|
+
padding-right: 20px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.page-header {
|
|
53
|
+
margin-bottom: 20px;
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
56
|
+
<link href="assets/css/bootstrap-responsive.min.css" rel="stylesheet">
|
|
57
|
+
<!-- rego CSS -->
|
|
58
|
+
<link href="assets/css/rego.css" rel="stylesheet" media="screen">
|
|
59
|
+
|
|
60
|
+
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
|
61
|
+
<!--[if lt IE 9]>
|
|
62
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
|
63
|
+
<![endif]-->
|
|
64
|
+
|
|
65
|
+
<!-- Fav and touch icons -->
|
|
66
|
+
<link rel="shortcut icon" href="../assets/ico/favicon.ico">
|
|
67
|
+
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
|
|
68
|
+
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
|
|
69
|
+
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
|
|
70
|
+
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
|
|
71
|
+
</head>
|
|
72
|
+
<body>
|
|
73
|
+
<!-- Part 1: Wrap all page content here -->
|
|
74
|
+
<div id="wrap">
|
|
75
|
+
<!-- Begin page content -->
|
|
76
|
+
<div class="container">
|
|
77
|
+
<div class="page-header">
|
|
78
|
+
<h1>Rego</h1>
|
|
79
|
+
A <a href="http://golang.org" target="_blank"/>Go</a> regular expression tester
|
|
80
|
+
</div>
|
|
81
|
+
<div class="row-fluid">
|
|
82
|
+
<form id="regexpForm" action="/test_regexp" method="POST" class="span6">
|
|
83
|
+
<label>Your regular expression :</label>
|
|
84
|
+
<input id="regexpInput" type="text" placeholder="r([a-z]+)go" value="r([a-z]+)go" />
|
|
85
|
+
|
|
86
|
+
<label>Test string :</label>
|
|
87
|
+
<textarea id="testStringInput" rows="5" cols="20" placeholder="rego">rego</textarea>
|
|
88
|
+
|
|
89
|
+
<label class="checkbox">
|
|
90
|
+
<input id="findAllSubmatchCheckbox" type="checkbox"> Find all submatch
|
|
91
|
+
</label>
|
|
92
|
+
|
|
93
|
+
<button id="clearAllFieldsButton" class="btn btn-warning" type="button">Clear all fields</button>
|
|
94
|
+
</form>
|
|
95
|
+
<form class="span6">
|
|
96
|
+
<label>Match :</label>
|
|
97
|
+
<div id="match" class="well">
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<label>Match groups :</label>
|
|
101
|
+
<table id="matchGroupsTable" class="table table-bordered">
|
|
102
|
+
<thead>
|
|
103
|
+
<tr>
|
|
104
|
+
<th>#</th>
|
|
105
|
+
<th>Group Name</th>
|
|
106
|
+
<th>Group Match</th>
|
|
107
|
+
</tr>
|
|
108
|
+
</thead>
|
|
109
|
+
<tbody>
|
|
110
|
+
</tbody>
|
|
111
|
+
</table>
|
|
112
|
+
</form>
|
|
113
|
+
</div>
|
|
114
|
+
<div class="row-fluid">
|
|
115
|
+
<div id="quickref" class="well">
|
|
116
|
+
<h3>Go RegExp Quick Reference (<a href="http://rubular.com/" target="_blank">© Rubular</a>)</h3>
|
|
117
|
+
<div style="float:left">
|
|
118
|
+
<table>
|
|
119
|
+
<tbody>
|
|
120
|
+
<tr>
|
|
121
|
+
<td><code>[abc]</code></td>
|
|
122
|
+
<td>A single character of: a, b or c</td>
|
|
123
|
+
</tr>
|
|
124
|
+
<tr>
|
|
125
|
+
<td><code>[^abc]</code></td>
|
|
126
|
+
<td>Any single character except: a, b, or c</td>
|
|
127
|
+
</tr>
|
|
128
|
+
<tr>
|
|
129
|
+
<td><code>[a-z]</code></td>
|
|
130
|
+
<td>Any single character in the range a-z</td>
|
|
131
|
+
</tr>
|
|
132
|
+
<tr>
|
|
133
|
+
<td><code>[a-zA-Z]</code></td>
|
|
134
|
+
<td>Any single character in the range a-z or A-Z</td>
|
|
135
|
+
</tr>
|
|
136
|
+
<tr>
|
|
137
|
+
<td><code>^</code></td>
|
|
138
|
+
<td>Start of line</td>
|
|
139
|
+
</tr>
|
|
140
|
+
<tr>
|
|
141
|
+
<td><code>$</code></td>
|
|
142
|
+
<td>End of line</td>
|
|
143
|
+
</tr>
|
|
144
|
+
<tr>
|
|
145
|
+
<td><code>\A</code></td>
|
|
146
|
+
<td>Start of string</td>
|
|
147
|
+
</tr>
|
|
148
|
+
<tr>
|
|
149
|
+
<td><code>\z</code></td>
|
|
150
|
+
<td>End of string</td>
|
|
151
|
+
</tr>
|
|
152
|
+
</tbody>
|
|
153
|
+
</table>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div style="float:left">
|
|
157
|
+
<table>
|
|
158
|
+
<tbody>
|
|
159
|
+
<tr>
|
|
160
|
+
<td><code>.</code></td>
|
|
161
|
+
<td>Any single character</td>
|
|
162
|
+
</tr>
|
|
163
|
+
<tr>
|
|
164
|
+
<td><code>\s</code></td>
|
|
165
|
+
<td>Any whitespace character</td>
|
|
166
|
+
</tr>
|
|
167
|
+
<tr>
|
|
168
|
+
<td><code>\S</code></td>
|
|
169
|
+
<td>Any non-whitespace character</td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr>
|
|
172
|
+
<td><code>\d</code></td>
|
|
173
|
+
<td>Any digit</td>
|
|
174
|
+
</tr>
|
|
175
|
+
<tr>
|
|
176
|
+
<td><code>\D</code></td>
|
|
177
|
+
<td>Any non-digit</td>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<td><code>\w</code></td>
|
|
181
|
+
<td>Any word character (letter, number, underscore)</td>
|
|
182
|
+
</tr>
|
|
183
|
+
<tr>
|
|
184
|
+
<td><code>\W</code></td>
|
|
185
|
+
<td>Any non-word character</td>
|
|
186
|
+
</tr>
|
|
187
|
+
<tr>
|
|
188
|
+
<td><code>\b</code></td>
|
|
189
|
+
<td>Any word boundary</td>
|
|
190
|
+
</tr>
|
|
191
|
+
</tbody>
|
|
192
|
+
</table>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<table>
|
|
196
|
+
<tbody>
|
|
197
|
+
<tr>
|
|
198
|
+
<td><code>(...)</code></td>
|
|
199
|
+
<td>Capture everything enclosed</td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr>
|
|
202
|
+
<td><code>(a|b)</code></td>
|
|
203
|
+
<td>a or b</td>
|
|
204
|
+
</tr>
|
|
205
|
+
<tr>
|
|
206
|
+
<td><code>a?</code></td>
|
|
207
|
+
<td>Zero or one of a</td>
|
|
208
|
+
</tr>
|
|
209
|
+
<tr>
|
|
210
|
+
<td><code>a*</code></td>
|
|
211
|
+
<td>Zero or more of a</td>
|
|
212
|
+
</tr>
|
|
213
|
+
<tr>
|
|
214
|
+
<td><code>a+</code></td>
|
|
215
|
+
<td>One or more of a</td>
|
|
216
|
+
</tr>
|
|
217
|
+
<tr>
|
|
218
|
+
<td><code>a{3}</code></td>
|
|
219
|
+
<td>Exactly 3 of a</td>
|
|
220
|
+
</tr>
|
|
221
|
+
<tr>
|
|
222
|
+
<td><code>a{3,}</code></td>
|
|
223
|
+
<td>3 or more of a</td>
|
|
224
|
+
</tr>
|
|
225
|
+
<tr>
|
|
226
|
+
<td><code>a{3,6}</code></td>
|
|
227
|
+
<td>Between 3 and 6 of a</td>
|
|
228
|
+
</tr>
|
|
229
|
+
</tbody>
|
|
230
|
+
</table>
|
|
231
|
+
|
|
232
|
+
<div id="quickrefFooter">
|
|
233
|
+
<p>
|
|
234
|
+
Full syntax reference at <a href="http://code.google.com/p/re2/wiki/Syntax" target="_blank">http://code.google.com/p/re2/wiki/Syntax</a>. Go RegExp doc at <a href="http://golang.org/pkg/regexp/" target="_blank">http://golang.org/pkg/regexp/</a>.
|
|
235
|
+
</p>
|
|
236
|
+
<!--
|
|
237
|
+
<p>
|
|
238
|
+
options:
|
|
239
|
+
<code>i</code> case insensitive
|
|
240
|
+
<code>m</code> make dot match newlines
|
|
241
|
+
<code>x</code> ignore whitespace in regex
|
|
242
|
+
<code>o</code> perform #{...} substitutions only once
|
|
243
|
+
</p>
|
|
244
|
+
-->
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div id="push"></div>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<div id="footer">
|
|
254
|
+
<div class="container">
|
|
255
|
+
<p class="muted credit">Built by <a href="https://github.com/stevedomin" target="_blank">Steve Domin</a>. Inspired by <a href="http://rubular.com/" target="_blank">Rubular</a>. You can find the sources at <a href="https://github.com/stevedomin/rego" target="_blank">github.com/stevedomin/rego</a>.</p>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
<!-- Le javascript
|
|
261
|
+
================================================== -->
|
|
262
|
+
<!-- Placed at the end of the document so the pages load faster -->
|
|
263
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
|
264
|
+
<script type="text/javascript" src="assets/js/rego.js"></script>
|
|
265
|
+
|
|
266
|
+
</body>
|
|
267
|
+
</html>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"fmt"
|
|
6
|
+
"html/template"
|
|
7
|
+
"log"
|
|
8
|
+
"net/http"
|
|
9
|
+
"os"
|
|
10
|
+
"regexp"
|
|
11
|
+
"strconv"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
type MatchResultResponse struct {
|
|
15
|
+
Matches [][]string `json:"matches"`
|
|
16
|
+
GroupsName []string `json:"groupsName"`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func handler(rw http.ResponseWriter, req *http.Request) {
|
|
20
|
+
t, _ := template.ParseFiles("index.html")
|
|
21
|
+
t.Execute(rw, nil)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
func regExpHandler(rw http.ResponseWriter, req *http.Request) {
|
|
25
|
+
var matches [][]string
|
|
26
|
+
|
|
27
|
+
req.ParseForm()
|
|
28
|
+
regexpString := req.FormValue("regexp")
|
|
29
|
+
testString := req.FormValue("testString")
|
|
30
|
+
findAllSubmatch, _ := strconv.ParseBool(req.FormValue("findAllSubmatch"))
|
|
31
|
+
|
|
32
|
+
log.Printf("Regexp : %s", regexpString)
|
|
33
|
+
log.Printf("Test string : %s", testString)
|
|
34
|
+
log.Printf("Find all : %t", findAllSubmatch)
|
|
35
|
+
|
|
36
|
+
m := &MatchResultResponse{}
|
|
37
|
+
|
|
38
|
+
r, err := regexp.Compile(regexpString)
|
|
39
|
+
if err != nil {
|
|
40
|
+
log.Printf("Invalid RegExp : %s \n", regexpString)
|
|
41
|
+
rw.WriteHeader(500)
|
|
42
|
+
fmt.Fprintf(rw, "Invalid RegExp : %s", regexpString)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if findAllSubmatch {
|
|
47
|
+
matches = r.FindAllStringSubmatch(testString, -1)
|
|
48
|
+
} else {
|
|
49
|
+
matches = [][]string{r.FindStringSubmatch(testString)}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
log.Println(matches)
|
|
53
|
+
|
|
54
|
+
if len(matches) > 0 {
|
|
55
|
+
m.Matches = matches
|
|
56
|
+
m.GroupsName = r.SubexpNames()[1:]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
enc := json.NewEncoder(rw)
|
|
60
|
+
enc.Encode(m)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func main() {
|
|
64
|
+
// Main handler (index.html)
|
|
65
|
+
http.HandleFunc("/", handler)
|
|
66
|
+
// Regex testing service
|
|
67
|
+
http.HandleFunc("/test_regexp/", regExpHandler)
|
|
68
|
+
// Static file serving
|
|
69
|
+
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))
|
|
70
|
+
|
|
71
|
+
port := os.Getenv("PORT")
|
|
72
|
+
if port == "" {
|
|
73
|
+
port = "3000"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Launch server
|
|
77
|
+
log.Printf("server listen to %s \n", ":"+port)
|
|
78
|
+
err := http.ListenAndServe(":"+port, nil)
|
|
79
|
+
if err != nil {
|
|
80
|
+
log.Fatal(err)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
FROM golang:alpine
|
|
2
|
+
ARG HTTP_SERVICE_PORT
|
|
3
|
+
ARG BUILD_CMD
|
|
4
|
+
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
ADD build/src.tar .
|
|
7
|
+
|
|
8
|
+
RUN go mod download
|
|
9
|
+
ENV HTTP_SERVICE_PORT ${HTTP_SERVICE_PORT}
|
|
10
|
+
|
|
11
|
+
RUN $BUILD_CMD
|
|
12
|
+
|
|
13
|
+
EXPOSE $HTTP_SERVICE_PORT
|
|
14
|
+
|
|
15
|
+
CMD ["/app/release"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# CMD caddy file-server --listen :$HTTP_SERVICE_PORT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -ex
|
|
3
|
+
|
|
4
|
+
SHELLDIR="$(dirname "$(realpath "$0")")"
|
|
5
|
+
|
|
6
|
+
cd "$SHELLDIR"
|
|
7
|
+
|
|
8
|
+
mkdir build
|
|
9
|
+
|
|
10
|
+
tar -cf build/src.tar --exclude='.lazycat' --exclude='.git' ../../
|
|
11
|
+
|
|
12
|
+
# docker -H ssh://box@$BUILD_DOMAIN:2222 build . -t $APP_IMAGE --build-arg BUILD_CMD="$BUILD_CMD"
|
|
13
|
+
|
|
14
|
+
# rm src.tar
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# hc_test
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
npm install
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Compiles and hot-reloads for development
|
|
9
|
+
```
|
|
10
|
+
npm run serve
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Compiles and minifies for production
|
|
14
|
+
```
|
|
15
|
+
npm run build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Lints and fixes files
|
|
19
|
+
```
|
|
20
|
+
npm run lint
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Customize configuration
|
|
24
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node_modules
|