Skip to content

Commit

Permalink
initially place under version control
Browse files Browse the repository at this point in the history
  • Loading branch information
rse committed Apr 3, 2015
1 parent 5442447 commit 0774626
Show file tree
Hide file tree
Showing 168 changed files with 6,513 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bower_components
node_modules
96 changes: 96 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
** es6-features -- ECMAScript 6 Feature Overview & Comparison
** Copyright (c) 2015 Ralf S. Engelschall <rse@engelschall.com>
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/* global module: true */
module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-bower-install-simple");

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
"bower-install-simple": {
"main": {
options: {
color: true,
production: true,
directory: "bower_components"
}
}
},
copy: {
"sanitize": {
src: [ "bower_components/sanitize.css/dist/sanitize.min.css" ],
dest: "lib/sanitize/sanitize.css"
},
"director": {
src: [ "bower_components/director/build/director.min.js" ],
dest: "lib/director/director.js"
},
"jquery": {
src: [ "bower_components/jquery/dist/jquery.min.js" ],
dest: "lib/jquery/jquery.js"
},
"mousetrap": {
src: [ "bower_components/mousetrap/mousetrap.min.js" ],
dest: "lib/mousetrap/mousetrap.js"
},
"typopro": {
files: [
{ expand: true, flatten: false, cwd: "bower_components/typopro/web",
src: "TypoPRO-OpenSans/**", dest: "lib/typopro/" },
{ expand: true, flatten: false, cwd: "bower_components/typopro/web",
src: "TypoPRO-DejaVu/**", dest: "lib/typopro/" },
{ expand: true, flatten: false, cwd: "bower_components/typopro/web",
src: "TypoPRO-Journal/**", dest: "lib/typopro/" }
]
},
"font-awesome-css": {
src: [ "bower_components/fontawesome/css/font-awesome.css" ],
dest: "lib/fontawesome/fontawesome.css",
options: {
process: function (content, srcpath) {
return content.replace(/\.\.\/fonts\/fontawesome-webfont/g, "fontawesome");
}
}
},
"font-awesome-fonts": {
files: [{
expand: true, flatten: false, cwd: "bower_components/fontawesome/fonts",
src: "fontawesome-webfont.*", dest: "lib/fontawesome/",
rename: function (src, dest) {
return src + dest.replace(/fontawesome-webfont/, "fontawesome");
}
}]
}
},
clean: {
clean: [ "lib" ],
distclean: [ "node_modules", "bower_components" ]
}
});

grunt.registerTask("default", [ "bower-install-simple", "copy" ]);
};

42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##
## es6-features -- ECMAScript 6 Feature Overview & Comparison
## Copyright (c) 2015 Ralf S. Engelschall <rse@engelschall.com>
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##

NPM = npm
GRUNT = ./node_modules/grunt-cli/bin/grunt

all: build

bootstrap:
@if [ ! -x $(GRUNT) ]; then $(NPM) install; fi

build: bootstrap
@$(GRUNT)
@sh convert.sh

clean: bootstrap
@$(GRUNT) clean:clean

distclean: bootstrap
@$(GRUNT) clean:clean clean:distclean

11 changes: 11 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "ecmascript6-features",
"dependencies": {
"sanitize.css": "2.0.0",
"typopro": "2.3.1",
"fontawesome": "4.3.0",
"director": "1.2.8",
"jquery": "2.1.3",
"mousetrap": "1.5.2"
}
}
141 changes: 141 additions & 0 deletions convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
** es6-features -- ECMAScript 6 Feature Overview & Comparison
** Copyright (c) 2015 Ralf S. Engelschall <rse@engelschall.com>
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

let fs = require("fs")

/* minimum Markdown translation ;-) */
let md = (txt) => {
return txt.replace(/`(.+?)`/g, "<code>$1</code>")
}

/* generate JavaScript code block */
let js = (clazz, title, code, icon) => {
/* protect special characters which are part of entity encoding */
code = code.replace(/&/g, "@1@")
code = code.replace(/;/g, "@2@")

/* convert characters which have special meaning in HTML */
code = code.replace(/&/g, "&amp;")
code = code.replace(/</g, "&lt;")
code = code.replace(/>/g, "&gt;")

/* unprotect special characters which are part of entity encoding */
code = code.replace(/@1@/g, "<span class=punctuation>&amp;</span>")
code = code.replace(/@2@([ \t\n]|$)/g, "<span class=semi>;</span>$1")
code = code.replace(/@2@/g, "<span class=punctuation>;</span>")

/* convert ellipsis to corresponding Unicode character */
code = code.replace(/\.\.\./g, "<span class=ellipsis>&hellip;</span>")

/* simple syntax-highlighting of JavaScript code, the rookie but sufficient way */
code = code.replace(
/(\s=\s|=&gt;|&gt;|&lt;|&amp;|===|[%+*{}().,\[\]-])/g,
"<span class=punctuation>$1</span>")
code = code.replace(
/(".+?"|'.+?'|`.+?`|\d+(?:\.\d+)?)/g,
"<span class=literal>$1</span>")
code = code.replace(
/\b(this|function|class(?=[^=])|extends|return|if|new|import|export|in|of|var|let|while|for|const)\b/g,
"<span class=keyword>$1</span>")
code = code.replace(
/(\s\/\/[^\n]*)/g,
"<span class=comment>$1</span>")
code = code.replace(
/\|(.+?)\|/g,
"<span class=mark>$1</span>")
code = code.replace(/class=([a-z]+)/g, "class=\"$1\"")

/* extend title with style switcher */
title = "<b>" + title + "</b> &mdash; " +
"style: <span class=\"style modernized\">modernized</span> | " +
"<span class=\"style traditional\">traditional</span>"

/* assemble everything */
txt = `<div class="js ${clazz}">\n`
txt += ` <div class="title">${title}</div>\n`
txt += ` <div class="code">${code}</div>\n`
txt += ` <i class="icon fa fa-circle"></i>\n`
txt += ` <i class="icon fa fa-${icon}"></i>\n`
txt += `</div>\n`

return txt
}

/* read the input source */
let txt = fs.readFileSync("features.txt", "utf8")

/* remove all comment lines */
txt = txt.replace(/^#.*$/mg, "")

/* iterate over input source */
let nav = ""
let out = ""

/* for every outer section... */
nav += "<ul>\n"
txt.replace(/\s*([^\n]+)\n====+[ \t]*\n((?:.|\n)+?)(?=[^\n]+\n====+[ \t]*\n|$)/g, (m, title, txt) => {
/* generate level-1 navigation entry */
nav += `<li class="title">${md(title)}\n`
nav += " <ul>\n"

/* for every inner section... */
txt.replace(/\s*([^\n]+)\n----+[ \t]*\n((?:.|\n)+?)(?=[^\n]+\n----+[ \t]*\n|$)/g, (m, subtitle, txt) => {
let id = subtitle.replace(/[^a-zA-Z0-9]+/g, "")

/* generate level-2 navigation entry */
nav += `<li class="subtitle subtitle_${id}">\n`
nav += ` <a href="#${id}">${md(subtitle)}</a> <i class="fa fa-arrow-circle-right"></i>`
nav += `</li>\n`

/* generate showcase header */
out += `<div class="showcase showcase_${id}">`
out += ` <a name="${id}">\n`
out += ` <div class="title">${md(title)}</div>\n`
out += ` <div class="subtitle">${md(subtitle)}</div>\n`

/* for the showcode content... */
txt.replace(/^\s*((?:.|\n)+?)\n\n(5\|(?:.|\n)+?\n)\n(6\|(?:.|\n)+?)\s*$/, (m, desc, es5, es6) => {
out += ` <div class="desc">${md(desc)}</div>\n`
es5 = es5.replace(/^5\| ?/mg, "").replace(/^\s*/, "")
es6 = es6.replace(/^6\| ?/mg, "").replace(/^\s*/, "")
out += js("es6", "ECMAScript 6", es6, "check-circle")
out += ' <div class="arrow"><i class="fa fa-caret-up"></i></div>'
out += js("es5", "ECMAScript 5", es5, "times-circle")
})
out += ` </a>\n`
out += `</div>\n`
})

nav += " </ul>\n"
nav += "</li>\n"
})
nav += "</ul>\n"

/* read the HTML template */
let tmpl = fs.readFileSync("features.html", "utf8")
tmpl = tmpl.replace(/%BODY%/, out).replace(/%NAV%/, nav)

/* write the resulting HTML page */
fs.writeFileSync("index.html", tmpl, "utf8")

27 changes: 27 additions & 0 deletions convert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
##
## es6-features -- ECMAScript 6 Feature Overview & Comparison
## Copyright (c) 2015 Ralf S. Engelschall <rse@engelschall.com>
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##

exec babel-node convert.js

64 changes: 64 additions & 0 deletions features.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--
es6-features ~~ ECMAScript 6 Feature Overview & Comparison
Copyright (c) 2015 Ralf S. Engelschall <rse@engelschall.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<title>ECMAScript 5 vs. ECMAScript 6</title>
<script src="lib/jquery/jquery.js" type="text/javascript"></script>
<script src="lib/director/director.js" type="text/javascript"></script>
<script src="lib/mousetrap/mousetrap.js" type="text/javascript"></script>
<script src="index.js" type="text/javascript"></script>
<link href="index.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<a href="https://github.com/rse/es6-overview">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 2000;"
src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"/>
</a>
<div class="head">
<span class="bold">ECMAScript 6</span> &mdash; Feature Overview &amp; Comparison
</div>
<div class="slogan">
See how more clean and compact<br/>
your JavaScript can look like and<br/>
<a href="http://babeljs.io/">start coding</a> in ES6 <a href="http://babeljs.io/">now</a> !!
</div>
<div class="nav">
%NAV%
</div>
<div class="content">
%BODY%
</div>
<div class="foot">
<div class="text">
Copyright &copy; 2015 <a href="http://engelschall.com/">Ralf S. Engelschall</a><br/>
Partially based on code snippets by <a href="http://git.io/es6features">Luke Hoban</a><br/>
Licensed under <a href="https://github.com/rse/es6-overview/blob/master/LICENSE">MIT License</a>.
</div>
</div>
</body>
</html>
Loading

0 comments on commit 0774626

Please sign in to comment.