forked from ktt-ol/ep_pad-lister
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 009df36
Showing
8 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
node_modules | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# en_pad-lister | ||
|
||
A plugin for Etherpad-lite that shows a list of all pads sorted by last edit date. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"parts": [ | ||
{ | ||
"name": "en_pad-lister", | ||
"hooks": { | ||
"expressCreateServer" : "ep_pad-lister/index:registerRoute", | ||
"eejsBlock_indexWrapper": "ep_pad-lister/index" | ||
} | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
var eejs = require('ep_etherpad-lite/node/eejs'); | ||
var padManager = require('ep_etherpad-lite/node/db/PadManager'); | ||
var dateFormat = require('dateformat'); | ||
|
||
exports.eejsBlock_indexWrapper = function (hook_name, args, cb) { | ||
args.content = args.content + eejs.require("ep_pad-lister/templates/linkToList.ejs"); | ||
return cb(); | ||
} | ||
|
||
exports.registerRoute = function (hook_name, args, cb) { | ||
var h = '<b>test</b>' | ||
args.app.get('/pad-lister/static/bootstrap.min.css', function (req, res) { | ||
res.sendfile(__dirname + '/static/css/bootstrap.min.css'); | ||
}); | ||
|
||
args.app.get('/pad-lister', function (req, res) { | ||
getDetailedPadList(function (pads) { | ||
var render_args = { | ||
pads: pads | ||
}; | ||
res.send(eejs.require('ep_pad-lister/templates/list.html', render_args)); | ||
}); | ||
}); | ||
}; | ||
|
||
function getDetailedPadList(callback) { | ||
var padNames = padManager.listAllPads().padIDs; | ||
|
||
var padData = []; | ||
padNames.forEach(function (padName) { | ||
padManager.getPad(padName, function (err, pad) { | ||
pad.getLastEdit(function (err, time) { | ||
padData.push({ | ||
name: padName, | ||
lastRevision: pad.head, | ||
lastAccess: time | ||
}); | ||
|
||
if (padData.length === padNames.length) { | ||
// sort | ||
padData = sortPadData(padData); | ||
// format each timestamp | ||
padData.forEach(function (padObj) { | ||
padObj.lastAccess = formatDate(padObj.lastAccess); | ||
}); | ||
callback(padData); | ||
} | ||
}); | ||
}); // end getPad | ||
}); // end forEach | ||
} | ||
|
||
// sort by last access | ||
function sortPadData(padData){ | ||
return padData.sort(function (a, b) { | ||
return b.lastAccess - a.lastAccess; | ||
}); | ||
} | ||
|
||
function formatDate(timestamp) { | ||
return dateFormat(new Date(timestamp), 'dd.mm.yyyy hh:MM:ss'); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "ep_pad-lister", | ||
"version": "1.0.0", | ||
"description": "Provides a separate list with pads, ordered by last edit.", | ||
"author": "[email protected]", | ||
"readmeFilename": "README.md", | ||
"dependencies": { | ||
"dateformat": "1.0.6-1.2.3" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10.3" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/ktt/en_pad-lister.git" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="pad-lister-link-container"> | ||
Get an overview of <em>all</em> pads in the <a href="pad-lister">Padlist</a>! | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Padlist</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"> | ||
<link href="/pad-lister/static/bootstrap.min.css" rel="stylesheet"> | ||
<style type="text/css"> | ||
body { | ||
font-size: 16px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div class="jumbotron"> | ||
<div class="container"> | ||
<h1>Padlist</h1> | ||
|
||
<p>All pads, sorted by last edit date.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="container"> | ||
|
||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Pad</th> | ||
<th>Revision</th> | ||
<th>Last edit date</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% pads.forEach(function (pad) { %> | ||
<tr> | ||
<td><a href="/public/<%= pad.name %>"><%= pad.name %></a></td> | ||
<td><%= pad.lastRevision %></td> | ||
<td><%= pad.lastAccess %></td> | ||
</tr> | ||
<% }) %> | ||
</tbody> | ||
</table> | ||
|
||
</div> | ||
</body> | ||
</html> |