X Tutup
Skip to content

Commit 887da56

Browse files
committed
enhancing gdocs.js to work with nested collections
1 parent 95a29d7 commit 887da56

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

gdocs.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
#!/usr/bin/env node
2+
23
var http = require('http');
34
var https = require('https');
45
var fs = require('fs');
56

7+
var collections = {
8+
'devguide': 'http://docs.google.com/feeds/default/private/full/folder%3A0B9PsajIPqzmANGUwMGVhZmYtMTk1ZC00NTdmLWIxMDAtZGI5YWNlZjQ2YjZl/contents',
9+
'api': 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDYjMwYTc2YWUtZTgzYy00YjIxLThlZDYtYWJlOTFlNzE2NzEw/contents',
10+
'cookbook': 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDNzkxZWM5ZTItN2M5NC00NWIxLTg2ZDMtMmYwNDY1NWM1MGU4/contents',
11+
'misc': 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDZjVlNmZkYzQtMjZlOC00NmZhLWI5MjAtMGRjZjlkOGJkMDBi/contents'
12+
}
13+
614
console.log('Google Docs...');
715

816
var flag = process && process.argv[2];
917
if (flag == '--login')
1018
askPassword(function(password){
1119
login(process.argv[3], password);
1220
});
13-
else if (flag == '--fetch')
14-
fetch();
15-
else
21+
else if (flag == '--fetch') {
22+
var collection = process.argv[3];
23+
if (collection) {
24+
fetch(collection, collections[collection]);
25+
} else {
26+
for (collection in collections)
27+
fetch(collection, collections[collection]);
28+
}
29+
} else
1630
help();
1731

1832
function help(){
1933
console.log('Synopsys');
20-
console.log('gdocs.js [--login|--fetch]');
34+
console.log('gdocs.js --login <username>');
35+
console.log('gdocs.js --fetch [<docs collection>]');
2136
process.exit(-1);
2237
};
2338

2439

25-
function fetch(){
40+
function fetch(name, url){
2641
//https://docs.google.com/feeds/default/private/full/folder%3Afolder_id/contents
27-
console.log('fetching a list of docs...');
28-
request('GET', 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDZDJmNzI3NjItODY1NS00YTg3LWE2MDItNmMyODE4MDdhNDFk/contents', {
42+
console.log('fetching a list of docs in collection ' + name + '...');
43+
request('GET', url, {
2944
headers: {
3045
'Gdata-Version': '3.0',
3146
'Authorization': 'GoogleLogin auth=' + getAuthToken()

0 commit comments

Comments
 (0)
X Tutup