diff --git a/.gitignore b/.gitignore index fecb262f..c37ad084 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,16 @@ -/site/index.html /build /html /log /node_modules -/site/de -/site/ru -/site/zh -/site/en -/site/fi -/site/tr +/.idea/* + +/site +!/site/favicon.ico +!/site/image +!/site/javascript +!/site/style +!/site/style + *.md~ *.src.md +*.DS_store diff --git a/.lvimrc b/.lvimrc new file mode 100644 index 00000000..23b445a9 --- /dev/null +++ b/.lvimrc @@ -0,0 +1,4 @@ +set wildignore=node_modules +set tabstop=2 +set shiftwidth=2 +set softtabstop=2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..fe3c6b6f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,19 @@ +# Contributing to Javascript Garden + +1. We're about Javascript AKA [ECMA script](http://www.ecma-international.org/ecma-262/5.1/) not a specific implementation. So we don't cover issues specific to one environment or interpreter, like browsers or V8 for node. +1. Micro-performance is out of scope: anything that's not a result of essential algorithmic complexity (e.g O(log n) vs O(n^2)) is down to a specific version of a specific interpreter (see 1). +1. Please test code examples to ensure they work, there's nothing more confusing than incorrect examples! +1. Contributing to JS Garden makes you a fantastic person, and Brendan Eich will find you immensely attractive. + +Thank you for being kind enough to help out! + +## Testing locally + +1. Run `npm run build` to build +1. Run a webserver from the root of the repo to view + +## Getting changes merged + +1. Squash your changes into one commit +1. Make sure the site still works :) +1. Make a PR diff --git a/JavaScript-Garden b/JavaScript-Garden new file mode 120000 index 00000000..dcc6db5e --- /dev/null +++ b/JavaScript-Garden @@ -0,0 +1 @@ +./site \ No newline at end of file diff --git a/README.md b/README.md index 6371eb25..be02cfd5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,18 @@ JavaScript Garden ================= +2024 update: this project has not been actively maintained in years. The original author +[took the site down](https://github.com/BonsaiDen/JavaScript-Garden/commit/93278fbcafa569fd193f8784abc267e9db09c645) +in 2022 (no judgement - updating it would be a big project!). At that point it was already long out of date, e.g. missing +the new language features from ES6 onwards. + +Many excellent modern guides exist, e.g. [Eloquent Javascript](https://eloquentjavascript.net/), or +the [MDN guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript). + +Thanks for all the maintainers and translators over the years! + +----- + **JavaScript Garden** is a growing collection of documentation about the most quirky parts of the JavaScript programming language. It gives advice to avoid common mistakes, subtle bugs, as well as performance issues and bad @@ -15,12 +27,15 @@ the excellent [guide][1] on the Mozilla Developer Network. ### The authors This guide is the work of two lovely Stack Overflow users, [Ivo Wetzel][6] -(Writing) and [Zhang Yi Jiang][5] (Design). +(Original English Language Version) and [Zhang Yi Jiang][5] (Design), and +[many others](https://github.com/BonsaiDen/JavaScript-Garden/graphs/contributors) +who've worked hard to provide translations or fixes. + +It was maintained by [Tim Ruffles](http://twitter.com/timruffles) from 2013-2020ish. -### Contributors +## Contributing - - [Caio Romão][8] (Spelling corrections) - - [Andreas Blixt][9] (Language corrections) +Please submit fixes and translations as [pull requests](https://help.github.com/articles/using-pull-requests). ### License diff --git a/build.js b/build.js index 7fb93be0..0c7be50a 100644 --- a/build.js +++ b/build.js @@ -1,206 +1,106 @@ -var fs = require('fs'), - path = require('path'); - jade = require('jade'), - md = require('node-markdown'), - Class = require('neko').Class; - -var format = new require('fomatto').Formatter(); - - -// Garden Generator ------------------------------------------------------------- -// ------------------------------------------------------------------------------ -var Garden = Class(function(options) { - var languages = fs.readdirSync(options.dir); - - this.languages = {}; - this.options = options; - this.options.language = this.json([this.options.dir, 'language.json'].join('/')); - - var that = this; - languages.forEach(function(lang) { - if (fs.statSync(that.options.dir + '/' + lang).isDirectory()) { - that.log('Parsing language "{}"...', lang); - that.lang = { - id: lang, - navigation: [], - index: [] - }; - - if (that.loadIndex()) { - that.languages[lang] = that.lang; - that.log(' Done.') - - } else { - that.log(' Error: Could not find "index.json"!') - } - } - }); - - delete this.lang; - this.log(''); - this.generateAll(); - -}, { - log: function() { - console.log(format.apply(null, arguments)); - }, - - loadIndex: function() { - var that = this; - this.lang.index = this.json([this.options.dir, - this.lang.id, 'index.json'].join('/')); - - if (this.lang.index === null) { - return false; - } - - that.lang.title = that.lang.index.langTitle; - this.lang.navigation = []; - this.lang.index.sections.forEach(function(section, i) { - that.loadSection(section); - that.lang.navigation.push({ - title: section.title, - link: section.dir, - articles: section.articles, - parsed: section.parsed - }); - }); - return true; - }, - - loadSection: function(section) { - var files = fs.readdirSync(this.folder(section.dir)); - section.parsed = {}; - section.link = section.dir; - - var that = this; - section.articles = section.articles || []; - section.articles.concat('index').forEach(function(article, e) { - if (files.indexOf(article + '.md') !== -1) { - var parsed = that.parseArticle(that.md(section.dir, article)); - section.parsed[article] = parsed; - if (section.articles.indexOf(article) !== -1) { - section.articles[e] = { - id: article, - link: section.link + '.' + article, - title: parsed.title, - parsed: parsed - }; - } - } - }); - }, - - parseArticle: function(text) { - var title = text.substring(0, text.indexOf('\n')); - text = text.substring(title.length); - title = md.Markdown(title.replace(/\#/g, '').trim()); - text = this.toMarkdown(text); - - var parts = text.split('

'); - var subs = []; - for(var i = 0, l = parts.length; i < l; i++) { - var sub = parts[i]; - subs.push((i > 0 ? '

' : '') + sub); - } - - return { - title: title.substring(3, title.length - 4), - text: text, - subs: subs - }; - }, - - toMarkdown: function(text) { - text = md.Markdown(text).replace(/'/g,'''); - text = text.replace(/
/g, ''); - - return text.replace(/