diff --git a/.editorconfig b/.editorconfig index b55be14..c8e529a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,11 @@ indent_size = 2 [*.css] indent_style = space indent_size = 2 + +[*.js] +indent_style = space +indent_size = 2 + +[*.y{a,}ml] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore index ca35be0..ee52763 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -_site +/_site/ +/node_modules/ +/Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..053c27d --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'github-pages' diff --git a/_config.yaml b/_config.yaml new file mode 100644 index 0000000..67f88b0 --- /dev/null +++ b/_config.yaml @@ -0,0 +1,7 @@ +exclude: + - node_modules + - CNAME + - Gemfile + - Gemfile.lock + - gulpfile.js + - package.json diff --git a/_js/demo.js b/_js/demo.js new file mode 100644 index 0000000..a711ec9 --- /dev/null +++ b/_js/demo.js @@ -0,0 +1,47 @@ +(function ($) { + + var editorconfig = require('editorconfig'); + + function createFiles() { + var configFiles = [], configSuffix = "/.editorconfig"; + $('.js-ec-demo-config').each(function () { + var pathLength, configPath, form = $(this); + configPath = form.find('[name="filename"]').val(); + pathLength = configPath.length - configSuffix.length; + if (configPath.indexOf(configSuffix, pathLength) !== -1) { + configFiles.push({ + name: configPath, + contents: form.find('[name="file"]').val() + }); + } + }); + return configFiles; + } + + // Resize textarea automatically + $('textarea').on('input', function () { + // Set textarea height + this.style.height = 'auto'; + this.style.height = this.scrollHeight + 16 + 'px'; + }).trigger('input'); + + function renderOutput(configFiles) { + $('.js-ec-demo-output').each(function () { + var output = "", config, key, filename; + filename = $(this).find('[name="filename"]'); + config = editorconfig.parseFromFiles(filename.val(), configFiles); + for (key in config) { + if (config.hasOwnProperty(key)) { + output += key + " = " + config[key] + "\n"; + } + } + $(this).find('pre').text(output); + }); + } + + // Update output automatically + $('input, textarea').on('input', function () { + renderOutput(createFiles()); + }).trigger('input'); + +}(jQuery)); diff --git a/_layouts/default.html b/_layouts/default.html index 6bfc743..2c9261d 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -17,7 +17,7 @@ - + + diff --git a/css/style.css b/css/style.css index 2e5327f..57a15b8 100644 --- a/css/style.css +++ b/css/style.css @@ -84,6 +84,31 @@ header h1 { padding-top: 0.5em; } .editor-logos img { max-width: 100%; max-height: 100%; } .editor-logos span { opacity: 0; float: left; margin-top: -3em; } +.demo:after { + content: ""; + clear: both; + display: block; +} +.demo-section { + float: left; + width: 50%; +} +.demo input, .demo textarea, .demo pre { + display: block; + width: 100%; + padding: 2%; + font-family: monospace,sans-serif; + border-radius: 3px; + background-color: #ffffff; + resize: none; + border: 1px solid #000; + margin: 0; + font-size: 12px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + /* ============================================================================= Sidebar customizations ========================================================================== */ diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..d3bdc1c --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var uglify = require('gulp-uglify'); +var browserify = require('gulp-browserify'); + +gulp.task('default', function() { + gulp.src('./_js/*.js') + .pipe(browserify()) + .pipe(uglify()) + .pipe(gulp.dest('./js')) +}); diff --git a/index.html b/index.html index 9a41451..5b07184 100644 --- a/index.html +++ b/index.html @@ -108,6 +108,41 @@

Supported Properties

+
+

Try It Out

+ +
+
+

EditorConfig File

+
+
+
+ +
+
+
+ +
+

Enforced Style for a Given File

+
+
+
+
+
+
+
+
diff --git a/js/demo.js b/js/demo.js new file mode 100644 index 0000000..8b04ca9 --- /dev/null +++ b/js/demo.js @@ -0,0 +1 @@ +!function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=n[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;si&&"!"===t.charAt(i);i++)e=!e,r++;r&&(this.pattern=t.substr(r)),this.negate=e}}function l(t,e){function n(){d.push(y),y=""}if(e=e||this.options,t="undefined"==typeof t?this.pattern:t,"undefined"==typeof t)throw new Error("undefined pattern");if(e.nobrace||!t.match(/\{.*\}/))return[t];var r=!1;if("{"!==t.charAt(0)){for(var i=null,o=0,s=t.length;s>o;o++){var a=t.charAt(o);if("\\"===a)r=!r;else if("{"===a&&!r){i=t.substr(0,o);break}}if(null===i)return[t];var u=l(t.substr(o),e);return u.map(function(t){return i+t})}var c=t.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);if(c){for(var f=l(t.substr(c[0].length),e),h=+c[1],p=+c[2],g=h>p?-1:1,d=[],o=h;o!=p+g;o+=g)for(var m=0,v=f.length;v>m;m++)d.push(o+f[m]);return d}var o=1,b=1,d=[],y="",r=!1;t:for(o=1,s=t.length;s>o;o++){var a=t.charAt(o);if(r)r=!1,y+="\\"+a;else switch(a){case"\\":r=!0;continue;case"{":b++,y+="{";continue;case"}":if(b--,0===b){n(),o++;break t}y+=a;continue;case",":1===b?n():y+=a;continue;default:y+=a;continue}}if(0!==b)return l("\\"+t,e);var f=l(t.substr(o),e),w=1===d.length;d=d.map(function(t){return l(t,e)}),d=d.reduce(function(t,e){return t.concat(e)}),w&&(d=d.map(function(t){return"{"+t+"}"}));for(var j=[],o=0,s=d.length;s>o;o++)for(var m=0,v=f.length;v>m;m++)j.push(d[o]+f[m]);return j}function p(t,e){function n(){if(o){switch(o){case"*":a+=O,u=!0;break;case"?":a+=k,u=!0;break;default:a+="\\"+o}o=!1}}var r=this.options;if(!r.noglobstar&&"**"===t)return w;if(""===t)return"";for(var i,o,s,a="",u=!!r.nocase,c=!1,f=[],h=!1,l=-1,p=-1,g="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",d=0,v=t.length;v>d&&(s=t.charAt(d));d++)if(r.debug&&console.error("%s %s %s %j",t,d,a,s),c&&A[s])a+="\\"+s,c=!1;else switch(s){case"/":return!1;case"\\":n(),c=!0;continue;case"?":case"*":case"+":case"@":case"!":if(r.debug&&console.error("%s %s %s %j <-- stateChar",t,d,a,s),h){"!"===s&&d===p+1&&(s="^"),a+=s;continue}n(),o=s,r.noext&&n();continue;case"(":if(h){a+="(";continue}if(!o){a+="\\(";continue}i=o,f.push({type:i,start:d-1,reStart:a.length}),a+="!"===o?"(?:(?!":"(?:",o=!1;continue;case")":if(h||!f.length){a+="\\)";continue}switch(u=!0,a+=")",i=f.pop().type){case"!":a+="[^/]*?)";break;case"?":case"+":case"*":a+=i;case"@":}continue;case"|":if(h||!f.length||c){a+="\\|",c=!1;continue}a+="|";continue;case"[":if(n(),h){a+="\\"+s;continue}h=!0,p=d,l=a.length,a+=s;continue;case"]":if(d===p+1||!h){a+="\\"+s,c=!1;continue}u=!0,h=!1,a+=s;continue;default:n(),c?c=!1:!A[s]||"^"===s&&h||(a+="\\"),a+=s}if(h){var b=t.substr(p+1),y=this.parse(b,L);a=a.substr(0,l)+"\\["+y[0],u=u||y[1]}for(var j;j=f.pop();){var x=a.slice(j.reStart+3);x=x.replace(/((?:\\{2})*)(\\?)\|/g,function(t,e,n){return n||(n="\\"),e+e+n+"|"});var _="*"===j.type?O:"?"===j.type?k:"\\"+j.type;u=!0,a=a.slice(0,j.reStart)+_+"\\("+x}n(),c&&(a+="\\\\");var E=!1;switch(a.charAt(0)){case".":case"[":case"(":E=!0}if(""!==a&&u&&(a="(?=.)"+a),E&&(a=g+a),e===L)return[a,u];if(!u)return m(t);var S=r.nocase?"i":"",$=new RegExp("^"+a+"$",S);return $._glob=t,$._src=a,$}function g(){if(this.regexp||this.regexp===!1)return this.regexp;var t=this.set;if(!t.length)return this.regexp=!1;var e=this.options,n=e.noglobstar?O:e.dot?_:E,r=e.nocase?"i":"",i=t.map(function(t){return t.map(function(t){return t===w?n:"string"==typeof t?v(t):t._src}).join("\\/")}).join("|");i="^(?:"+i+")$",this.negate&&(i="^(?!"+i+").*$");try{return this.regexp=new RegExp(i,r)}catch(o){return this.regexp=!1}}function d(t,e){if(this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;var n=this.options;"win32"===r&&(t=t.split("\\").join("/")),t=t.split(S),n.debug&&console.error(this.pattern,"split",t);for(var i=this.set,o=0,s=i.length;s>o;o++){var a=i[o],u=this.matchOne(t,a,e);if(u)return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}function m(t){return t.replace(/\\(.)/g,"$1")}function v(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}n?n.exports=u:e.minimatch=u,t||(t=function(t){switch(t){case"sigmund":return function(t){return JSON.stringify(t)};case"path":return{basename:function(t){t=t.split(/[\/\\]/);var e=t.pop();return e||(e=t.pop()),e}};case"lru-cache":return function(){var t={},e=0;this.set=function(n,r){e++,e>=100&&(t={}),t[n]=r},this.get=function(e){return t[e]}}}}),u.Minimatch=c;var b=t("lru-cache"),y=u.cache=new b({max:100}),w=u.GLOBSTAR=c.GLOBSTAR={},j=t("sigmund"),x=t("path"),k="[^/]",O=k+"*?",_="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",E="(?:(?!(?:\\/|^)\\.).)*?",A=i("().*{}+?[]^$\\!"),S=/\/+/;u.monkeyPatch=o,u.filter=s,u.defaults=function(t){if(!t||!Object.keys(t).length)return u;var e=u,n=function(n,r,i){return e.minimatch(n,r,a(t,i))};return n.Minimatch=function(n,r){return new e.Minimatch(n,a(t,r))},n},c.defaults=function(t){return t&&Object.keys(t).length?u.defaults(t).Minimatch:c},c.prototype.make=f,c.prototype.parseNegate=h,u.braceExpand=function(t,e){return new c(t,e).braceExpand()},c.prototype.braceExpand=l,c.prototype.parse=p;var L={};u.makeRe=function(t,e){return new c(t,e||{}).makeRe()},c.prototype.makeRe=g,u.match=function(t,e,n){var r=new c(e,n);return t=t.filter(function(t){return r.match(t)}),n.nonull&&!t.length&&t.push(e),t},c.prototype.match=d,c.prototype.matchOne=function(t,e,n){var r=this.options;r.debug&&console.error("matchOne",{"this":this,file:t,pattern:e}),r.matchBase&&1===e.length&&(t=x.basename(t.join("/")).split("/")),r.debug&&console.error("matchOne",t.length,e.length);for(var i=0,o=0,s=t.length,a=e.length;s>i&&a>o;i++,o++){r.debug&&console.error("matchOne loop");var u=e[o],c=t[i];if(r.debug&&console.error(e,u,c),u===!1)return!1;if(u===w){r.debug&&console.error("GLOBSTAR",[e,u,c]);var f=i,h=o+1;if(h===a){for(r.debug&&console.error("** at the end");s>i;i++)if("."===t[i]||".."===t[i]||!r.dot&&"."===t[i].charAt(0))return!1;return!0}t:for(;s>f;){var l=t[f];if(r.debug&&console.error("\nglobstar while",t,f,e,h,l),this.matchOne(t.slice(f),e.slice(h),n))return r.debug&&console.error("globstar found match!",f,s,l),!0;if("."===l||".."===l||!r.dot&&"."===l.charAt(0)){r.debug&&console.error("dot detected!",t,f,e,h);break t}r.debug&&console.error("globstar swallow a segment, and continue"),f++}return n&&f===s?!0:!1}var p;if("string"==typeof u?(p=r.nocase?c.toLowerCase()===u.toLowerCase():c===u,r.debug&&console.error("string match",u,c,p)):(p=c.match(u),r.debug&&console.error("pattern match",u,c,p)),!p)return!1}if(i===s&&o===a)return!0;if(i===s)return n;if(o===a){var g=i===s-1&&""===t[i];return g}throw new Error("wtf?")}}("function"==typeof t?t:null,this,"object"==typeof e?e:null,"object"==typeof n?n.platform:"win32")}).call(this,t("1YiZ5S"))},{"1YiZ5S":11,"lru-cache":6,path:10,sigmund:7}],4:[function(t,e){function n(t){var e={},n=null,r=[[n,e]],o=t.split(/\r\n|\r|\n/);return o.forEach(function(t){var o;i.comment.test(t)||(i.param.test(t)?(o=t.match(i.param),e[o[1]]=o[2]):i.section.test(t)&&(o=t.match(i.section),n=o[1],e={},r.push([n,e])))}),r}var r=t("fs"),i={section:/^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,param:/^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,comment:/^\s*[#;].*$/};e.exports.parse=function(t,e){e&&r.readFile(t,"utf8",function(t,r){t?e(t):e(null,n(r))})},e.exports.parseSync=function(t){return n(r.readFileSync(t,"utf8"))},e.exports.parseString=n},{fs:9}],5:[function(t,e){function n(t){var e=arguments;this.components="string"==typeof t?t.split(".").map(function(t){return parseInt(t,10)}):Object.keys(arguments).map(function(t){return e[t]});var n=this.components.length;if(this.major=n?this.components[0]:0,this.minor=n>1?this.components[1]:0,this.build=n>2?this.components[2]:0,this.revision=n>3?this.components[3]:0,"string"==typeof t){var r=t.split("-");2===r.length&&(this.configuration=r[1])}}n.prototype={toString:function(){var t=this.components.join(".");return"undefined"!=typeof this.configuration&&(t+="-"+this.configuration),t},gte:function(t){return this.major=p))for(var t in h){if(s>=p)break;var e=h[t];c&&c(e.key,e.value),p-=e.length,delete f[e.key],delete h[t]}}if(!(this instanceof r))return new r(e);var s;"number"==typeof e&&(s=e,e={max:s}),s=e.max,e||(e={});var a=e.length||n;"function"!=typeof a&&(a=n),(!s||"number"!=typeof s||0>=s)&&(s=1/0);var u=e.maxAge||null,c=e.dispose,f=Object.create(null),h=Object.create(null),l=0,p=0,g=0;Object.defineProperty(this,"max",{set:function(t){(!t||"number"!=typeof t||0>=t)&&(t=1/0),s=t,p>s&&o()},get:function(){return s},enumerable:!0}),Object.defineProperty(this,"lengthCalculator",{set:function(t){if("function"!=typeof t){a=n,p=g;for(var e in f)f[e].length=1}else{a=t,p=0;for(var e in f)f[e].length=a(f[e].value),p+=f[e].length}p>s&&o()},get:function(){return a},enumerable:!0}),Object.defineProperty(this,"length",{get:function(){return p},enumerable:!0}),Object.defineProperty(this,"itemCount",{get:function(){return g},enumerable:!0}),this.reset=function(){if(c)for(var t in f)c(t,f[t].value);f={},h={},l=0,p=0,g=0},this.dump=function(){return f},this.set=function(e,n){if(t(f,e))return c&&c(e,f[e].value),u&&(f[e].now=Date.now()),f[e].value=n,this.get(e),!0;var r=a(n),d=u?Date.now():0,m=new i(e,n,l++,r,d);return m.length>s?(c&&c(e,n),!1):(p+=m.length,h[m.lu]=f[e]=m,g++,p>s&&o(),!0)},this.get=function(e){if(t(f,e)){var n=f[e];return u&&Date.now()-n.now>u?void this.del(e):(delete h[n.lu],n.lu=l++,h[n.lu]=n,n.value)}},this.del=function(e){if(t(f,e)){var n=f[e];c&&c(e,n.value),delete f[e],delete h[n.lu],p-=n.length,g--}}}function i(t,e,n,r,i){this.key=t,this.value=e,this.lu=n,this.length=r,this.now=i}"object"==typeof e&&e.exports?e.exports=r:this.LRUCache=r}()},{}],7:[function(t,e){function n(t,e){function n(t,s){return s>e||"function"==typeof t||"undefined"==typeof t?void 0:"object"!=typeof t||!t||t instanceof o?void(i+=t):void(-1===r.indexOf(t)&&s!==e&&(r.push(t),i+="{",Object.keys(t).forEach(function(e){if("_"!==e.charAt(0)){var r=typeof t[e];"function"!==r&&"undefined"!==r&&(i+=e,n(t[e],s+1))}})))}e=e||10;var r=[],i="",o=RegExp;return n(t,0),i}e.exports=n},{}],8:[function(t,e){e.exports={name:"editorconfig",version:"0.11.4",description:"EditorConfig File Locator and Interpreter for Node.js",keywords:["editorconfig","core"],main:"editorconfig.js",contributors:[{name:"Hong Xu",url:"topbug.net"},{name:"Jed Hunsaker",email:"jed.hunsaker[at]gmail.com"},{name:"Trey Hunner",url:"http://treyhunner.com"}],directories:{bin:"./bin",lib:"./lib"},scripts:{pretest:"cmake .",test:"ctest .","test-verbose":"ctest -VV --output-on-failure .",codepaint:"codepaint xform -e **/**.js"},repository:{type:"git",url:"git://github.com/editorconfig/editorconfig-core-js.git"},bugs:{url:"https://github.com/editorconfig/editorconfig-core-js/issues"},author:{name:"EditorConfig Team"},license:{type:"MIT",url:"http://editorconfig.mit-license.org/2012"},dependencies:{commander:"~1.1.1","lru-cache":"~2.0.0",sigmund:"~1.0.0"},bin:{editorconfig:"bin\\editorconfig"},_id:"editorconfig@0.11.4",dist:{shasum:"3b7dfb616280ce5b8ad32f0e4417cdf9e74ec351",tarball:"http://registry.npmjs.org/editorconfig/-/editorconfig-0.11.4.tgz"},_from:"editorconfig@^0.11.4",_npmVersion:"1.3.8",_npmUser:{name:"jedhunsaker",email:"jed.hunsaker@gmail.com"},maintainers:[{name:"trey",email:"trey@treyhunner.com"},{name:"jedhunsaker",email:"jed.hunsaker@gmail.com"}],_shasum:"3b7dfb616280ce5b8ad32f0e4417cdf9e74ec351",_resolved:"https://registry.npmjs.org/editorconfig/-/editorconfig-0.11.4.tgz"}},{}],9:[function(){},{}],10:[function(t,e,n){(function(t){function e(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r=-1&&!i;o--){var s=o>=0?arguments[o]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=e(r(n.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(t){var i=n.isAbsolute(t),o="/"===s(t,-1);return t=e(r(t.split("/"),function(t){return!!t}),!i).join("/"),t||i||(t="."),t&&o&&(t+="/"),(i?"/":"")+t},n.isAbsolute=function(t){return"/"===t.charAt(0)},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,function(t){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},n.relative=function(t,e){function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),s=Math.min(i.length,o.length),a=s,u=0;s>u;u++)if(i[u]!==o[u]){a=u;break}for(var c=[],u=a;ue&&(e=t.length+e),t.substr(e,n)}}).call(this,t("1YiZ5S"))},{"1YiZ5S":11}],11:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}]},{},[1]); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..40220fd --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "editorconfig.org", + "devDependencies": { + "editorconfig": "^0.11.4", + + "gulp": "^3.8.9", + "gulp-uglify": "^1.0.1", + "gulp-browserify": "^0.5.0" + }, + "scripts": { + "build": "./node_modules/.bin/gulp" + } +}