commit 2535f533105c3c5958444f4d74fabc3bad780aff Author: alban Date: Sun Sep 22 18:35:08 2019 +0200 [init] diff --git a/README.md b/README.md new file mode 100644 index 0000000..96b7e7c --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Hello World plugin + +Just a PeerTube plugin example, that says "Hello world". diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 0000000..1a5aacc --- /dev/null +++ b/assets/style.css @@ -0,0 +1,3 @@ +body { + --mainBackgroundColor: black !important; +} diff --git a/client/common-client-plugin.js b/client/common-client-plugin.js new file mode 100644 index 0000000..ea916c1 --- /dev/null +++ b/client/common-client-plugin.js @@ -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 + } +} diff --git a/main.js b/main.js new file mode 100644 index 0000000..f306bd8 --- /dev/null +++ b/main.js @@ -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 +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..20246a2 --- /dev/null +++ b/package.json @@ -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" ] + } + ] +} diff --git a/public/images/interhack-logo.png b/public/images/interhack-logo.png new file mode 100644 index 0000000..debab4a Binary files /dev/null and b/public/images/interhack-logo.png differ