mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-08 14:54:44 +00:00
enhancing gdocs.js to work with nested collections
This commit is contained in:
parent
95a29d7bde
commit
887da5684b
1 changed files with 22 additions and 7 deletions
29
gdocs.js
29
gdocs.js
|
|
@ -1,8 +1,16 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var https = require('https');
|
var https = require('https');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var collections = {
|
||||||
|
'devguide': 'http://docs.google.com/feeds/default/private/full/folder%3A0B9PsajIPqzmANGUwMGVhZmYtMTk1ZC00NTdmLWIxMDAtZGI5YWNlZjQ2YjZl/contents',
|
||||||
|
'api': 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDYjMwYTc2YWUtZTgzYy00YjIxLThlZDYtYWJlOTFlNzE2NzEw/contents',
|
||||||
|
'cookbook': 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDNzkxZWM5ZTItN2M5NC00NWIxLTg2ZDMtMmYwNDY1NWM1MGU4/contents',
|
||||||
|
'misc': 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDZjVlNmZkYzQtMjZlOC00NmZhLWI5MjAtMGRjZjlkOGJkMDBi/contents'
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Google Docs...');
|
console.log('Google Docs...');
|
||||||
|
|
||||||
var flag = process && process.argv[2];
|
var flag = process && process.argv[2];
|
||||||
|
|
@ -10,22 +18,29 @@ if (flag == '--login')
|
||||||
askPassword(function(password){
|
askPassword(function(password){
|
||||||
login(process.argv[3], password);
|
login(process.argv[3], password);
|
||||||
});
|
});
|
||||||
else if (flag == '--fetch')
|
else if (flag == '--fetch') {
|
||||||
fetch();
|
var collection = process.argv[3];
|
||||||
else
|
if (collection) {
|
||||||
|
fetch(collection, collections[collection]);
|
||||||
|
} else {
|
||||||
|
for (collection in collections)
|
||||||
|
fetch(collection, collections[collection]);
|
||||||
|
}
|
||||||
|
} else
|
||||||
help();
|
help();
|
||||||
|
|
||||||
function help(){
|
function help(){
|
||||||
console.log('Synopsys');
|
console.log('Synopsys');
|
||||||
console.log('gdocs.js [--login|--fetch]');
|
console.log('gdocs.js --login <username>');
|
||||||
|
console.log('gdocs.js --fetch [<docs collection>]');
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function fetch(){
|
function fetch(name, url){
|
||||||
//https://docs.google.com/feeds/default/private/full/folder%3Afolder_id/contents
|
//https://docs.google.com/feeds/default/private/full/folder%3Afolder_id/contents
|
||||||
console.log('fetching a list of docs...');
|
console.log('fetching a list of docs in collection ' + name + '...');
|
||||||
request('GET', 'http://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDZDJmNzI3NjItODY1NS00YTg3LWE2MDItNmMyODE4MDdhNDFk/contents', {
|
request('GET', url, {
|
||||||
headers: {
|
headers: {
|
||||||
'Gdata-Version': '3.0',
|
'Gdata-Version': '3.0',
|
||||||
'Authorization': 'GoogleLogin auth=' + getAuthToken()
|
'Authorization': 'GoogleLogin auth=' + getAuthToken()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue