2019-07-16 09:53:38 +00:00
|
|
|
function register ({ registerHook, peertubeHelpers }) {
|
|
|
|
registerHook({
|
2019-07-22 12:08:20 +00:00
|
|
|
target: 'action:application.init',
|
|
|
|
handler: () => onApplicationInit(peertubeHelpers)
|
2019-07-16 09:53:38 +00:00
|
|
|
})
|
2019-07-22 13:38:26 +00:00
|
|
|
|
|
|
|
// Videos list
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.trending-videos.videos.list.params',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: params => Object.assign({}, params, { sort: '-views' })
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.trending-videos.videos.list.result',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: result => addSymbolToVideoNameResult(result, '<3')
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.local-videos.videos.list.params',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: params => Object.assign({}, params, { sort: '-views' })
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.local-videos.videos.list.result',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: result => addSymbolToVideoNameResult(result, ':)')
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.recently-added-videos.videos.list.params',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: params => Object.assign({}, params, { filter: 'all-local' })
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.recently-added-videos.videos.list.result',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: result => addSymbolToVideoNameResult(result, 'o/')
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.user-subscriptions-videos.videos.list.params',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: params => Object.assign({}, params, { sort: '-views' })
|
|
|
|
})
|
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'filter:api.user-subscriptions-videos.videos.list.result',
|
2019-07-22 13:38:26 +00:00
|
|
|
handler: result => addSymbolToVideoNameResult(result, ':D')
|
|
|
|
})
|
|
|
|
|
2019-07-26 07:42:52 +00:00
|
|
|
// Router hooks
|
|
|
|
|
|
|
|
registerHook({
|
|
|
|
target: 'action:router.navigation-end',
|
|
|
|
handler: params => console.log('New URL! %s.', params.path)
|
|
|
|
})
|
|
|
|
|
2019-07-22 14:40:52 +00:00
|
|
|
// Fake hook
|
2019-07-22 13:38:26 +00:00
|
|
|
|
|
|
|
registerHook({
|
2019-07-22 14:40:52 +00:00
|
|
|
target: 'fakeHook',
|
|
|
|
handler: () => console.log('fake hook')
|
2019-07-22 13:38:26 +00:00
|
|
|
})
|
|
|
|
|
2019-07-16 09:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
register
|
|
|
|
}
|
2019-07-16 14:00:11 +00:00
|
|
|
|
2019-07-22 12:08:20 +00:00
|
|
|
function onApplicationInit (peertubeHelpers) {
|
2019-07-16 14:00:11 +00:00
|
|
|
console.log('Hello application world')
|
|
|
|
|
|
|
|
const baseStaticUrl = peertubeHelpers.getBaseStaticRoute()
|
|
|
|
const imageUrl = baseStaticUrl + '/images/chocobo.png'
|
|
|
|
|
|
|
|
const topLeftBlock = document.querySelector('.top-left-block')
|
|
|
|
|
|
|
|
topLeftBlock.style.backgroundImage = 'url(' + imageUrl + ')'
|
|
|
|
}
|
2019-07-22 13:38:26 +00:00
|
|
|
|
|
|
|
function addSymbolToVideoNameResult (result, symbol) {
|
|
|
|
result.data.forEach(v => v.name += ' ' + symbol)
|
|
|
|
|
|
|
|
return {
|
|
|
|
data: result.data,
|
|
|
|
total: result.total
|
|
|
|
}
|
|
|
|
}
|