active_designer 0.0.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.
Files changed (29) hide show
  1. checksums.yaml +7 -0
  2. data/bin/active_designer +8 -0
  3. data/lib/active_designer/file_converter.rb +27 -0
  4. data/lib/active_designer/public/css/bootstrap.min.css +7 -0
  5. data/lib/active_designer/public/css/cards.css +107 -0
  6. data/lib/active_designer/public/css/font-awesome-4.7.0/css/font-awesome.min.css +4 -0
  7. data/lib/active_designer/public/css/font-awesome-4.7.0/fonts/FontAwesome.otf +0 -0
  8. data/lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.eot +0 -0
  9. data/lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.svg +2671 -0
  10. data/lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf +0 -0
  11. data/lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.woff +0 -0
  12. data/lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2 +0 -0
  13. data/lib/active_designer/public/css/main.css +199 -0
  14. data/lib/active_designer/public/js/bootstrap.min.js +7 -0
  15. data/lib/active_designer/public/js/jquery-3.1.1.js +10220 -0
  16. data/lib/active_designer/public/js/jsPlumb-2.2.8.js +13836 -0
  17. data/lib/active_designer/public/js/schema/add-column.js +82 -0
  18. data/lib/active_designer/public/js/schema/edit-checker.js +14 -0
  19. data/lib/active_designer/public/js/schema/edit-table-name.js +77 -0
  20. data/lib/active_designer/public/js/schema/jsPlumb.js +70 -0
  21. data/lib/active_designer/public/js/schema/listeners.js +265 -0
  22. data/lib/active_designer/public/js/schema/main.js +72 -0
  23. data/lib/active_designer/public/js/schema/mouse-controls.js +15 -0
  24. data/lib/active_designer/public/js/schema/table-html.js +24 -0
  25. data/lib/active_designer/public/js/tether.min.js +1 -0
  26. data/lib/active_designer/schema_creator.rb +86 -0
  27. data/lib/active_designer/template.html.erb +121 -0
  28. data/lib/active_designer.rb +69 -0
  29. metadata +76 -0
@@ -0,0 +1 @@
1
+ !function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e(require,exports,module):t.Tether=e()}(this,function(t,e,o){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){var e=t.getBoundingClientRect(),o={};for(var n in e)o[n]=e[n];if(t.ownerDocument!==document){var r=t.ownerDocument.defaultView.frameElement;if(r){var s=i(r);o.top+=s.top,o.bottom+=s.top,o.left+=s.left,o.right+=s.left}}return o}function r(t){var e=getComputedStyle(t)||{},o=e.position,n=[];if("fixed"===o)return[t];for(var i=t;(i=i.parentNode)&&i&&1===i.nodeType;){var r=void 0;try{r=getComputedStyle(i)}catch(s){}if("undefined"==typeof r||null===r)return n.push(i),n;var a=r,f=a.overflow,l=a.overflowX,h=a.overflowY;/(auto|scroll)/.test(f+h+l)&&("absolute"!==o||["relative","absolute","fixed"].indexOf(r.position)>=0)&&n.push(i)}return n.push(t.ownerDocument.body),t.ownerDocument!==document&&n.push(t.ownerDocument.defaultView),n}function s(){A&&document.body.removeChild(A),A=null}function a(t){var e=void 0;t===document?(e=document,t=document.documentElement):e=t.ownerDocument;var o=e.documentElement,n=i(t),r=P();return n.top-=r.top,n.left-=r.left,"undefined"==typeof n.width&&(n.width=document.body.scrollWidth-n.left-n.right),"undefined"==typeof n.height&&(n.height=document.body.scrollHeight-n.top-n.bottom),n.top=n.top-o.clientTop,n.left=n.left-o.clientLeft,n.right=e.body.clientWidth-n.width-n.left,n.bottom=e.body.clientHeight-n.height-n.top,n}function f(t){return t.offsetParent||document.documentElement}function l(){var t=document.createElement("div");t.style.width="100%",t.style.height="200px";var e=document.createElement("div");h(e.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),e.appendChild(t),document.body.appendChild(e);var o=t.offsetWidth;e.style.overflow="scroll";var n=t.offsetWidth;o===n&&(n=e.clientWidth),document.body.removeChild(e);var i=o-n;return{width:i,height:i}}function h(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=[];return Array.prototype.push.apply(e,arguments),e.slice(1).forEach(function(e){if(e)for(var o in e)({}).hasOwnProperty.call(e,o)&&(t[o]=e[o])}),t}function u(t,e){if("undefined"!=typeof t.classList)e.split(" ").forEach(function(e){e.trim()&&t.classList.remove(e)});else{var o=new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi"),n=c(t).replace(o," ");g(t,n)}}function d(t,e){if("undefined"!=typeof t.classList)e.split(" ").forEach(function(e){e.trim()&&t.classList.add(e)});else{u(t,e);var o=c(t)+(" "+e);g(t,o)}}function p(t,e){if("undefined"!=typeof t.classList)return t.classList.contains(e);var o=c(t);return new RegExp("(^| )"+e+"( |$)","gi").test(o)}function c(t){return t.className instanceof t.ownerDocument.defaultView.SVGAnimatedString?t.className.baseVal:t.className}function g(t,e){t.setAttribute("class",e)}function m(t,e,o){o.forEach(function(o){-1===e.indexOf(o)&&p(t,o)&&u(t,o)}),e.forEach(function(e){p(t,e)||d(t,e)})}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function y(t,e){var o=arguments.length<=2||void 0===arguments[2]?1:arguments[2];return t+o>=e&&e>=t-o}function b(){return"undefined"!=typeof performance&&"undefined"!=typeof performance.now?performance.now():+new Date}function w(){for(var t={top:0,left:0},e=arguments.length,o=Array(e),n=0;e>n;n++)o[n]=arguments[n];return o.forEach(function(e){var o=e.top,n=e.left;"string"==typeof o&&(o=parseFloat(o,10)),"string"==typeof n&&(n=parseFloat(n,10)),t.top+=o,t.left+=n}),t}function C(t,e){return"string"==typeof t.left&&-1!==t.left.indexOf("%")&&(t.left=parseFloat(t.left,10)/100*e.width),"string"==typeof t.top&&-1!==t.top.indexOf("%")&&(t.top=parseFloat(t.top,10)/100*e.height),t}function O(t,e){return"scrollParent"===e?e=t.scrollParents[0]:"window"===e&&(e=[pageXOffset,pageYOffset,innerWidth+pageXOffset,innerHeight+pageYOffset]),e===document&&(e=e.documentElement),"undefined"!=typeof e.nodeType&&!function(){var t=e,o=a(e),n=o,i=getComputedStyle(e);if(e=[n.left,n.top,o.width+n.left,o.height+n.top],t.ownerDocument!==document){var r=t.ownerDocument.defaultView;e[0]+=r.pageXOffset,e[1]+=r.pageYOffset,e[2]+=r.pageXOffset,e[3]+=r.pageYOffset}$.forEach(function(t,o){t=t[0].toUpperCase()+t.substr(1),"Top"===t||"Left"===t?e[o]+=parseFloat(i["border"+t+"Width"]):e[o]-=parseFloat(i["border"+t+"Width"])})}(),e}var E=function(){function t(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,o,n){return o&&t(e.prototype,o),n&&t(e,n),e}}(),x=void 0;"undefined"==typeof x&&(x={modules:[]});var A=null,T=function(){var t=0;return function(){return++t}}(),S={},P=function(){var t=A;t||(t=document.createElement("div"),t.setAttribute("data-tether-id",T()),h(t.style,{top:0,left:0,position:"absolute"}),document.body.appendChild(t),A=t);var e=t.getAttribute("data-tether-id");return"undefined"==typeof S[e]&&(S[e]=i(t),M(function(){delete S[e]})),S[e]},W=[],M=function(t){W.push(t)},_=function(){for(var t=void 0;t=W.pop();)t()},k=function(){function t(){n(this,t)}return E(t,[{key:"on",value:function(t,e,o){var n=arguments.length<=3||void 0===arguments[3]?!1:arguments[3];"undefined"==typeof this.bindings&&(this.bindings={}),"undefined"==typeof this.bindings[t]&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:o,once:n})}},{key:"once",value:function(t,e,o){this.on(t,e,o,!0)}},{key:"off",value:function(t,e){if("undefined"!=typeof this.bindings&&"undefined"!=typeof this.bindings[t])if("undefined"==typeof e)delete this.bindings[t];else for(var o=0;o<this.bindings[t].length;)this.bindings[t][o].handler===e?this.bindings[t].splice(o,1):++o}},{key:"trigger",value:function(t){if("undefined"!=typeof this.bindings&&this.bindings[t]){for(var e=0,o=arguments.length,n=Array(o>1?o-1:0),i=1;o>i;i++)n[i-1]=arguments[i];for(;e<this.bindings[t].length;){var r=this.bindings[t][e],s=r.handler,a=r.ctx,f=r.once,l=a;"undefined"==typeof l&&(l=this),s.apply(l,n),f?this.bindings[t].splice(e,1):++e}}}}]),t}();x.Utils={getActualBoundingClientRect:i,getScrollParents:r,getBounds:a,getOffsetParent:f,extend:h,addClass:d,removeClass:u,hasClass:p,updateClasses:m,defer:M,flush:_,uniqueId:T,Evented:k,getScrollBarSize:l,removeUtilElements:s};var B=function(){function t(t,e){var o=[],n=!0,i=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(o.push(s.value),!e||o.length!==e);n=!0);}catch(f){i=!0,r=f}finally{try{!n&&a["return"]&&a["return"]()}finally{if(i)throw r}}return o}return function(e,o){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,o);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),E=function(){function t(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,o,n){return o&&t(e.prototype,o),n&&t(e,n),e}}(),z=function(t,e,o){for(var n=!0;n;){var i=t,r=e,s=o;n=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,r);if(void 0!==a){if("value"in a)return a.value;var f=a.get;if(void 0===f)return;return f.call(s)}var l=Object.getPrototypeOf(i);if(null===l)return;t=l,e=r,o=s,n=!0,a=l=void 0}};if("undefined"==typeof x)throw new Error("You must include the utils.js file before tether.js");var j=x.Utils,r=j.getScrollParents,a=j.getBounds,f=j.getOffsetParent,h=j.extend,d=j.addClass,u=j.removeClass,m=j.updateClasses,M=j.defer,_=j.flush,l=j.getScrollBarSize,s=j.removeUtilElements,Y=function(){if("undefined"==typeof document)return"";for(var t=document.createElement("div"),e=["transform","WebkitTransform","OTransform","MozTransform","msTransform"],o=0;o<e.length;++o){var n=e[o];if(void 0!==t.style[n])return n}}(),L=[],D=function(){L.forEach(function(t){t.position(!1)}),_()};!function(){var t=null,e=null,o=null,n=function i(){return"undefined"!=typeof e&&e>16?(e=Math.min(e-16,250),void(o=setTimeout(i,250))):void("undefined"!=typeof t&&b()-t<10||(null!=o&&(clearTimeout(o),o=null),t=b(),D(),e=b()-t))};"undefined"!=typeof window&&"undefined"!=typeof window.addEventListener&&["resize","scroll","touchmove"].forEach(function(t){window.addEventListener(t,n)})}();var X={center:"center",left:"right",right:"left"},F={middle:"middle",top:"bottom",bottom:"top"},H={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"},N=function(t,e){var o=t.left,n=t.top;return"auto"===o&&(o=X[e.left]),"auto"===n&&(n=F[e.top]),{left:o,top:n}},U=function(t){var e=t.left,o=t.top;return"undefined"!=typeof H[t.left]&&(e=H[t.left]),"undefined"!=typeof H[t.top]&&(o=H[t.top]),{left:e,top:o}},V=function(t){var e=t.split(" "),o=B(e,2),n=o[0],i=o[1];return{top:n,left:i}},R=V,q=function(t){function e(t){var o=this;n(this,e),z(Object.getPrototypeOf(e.prototype),"constructor",this).call(this),this.position=this.position.bind(this),L.push(this),this.history=[],this.setOptions(t,!1),x.modules.forEach(function(t){"undefined"!=typeof t.initialize&&t.initialize.call(o)}),this.position()}return v(e,t),E(e,[{key:"getClass",value:function(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0],e=this.options.classes;return"undefined"!=typeof e&&e[t]?this.options.classes[t]:this.options.classPrefix?this.options.classPrefix+"-"+t:t}},{key:"setOptions",value:function(t){var e=this,o=arguments.length<=1||void 0===arguments[1]?!0:arguments[1],n={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether"};this.options=h(n,t);var i=this.options,s=i.element,a=i.target,f=i.targetModifier;if(this.element=s,this.target=a,this.targetModifier=f,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),["element","target"].forEach(function(t){if("undefined"==typeof e[t])throw new Error("Tether Error: Both element and target must be defined");"undefined"!=typeof e[t].jquery?e[t]=e[t][0]:"string"==typeof e[t]&&(e[t]=document.querySelector(e[t]))}),d(this.element,this.getClass("element")),this.options.addTargetClasses!==!1&&d(this.target,this.getClass("target")),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");this.targetAttachment=R(this.options.targetAttachment),this.attachment=R(this.options.attachment),this.offset=V(this.options.offset),this.targetOffset=V(this.options.targetOffset),"undefined"!=typeof this.scrollParents&&this.disable(),"scroll-handle"===this.targetModifier?this.scrollParents=[this.target]:this.scrollParents=r(this.target),this.options.enabled!==!1&&this.enable(o)}},{key:"getTargetBounds",value:function(){if("undefined"==typeof this.targetModifier)return a(this.target);if("visible"===this.targetModifier){if(this.target===document.body)return{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth};var t=a(this.target),e={height:t.height,width:t.width,top:t.top,left:t.left};return e.height=Math.min(e.height,t.height-(pageYOffset-t.top)),e.height=Math.min(e.height,t.height-(t.top+t.height-(pageYOffset+innerHeight))),e.height=Math.min(innerHeight,e.height),e.height-=2,e.width=Math.min(e.width,t.width-(pageXOffset-t.left)),e.width=Math.min(e.width,t.width-(t.left+t.width-(pageXOffset+innerWidth))),e.width=Math.min(innerWidth,e.width),e.width-=2,e.top<pageYOffset&&(e.top=pageYOffset),e.left<pageXOffset&&(e.left=pageXOffset),e}if("scroll-handle"===this.targetModifier){var t=void 0,o=this.target;o===document.body?(o=document.documentElement,t={left:pageXOffset,top:pageYOffset,height:innerHeight,width:innerWidth}):t=a(o);var n=getComputedStyle(o),i=o.scrollWidth>o.clientWidth||[n.overflow,n.overflowX].indexOf("scroll")>=0||this.target!==document.body,r=0;i&&(r=15);var s=t.height-parseFloat(n.borderTopWidth)-parseFloat(n.borderBottomWidth)-r,e={width:15,height:.975*s*(s/o.scrollHeight),left:t.left+t.width-parseFloat(n.borderLeftWidth)-15},f=0;408>s&&this.target===document.body&&(f=-11e-5*Math.pow(s,2)-.00727*s+22.58),this.target!==document.body&&(e.height=Math.max(e.height,24));var l=this.target.scrollTop/(o.scrollHeight-s);return e.top=l*(s-e.height-f)+t.top+parseFloat(n.borderTopWidth),this.target===document.body&&(e.height=Math.max(e.height,24)),e}}},{key:"clearCache",value:function(){this._cache={}}},{key:"cache",value:function(t,e){return"undefined"==typeof this._cache&&(this._cache={}),"undefined"==typeof this._cache[t]&&(this._cache[t]=e.call(this)),this._cache[t]}},{key:"enable",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];this.options.addTargetClasses!==!1&&d(this.target,this.getClass("enabled")),d(this.element,this.getClass("enabled")),this.enabled=!0,this.scrollParents.forEach(function(e){e!==t.target.ownerDocument&&e.addEventListener("scroll",t.position)}),e&&this.position()}},{key:"disable",value:function(){var t=this;u(this.target,this.getClass("enabled")),u(this.element,this.getClass("enabled")),this.enabled=!1,"undefined"!=typeof this.scrollParents&&this.scrollParents.forEach(function(e){e.removeEventListener("scroll",t.position)})}},{key:"destroy",value:function(){var t=this;this.disable(),L.forEach(function(e,o){e===t&&L.splice(o,1)}),0===L.length&&s()}},{key:"updateAttachClasses",value:function(t,e){var o=this;t=t||this.attachment,e=e||this.targetAttachment;var n=["left","top","bottom","right","middle","center"];"undefined"!=typeof this._addAttachClasses&&this._addAttachClasses.length&&this._addAttachClasses.splice(0,this._addAttachClasses.length),"undefined"==typeof this._addAttachClasses&&(this._addAttachClasses=[]);var i=this._addAttachClasses;t.top&&i.push(this.getClass("element-attached")+"-"+t.top),t.left&&i.push(this.getClass("element-attached")+"-"+t.left),e.top&&i.push(this.getClass("target-attached")+"-"+e.top),e.left&&i.push(this.getClass("target-attached")+"-"+e.left);var r=[];n.forEach(function(t){r.push(o.getClass("element-attached")+"-"+t),r.push(o.getClass("target-attached")+"-"+t)}),M(function(){"undefined"!=typeof o._addAttachClasses&&(m(o.element,o._addAttachClasses,r),o.options.addTargetClasses!==!1&&m(o.target,o._addAttachClasses,r),delete o._addAttachClasses)})}},{key:"position",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];if(this.enabled){this.clearCache();var o=N(this.targetAttachment,this.attachment);this.updateAttachClasses(this.attachment,o);var n=this.cache("element-bounds",function(){return a(t.element)}),i=n.width,r=n.height;if(0===i&&0===r&&"undefined"!=typeof this.lastSize){var s=this.lastSize;i=s.width,r=s.height}else this.lastSize={width:i,height:r};var h=this.cache("target-bounds",function(){return t.getTargetBounds()}),u=h,d=C(U(this.attachment),{width:i,height:r}),p=C(U(o),u),c=C(this.offset,{width:i,height:r}),g=C(this.targetOffset,u);d=w(d,c),p=w(p,g);for(var m=h.left+p.left-d.left,v=h.top+p.top-d.top,y=0;y<x.modules.length;++y){var b=x.modules[y],O=b.position.call(this,{left:m,top:v,targetAttachment:o,targetPos:h,elementPos:n,offset:d,targetOffset:p,manualOffset:c,manualTargetOffset:g,scrollbarSize:S,attachment:this.attachment});if(O===!1)return!1;"undefined"!=typeof O&&"object"==typeof O&&(v=O.top,m=O.left)}var E={page:{top:v,left:m},viewport:{top:v-pageYOffset,bottom:pageYOffset-v-r+innerHeight,left:m-pageXOffset,right:pageXOffset-m-i+innerWidth}},A=this.target.ownerDocument,T=A.defaultView,S=void 0;return A.body.scrollWidth>T.innerWidth&&(S=this.cache("scrollbar-size",l),E.viewport.bottom-=S.height),A.body.scrollHeight>T.innerHeight&&(S=this.cache("scrollbar-size",l),E.viewport.right-=S.width),(-1===["","static"].indexOf(A.body.style.position)||-1===["","static"].indexOf(A.body.parentElement.style.position))&&(E.page.bottom=A.body.scrollHeight-v-r,E.page.right=A.body.scrollWidth-m-i),"undefined"!=typeof this.options.optimizations&&this.options.optimizations.moveElement!==!1&&"undefined"==typeof this.targetModifier&&!function(){var e=t.cache("target-offsetparent",function(){return f(t.target)}),o=t.cache("target-offsetparent-bounds",function(){return a(e)}),n=getComputedStyle(e),i=o,r={};if(["Top","Left","Bottom","Right"].forEach(function(t){r[t.toLowerCase()]=parseFloat(n["border"+t+"Width"])}),o.right=A.body.scrollWidth-o.left-i.width+r.right,o.bottom=A.body.scrollHeight-o.top-i.height+r.bottom,E.page.top>=o.top+r.top&&E.page.bottom>=o.bottom&&E.page.left>=o.left+r.left&&E.page.right>=o.right){var s=e.scrollTop,l=e.scrollLeft;E.offset={top:E.page.top-o.top+s-r.top,left:E.page.left-o.left+l-r.left}}}(),this.move(E),this.history.unshift(E),this.history.length>3&&this.history.pop(),e&&_(),!0}}},{key:"move",value:function(t){var e=this;if("undefined"!=typeof this.element.parentNode){var o={};for(var n in t){o[n]={};for(var i in t[n]){for(var r=!1,s=0;s<this.history.length;++s){var a=this.history[s];if("undefined"!=typeof a[n]&&!y(a[n][i],t[n][i])){r=!0;break}}r||(o[n][i]=!0)}}var l={top:"",left:"",right:"",bottom:""},u=function(t,o){var n="undefined"!=typeof e.options.optimizations,i=n?e.options.optimizations.gpu:null;if(i!==!1){var r=void 0,s=void 0;t.top?(l.top=0,r=o.top):(l.bottom=0,r=-o.bottom),t.left?(l.left=0,s=o.left):(l.right=0,s=-o.right),l[Y]="translateX("+Math.round(s)+"px) translateY("+Math.round(r)+"px)","msTransform"!==Y&&(l[Y]+=" translateZ(0)")}else t.top?l.top=o.top+"px":l.bottom=o.bottom+"px",t.left?l.left=o.left+"px":l.right=o.right+"px"},d=!1;if((o.page.top||o.page.bottom)&&(o.page.left||o.page.right)?(l.position="absolute",u(o.page,t.page)):(o.viewport.top||o.viewport.bottom)&&(o.viewport.left||o.viewport.right)?(l.position="fixed",u(o.viewport,t.viewport)):"undefined"!=typeof o.offset&&o.offset.top&&o.offset.left?!function(){l.position="absolute";var n=e.cache("target-offsetparent",function(){return f(e.target)});f(e.element)!==n&&M(function(){e.element.parentNode.removeChild(e.element),n.appendChild(e.element)}),u(o.offset,t.offset),d=!0}():(l.position="absolute",u({top:!0,left:!0},t.page)),!d){for(var p=!0,c=this.element.parentNode;c&&1===c.nodeType&&"BODY"!==c.tagName;){if("static"!==getComputedStyle(c).position){p=!1;break}c=c.parentNode}p||(this.element.parentNode.removeChild(this.element),this.element.ownerDocument.body.appendChild(this.element))}var g={},m=!1;for(var i in l){var v=l[i],b=this.element.style[i];b!==v&&(m=!0,g[i]=v)}m&&M(function(){h(e.element.style,g)})}}}]),e}(k);q.modules=[],x.position=D;var I=h(q,x),B=function(){function t(t,e){var o=[],n=!0,i=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(o.push(s.value),!e||o.length!==e);n=!0);}catch(f){i=!0,r=f}finally{try{!n&&a["return"]&&a["return"]()}finally{if(i)throw r}}return o}return function(e,o){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,o);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),j=x.Utils,a=j.getBounds,h=j.extend,m=j.updateClasses,M=j.defer,$=["left","top","right","bottom"];x.modules.push({position:function(t){var e=this,o=t.top,n=t.left,i=t.targetAttachment;if(!this.options.constraints)return!0;var r=this.cache("element-bounds",function(){return a(e.element)}),s=r.height,f=r.width;if(0===f&&0===s&&"undefined"!=typeof this.lastSize){var l=this.lastSize;f=l.width,s=l.height}var u=this.cache("target-bounds",function(){return e.getTargetBounds()}),d=u.height,p=u.width,c=[this.getClass("pinned"),this.getClass("out-of-bounds")];this.options.constraints.forEach(function(t){var e=t.outOfBoundsClass,o=t.pinnedClass;e&&c.push(e),o&&c.push(o)}),c.forEach(function(t){["left","top","right","bottom"].forEach(function(e){c.push(t+"-"+e)})});var g=[],v=h({},i),y=h({},this.attachment);return this.options.constraints.forEach(function(t){var r=t.to,a=t.attachment,l=t.pin;"undefined"==typeof a&&(a="");var h=void 0,u=void 0;if(a.indexOf(" ")>=0){var c=a.split(" "),m=B(c,2);u=m[0],h=m[1]}else h=u=a;var b=O(e,r);("target"===u||"both"===u)&&(o<b[1]&&"top"===v.top&&(o+=d,v.top="bottom"),o+s>b[3]&&"bottom"===v.top&&(o-=d,v.top="top")),"together"===u&&("top"===v.top&&("bottom"===y.top&&o<b[1]?(o+=d,v.top="bottom",o+=s,y.top="top"):"top"===y.top&&o+s>b[3]&&o-(s-d)>=b[1]&&(o-=s-d,v.top="bottom",y.top="bottom")),"bottom"===v.top&&("top"===y.top&&o+s>b[3]?(o-=d,v.top="top",o-=s,y.top="bottom"):"bottom"===y.top&&o<b[1]&&o+(2*s-d)<=b[3]&&(o+=s-d,v.top="top",y.top="top")),"middle"===v.top&&(o+s>b[3]&&"top"===y.top?(o-=s,y.top="bottom"):o<b[1]&&"bottom"===y.top&&(o+=s,y.top="top"))),("target"===h||"both"===h)&&(n<b[0]&&"left"===v.left&&(n+=p,v.left="right"),n+f>b[2]&&"right"===v.left&&(n-=p,v.left="left")),"together"===h&&(n<b[0]&&"left"===v.left?"right"===y.left?(n+=p,v.left="right",n+=f,y.left="left"):"left"===y.left&&(n+=p,v.left="right",n-=f,y.left="right"):n+f>b[2]&&"right"===v.left?"left"===y.left?(n-=p,v.left="left",n-=f,y.left="right"):"right"===y.left&&(n-=p,v.left="left",n+=f,y.left="left"):"center"===v.left&&(n+f>b[2]&&"left"===y.left?(n-=f,y.left="right"):n<b[0]&&"right"===y.left&&(n+=f,y.left="left"))),("element"===u||"both"===u)&&(o<b[1]&&"bottom"===y.top&&(o+=s,y.top="top"),o+s>b[3]&&"top"===y.top&&(o-=s,y.top="bottom")),("element"===h||"both"===h)&&(n<b[0]&&("right"===y.left?(n+=f,y.left="left"):"center"===y.left&&(n+=f/2,y.left="left")),n+f>b[2]&&("left"===y.left?(n-=f,y.left="right"):"center"===y.left&&(n-=f/2,y.left="right"))),"string"==typeof l?l=l.split(",").map(function(t){return t.trim()}):l===!0&&(l=["top","left","right","bottom"]),l=l||[];var w=[],C=[];o<b[1]&&(l.indexOf("top")>=0?(o=b[1],w.push("top")):C.push("top")),o+s>b[3]&&(l.indexOf("bottom")>=0?(o=b[3]-s,w.push("bottom")):C.push("bottom")),n<b[0]&&(l.indexOf("left")>=0?(n=b[0],w.push("left")):C.push("left")),n+f>b[2]&&(l.indexOf("right")>=0?(n=b[2]-f,w.push("right")):C.push("right")),w.length&&!function(){var t=void 0;t="undefined"!=typeof e.options.pinnedClass?e.options.pinnedClass:e.getClass("pinned"),g.push(t),w.forEach(function(e){g.push(t+"-"+e)})}(),C.length&&!function(){var t=void 0;t="undefined"!=typeof e.options.outOfBoundsClass?e.options.outOfBoundsClass:e.getClass("out-of-bounds"),g.push(t),C.forEach(function(e){g.push(t+"-"+e)})}(),(w.indexOf("left")>=0||w.indexOf("right")>=0)&&(y.left=v.left=!1),(w.indexOf("top")>=0||w.indexOf("bottom")>=0)&&(y.top=v.top=!1),(v.top!==i.top||v.left!==i.left||y.top!==e.attachment.top||y.left!==e.attachment.left)&&(e.updateAttachClasses(y,v),e.trigger("update",{attachment:y,targetAttachment:v}))}),M(function(){e.options.addTargetClasses!==!1&&m(e.target,g,c),m(e.element,g,c)}),{top:o,left:n}}});var j=x.Utils,a=j.getBounds,m=j.updateClasses,M=j.defer;x.modules.push({position:function(t){var e=this,o=t.top,n=t.left,i=this.cache("element-bounds",function(){return a(e.element)}),r=i.height,s=i.width,f=this.getTargetBounds(),l=o+r,h=n+s,u=[];o<=f.bottom&&l>=f.top&&["left","right"].forEach(function(t){var e=f[t];(e===n||e===h)&&u.push(t)}),n<=f.right&&h>=f.left&&["top","bottom"].forEach(function(t){var e=f[t];(e===o||e===l)&&u.push(t)});var d=[],p=[],c=["left","top","right","bottom"];return d.push(this.getClass("abutted")),c.forEach(function(t){d.push(e.getClass("abutted")+"-"+t)}),u.length&&p.push(this.getClass("abutted")),u.forEach(function(t){p.push(e.getClass("abutted")+"-"+t)}),M(function(){e.options.addTargetClasses!==!1&&m(e.target,p,d),m(e.element,p,d)}),!0}});var B=function(){function t(t,e){var o=[],n=!0,i=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(o.push(s.value),!e||o.length!==e);n=!0);}catch(f){i=!0,r=f}finally{try{!n&&a["return"]&&a["return"]()}finally{if(i)throw r}}return o}return function(e,o){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,o);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();return x.modules.push({position:function(t){var e=t.top,o=t.left;if(this.options.shift){var n=this.options.shift;"function"==typeof this.options.shift&&(n=this.options.shift.call(this,{top:e,left:o}));var i=void 0,r=void 0;if("string"==typeof n){n=n.split(" "),n[1]=n[1]||n[0];var s=n,a=B(s,2);i=a[0],r=a[1],i=parseFloat(i,10),r=parseFloat(r,10)}else i=n.top,r=n.left;return e+=i,o+=r,{top:e,left:o}}}}),I});
@@ -0,0 +1,86 @@
1
+ module ActiveDesigner
2
+ class SchemaCreator
3
+
4
+ attr_reader :output
5
+
6
+ def format(schema)
7
+ schema = delete_comments(schema.split("\n"))
8
+ create_tables(schema)
9
+ end
10
+
11
+ def delete_comments(schema)
12
+ t = schema.map do |line|
13
+ line = line.strip
14
+ line if line[0] != "#" && !line.empty?
15
+ end.compact
16
+ end
17
+
18
+ def create_tables(schema)
19
+ tables = {}
20
+ table_index = 100
21
+ column_index = 100
22
+ reference_index = 100
23
+ table_id = nil
24
+ schema.each do |line|
25
+ if line.include?("create_table")
26
+ table_index += 1
27
+ column_index = 100
28
+ reference_index = 100
29
+ table_name = format_name(line)
30
+ table_id = "tbl-" + table_index.to_s
31
+ tables[table_id] = {
32
+ name: table_name,
33
+ original_name: table_name,
34
+ status: { original: true, modified: false, new: false, deleted: false },
35
+ columns: {},
36
+ references: {},
37
+ id: table_id
38
+ }
39
+ elsif line.include?("t.")
40
+ column_name = format_name(line)
41
+ if !column_name.include?('_id')
42
+ column_index += 1
43
+ column_type = format_type(line)
44
+ column_id = "col-#{table_index.to_s}-#{column_index.to_s}"
45
+ tables[table_id][:columns][column_id] = {
46
+ name: column_name,
47
+ original_name: column_name,
48
+ type: column_type,
49
+ original_type: column_type,
50
+ id: column_id,
51
+ status: { original: true, new: false, modified: false, deleted: false }
52
+ }
53
+ end
54
+ elsif line.include?("add_foreign_key")
55
+ reference_index += 1
56
+ components = line.split(" ")
57
+ table_name = components[1].delete("\",")
58
+ foreign_table_name = components[2].delete("\"")
59
+ table_id = ""
60
+ foreign_table_id = ""
61
+ tables.each do |table|
62
+ table_id = table[0] if table[1][:name] == table_name
63
+ foreign_table_id = table[0] if table[1][:name] == foreign_table_name
64
+ end
65
+ reference_id = "ref-#{table_id.split('-')[1]}-#{reference_index}"
66
+ tables[table_id][:references][reference_id] = {
67
+ id: reference_id,
68
+ table_id: table_id,
69
+ foreign_table_name: foreign_table_name,
70
+ foreign_table_id: foreign_table_id,
71
+ status: { original: true, new: false, deleted: false }
72
+ }
73
+ end
74
+ end
75
+ tables
76
+ end
77
+
78
+ def format_name(line)
79
+ name = line.split(" ")[1].delete("\",")
80
+ end
81
+
82
+ def format_type(line)
83
+ line.split(" ")[0].split(".")[1]
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,121 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <title>SQL Helper</title>
6
+ <link rel="stylesheet" href="<%= @path %>/public/css/bootstrap.min.css">
7
+ <script src="<%= @path %>/public/js/tether.min.js"></script>
8
+ <script src="<%= @path %>/public/js/jquery-3.1.1.js"></script>
9
+ <script src="<%= @path %>/public/js/bootstrap.min.js"></script>
10
+ <script src="<%= @path %>/public/js/jsPlumb-2.2.8.js"></script>
11
+ <script src="<%= @path %>/public/js/schema/jsPlumb.js"></script>
12
+ <script src="<%= @path %>/public/js/schema/edit-checker.js"></script>
13
+ <script src="<%= @path %>/public/js/schema/edit-table-name.js"></script>
14
+ <script src="<%= @path %>/public/js/schema/listeners.js"></script>
15
+ <script src="<%= @path %>/public/js/schema/mouse-controls.js"></script>
16
+ <script src="<%= @path %>/public/js/schema/add-column.js"></script>
17
+ <script src="<%= @path %>/public/js/schema/table-html.js"></script>
18
+ <link rel="stylesheet" href="<%= @path %>/public/css/main.css" >
19
+ <link rel="stylesheet" href="<%= @path %>/public/css/cards.css" >
20
+ <link rel="stylesheet" href="<%= @path %>/public/css/font-awesome-4.7.0/css/font-awesome.min.css">
21
+ </head>
22
+
23
+ <body>
24
+ <nav class="navbar bg-inverse">
25
+ <ul class="nav navbar-nav">
26
+ <li class="nav-item taco float-xs-left">
27
+ <a class="btn btn-default" data-toggle='popover' data-trigger='hover' data-content='Create a new table' href='#' >
28
+ <i class="fa fa-plus-square-o fa-3x" aria-hidden="true"></i>
29
+ </a>
30
+ </li>
31
+
32
+ <li class="nav-item float-xs-left scroller">
33
+ <div class="switch">
34
+ <div id='zoom-out' class='zoom-button'>
35
+ <i class="fa fa-chevron-circle-left fa-2x" aria-hidden="true"></i>
36
+ </div>
37
+ <div class='slider-box'>
38
+ </div>
39
+ <div class="slider round">
40
+ <i class="fa fa-arrows-h" aria-hidden="true"></i>
41
+ </div>
42
+ <div id='zoom-in' class='zoom-button'>
43
+ <i class="fa fa-chevron-circle-right fa-2x" aria-hidden="true"></i>
44
+ </div>
45
+ </div>
46
+
47
+ </li>
48
+
49
+ <li class="nav-item float-xs-center">
50
+ <a class="btn btn-default navbar-brand" data-toggle='popover' data-trigger='hover' data-placement="left" data-content='Enter name of database' href='#' >
51
+ <h2><%= @file_name %></h2>
52
+ </a>
53
+ </li>
54
+ </ul>
55
+ </nav>
56
+ <div class="alert-bar">
57
+
58
+ </div>
59
+
60
+ <div id="bar" class="canvasBorder" >
61
+ <div id="foo" class="jsPlumbBoundary" >
62
+ <% table_x = 10 %>
63
+ <% table_y = 10 %>
64
+ <% @tables.each do |table_id,table| %>
65
+ <div class='card' id='<%= table_id %>' style="top:<%="#{table_y}"%>px;left:<%="#{table_x}"%>px;">
66
+ <div class='card-header'>
67
+ <i class="fa fa-arrows" aria-hidden="true"></i>
68
+ <h4 class='card-title table-title' data-toggle='popover' data-trigger='hover' data-content='Edit table name'>
69
+ <%= table[:name] %>
70
+ </h4>
71
+ <div class='table-nav-buttons'>
72
+ <i class='fa fa-plus-square' data-toggle='popover' data-trigger='hover' data-content='Add column'></i>
73
+ <i class='fa fa-trash delete-table' data-toggle='popover' data-trigger='hover' data-content='Destroy table'></i>
74
+ </div>
75
+ </div>
76
+ <div class='card-block'>
77
+ <ul class='list-group'>
78
+ <li class='list-group-item' id="<%= table_id %>-id-column">
79
+ <span class='tag tag-default float-xs-left type-span'>integer</span>
80
+ <div class='column-title-outer' >
81
+ <span class='column-title' >id</span>
82
+ </div>
83
+ </li>
84
+ <% table[:columns].each do |column_id,column| %>
85
+ <li class='list-group-item' id='<%= column_id %>'>
86
+ <span class='tag tag-default float-xs-left type-span' data-toggle='popover' data-trigger='hover' data-content='Edit type'><%= column[:type] %></span>
87
+ <div class='column-title-outer' >
88
+ <span class='column-title' data-toggle='popover' data-trigger='hover' data-content='Edit column name'><%= column[:name] %></span>
89
+ </div>
90
+ <i class='fa fa-trash delete-column' data-toggle='popover' data-trigger='hover' data-content='Destroy column'></i>
91
+ </li>
92
+ <% end %>
93
+ <% table[:references].each do |reference_id,reference| %>
94
+ <li class='list-group-item' id='<%= reference_id %>'>
95
+ <span class='tag tag-default float-xs-left type-span'>integer</span>
96
+ <div class='column-title-outer' >
97
+ <span class='column-title'><%= "#{reference[:foreign_table_name]}_id" %></span>
98
+ </div>
99
+ <i class='fa fa-trash delete-ref' data-toggle='popover' data-trigger='hover' data-content='Destroy table'></i>
100
+ </li>
101
+ <% end %>
102
+ </ul>
103
+ </div>
104
+ </div>
105
+ <% if table_x >= 650 %>
106
+ <% table_x = 10 %>
107
+ <% table_y = table_y + 300 %>
108
+ <% else %>
109
+ <% table_x = table_x + 275 %>
110
+ <% end %>
111
+ <% end %>
112
+ </div>
113
+ </div>
114
+ <script>localStorage.setItem("schema",JSON.stringify(<%= @schema %>))</script>
115
+ <!-- <script>localStorage.setItem("schema",JSON.parse(<%= @schema %>))</script> -->
116
+
117
+ </body>
118
+
119
+ <script src="<%= @path %>/public/js/schema/main.js"></script>
120
+
121
+ </html>
@@ -0,0 +1,69 @@
1
+ require 'erb'
2
+ require 'active_designer/file_converter.rb'
3
+
4
+ module ActiveDesigner
5
+
6
+ def self.call(argv,stdin,stdout,stderr)
7
+ command = argv[0]
8
+
9
+ if !command
10
+ stderr.puts "No command was provided, use -h or --help for more information"
11
+ return 1
12
+ end
13
+
14
+ if command == "--help" || command == "-h"
15
+ stdout.puts "To create a schema run '$ active-designer create filepath'"
16
+ stdout.puts "If youre in the root of a Sinatra or Ruby on Rails project the filepath should be './db/schema.rb'"
17
+ return 0
18
+ end
19
+
20
+ if command == "--create"
21
+ input_path = argv[1]
22
+ output_path = "active_designer/index.html"
23
+ output_dir = File.dirname output_path
24
+
25
+ if !input_path
26
+ stderr.puts "No path was provided, use -h or --help for more information"
27
+ return 1
28
+ end
29
+
30
+ if !File.exist?(input_path)
31
+ stderr.puts "#{input_path.inspect} does not exist, use -h or --help for more information"
32
+ return 1
33
+ end
34
+
35
+ Dir.mkdir output_dir unless Dir.exist?(output_dir)
36
+
37
+ if File.exist?(output_path) && !overwrite?(stdin, stdout, output_path)
38
+ stderr.puts "Aborted"
39
+ return 1
40
+ end
41
+
42
+ return create(output_path,input_path,stdout)
43
+ end
44
+
45
+ if command
46
+ stderr.puts "#{command.inspect} is not a known command, use -h or --help for more information"
47
+ return 1
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def self.overwrite?(stdin, stdout, path)
54
+ loop do
55
+ stdout.print "Do you wish to overwrite #{path}?(y/n) "
56
+ answer = stdin.gets.chomp.downcase
57
+ return answer == "y" if answer == "y" || answer == "n"
58
+ end
59
+ end
60
+
61
+ def self.create(output_path,input_path,stdout)
62
+ input_body = File.read(input_path)
63
+ converter = ActiveDesigner::FileConverter.new(input_body)
64
+ File.write(output_path, converter.render)
65
+ stdout.puts "\nCreated #{output_path}"
66
+ return 0
67
+ end
68
+
69
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_designer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thom Schlereth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Active Designer is a gem that allows a user to easily create a visual
14
+ format of their Active Record schema.rb file for an SQL database. With just one
15
+ command from the command line, it creates an HTML file in the root of the user’s
16
+ Ruby project. Active Designer is an easy to use Visual Interface that opens locally
17
+ in the browser and works offline to CRUD tables and columns!
18
+ email: thomschlereth@gmail.com
19
+ executables:
20
+ - active_designer
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - bin/active_designer
25
+ - lib/active_designer.rb
26
+ - lib/active_designer/file_converter.rb
27
+ - lib/active_designer/public/css/bootstrap.min.css
28
+ - lib/active_designer/public/css/cards.css
29
+ - lib/active_designer/public/css/font-awesome-4.7.0/css/font-awesome.min.css
30
+ - lib/active_designer/public/css/font-awesome-4.7.0/fonts/FontAwesome.otf
31
+ - lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.eot
32
+ - lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.svg
33
+ - lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf
34
+ - lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.woff
35
+ - lib/active_designer/public/css/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2
36
+ - lib/active_designer/public/css/main.css
37
+ - lib/active_designer/public/js/bootstrap.min.js
38
+ - lib/active_designer/public/js/jquery-3.1.1.js
39
+ - lib/active_designer/public/js/jsPlumb-2.2.8.js
40
+ - lib/active_designer/public/js/schema/add-column.js
41
+ - lib/active_designer/public/js/schema/edit-checker.js
42
+ - lib/active_designer/public/js/schema/edit-table-name.js
43
+ - lib/active_designer/public/js/schema/jsPlumb.js
44
+ - lib/active_designer/public/js/schema/listeners.js
45
+ - lib/active_designer/public/js/schema/main.js
46
+ - lib/active_designer/public/js/schema/mouse-controls.js
47
+ - lib/active_designer/public/js/schema/table-html.js
48
+ - lib/active_designer/public/js/tether.min.js
49
+ - lib/active_designer/schema_creator.rb
50
+ - lib/active_designer/template.html.erb
51
+ homepage: http://rubygems.org/gems/active-designer
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.5.1
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Active Designer is an easy to use Visual Interface that opens locally in
75
+ the browser and works offline to CRUD tables and columns!
76
+ test_files: []