-
-
Save psychobunny/0973296708cdb9f126ed to your computer and use it in GitHub Desktop.
Widget Fix for @TheSBros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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