Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Meetups.js is now usable as module.

Signed-off-by: François de Metz <francois@stormz.me>
  • Loading branch information...
commit 46b2349fbc3dc7198710ceda62a6b1d911ded117 1 parent 616f6c5
@francois2metz francois2metz authored
Showing with 21 additions and 11 deletions.
  1. +1 −0  package.json
  2. +20 −11 utils/meetups.js
View
1  package.json
@@ -7,6 +7,7 @@
"type": "git",
"url": "git://github.com/parisjs/parisjs-website.git"
},
+ "main": "./utils/meetups.js",
"dependencies": {
"jsdom": "",
"underscore": ""
View
31 utils/meetups.js
@@ -19,7 +19,7 @@
* node utils/meetups.js parse > meetups.json
* node utils/meetups.js update < meetups.json
*
- * Example:
+ * Examples:
* You want to update the HTML of all talks
* 1. Parse meetups and export to json
* node utils/meetups.js parse > meetups.json
@@ -28,6 +28,10 @@
* node utils/meetups.js update < meetups.json > index2.html
* 4. Move the generated HTML to index.html
* mv index2.html index.html
+ *
+ * You want to extract talks informations from your code
+ * 1. var parisjs = require('parisjs-website');
+ * 2. parisjs.parseMeetups('http://parisjs.org', function(meetups) {})
*/
var jsdom = require('jsdom')
@@ -35,18 +39,21 @@ var jsdom = require('jsdom')
, _ = require('underscore')
;
-if (process.argv.length == 3) {
- var website = __dirname + '/../index.html';
- if (process.argv[2] == 'parse') {
- return parseMeetups(website, console.log);
- } else if (process.argv[2] == 'update') {
- return updateMeetups(website, console.log);
+function cli() {
+ if (process.argv.length == 3) {
+ var website = __dirname + '/../index.html';
+ if (process.argv[2] == 'parse') {
+ return parseMeetups(website, console.log);
+ } else if (process.argv[2] == 'update') {
+ return updateMeetups(website, console.log);
+ }
}
+ console.log('usage');
+ console.log('node utils/meetups.js parse');
+ console.log('node utils/meetups.js update');
}
-console.log('usage');
-console.log('node utils/meetups.js parse');
-console.log('node utils/meetups.js update');
-return;
+if (process.argv.length >= 2 && process.argv[1] == __filename)
+ cli();
function readStdin(callback) {
var data = "";
@@ -158,3 +165,5 @@ function extractTalks($, $talks) {
}
});
}
+
+exports.parseMeetups = parseMeetups;
Please sign in to comment.
Something went wrong with that request. Please try again.