Skip to content

Instantly share code, notes, and snippets.

@caleorourke
Last active August 29, 2015 13:57
Show Gist options
  • Save caleorourke/9522318 to your computer and use it in GitHub Desktop.
Save caleorourke/9522318 to your computer and use it in GitHub Desktop.
/*
 * # Milestones
 * # Fetch data from the most recent milestone and code commit
 *
 * Copyright (c) 2014 SoftLayer, an IBM Company
 * Released under the MIT license
 *
 */

module.exports = function() {

  var config = this.file.readYAML("../_config.yml");  // Read in the configuration and parse it into an object
  var callback = ["?state=closed/callback?"];

  // Fetch date and title from last milestone closed

  var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

  $.ajax({
    url: "<%= site.api.milestones %><%= callback %>",
    dataType: "jsonp",
    success: function (json) {
      var lastMilestone = json.data[0];

      var stamp = new Date(lastMilestone.updated_at),
          stampString = month[stamp.getMonth()] + " " + stamp.getDate();
      $("#mdate").text(stampString);
      $("#mtitle").text(lastMilestone.title);
    }
  });

  // Fetch date from last commit record

  $.ajax({
    url: "https://api.github.com/repos/softlayer/jumpgate/commits?state=closed/callback?",
    dataType: "jsonp",
    success: function (json) {
        var lastCommit = json.data[0];

        var stamp = new Date(lastCommit.commit.committer.date),
            stampString = month[stamp.getMonth()] + " " + stamp.getDate();
        $("#cdate").text(stampString);
    }
  });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment