HydraShare / hydra

Hydra is a web platform to share your example files from Grasshopper and Dynamo
http://hydrashare.github.io/hydra/
MIT License
69 stars 151 forks source link

Adopt to Github Versions #6

Open mostaphaRoudsari opened 9 years ago

mostaphaRoudsari commented 9 years ago

We can use github's versions for the zip file as the main driver of the versions. The version input by user can move to README.md file.

mostaphaRoudsari commented 9 years ago

Here is what I use now for input.json file. It can't be changed to README.md. Finding related files with each change can be tricky assuming there can be cases that not all the files get updated. Then there should be a recursive search to find the file. This functionality will be only useful for the viewer.

function get_commit_history(member, forkName, name){
  var dates = [];

  var inputFileHistory = "https://api.github.com/repos/" + member + "/" + forkName + "/commits?path=" + name + "/input.json";
  var inputHistoryString = UrlFetchApp.fetch(inputFileHistory).getContentText();
  var inputHistoryData = JSON.parse(inputHistoryString);

  // collect all dates
  for (d = 0; d < inputHistoryData.length; d++){
    var commit = inputHistoryData[d];
    // adding milliseconds to date > http://stackoverflow.com/questions/6683872/why-does-my-date-object-in-google-apps-script-return-nan
    var dt = Date.parse(commit.commit.committer.date.replace("Z", ".000Z"));
    var dtt = new Date(dt);
    dates.push(dtt);
  }

  // sort list of dates
  dates.sort();

  return dates
}