mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Merge pull request #1061 from qistoph/difflink
Add Github diff link to update info
This commit is contained in:
commit
3ff278291f
@ -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 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 Bulgarian translations for MagicMirror² and Alert module
|
||||||
- Add graceful shutdown of modules by calling `stop` function of each `node_helper` on SIGINT before exiting.
|
- 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
|
### Updated
|
||||||
|
|
||||||
|
@ -64,7 +64,10 @@ module.exports = NodeHelper.create({
|
|||||||
sg.git.fetch().status(function(err, data) {
|
sg.git.fetch().status(function(err, data) {
|
||||||
data.module = sg.module;
|
data.module = sg.module;
|
||||||
if (!err) {
|
if (!err) {
|
||||||
self.sendSocketNotification("STATUS", data);
|
sg.git.log({"-1": null}, function(err, data2) {
|
||||||
|
data.hash = data2.latest.hash;
|
||||||
|
self.sendSocketNotification("STATUS", data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -34,6 +34,17 @@ Module.register("updatenotification", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
diffLink: function(text) {
|
||||||
|
var localRef = this.status.hash;
|
||||||
|
var remoteRef = this.status.tracking.replace(/.*\//, "");
|
||||||
|
return "<a href=\"https://github.com/MichMich/MagicMirror/compare/"+localRef+"..."+remoteRef+"\" "+
|
||||||
|
"class=\"xsmall dimmed\" "+
|
||||||
|
"style=\"text-decoration: none;\" "+
|
||||||
|
"target=\"_blank\" >" +
|
||||||
|
text +
|
||||||
|
"</a>";
|
||||||
|
},
|
||||||
|
|
||||||
// Override dom generator.
|
// Override dom generator.
|
||||||
getDom: function () {
|
getDom: function () {
|
||||||
var wrapper = document.createElement("div");
|
var wrapper = document.createElement("div");
|
||||||
@ -47,9 +58,14 @@ Module.register("updatenotification", {
|
|||||||
icon.innerHTML = " ";
|
icon.innerHTML = " ";
|
||||||
message.appendChild(icon);
|
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");
|
var text = document.createElement("span");
|
||||||
if (this.status.module == "default") {
|
if (this.status.module == "default") {
|
||||||
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
|
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
|
||||||
|
subtextHtml = this.diffLink(subtextHtml);
|
||||||
} else {
|
} else {
|
||||||
text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module);
|
text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module);
|
||||||
}
|
}
|
||||||
@ -58,9 +74,7 @@ Module.register("updatenotification", {
|
|||||||
wrapper.appendChild(message);
|
wrapper.appendChild(message);
|
||||||
|
|
||||||
var subtext = document.createElement("div");
|
var subtext = document.createElement("div");
|
||||||
subtext.innerHTML = this.translate("UPDATE_INFO")
|
subtext.innerHTML = subtextHtml;
|
||||||
.replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits"))
|
|
||||||
.replace("BRANCH_NAME", this.status.current);
|
|
||||||
subtext.className = "xsmall dimmed";
|
subtext.className = "xsmall dimmed";
|
||||||
wrapper.appendChild(subtext);
|
wrapper.appendChild(subtext);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user