exports.index = function(req) { if (module.config) { return this.mapRequest(req); } else { return gluestick.loadModule("WebMapper").mapRequest(req); } }
/** * Checks if the module function call is allowed by WebMapper configuration and module variable "web_actions". */ function isCallAllowed(obj_name, action) { if (!ringo_arrays.contains(module.config.allowed, obj_name)) { return false; } else { var obj = gluestick.loadModule(obj_name); if (typeof(obj.web_actions) == "object" && (obj.web_actions instanceof Array)) { return ringo_arrays.contains(obj.web_actions, action); } else { return true; } } }
exports.mapRequest = function(req) { var p = req.params || {}; var mod_name = ""; var action = ""; // Find out which module and function to call: if (typeof(p.call) == 'string' && p.call.indexOf(".") > 0) { var call = p.call.split("."); action = call.pop(); mod_name = call.join("."); } else if (typeof(p.module) == 'string' && typeof(p.action) == 'string') { [mod_name, action] = [p.module, p.action]; } else { [mod_name, action] = module.config.default_call; } // Check if web clients are allowed to call this function: if (!isCallAllowed(mod_name, action)) { log.warn("mapRequest", "404", req.method, req.path, uneval(req.params)); var result = gluestick.loadModule("Site").showError(404); } else { // Get result from module function: var result = gluestick.loadModule(mod_name)[action](req); } // Return result: if (typeof(result) != "string") { return this.returnResponse(result); } else { return this.returnResponse({ "status": default_status, "headers": default_headers, "body": [ result ] }); } }
GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with PolicyFeed. If not, see <http://www.gnu.org/licenses/>. */ // Requirements: var config = require("config"); var gluestick = require("gluestick"); var mail = require("ringo/mail"); var ringo_objects = require("ringo/utils/objects"); var ringo_strings = require("ringo/utils/strings"); var scheduler = require("ringo/scheduler"); // Database to use: var db = gluestick.loadModule("DB_urls"); var log = require("ringo/logging").getLogger(module.id); // Configuration: module.config = config[module.id] || { message: { to: "*****@*****.**", from: false, subject: module.id + " status" } }; /**