This commit is contained in:
alban 2019-09-22 18:35:08 +02:00
commit 2535f53310
6 changed files with 182 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Hello World plugin
Just a PeerTube plugin example, that says "Hello world".

3
assets/style.css Normal file
View File

@ -0,0 +1,3 @@
body {
--mainBackgroundColor: black !important;
}

View File

@ -0,0 +1,90 @@
function register ({ registerHook, peertubeHelpers }) {
registerHook({
target: 'action:application.init',
handler: () => onApplicationInit(peertubeHelpers)
})
// Videos list
registerHook({
target: 'filter:api.trending-videos.videos.list.params',
handler: params => Object.assign({}, params, { sort: '-views' })
})
registerHook({
target: 'filter:api.trending-videos.videos.list.result',
handler: result => addSymbolToVideoNameResult(result, '<3')
})
registerHook({
target: 'filter:api.local-videos.videos.list.params',
handler: params => Object.assign({}, params, { sort: '-views' })
})
registerHook({
target: 'filter:api.local-videos.videos.list.result',
handler: result => addSymbolToVideoNameResult(result, ':)')
})
registerHook({
target: 'filter:api.recently-added-videos.videos.list.params',
handler: params => Object.assign({}, params, { filter: 'all-local' })
})
registerHook({
target: 'filter:api.recently-added-videos.videos.list.result',
handler: result => addSymbolToVideoNameResult(result, 'o/')
})
registerHook({
target: 'filter:api.user-subscriptions-videos.videos.list.params',
handler: params => Object.assign({}, params, { sort: '-views' })
})
registerHook({
target: 'filter:api.user-subscriptions-videos.videos.list.result',
handler: result => addSymbolToVideoNameResult(result, ':D')
})
// Router hooks
registerHook({
target: 'action:router.navigation-end',
handler: params => console.log('New URL! %s.', params.path)
})
// Fake hook
registerHook({
target: 'fakeHook',
handler: () => console.log('fake hook')
})
}
export {
register
}
function onApplicationInit (peertubeHelpers) {
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 + ')'
peertubeHelpers.translate('User name')
.then(translation => console.log('Translated User name by ' + translation))
}
function addSymbolToVideoNameResult (result, symbol) {
result.data.forEach(v => v.name += ' ' + symbol)
return {
data: result.data,
total: result.total
}
}

58
main.js Normal file
View File

@ -0,0 +1,58 @@
/**
* Based on chocobozz hello world + framalogo plugin examples
* @since 2019-09-21
* @author alban
* @license GPLv3+
*/
async function register ({
registerHook,
registerSetting,
settingsManager,
storageManager,
videoCategoryManager,
videoLicenceManager,
videoLanguageManager
}) {
videoCategoryManager.deleteCategory(2); // Films
videoCategoryManager.deleteCategory(3); // Vehicles
videoCategoryManager.deleteCategory(5); // Sports
videoCategoryManager.deleteCategory(6); // Travels
videoCategoryManager.deleteCategory(9); // Comedy
videoCategoryManager.deleteCategory(10); // Entertainment
videoCategoryManager.deleteCategory(11); // News & Politics
videoCategoryManager.deleteCategory(15); // Science & Technology
videoCategoryManager.deleteCategory(16); // Animals
videoCategoryManager.deleteCategory(17); // Kids
videoCategoryManager.deleteCategory(18); // Food
videoCategoryManager.deleteCategory(12); // How To
// 1 Music
// 4 Art
// 7 Gaming
// 8 People
// 13 Education
// 14 Activism
videoCategoryManager.addCategory(100); // Workshops
videoCategoryManager.addCategory(101); // Presentations
videoCategoryManager.addCategory(102); // Conferences
videoCategoryManager.addCategory(103); // Software
videoCategoryManager.addCategory(104); // DIY
videoCategoryManager.addCategory(105); // Electronics
videoCategoryManager.addCategory(106); // Demos
videoCategoryManager.addCategory(107); // Hardware
videoCategoryManager.addCategory(108); // Sysadmin
}
async function unregister () {
return
}
module.exports = {
register,
unregister
}

28
package.json Normal file
View File

@ -0,0 +1,28 @@
{
"name": "peertube-plugin-interhack",
"version": "0.1",
"description": "Interhack PeerTube plugin",
"engine": {
"peertube": ">=1.3.0"
},
"keywords": [
"peertube",
"plugin"
],
"homepage": "https://git.interhacker.space/alban/peertube-plugin-interhack",
"author": "alban",
"bugs": "https://git.interhacker.space/alban/peertube-plugin-interhack/issues",
"library": "./main.js",
"staticDirs": {
"images": "public/images"
},
"css": [
"assets/style.css",
],
"clientScripts": [
{
"script": "client/common-client-plugin.js",
"scopes": [ "common" ]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 KiB