-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.js
36 lines (30 loc) · 829 Bytes
/
hooks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* registerHooks
* @param object locals explorer locals (see https://github.com/soyuka/explorer/blob/master/Plugins.md)
* @param object config explorer configuration
* @return string
*/
function registerHooks(config, user) {
return {
//hooking on directory
directory: function(tree, path) {
var l = tree.length
var found = false
//searches for an audio file
while(l-- && !found) {
var e = tree[l]
if(!e) {
continue;
}
if(e.type == 'audio') {
found = true
}
}
if(found === false)
return '' //don't polute view
//Directory hook wants a <dd> element, adding our route
return '<li><a href="/p/m3u?path='+path+'&key='+user.key+'">M3u</a></li>'
}
}
}
module.exports = registerHooks