Skip to content

Commit

Permalink
stupid line endings bit us. cc @adeelejaz
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Aug 3, 2012
1 parent c95fd73 commit 836d110
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 30 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
@@ -0,0 +1,8 @@
; editorconfig.org
root = true

; Unix-style newlines
[*]
end_of_line = LF
indent_style = space
indent_size = 2
38 changes: 19 additions & 19 deletions lib/app.js
@@ -1,6 +1,6 @@
// Native modules // Native modules
var fs = require('fs'); var fs = require('fs');
var request = require('request'); var request = require('request');


// Third-party modules // Third-party modules
var Backbone = require('backbone'); var Backbone = require('backbone');
Expand All @@ -10,7 +10,7 @@ var async = require('async');


//polyfill or no //polyfill or no
Handlebars.registerHelper('polyfillaction', function(tags) { Handlebars.registerHelper('polyfillaction', function(tags) {
if(tags && tags.indexOf('polyfill') > -1) { if(tags && tags.indexOf('polyfill') > -1) {
return 'with <b class=polyfill>polyfill</b>'; return 'with <b class=polyfill>polyfill</b>';
} }
if(tags && tags.indexOf('fallback') > -1) { if(tags && tags.indexOf('fallback') > -1) {
Expand All @@ -29,7 +29,7 @@ Handlebars.registerHelper('featuretag', function(feature) {
}); });


Handlebars.registerHelper('testurl', function(url) { 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 // File paths
Expand All @@ -53,7 +53,7 @@ exports.Feature = Backbone.Model.extend({
var i, len, parts, key, val, posttags; var i, len, parts, key, val, posttags;
var obj = { contents: '' }; var obj = { contents: '' };
var docs = this.get('contents').split('\n\n'); 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')) { if(this.has('editfrag')) {
obj.editurl = paths.githuburl + this.get('editfrag') + '.md'; obj.editurl = paths.githuburl + this.get('editfrag') + '.md';
Expand All @@ -62,43 +62,43 @@ exports.Feature = Backbone.Model.extend({


for (i = 0, len = lines.length; i < len; i++) { for (i = 0, len = lines.length; i < len; i++) {
parts = lines[i].trim().split(':'); parts = lines[i].trim().split(':');

if (parts.length < 2) { if (parts.length < 2) {
console.error(lines); console.error(lines);
throw new Error('Invalid key: val ... ' + obj.slug); throw new Error('Invalid key: val ... ' + obj.slug);
} }

key = parts[0]; key = parts[0];
val = parts.slice(1).join(':').trim(); val = parts.slice(1).join(':').trim();

if(key == 'tags') { if(key == 'tags') {
posttags = val.split(' '); posttags = val.split(' ');


//if it is not whitespace separated it must be comma separated //if it is not whitespace separated it must be comma separated
if(posttags.length === 1) { if(posttags.length === 1) {
posttags.join(' ').split(','); posttags.join(' ').split(',');
} }
posttags = posttags.map(function(tag) { posttags = posttags.map(function(tag) {
tag = tag.trim(); tag = tag.trim();


//catch use of tags like polyfill, gtie9 //catch use of tags like polyfill, gtie9
tag = /([^,]*)/.exec(tag)[1]; tag = /([^,]*)/.exec(tag)[1];
return tag; return tag;

}); });
val = posttags.join(' '); val = posttags.join(' ');
} }

if(key == 'kind') { if(key == 'kind') {
obj.moreurl = paths.caniuseurl + obj.slug; obj.moreurl = paths.caniuseurl + obj.slug;
} }

obj[key] = (key === 'polyfillurls') ? "" + Markdown(val) : "" + val.trim(); obj[key] = (key === 'polyfillurls') ? "" + Markdown(val) : "" + val.trim();
} }


obj.contents = "" + Markdown(docs.slice(1).join("\n\n")); obj.contents = "" + Markdown(docs.slice(1).join("\n\n"));



// Update the model to use the metadata and contents // Update the model to use the metadata and contents
this.set(obj); this.set(obj);
} }
Expand Down Expand Up @@ -139,7 +139,7 @@ exports.Markup = Backbone.View.extend({
// Read in the template and compile via handlebars to a reusable // Read in the template and compile via handlebars to a reusable
// property that can be accessed in render. // property that can be accessed in render.
var source = fs.readFileSync(paths.template).toString(); 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 // Triggered only when argument checkurls is passed to CLI
Expand All @@ -150,7 +150,7 @@ exports.Markup = Backbone.View.extend({
var callback = callback; var callback = callback;


async.forEachSeries( async.forEachSeries(
this.collection.toArray(), this.collection.toArray(),
function(feature, callback) { function(feature, callback) {
var req = request({ var req = request({
method: 'GET', method: 'GET',
Expand All @@ -170,7 +170,7 @@ exports.Markup = Backbone.View.extend({
updateUrlCallback(); updateUrlCallback();
}); });
}, },

render: function() { render: function() {
console.log("rendering to the file…"); console.log("rendering to the file…");


Expand All @@ -179,4 +179,4 @@ exports.Markup = Backbone.View.extend({
fs.writeFileSync(paths.output, html); fs.writeFileSync(paths.output, html);
console.log("Your index page is now ready") console.log("Your index page is now ready")
} }
}); });
22 changes: 11 additions & 11 deletions posts/input-number.md
@@ -1,11 +1,11 @@
feature: <input type=number> feature: <input type=number>
status: use status: use
tags: polyfill fallback tags: polyfill fallback
kind: html kind: html
polyfillurls: [Number polyfill](https://github.com/jonstipe/number-polyfill) polyfillurls: [Number polyfill](https://github.com/jonstipe/number-polyfill)


A number input will fallback to a plain text input if it's not supported. 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. 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. 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.

7 comments on commit 836d110

@adeelejaz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me bad.. I apologize for the oversight :( I did the commit from the work machine running Windows for GitHub....

@paulirish
Copy link
Member Author

@paulirish paulirish commented on 836d110 Aug 6, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adeelejaz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Sublime Text 2, beta build. What chaos did this cause btw?

@paulirish
Copy link
Member Author

@paulirish paulirish commented on 836d110 Aug 7, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adeelejaz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn. It never crossed my mind. Plugin installed. Thanks!

@s10wen
Copy link

@s10wen s10wen commented on 836d110 Aug 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulirish is there any online resource that documents positives and negatives of indentation formatting?

Would be great if there was a unified model and everyone followed it.

Personally I used to use 1 Tab, but changed to 2 Spaces to keep inline with H5BP, but never knew the reason behind it.

@paulirish
Copy link
Member Author

@paulirish paulirish commented on 836d110 Aug 9, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.