Skip to content

Commit

Permalink
super minimal /list page showing all pads
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Dec 2, 2013
1 parent cd7dc14 commit 25f59ef
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ep.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"parts": [
{
"name": "list",
"hooks": {
"expressCreateServer": "ep_padlist:expressCreateServer",
"eejsBlock_indexWrapper": "ep_padlist:indexWrapper"
}
}
]
}
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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 + '<br><br><div style="text-align:center;"><a href="/list">All Pads</a></div>';
return cb();
}
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
15 changes: 15 additions & 0 deletions templates/pads.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<title>Pads</title>
</head>
<body>
<h1>Pads</h1>

<ul>
<% pads.forEach(function(pad){ %>
<li><a href="/<%= pad.toString() %>"><%= pad.toString() %></a></li>
<% }) %>
</ul>

</body>
</html>

0 comments on commit 25f59ef

Please sign in to comment.