Skip to content

Instantly share code, notes, and snippets.

@psychobunny psychobunny/gist:0973296708cdb9f126ed Secret
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.