Permalink
Browse files

Meetups.js is now usable as module.

Signed-off-by: François de Metz <francois@stormz.me>
  • Loading branch information...
1 parent 616f6c5 commit 46b2349fbc3dc7198710ceda62a6b1d911ded117 @francois2metz francois2metz committed Feb 24, 2012
Showing with 21 additions and 11 deletions.
  1. +1 −0 package.json
  2. +20 −11 utils/meetups.js
View
@@ -7,6 +7,7 @@
"type": "git",
"url": "git://github.com/parisjs/parisjs-website.git"
},
+ "main": "./utils/meetups.js",
"dependencies": {
"jsdom": "",
"underscore": ""
View
@@ -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,25 +28,32 @@
* 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')
, fs = require('fs')
, _ = 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;

0 comments on commit 46b2349

Please sign in to comment.