diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 664798c0..1324c806 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -37,11 +37,13 @@ use OCA\Social\Search\UnifiedSearchProvider; use OCA\Social\Service\ConfigService; use OCA\Social\Service\UpdateService; use OCA\Social\WellKnown\WebfingerHandler; +use OCA\Social\Listeners\ProfileSectionListener; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\QueryException; +use OCP\Profile\BeforeTemplateRenderedEvent; use OCP\IDBConnection; use OCP\IServerContainer; use OC\DB\SchemaWrapper; @@ -62,19 +64,12 @@ class Application extends App implements IBootstrap { parent::__construct(self::APP_NAME, $params); } - - /** - * @param IRegistrationContext $context - */ public function register(IRegistrationContext $context): void { $context->registerSearchProvider(UnifiedSearchProvider::class); $context->registerWellKnownHandler(WebfingerHandler::class); + $context->registerEventListener(BeforeTemplateRenderedEvent::class, ProfileSectionListener::class); } - - /** - * @param IBootContext $context - */ public function boot(IBootContext $context): void { $manager = $context->getServerContainer() ->getNotificationManager(); diff --git a/lib/Listeners/ProfileSectionListener.php b/lib/Listeners/ProfileSectionListener.php new file mode 100644 index 00000000..41d0fdf6 --- /dev/null +++ b/lib/Listeners/ProfileSectionListener.php @@ -0,0 +1,21 @@ + +// SPDX-License-Identifier: AGPL-3.0-or-later + +namespace OCA\Social\Listeners; + +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Profile\BeforeTemplateRenderedEvent; +use OCP\Util; + +class ProfileSectionListener implements IEventListener { + public function handle(Event $event): void { + if (!($event instanceof BeforeTemplateRenderedEvent)) { + return; + } + Util::addScript('social', 'social-profilePage'); + } +} diff --git a/src/components/TimelineEntry.vue b/src/components/TimelineEntry.vue index efa2af96..465359b3 100644 --- a/src/components/TimelineEntry.vue +++ b/src/components/TimelineEntry.vue @@ -11,7 +11,7 @@
- + @@ -50,7 +50,14 @@ export default { UserEntry }, props: { - item: { type: Object, default: () => {} } + item: { + type: Object, + default: () => {} + }, + isProfilePage: { + type: Boolean, + default: false, + }, }, data() { return { diff --git a/src/components/TimelinePost.vue b/src/components/TimelinePost.vue index 7a85388a..eb07ff9d 100644 --- a/src/components/TimelinePost.vue +++ b/src/components/TimelinePost.vue @@ -32,7 +32,7 @@
-
+
diff --git a/src/mixins/serverData.js b/src/mixins/serverData.js index eff54329..42fd4a03 100644 --- a/src/mixins/serverData.js +++ b/src/mixins/serverData.js @@ -37,6 +37,9 @@ export default { * @property setup */ serverData() { + if (!this.$store) { + return {} + } return this.$store.getters.getServerData }, hostname() { diff --git a/src/profile.js b/src/profile.js new file mode 100644 index 00000000..d0066453 --- /dev/null +++ b/src/profile.js @@ -0,0 +1,26 @@ +// SPDX-FileCopyrigthText: 2022 Carl Schwan +// SPDX-License-Identifier: AGPL-3.0-or-later + +// eslint-disable-next-line +__webpack_nonce__ = btoa(OC.requestToken) +// eslint-disable-next-line +__webpack_public_path__ = OC.linkTo('social', 'js/') + +import ProfilePageIntegration from './views/ProfilePageIntegration.vue' +import Vue from 'vue' +import { sync } from 'vuex-router-sync' + +if (!OCA?.Core?.ProfileSections) { + exit(); +} + +Vue.prototype.t = t +Vue.prototype.n = n +Vue.prototype.OC = OC +Vue.prototype.OCA = OCA + +const View = Vue.extend(ProfilePageIntegration) + +OCA.Core.ProfileSections.registerSection((el, userId) => { + return View +}) diff --git a/src/views/ProfilePageIntegration.vue b/src/views/ProfilePageIntegration.vue new file mode 100644 index 00000000..b2d083d6 --- /dev/null +++ b/src/views/ProfilePageIntegration.vue @@ -0,0 +1,59 @@ + + + diff --git a/webpack.common.js b/webpack.common.js index 19793810..d432a44c 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -7,6 +7,7 @@ const webpackConfig = require('@nextcloud/webpack-vue-config') webpackConfig.entry = { social: path.join(__dirname, 'src', 'main.js'), ostatus: path.join(__dirname, 'src', 'ostatus.js'), + profilePage: path.join(__dirname, 'src', 'profile.js'), } module.exports = webpackConfig