From 25f59ef370ad9873741b7873d4caa1cbb1d6067c Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 2 Dec 2013 15:14:39 -0800 Subject: [PATCH] super minimal `/list` page showing all pads --- ep.json | 11 +++++++++++ index.js | 21 +++++++++++++++++++++ package.json | 11 +++++++++++ templates/pads.html | 15 +++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 ep.json create mode 100644 index.js create mode 100644 package.json create mode 100644 templates/pads.html diff --git a/ep.json b/ep.json new file mode 100644 index 0000000..ec1ed9d --- /dev/null +++ b/ep.json @@ -0,0 +1,11 @@ +{ + "parts": [ + { + "name": "list", + "hooks": { + "expressCreateServer": "ep_padlist:expressCreateServer", + "eejsBlock_indexWrapper": "ep_padlist:indexWrapper" + } + } + ] +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..268e37e --- /dev/null +++ b/index.js @@ -0,0 +1,21 @@ +var eejs = require('ep_etherpad-lite/node/eejs') + , padManager = require('ep_etherpad-lite/node/db/PadManager') + , api = require('ep_etherpad-lite/node/db/API'); + +exports.expressCreateServer = function (hook_name, args, cb) { + args.app.get('/list', function(req, res) { + var render_args = { + pads: [] + }; + padManager.listAllPads(function(null_value, pads){ + render_args.pads = pads.padIDs; + res.send( eejs.require('ep_padlist/templates/pads.html', render_args) ); + cb(); + }); + }); +} + +exports.indexWrapper = function (hook_name, args, cb) { + args.content = args.content + '

All Pads
'; + return cb(); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..86dd02d --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "ep_padlist", + "version": "0.0.1", + "description": "Display a list of pads at /list", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Aaron Parecki", + "license": "Apache 2.0" +} diff --git a/templates/pads.html b/templates/pads.html new file mode 100644 index 0000000..6646e0b --- /dev/null +++ b/templates/pads.html @@ -0,0 +1,15 @@ + + + Pads + + +

Pads

+ + + + + \ No newline at end of file