{ "ctime": 1414595693138, "mtime": 1482624819464, "name": "echo", "path": "", "description": "", "language": "javascript", "isPublic": false, "customTimeout": 60000, "themeName": "custom", "themeStatus": "disabled", "mschemaStatus": "disabled", "status": "active", "gist": "https://gist.github.com/Marak/357645b8a17daeb17458", "mainEntry": "", "ran": 348073, "owner": "marak", "cron": "* * * * *", "lastCron": "Sun Jul 12 2015 20:33:11 GMT-0400 (EDT)", "cronActive": true, "mschema": { "param1": { "type": "string", "default": "foo" }, "param2": { "type": "string", "default": "bar" } }, "sourceType": "code", "source": "module['exports'] = function echoHttp (hook) {\r\n console.log(hook.req.url);\r\n hook.res.json(hook.params);\r\n };", "themeSource": "\n\n \n \n \n \n \n \n \n \n \n hook\n \n \n \n \n \n \n
\n
\n
\n \"hook.io\"\n
\n
\n \"pipe\"\n
\n
\n\n
\n
\n
\n
\n
\n Change Theme: \n
\n
\n
\n \n \n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n hook output\n
\n \n
\n
\n
\n
\n\n
\n
\n Did you know this page is a fully qualified web-service? Read more here.\n
\n
\n
\n
\n
\n\n
\n
\n \n
\n Copyright hook.io 2016\n
\n
\n
\n
\n
\n \n \n", "presenterSource": "var request = require('hyperquest');\nvar dateFormat = require('dateformat');\nvar forms = require('mschema-forms');\nvar mustache = require('mustache');\n\nmodule['exports'] = function view (opts, callback) {\n\n var params = opts.request.resource.params;\n\n var req = opts.request,\n res = opts.response\n result = opts;\n\n var $ = this.$;\n var run = params.run;\n $('title').html(req.params.owner + \"/\" + req.params.hook);\n \n \n// $('.themeSelector').append('')\n \n var gist = opts.gist || params.gist;\n $('.gistEmbed').html('');\n \n if (result.output !== null) {\n\n if (result.headers && result.headers.code === 500) {\n return showForm(function(){\n $('.hookResult .message').html('Error executing Hook!');\n $('.hookResult .message').addClass('error');\n $('.hookResult .message').removeClass('success');\n var errors = JSON.parse(result.output.toString());\n errors.forEach(function(e){\n $('form input[name=\"' + e.property + '\"]').addClass('error');\n });\n return callback(null, $.html());\n });\n }\n \n $('.hookOutput').html('');\n\n // return callback(null, $.html());\n\n }\n\n\n var strParams = '';\n var ignoreParams = ['hook', 'subhook', 'username', 'format', 'run'];\n for (var p in params) {\n if (ignoreParams.indexOf(p) === -1) {\n strParams += (\"&\" + p + \"=\" + encodeURI(params[p]));\n }\n }\n\n $('.forkButton').attr('data-url', 'https://hook.io/' + req.hook.owner + \"/\" + req.hook.name + \"?fork=true\");\n\n // $('.hookResult').remove();\n showForm(callback);\n function showForm (cb) {\n var formSchema = req.hook.mschema || {};\n\n for (var p in formSchema) {\n if(typeof params[p] !== 'undefined') {\n formSchema[p].default = params[p];\n }\n }\n\n formSchema.run = {\n \"type\": \"string\",\n \"default\": \"true\",\n \"format\": \"hidden\"\n };\n\n formSchema.format = {\n \"type\": \"string\",\n \"default\": \"friendly\",\n \"enum\": [\"raw\", \"friendly\"]\n };\n\n formSchema.theme = {\n \"type\": \"string\",\n \"format\": \"hidden\",\n \"default\": params.theme\n };\n\n\n var themeSelect = '
\\\n Switch Theme:
';\n \n\n forms.generate({\n type: \"generic\",\n form: {\n legend: req.hook.name + ' form',\n submit: \"Submit\",\n action: \"\"\n },\n schema: formSchema,\n }, function (err, result){\n $('.testForm').html(result);\n cb(null, $.html());\n });\n \n }\n\n};", "isPrivate": false, "_rev": "199198-76ee6d86a2c67bb2733b12bf879d9c19", "id": "37d6b9e45bbb38e468d418d6e2008e6d" }