8000 angular.js/gdocs.js at location-fix · salzig/angular.js · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"css","path":"css","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"example","path":"example","contentType":"directory"},{"name":"i18n","path":"i18n","contentType":"directory"},{"name":"images","path":"images","contentType":"directory"},{"name":"lib","path":"lib","contentType":"directory"},{"name":"logs","path":"logs","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"Gruntfile.js","path":"Gruntfile.js","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"angularFiles.js","path":"angularFiles.js","contentType":"file"},{"name":"changelog.js","path":"changelog.js","contentType":"file"},{"name":"changelog.spec.js","path":"changelog.spec.js","contentType":"file"},{"name":"changelog.tmp.md","path":"changelog.tmp.md","contentType":"file"},{"name":"check-size.sh","path":"check-size.sh","contentType":"file"},{"name":"gdocs.js","path":"gdocs.js","contentType":"file"},{"name":"gen_docs.sh","path":"gen_docs.sh","contentType":"file"},{"name":"init-repo.sh","path":"init-repo.sh","contentType":"file"},{"name":"package.json","path":"package.json","contentType":"file"},{"name":"release-commit.sh","path":"release-commit.sh","contentType":"file"},{"name":"start-iteration.sh","path":"start-iteration.sh","contentType":"file"},{"name":"testacular-e2e.conf.js","path":"testacular-e2e.conf.js","contentType":"file"},{"name":"testacular-jqlite.conf.js","path":"testacular-jqlite.conf.js","contentType":"file"},{"name":"testacular-jquery.conf.js","path":"testacular-jquery.conf.js","contentType":"file"},{"name":"testacular-modules.conf.js","path":"testacular-modules.conf.js","contentType":"file"},{"name":"validate-commit-msg.js","path":"validate-commit-msg.js","contentType":"file"},{"name":"validate-commit-msg.spec.js","path":"validate-commit-msg.spec.js","contentType":"file"},{"name":"version.js","path":"version.js","contentType":"file"},{"name":"version.yaml","path":"version.yaml","contentType":"file"},{"name":"watchr-docs.rb","path":"watchr-docs.rb","contentType":"file"}],"totalCount":36}},"fileTreeProcessingTime":3.3124589999999996,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":14690389,"defaultBranch":"master","name":"angular.js","ownerLogin":"salzig","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2013-11-25T16:06:03.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/99911?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"location-fix","listCacheKey":"v0:1385397458.0","canEdit":false,"refType":"branch","currentOid":"25bcc87501ac5208db2220a803131fe6245946ee"},"path":"gdocs.js","currentUser":null,"blob":{"rawLines":["#!/usr/bin/env node","","var http = require('http');","var https = require('https');","var fs = require('fs');","","var collections = {"," 'guide': 'https://docs.google.com/feeds/default/private/full/folder%3A0B9PsajIPqzmANGUwMGVhZmYtMTk1ZC00NTdmLWIxMDAtZGI5YWNlZjQ2YjZl/contents',"," 'api': 'https://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDYjMwYTc2YWUtZTgzYy00YjIxLThlZDYtYWJlOTFlNzE2NzEw/contents',"," 'tutorial': 'https://docs.google.com/feeds/default/private/full/folder%3A0B9PsajIPqzmAYWMxYWE3MzYtYzdjYS00OGQxLWJhZjItYzZkMzJiZTRhZjFl/contents',"," 'cookbook': 'https://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDNzkxZWM5ZTItN2M5NC00NWIxLTg2ZDMtMmYwNDY1NWM1MGU4/contents',"," 'misc': 'https://docs.google.com/feeds/default/private/full/folder%3A0B7Ovm8bUYiUDZjVlNmZkYzQtMjZlOC00NmZhLWI5MjAtMGRjZjlkOGJkMDBi/contents'","};","","console.log('Google Docs...');","","var flag = process \u0026\u0026 process.argv[2];","if (flag == '--login') {"," var username = process.argv[3];"," if (username) {"," askPassword(function(password){"," login(username, password);"," });"," } else {"," console.log('Missing username!');"," }","} else if (flag == '--fetch') {"," var collection = process.argv[3];"," if (collection) {"," fetch(collection, collections[collection]);"," } else {"," for (collection in collections)"," fetch(collection, collections[collection]);"," }","} else {"," help();","}","","function help() {"," console.log('Synopsys');"," console.log('gdocs.js --login \u003cusername\u003e');"," console.log('gdocs.js --fetch [\u003cdocs collection\u003e]');"," process.exit(-1);","};","","","function fetch(collection, url){"," console.log('fetching a list of docs in collection ' + collection + '...');"," request('GET', url, {"," headers: {"," 'Gdata-Version': '3.0',"," 'Authorization': 'GoogleLogin auth=' + getAuthToken()"," }"," },"," function(chunk){"," var entries = chunk.split('\u003centry');"," entries.shift();"," entries.forEach(function(entry){"," var title = entry.match(/\u003ctitle\u003e(.*?)\u003c\\/title\u003e/)[1];"," if (title.match(/\\.ngdoc$/)) {"," var exportUrl = entry.match(/\u003ccontent type='text\\/html' src='(.*?)'\\/\u003e/)[1];"," download(collection, title, exportUrl);"," };"," });"," }"," );","}","","function download(collection, name, url) {"," console.log('Downloading:', name, '...');"," request('GET', url + '\u0026exportFormat=txt',"," {"," headers: {"," 'Gdata-Version': '3.0',"," 'Authorization': 'GoogleLogin auth=' + getAuthToken()"," }"," },"," function(data){"," data = data.replace('\\ufeff', '');"," data = data.replace(/\\r\\n/mg, '\\n');",""," // strip out all text annotations"," data = data.replace(/\\[[a-zA-Z]{1,2}\\]/mg, '');",""," // strip out all docos comments"," data = data.replace(/^[^\\s_]+:\\n\\S+[\\S\\s]*$/m, '');",""," // fix smart-quotes"," data = data.replace(/[“”]/g, '\"');"," data = data.replace(/[‘’]/g, \"'\");","",""," data = data + '\\n';",""," //this should be a bug in Google Doc API, hence need to remove this once the bug is fixed"," data = data.replace(/\\n\\n/g, '\\n');",""," fs.writeFileSync('docs/content/' + collection + '/' + name, reflow(data, 100));"," }"," );","}","","/**"," * token=$(curl"," * -s https://www.google.com/accounts/ClientLogin"," * -d Email=...username..."," * -d Passwd=...password..."," * -d accountType=GOOGLE"," * -d service=writely"," * -d Gdata-version=3.0 | cut -d \"=\" -f 2)"," */","function login(username, password){"," request('POST', 'https://www.google.com/accounts/ClientLogin',"," {"," data: {"," Email: username,"," Passwd: password,"," accountType: 'GOOGLE',"," service: 'writely',"," 'Gdata-version': '3.0'"," },"," headers: {"," 'Content-type': 'application/x-www-form-urlencoded'"," }"," },"," function(chunk){"," var token;"," chunk.split('\\n').forEach(function(line){"," var parts = line.split('=');"," if (parts[0] == 'Auth') {"," token = parts[1];"," }"," });"," if (token) {"," fs.writeFileSync('tmp/gdocs.auth', token);"," console.log(\"logged in, token saved in 'tmp/gdocs.auth'\");"," } else {"," console.log('failed to log in');"," }"," }"," );","}","","function getAuthToken() {"," var pwdFile = 'tmp/gdocs.auth';"," try {"," fs.statSync(pwdFile);"," return fs.readFileSync(pwdFile);"," } catch (e) {"," console.log('Please log in first...');"," }","}","","function request(method, url, options, response) {"," var url = url.match(/http(s?):\\/\\/(.+?)(\\/.*)/);"," var isHttps = url[1];"," var request = (isHttps ? https : http).request({"," host: url[2],"," port: (url[1] ? 443 : 80),"," path: url[3],"," method: method"," }, function(res){"," switch (res.statusCode) {"," case 200:"," var data = [];"," res.setEncoding('utf8');"," res.on('end', function () { response(data.join('')); });"," res.on('close', function () { response(data.join('')); }); // https"," res.on('data', function (chunk) { data.push(chunk); });"," res.on('error', function (e) { console.log(e); });"," break;"," case 401:"," console.log('Eror: Login credentials expired! Please login.');"," break;"," default:"," var data = [];"," console.log('ERROR: ', res.statusCode);"," console.log('REQUEST URL: ', url[0]);"," console.log('REQUEST POST: ', options.data);"," console.log('REQUEST HEADERS: ', options.headers);"," console.log('RESPONSE HEADERS: ', res.headers);"," res.on('end', function (){ console.log('BODY: ', data.join('')); });"," res.on('close', function (){ console.log('BODY: ', data.join('')); }); // https"," res.on('data', function (chunk) { data.push(chunk); });"," res.on('error', function (e){ console.log(e); });"," }"," });"," for(var header in options.headers) {"," request.setHeader(header, options.headers[header]);"," }"," if (options.data)"," request.write(encodeData(options.data));"," request.on('end', function() {"," console.log('end');"," });"," request.end();","}","","function encodeData(obj) {"," var pairs = [];"," for(var key in obj) {"," pairs.push(key + '=' + obj[key]);"," }"," return pairs.join('\u0026') + '\\n';","}","","function askPassword(callback) {"," var stdin = process.openStdin(),"," stdio = process.binding(\"stdio\");",""," stdio.setRawMode();",""," console.log('Enter your password:');"," var password = \"\";"," stdin.on(\"data\", function(c) {"," c = c + \"\";"," switch (c) {"," case \"\\n\": case \"\\r\": case \"\\u0004\":"," stdio.setRawMode(false);"," stdin.pause();"," callback(password);"," break;"," case \"\\u0003\":"," process.exit();"," break;"," default:"," password += c;"," break;"," }"," })","","}","","function reflow(text, margin) {"," var lines = [];"," text.split(/\\n/).forEach(function(line) {"," var col = 0;"," var reflowLine = '';"," function flush() {"," reflowLine = reflowLine.replace(/\\s*$/, '');"," lines.push(reflowLine);"," reflowLine = '';"," col = 0;"," }"," line.replace(/\\s*\\S*\\s*/g, function(chunk){"," if (col + chunk.length \u003e margin) flush();"," reflowLine += chunk;"," col += chunk.length;"," });"," flush();"," });"," return lines.join('\\n');","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/salzig/angular.js/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"gdocs.js","displayUrl":"https://github.com/salzig/angular.js/blob/location-fix/gdocs.js?raw=true","headerInfo":{"blobSize":"7.12 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"31377df","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fsalzig%2Fangular.js%2Fblob%2Flocation-fix%2Fgdocs.js","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"253","truncatedSloc":"229"},"mode":"executable file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"JavaScript","languageID":183,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/salzig/angular.js/blob/location-fix/gdocs.js","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/salzig/angular.js/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/salzig/angular.js/raw/refs/heads/location-fix/gdocs.js","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/salzig/angular.js/branches":{"post":"kieSEMVdjqj-ghkIy1J4UHJJbiWEwqfsJeMxvrMvwMEGagiZSWcgO5FBDzRhdZp0L0kc4AcsW1gS8HhSjZicbg"},"/repos/preferences":{"post":"G5m5O-zTsOds10EUnH15-zWQT4abx8Zjx92az-K56KYCc0KDoicVfdUk7WxRSDcNOPqGjt-VjnlTSXfzYlES-w"}}},"title":"angular.js/gdocs.js at location-fix · salzig/angular.js","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0