diff options
author | Guy Sheffer <guysoft@gmail.com> | 2015-10-30 19:17:17 +0300 |
---|---|---|
committer | Guy Sheffer <guysoft@gmail.com> | 2015-10-30 19:17:17 +0300 |
commit | fec45f2c1f30ced23f062d7f4bf30719c1e906b5 (patch) | |
tree | 9b1aab15254b572e6e4248225590e4b5e3e2a92e | |
parent | a65164bfef22a9ef73782382b334dcb84bb9d323 (diff) |
Add container static html generation scriptcloud
-rw-r--r-- | src/nightly_build_scripts/generate_nightly_page.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js new file mode 100644 index 0000000..1a38673 --- /dev/null +++ b/src/nightly_build_scripts/generate_nightly_page.js @@ -0,0 +1,36 @@ + var pkgcloud = require('pkgcloud'), fs = require('fs'), path = require('path'); + + if(!String.prototype.startsWith){ + String.prototype.startsWith = function (str) { + return !this.indexOf(str); + } +} + + var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: path.join(__dirname, 'key.json'), // path to a JSON key file + //#projectId: 'eco-channel-658' // project id +}); + + var cointainer = "octoprint"; + + client.getFiles(cointainer, function (err, files) { + + var stream = fs.createWriteStream(path.join(__dirname, 'index.html')); + + + stream.write("<html><title>OctoPrint Nightly builds</title><body><h1>OctoPi Nightly Builds</h1><table>\n"); + files.sort(function(a,b) { + if (a.name.startsWith("bananapi") && b.name.startsWith("octopi")) return 1; + if (b.name.startsWith("bananapi") && a.name.startsWith("octopi")) return -1; + if(a.timeCreated < b.timeCreated) return 1; + if(a.timeCreated > b.timeCreated) return -1; + return 0; + } +).forEach(function(fileObj) { + + stream.write('<tr><td><a href="https://storage.googleapis.com/octoprint/' + fileObj.name + ' " >' + fileObj.name + "</a> <td>" + fileObj.timeCreated +" </td></td></tr>\n"); + }); + stream.write("</table></body></html>\n"); + + });
\ No newline at end of file |