Browse Source
Add mastodon personal info field
Add mastodon personal info field
Signed-off-by: Carl Schwan <carl@carlschwan.eu>pull/34940/head
16 changed files with 231 additions and 22 deletions
-
6apps/provisioning_api/lib/Controller/UsersController.php
-
8apps/settings/css/settings.css
-
2apps/settings/css/settings.css.map
-
8apps/settings/css/settings.scss
-
9apps/settings/lib/Controller/UsersController.php
-
1apps/settings/lib/Settings/Personal/PersonalInfo.php
-
50apps/settings/src/components/PersonalInfo/MastodonSection.vue
-
5apps/settings/src/constants/AccountPropertyConstants.js
-
3apps/settings/src/main-personal-info.js
-
16apps/settings/templates/settings/personal/personal.info.php
-
2core/Controller/ClientFlowLoginV2Controller.php
-
40core/img/actions/mastodon.svg
-
9lib/private/Accounts/AccountManager.php
-
90lib/private/Profile/Actions/MastodonAction.php
-
2lib/private/Profile/ProfileManager.php
-
2lib/public/Accounts/IAccountManager.php
2
apps/settings/css/settings.css.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,50 @@ |
|||||
|
<!-- |
||||
|
- @copyright 2022 Christopher Ng <chrng8@gmail.com> |
||||
|
- |
||||
|
- @author Christopher Ng <chrng8@gmail.com> |
||||
|
- |
||||
|
- @license AGPL-3.0-or-later |
||||
|
- |
||||
|
- 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 <http://www.gnu.org/licenses/>. |
||||
|
- |
||||
|
--> |
||||
|
|
||||
|
<template> |
||||
|
<AccountPropertySection v-bind.sync="mastodon" |
||||
|
:placeholder="t('settings', 'Your Mastodon handle')" /> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { loadState } from '@nextcloud/initial-state' |
||||
|
|
||||
|
import AccountPropertySection from './shared/AccountPropertySection.vue' |
||||
|
|
||||
|
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js' |
||||
|
|
||||
|
const { mastodon } = loadState('settings', 'personalInfoParameters', {}) |
||||
|
|
||||
|
export default { |
||||
|
name: 'TwitterSection', |
||||
|
|
||||
|
components: { |
||||
|
AccountPropertySection, |
||||
|
}, |
||||
|
|
||||
|
data() { |
||||
|
return { |
||||
|
mastodon: { ...mastodon, readable: NAME_READABLE_ENUM[mastodon.name] }, |
||||
|
} |
||||
|
}, |
||||
|
} |
||||
|
</script> |
||||
@ -0,0 +1,40 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
|
<svg |
||||
|
fill="#000000" |
||||
|
viewBox="0 0 32 32" |
||||
|
width="32px" |
||||
|
height="32px" |
||||
|
version="1.1" |
||||
|
id="svg4" |
||||
|
sodipodi:docname="mastodon.svg" |
||||
|
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)" |
||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
||||
|
xmlns="http://www.w3.org/2000/svg" |
||||
|
xmlns:svg="http://www.w3.org/2000/svg"> |
||||
|
<defs |
||||
|
id="defs8" /> |
||||
|
<sodipodi:namedview |
||||
|
id="namedview6" |
||||
|
pagecolor="#ffffff" |
||||
|
bordercolor="#000000" |
||||
|
borderopacity="0.25" |
||||
|
inkscape:showpageshadow="2" |
||||
|
inkscape:pageopacity="0.0" |
||||
|
inkscape:pagecheckerboard="0" |
||||
|
inkscape:deskcolor="#d1d1d1" |
||||
|
showgrid="false" |
||||
|
inkscape:zoom="27.21875" |
||||
|
inkscape:cx="23.990815" |
||||
|
inkscape:cy="11.646383" |
||||
|
inkscape:window-width="1920" |
||||
|
inkscape:window-height="1007" |
||||
|
inkscape:window-x="0" |
||||
|
inkscape:window-y="0" |
||||
|
inkscape:window-maximized="1" |
||||
|
inkscape:current-layer="svg4" /> |
||||
|
<path |
||||
|
d="M 16.092108,4.0424002e-4 C 12.062352,0.01674741 8.0611741,0.52836757 5.9792557,1.4882781 c 0,0 -4.4792557,2.0390593 -4.4792557,8.9845679 0,8.267636 -0.006,18.650381 7.4211287,20.658254 2.8443783,0.76446 5.2904523,0.928996 7.2569683,0.815594 3.568811,-0.201455 5.333936,-1.295049 5.333936,-1.295049 l -0.119865,-2.637001 c 0,0 -2.313201,0.815177 -5.177591,0.721787 -2.837706,-0.100064 -5.827232,-0.31302 -6.2928463,-3.856484 -0.042694,-0.329532 -0.063873,-0.663192 -0.062538,-0.995391 6.0129483,1.492897 11.1403013,0.650223 12.5518183,0.479455 3.941035,-0.478955 7.371787,-2.95017 7.809382,-5.208861 0.685746,-3.559473 0.627983,-8.682304 0.627983,-8.682304 0,-6.9455086 -4.47144,-8.9845679 -4.47144,-8.9845679 C 24.181616,0.4629949 20.121863,-0.01593892 16.092108,4.0424002e-4 Z M 11.779618,5.2978601 c 1.380664,0.037022 2.744984,0.6547271 3.585489,1.9595116 l 0.81299,1.3810381 0.810383,-1.3810381 c 1.687681,-2.6242446 5.470248,-2.4605003 7.269996,-0.429946 1.659664,1.9318288 1.289838,3.1786613 1.289838,11.8091823 v 0.0025 H 22.28333 v -7.509723 c 0,-3.5154475 -4.481861,-3.6512167 -4.481861,0.487271 v 4.351575 H 14.55733 V 11.6167 c 0,-4.1384877 -4.479254,-4.0053242 -4.479254,-0.489878 v 7.509724 H 6.8052731 c 0,-8.6371452 -0.3631558,-9.8919821 1.2898381,-11.8091356 C 9.0016558,5.8054625 10.398956,5.2608226 11.779618,5.2978448 Z" |
||||
|
id="path2" |
||||
|
style="stroke-width:1.33413" /> |
||||
|
</svg> |
||||
@ -0,0 +1,90 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
/** |
||||
|
* @copyright 2021 Christopher Ng <chrng8@gmail.com> |
||||
|
* |
||||
|
* @author Christopher Ng <chrng8@gmail.com> |
||||
|
* |
||||
|
* @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 <http://www.gnu.org/licenses/>. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
namespace OC\Profile\Actions; |
||||
|
|
||||
|
use function Safe\substr; |
||||
|
use OCP\Accounts\IAccountManager; |
||||
|
use OCP\IURLGenerator; |
||||
|
use OCP\IUser; |
||||
|
use OCP\L10N\IFactory; |
||||
|
use OCP\Profile\ILinkAction; |
||||
|
|
||||
|
class MastodonAction implements ILinkAction { |
||||
|
private ?string $value = null; |
||||
|
private IAccountManager $accountManager; |
||||
|
private IFactory $l10nFactory; |
||||
|
private IURLGenerator $urlGenerator; |
||||
|
|
||||
|
public function __construct( |
||||
|
IAccountManager $accountManager, |
||||
|
IFactory $l10nFactory, |
||||
|
IURLGenerator $urlGenerator |
||||
|
) { |
||||
|
$this->accountManager = $accountManager; |
||||
|
$this->l10nFactory = $l10nFactory; |
||||
|
$this->urlGenerator = $urlGenerator; |
||||
|
} |
||||
|
|
||||
|
public function preload(IUser $targetUser): void { |
||||
|
$account = $this->accountManager->getAccount($targetUser); |
||||
|
$this->value = $account->getProperty(IAccountManager::PROPERTY_MASTODON)->getValue(); |
||||
|
} |
||||
|
|
||||
|
public function getAppId(): string { |
||||
|
return 'core'; |
||||
|
} |
||||
|
|
||||
|
public function getId(): string { |
||||
|
return IAccountManager::PROPERTY_MASTODON; |
||||
|
} |
||||
|
|
||||
|
public function getDisplayId(): string { |
||||
|
return $this->l10nFactory->get('lib')->t('Mastodon'); |
||||
|
} |
||||
|
|
||||
|
public function getTitle(): string { |
||||
|
$displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value; |
||||
|
return $this->l10nFactory->get('lib')->t('View %s on Mastodon', [$displayUsername]); |
||||
|
} |
||||
|
|
||||
|
public function getPriority(): int { |
||||
|
return 50; |
||||
|
} |
||||
|
|
||||
|
public function getIcon(): string { |
||||
|
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mastodon.svg')); |
||||
|
} |
||||
|
|
||||
|
public function getTarget(): ?string { |
||||
|
if (empty($this->value)) { |
||||
|
return null; |
||||
|
} |
||||
|
$username = $this->value[0] === '@' ? substr($this->value, 1) : $this->value; |
||||
|
[$username, $instance] = explode('@', $username); |
||||
|
return 'https://' . $instance . '/@' . $username; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue