Skip to content

Instantly share code, notes, and snippets.

@psychobunny
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychobunny/0973296708cdb9f126ed to your computer and use it in GitHub Desktop.
Save psychobunny/0973296708cdb9f126ed to your computer and use it in GitHub Desktop.
Widget Fix for @TheSBros
(function(module) {
"use strict";
var Widget = {
templates: {}
};
var async = module.parent.require('async'),
fs = module.parent.require('fs'),
path = module.parent.require('path');
Widget.renderStatusWidget = function(widget, callback) {
var html = Widget.templates["status.tpl"];
callback(null, html);
};
Widget.defineWidgets = function(widgets, callback) {
widgets = widgets.concat([
{
widget: "status",
name: "Server Status",
description: "Minecraft Server Status.",
content: Widget.templates["admin/status.tpl"]
}
]);
callback(null, widgets);
};
Widget.addRoutes = function(custom_routes, callback) {
var templatesToLoad = [
"status.tpl", "admin/status.tpl"
];
function loadTemplate(template, next) {
fs.readFile(path.resolve(__dirname, './templates/' + template), function (err, data) {
Widget.templates[template] = data.toString();
next(err);
});
}
async.each(templatesToLoad, loadTemplate, function(err) {
if (err) {
throw new Error("Error loading templates: " + err);
}
callback(err, custom_routes);
});
};
module.exports = Widget;
}(module));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment