From e7b9100f1c46cf11792d879e060cad144419a99e Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Mon, 16 Oct 2017 09:35:25 +0200 Subject: [PATCH 1/2] Add Github link to update info --- .../default/updatenotification/node_helper.js | 5 ++++- .../updatenotification/updatenotification.js | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/default/updatenotification/node_helper.js b/modules/default/updatenotification/node_helper.js index 6196552f..df989faa 100644 --- a/modules/default/updatenotification/node_helper.js +++ b/modules/default/updatenotification/node_helper.js @@ -64,7 +64,10 @@ module.exports = NodeHelper.create({ sg.git.fetch().status(function(err, data) { data.module = sg.module; if (!err) { - self.sendSocketNotification("STATUS", data); + sg.git.log({"-1": null}, function(err, data2) { + data.hash = data2.latest.hash; + self.sendSocketNotification("STATUS", data); + }); } }); }); diff --git a/modules/default/updatenotification/updatenotification.js b/modules/default/updatenotification/updatenotification.js index bf7ec2c1..306ac6ae 100644 --- a/modules/default/updatenotification/updatenotification.js +++ b/modules/default/updatenotification/updatenotification.js @@ -34,6 +34,17 @@ Module.register("updatenotification", { } }, + diffLink: function(text) { + var localRef = this.status.hash; + var remoteRef = this.status.tracking.replace(/.*\//, ""); + return "" + + text + + ""; + }, + // Override dom generator. getDom: function () { var wrapper = document.createElement("div"); @@ -47,9 +58,14 @@ Module.register("updatenotification", { icon.innerHTML = " "; message.appendChild(icon); + var subtextHtml = this.translate("UPDATE_INFO") + .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits")) + .replace("BRANCH_NAME", this.status.current); + var text = document.createElement("span"); if (this.status.module == "default") { text.innerHTML = this.translate("UPDATE_NOTIFICATION"); + subtextHtml = this.diffLink(subtextHtml); } else { text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module); } @@ -58,9 +74,7 @@ Module.register("updatenotification", { wrapper.appendChild(message); var subtext = document.createElement("div"); - subtext.innerHTML = this.translate("UPDATE_INFO") - .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits")) - .replace("BRANCH_NAME", this.status.current); + subtext.innerHTML = subtextHtml; subtext.className = "xsmall dimmed"; wrapper.appendChild(subtext); } From 4e8bf216df61606b7cc7e7ab6ce11da1468335bc Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Mon, 16 Oct 2017 14:26:15 +0200 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13a52cb9..243b82d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Add option to use [Nunjucks](https://mozilla.github.io/nunjucks/) templates in modules. (See `helloworld` module as an example.) - Add Bulgarian translations for MagicMirror² and Alert module - Add graceful shutdown of modules by calling `stop` function of each `node_helper` on SIGINT before exiting. +- Link update subtext to Github diff of current version versus tracking branch. ### Updated