2016-07-07 01:11:56 -07:00
|
|
|
import { sendPug } from '../pug';
|
2015-10-26 22:56:53 -07:00
|
|
|
|
2016-05-21 16:59:28 -07:00
|
|
|
export default function initialize(app, channelIndex, maxEntries) {
|
2015-10-26 22:56:53 -07:00
|
|
|
app.get('/', (req, res) => {
|
|
|
|
|
channelIndex.listPublicChannels().then((channels) => {
|
|
|
|
|
channels.sort((a, b) => {
|
|
|
|
|
if (a.usercount === b.usercount) {
|
|
|
|
|
return a.uniqueName > b.uniqueName ? -1 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return b.usercount - a.usercount;
|
|
|
|
|
});
|
|
|
|
|
|
2016-05-21 16:59:28 -07:00
|
|
|
channels = channels.slice(0, maxEntries);
|
|
|
|
|
|
2016-07-07 01:11:56 -07:00
|
|
|
sendPug(res, 'index', {
|
2015-10-26 22:56:53 -07:00
|
|
|
channels: channels
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|