Skip to content

Commit 8a57245

Browse files
committed
md-import refactoring
1 parent 13636f6 commit 8a57245

18 files changed

+149
-33
lines changed

.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Created by https://www.gitignore.io
2+
3+
### WebStorm ###
4+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
5+
6+
*.iml
7+
8+
## Directory-based project format:
9+
.idea/
10+
11+
## File-based project format:
12+
*.ipr
13+
*.iws
14+
15+
## Plugin-specific files:
16+
17+
# IntelliJ
18+
/out/
19+
20+
# mpeltonen/sbt-idea plugin
21+
.idea_modules/
22+
23+
# JIRA plugin
24+
atlassian-ide-plugin.xml
25+
26+
# Crashlytics plugin (for Android Studio and IntelliJ)
27+
com_crashlytics_export_strings.xml
28+
crashlytics.properties
29+
crashlytics-build.properties
30+
31+
32+
### Node ###
33+
# Logs
34+
logs
35+
*.log
36+
37+
# Runtime data
38+
pids
39+
*.pid
40+
*.seed
41+
42+
# Directory for instrumented libs generated by jscoverage/JSCover
43+
lib-cov
44+
45+
# Coverage directory used by tools like istanbul
46+
coverage
47+
48+
# node-waf configuration
49+
.lock-wscript
50+
51+
# Compiled binary addons (http://nodejs.org/api/addons.html)
52+
build/Release
53+
54+
# Dependency directory
55+
node_modules

dist/index.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,12 @@ <h2 class="List-Header">Testing / Lint / Quality checkers</h2>
436436
</header>
437437
<p class="List-Item-Description List-Item-Description--Short">Forbid the ES6 `class` keyword. [Why?](https://github.com/eslint/eslint/pull/2096#issuecomment-83044888)</p>
438438
</article>
439+
<article class="List-Item">
440+
<header class="List-Item-Header">
441+
<cite class="List-Item-Title"><a href="https://github.com/johnstonbl01/eslint-no-inferred-method-name">ESLint no-inferred-methodname</a></cite>
442+
</header>
443+
<p class="List-Item-Description List-Item-Description--Short">A custom rule for a common problem.</p>
444+
</article>
439445
<article class="List-Item">
440446
<header class="List-Item-Header">
441447
<cite class="List-Item-Title"><a href="https://github.com/gotwarlost/istanbul">Istanbul</a></cite>
@@ -690,6 +696,12 @@ <h2 class="List-Header">React</h2>
690696
</header>
691697
<p class="List-Item-Description List-Item-Description--Short"></p>
692698
</article>
699+
<article class="List-Item">
700+
<header class="List-Item-Header">
701+
<cite class="List-Item-Title"><a href="https://medium.com/javascript-scene/jsx-looks-like-an-abomination-1c1ec351a918">JSX Looks Like an Abomination but it's Good for You</a></cite>
702+
</header>
703+
<p class="List-Item-Description List-Item-Description--Short">My take on JSX</p>
704+
</article>
693705
<article class="List-Item">
694706
<header class="List-Item-Header">
695707
<cite class="List-Item-Title"><a href="https://www.youtube.com/watch?v=I7IdS-PbEgI&amp;list=PLb0IAmt7-GS1cbw4qonlQztYV1TAW0sCr">Immutable Data and React</a></cite>
@@ -720,6 +732,36 @@ <h2 class="List-Header">React</h2>
720732
</header>
721733
<p class="List-Item-Description List-Item-Description--Short"></p>
722734
</article>
735+
<article class="List-Item">
736+
<header class="List-Item-Header">
737+
<cite class="List-Item-Title"><a href="https://github.com/paypal/react-engine">react-engine</a></cite>
738+
</header>
739+
<p class="List-Item-Description List-Item-Description--Short">PayPal's isomorphic React view engine for Express or Kraken</p>
740+
</article>
741+
<article class="List-Item">
742+
<header class="List-Item-Header">
743+
<cite class="List-Item-Title"><a href="http://projects.formidablelabs.com/radium/">Radium</a></cite>
744+
</header>
745+
<p class="List-Item-Description List-Item-Description--Short">Simplify inline styles</p>
746+
</article>
747+
<article class="List-Item">
748+
<header class="List-Item-Header">
749+
<cite class="List-Item-Title"><a href="https://github.com/yannickcr/eslint-plugin-react">eslint-plugin-react</a></cite>
750+
</header>
751+
<p class="List-Item-Description List-Item-Description--Short"></p>
752+
</article>
753+
<article class="List-Item">
754+
<header class="List-Item-Header">
755+
<cite class="List-Item-Title"><a href="https://gaearon.github.io/react-hot-loader/">React Hot Loader</a></cite>
756+
</header>
757+
<p class="List-Item-Description List-Item-Description--Short">for Webpack</p>
758+
</article>
759+
<article class="List-Item">
760+
<header class="List-Item-Header">
761+
<cite class="List-Item-Title"><a href="https://github.com/milankinen/livereactload">livereactload</a></cite>
762+
</header>
763+
<p class="List-Item-Description List-Item-Description--Short">for Browserify</p>
764+
</article>
723765
</div>
724766
</section>
725767
<section id="0011-Web-Components" class="List">

dist/js/vendor/jquery-1.11.2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ var gulp = require('gulp'),
88
path = require('path'),
99
sass = require('gulp-sass'),
1010
sourcemaps = require('gulp-sourcemaps'),
11-
watch = require('gulp-watch'),
12-
yaml = require('read-yaml');
13-
11+
watch = require('gulp-watch')
12+
1413
var paths = {
1514
sass: ['./src/sass/**/*.scss'],
16-
static: ['./src/static/*.*'],
15+
assets: ['./src/assets/*.*'],
1716
js: ['./src/js/**/*.js'],
1817
dist: './dist'
1918
};
@@ -35,15 +34,15 @@ gulp.task('sass', function () {
3534
.pipe( gulp.dest(path.join(paths.dist, 'css')) );
3635
});
3736

38-
gulp.task('static', function() {
39-
return gulp.src(paths.static)
37+
gulp.task('assets', function() {
38+
return gulp.src(paths.assets)
4039
.pipe(gulp.dest(paths.dist));
4140
});
4241

4342
gulp.task('templates', function() {
4443
return gulp.src('./src/jade/*.jade')
4544
.pipe(data( function(file) {
46-
var json = require('./src/data/the-big-data.json');
45+
var json = require('./src/data/essential-javascript-links.json');
4746
json._ = lodash;
4847
return json;
4948
} ))
@@ -57,13 +56,13 @@ gulp.task('js', function() {
5756
});
5857

5958
gulp.task('deploy', function() {
60-
ghPages.publish(paths.dist);
59+
ghPages.publish(paths.dist);
6160
});
6261

6362
// Rerun the task when a file changes
6463
gulp.task('watch', function() {
65-
gulp.watch('./src/**/*', ['sass', 'static', 'templates', 'js']);
64+
gulp.watch('./src/**/*', ['sass', 'assets', 'templates', 'js']);
6665
});
6766

6867
// The default task (called when you run `gulp` from cli)
69-
gulp.task('default', ['sass', 'static', 'templates', 'js']);
68+
gulp.task('default', ['sass', 'assets', 'templates', 'js']);

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.0.1",
44
"description": "Essential JavaScript Links website.",
55
"scripts": {
6-
"cleanup": "cat README.md | node scripts/cleanup.js > build/README.md"
6+
"cleanup": "cat README.md | node scripts/cleanup.js > build/README.md",
7+
"md-import": "node scripts/md-import.js src/data/essential-javascript-links.md src/data/essential-javascript-links.json src/data/theBookData.json theBookData"
78
},
89
"engines": {
910
"node": "0.10.x"
@@ -23,18 +24,15 @@
2324
},
2425
"devDependencies": {
2526
"autoprefixer-core": "^5.1.10",
27+
"gh-pages": "^0.3.0",
2628
"gulp": "^3.8.11",
2729
"gulp-data": "^1.2.0",
28-
"gulp-gh-pages": "^0.5.1",
2930
"gulp-jade": "^1.0.0",
3031
"gulp-postcss": "^5.1.3",
3132
"gulp-print": "^1.1.0",
3233
"gulp-sass": "^1.3.3",
3334
"gulp-sourcemaps": "^1.5.1",
3435
"gulp-watch": "^4.2.4",
35-
"gulp-yaml": "^0.2.4",
36-
"js-yaml": "^3.3.0",
37-
"node-sass": "^2.1.1",
38-
"read-yaml": "^1.0.0"
36+
"node-sass": "^2.1.1"
3937
}
4038
}

src/data/md-import.js renamed to scripts/md-import.js

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
var fs = require('fs'),
2-
md = require('markdown').markdown;
2+
path = require('path');
33

4-
var markdownPath = 'essential-javascript-links.md',
5-
moreMetaData = {
6-
path: 'theBookData.json',
7-
id: 'theBookData'
8-
},
9-
jsonOutPath = 'the-big-data.json';
4+
var argv = process.argv,
5+
markdownPath, jsonOutPath, moreMetaData;
6+
7+
if ( !(markdownPath = argv[2]) ||
8+
!(jsonOutPath = argv[3]) )
9+
return console.error('Usage: <source.md> <destination.json> [<data-to-merge.json> [varInTheMergeData]]');
10+
11+
if (argv[4])
12+
moreMetaData = {
13+
path: argv[4],
14+
id: argv[5] || path.base(argv[4], '.json')
15+
};
1016

1117
fs.readFile(markdownPath, {encoding: 'UTF-8', flag: 'r'}, function (err, data) {
12-
if (err) return;
18+
if (err)
19+
return console.error('Couldn\'t open ' + path.resolve(markdownPath));
1320

1421
var allLinks = [],
1522
categories = [];
@@ -20,10 +27,21 @@ fs.readFile(markdownPath, {encoding: 'UTF-8', flag: 'r'}, function (err, data) {
2027
currentMeta = {},
2128
currentMetaIndex = {};
2229

23-
moreMeta = JSON.parse(fs.readFileSync(moreMetaData.path, 'utf8'))[moreMetaData.id];
24-
moreMeta.forEach(function(el) {
25-
moreMetaIndex[el.title] = el.items;
26-
});
30+
if (moreMetaData) {
31+
try {
32+
var moreMetaString = fs.readFileSync(moreMetaData.path, 'utf8');
33+
}
34+
catch (e) {
35+
return console.error('Couldn\'t open ' + path.resolve(moreMetaData.path));
36+
}
37+
38+
if (!(moreMeta = JSON.parse(moreMetaString)[moreMetaData.id]))
39+
return console.error('Couln\'t get a value of ' + moreMetaData.id + ' from ' + moreMetaData.path);
40+
41+
moreMeta.forEach(function(el) {
42+
moreMetaIndex[el.title] = el.items;
43+
});
44+
}
2745

2846
data.split(/\r?\n/).forEach( function(line) {
2947
var match;
@@ -46,8 +64,9 @@ fs.readFile(markdownPath, {encoding: 'UTF-8', flag: 'r'}, function (err, data) {
4664
short_description: match[4],
4765
categories: [currentCategory]
4866
};
49-
enhanceMeta(current, currentMetaIndex[current.title]);
50-
// current.rank = current.rank || 0; // no rank? end of the line for you.
67+
68+
if (moreMetaData)
69+
enhanceMeta(current, currentMetaIndex[current.title]);
5170
allLinks.push(current);
5271
}
5372

@@ -78,5 +97,8 @@ fs.readFile(markdownPath, {encoding: 'UTF-8', flag: 'r'}, function (err, data) {
7897
});
7998

8099
var theBigString = JSON.stringify({allTheLinks: allLinks, linkCategories: categories}, null, 2);
81-
fs.writeFile(jsonOutPath, theBigString);
100+
fs.writeFile(jsonOutPath, theBigString, function(err){
101+
if (err)
102+
console.error('Couldn\'t write' + path.resolve(jsonOutPath));
103+
});
82104
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/js/vendor/jquery-1.11.2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)