diff --git a/lib/Controller/OStatusController.php b/lib/Controller/OStatusController.php index 5d6b0f77..31eda483 100644 --- a/lib/Controller/OStatusController.php +++ b/lib/Controller/OStatusController.php @@ -42,7 +42,10 @@ use OCA\Social\Service\CurlService; use OCA\Social\Service\MiscService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http\TemplateResponse; use OCP\IRequest; +use OCP\IUserManager; +use OCP\IUserSession; class OStatusController extends Controller { @@ -64,6 +67,9 @@ class OStatusController extends Controller { /** @var MiscService */ private $miscService; + /** @var IUserManager */ + private $userSession; + /** * OStatusController constructor. @@ -76,7 +82,7 @@ class OStatusController extends Controller { */ public function __construct( IRequest $request, CacheActorService $cacheActorService, AccountService $accountService, - CurlService $curlService, MiscService $miscService + CurlService $curlService, MiscService $miscService, IUserSession $userSession ) { parent::__construct(Application::APP_NAME, $request); @@ -84,6 +90,7 @@ class OStatusController extends Controller { $this->accountService = $accountService; $this->curlService = $curlService; $this->miscService = $miscService; + $this->userSession = $userSession; } @@ -131,10 +138,24 @@ class OStatusController extends Controller { throw new RetrieveAccountFormatException(); } + $user = $this->userSession->getUser(); + if ($user === null) { + return $this->fail('Failed to retrieve current user'); + } + $template = $this->get('template', $link, ''); $url = str_replace('{uri}', $following->getAccount(), $template); - return $this->success(['url' => $url]); + return new TemplateResponse('social', 'ostatus', [ + 'serverData' => [ + 'url' => $url, + 'account' => $account, + 'currentUser' => [ + 'uid' => $user->getUID(), + 'displayName' => $user->getDisplayName(), + ] + ] + ], 'guest'); } catch (Exception $e) { return $this->fail($e); } diff --git a/src/ostatus.js b/src/ostatus.js new file mode 100644 index 00000000..b02f6b7e --- /dev/null +++ b/src/ostatus.js @@ -0,0 +1,41 @@ +/* + * @copyright Copyright (c) 2019 Julius Härtl + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import Vue from 'vue' +import store from './store' +import OStatus from './views/OStatus' + +// eslint-disable-next-line +__webpack_nonce__ = btoa(OC.requestToken) +// eslint-disable-next-line +__webpack_public_path__ = OC.linkTo('social', 'js/') + +Vue.prototype.t = t +Vue.prototype.n = n +Vue.prototype.OC = OC +Vue.prototype.OCA = OCA + +/* eslint-disable-next-line no-new */ +new Vue({ + render: h => h(OStatus), + store: store +}).$mount('#vue-content') diff --git a/src/views/OStatus.vue b/src/views/OStatus.vue new file mode 100644 index 00000000..dcda26b1 --- /dev/null +++ b/src/views/OStatus.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/templates/ostatus.php b/templates/ostatus.php new file mode 100644 index 00000000..dac1a5d0 --- /dev/null +++ b/templates/ostatus.php @@ -0,0 +1,28 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +script('social', 'ostatus'); +style('social', 'style'); +?> + +
diff --git a/webpack.common.js b/webpack.common.js index 65c22909..baaf5b52 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -3,11 +3,14 @@ const VueLoaderPlugin = require('vue-loader/lib/plugin'); module.exports = { - entry: path.join(__dirname, 'src', 'main.js'), + entry: { + social: path.join(__dirname, 'src', 'main.js'), + ostatus: path.join(__dirname, 'src', 'ostatus.js'), + }, output: { path: path.resolve(__dirname, './js'), publicPath: '/js/', - filename: 'social.js', + filename: '[name].js', chunkFilename: '[name].[chunkhash].js' }, module: {