From 836d110f2eb3c1fc959893b8b9a6612dff9f69bf Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 3 Aug 2012 14:19:26 +0400 Subject: [PATCH] stupid line endings bit us. cc @adeelejaz --- .editorconfig | 8 ++++++++ lib/app.js | 38 +++++++++++++++++++------------------- posts/input-number.md | 22 +++++++++++----------- 3 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..71de6d65 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +; editorconfig.org +root = true + +; Unix-style newlines +[*] +end_of_line = LF +indent_style = space +indent_size = 2 diff --git a/lib/app.js b/lib/app.js index 9e7f8d81..b7db7ab1 100644 --- a/lib/app.js +++ b/lib/app.js @@ -1,6 +1,6 @@ // Native modules var fs = require('fs'); -var request = require('request'); +var request = require('request'); // Third-party modules var Backbone = require('backbone'); @@ -10,7 +10,7 @@ var async = require('async'); //polyfill or no Handlebars.registerHelper('polyfillaction', function(tags) { - if(tags && tags.indexOf('polyfill') > -1) { + if(tags && tags.indexOf('polyfill') > -1) { return 'with polyfill'; } if(tags && tags.indexOf('fallback') > -1) { @@ -29,7 +29,7 @@ Handlebars.registerHelper('featuretag', function(feature) { }); Handlebars.registerHelper('testurl', function(url) { - return /caniuse/.exec(url) != null? 'View browser share %': 'Learn more'; + return /caniuse/.exec(url) != null? 'View browser share %': 'Learn more'; }); // File paths @@ -53,7 +53,7 @@ exports.Feature = Backbone.Model.extend({ var i, len, parts, key, val, posttags; var obj = { contents: '' }; var docs = this.get('contents').split('\n\n'); - var lines = docs[0].split('\n'); + var lines = docs[0].split('\n|\r'); if(this.has('editfrag')) { obj.editurl = paths.githuburl + this.get('editfrag') + '.md'; @@ -62,43 +62,43 @@ exports.Feature = Backbone.Model.extend({ for (i = 0, len = lines.length; i < len; i++) { parts = lines[i].trim().split(':'); - + if (parts.length < 2) { console.error(lines); - throw new Error('Invalid key: val ... ' + obj.slug); + throw new Error('Invalid key: val ... ' + obj.slug); } - + key = parts[0]; val = parts.slice(1).join(':').trim(); - + if(key == 'tags') { posttags = val.split(' '); //if it is not whitespace separated it must be comma separated if(posttags.length === 1) { posttags.join(' ').split(','); - } + } posttags = posttags.map(function(tag) { tag = tag.trim(); //catch use of tags like polyfill, gtie9 tag = /([^,]*)/.exec(tag)[1]; return tag; - + }); val = posttags.join(' '); - } - + } + if(key == 'kind') { obj.moreurl = paths.caniuseurl + obj.slug; - } - + } + obj[key] = (key === 'polyfillurls') ? "" + Markdown(val) : "" + val.trim(); } obj.contents = "" + Markdown(docs.slice(1).join("\n\n")); - + // Update the model to use the metadata and contents this.set(obj); } @@ -139,7 +139,7 @@ exports.Markup = Backbone.View.extend({ // Read in the template and compile via handlebars to a reusable // property that can be accessed in render. var source = fs.readFileSync(paths.template).toString(); - this.template = Handlebars.compile(source); + this.template = Handlebars.compile(source); }, // Triggered only when argument checkurls is passed to CLI @@ -150,7 +150,7 @@ exports.Markup = Backbone.View.extend({ var callback = callback; async.forEachSeries( - this.collection.toArray(), + this.collection.toArray(), function(feature, callback) { var req = request({ method: 'GET', @@ -170,7 +170,7 @@ exports.Markup = Backbone.View.extend({ updateUrlCallback(); }); }, - + render: function() { console.log("rendering to the fileā€¦"); @@ -179,4 +179,4 @@ exports.Markup = Backbone.View.extend({ fs.writeFileSync(paths.output, html); console.log("Your index page is now ready") } -}); +}); diff --git a/posts/input-number.md b/posts/input-number.md index d619409b..73ef0a07 100644 --- a/posts/input-number.md +++ b/posts/input-number.md @@ -1,11 +1,11 @@ -feature: -status: use -tags: polyfill fallback -kind: html -polyfillurls: [Number polyfill](https://github.com/jonstipe/number-polyfill) - -A number input will fallback to a plain text input if it's not supported. - -So far, Chrome, Safari and Opera support it. Jonathan Stipe's [Number polyfill](https://github.com/jonstipe/number-polyfill) doesn't need any additional code changes but does require jQuery and CSS to style buttons. - -Safari on iOS and the Browser on Android 4.0 (Ice Cream Sandwich) do show number input, but do not use "step", "min" or "max" attributes and neither show increment/decrement buttons. +feature: +status: use +tags: polyfill fallback +kind: html +polyfillurls: [Number polyfill](https://github.com/jonstipe/number-polyfill) + +A number input will fallback to a plain text input if it's not supported. + +So far, Chrome, Safari and Opera support it. Jonathan Stipe's [Number polyfill](https://github.com/jonstipe/number-polyfill) doesn't need any additional code changes but does require jQuery and CSS to style buttons. + +Safari on iOS and the Browser on Android 4.0 (Ice Cream Sandwich) do show number input, but do not use "step", "min" or "max" attributes and neither show increment/decrement buttons.