Jump to content

Расширение:UserProfileV2

From mediawiki.org
This page is a translated version of the page Extension:UserProfileV2 and the translation is 100% complete.
Справка по расширениям MediaWiki
UserProfileV2
Статус релиза: стабильно
Реализация API , База данных , MyWiki
Описание Интерактивное отображение страницы профиля пользователя
Автор(ы) Telepedia (Original Authorityобсуждение)
Последняя версия 1.0.4 (2025/03/02)
Политика совместимости Основная ветвь поддерживает обратную совместимость.
MediaWiki 1.41+
PHP 8.0+
Лицензия GNU General Public License 2.0 или позднее
Скачать
README
wgUserProfileV2Color, wgUserProfileV2AvatarBorderRadius, wgUserProfileV2Backend
profilemanager
Переведите расширение UserProfileV2

UserProfileV2 — это расширение MediaWiki для отображения профилей пользователей. Оно было создано как замена расширению SocialProfile на Telepedia и предназначено для предоставления более надёжных и базовых элементов профиля без превращения MediaWiki в социальную сеть.

UserProfileV2 было разработано с целью работы на вики-фермах, в первую очередь с Telepedia и Miraheze. На одиночных вики оно также будет работать, но разработка ориентирована на экосистему ферм с использованием CentralAuth.

Установка

  • Скачайте и распакуйте файл(ы) в папку с названием UserProfileV2 в вашей папке extensions/.
  • Добавьте следующий код в конце вашего файла LocalSettings.php :
    wfLoadExtension( 'UserProfileV2' );
    
  • Настройте, как вам требуется.
  • Yes Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.

Использование

UserProfileV2 will replace the default user page fetched when MediaWiki renders a page within the User: and User talk: namespaces. Содержание страницы участника будет отображаться прямо под шапкой сайта.

Все данные профиля хранятся в настройках и доступны через API с использованием JS. Участники могут править свой профиль, нажав кнопку редактирования на своей странице профиля или через настройки. Интерфейс для редактирования профиля со страницы участника полностью написан на JS, поэтому не будет работать, если тот отключён. Аватар также возможно изменить прямо со страницы участника.

System Administrators etc can assign the profilemanager permission to a specific user group to allow them to modify a users profile to remove spam etc. Тот, у кого есть это право, может удалить аватар участника, но по очевидным причинам не может установить новый.

Примечания

  • В настоящее время нет поддержки для иных методов получения глобального аватара участника, кроме использования его идентификатора CentralAuth. Возможно, в будущем расширение будет зависеть от CentralIdProvider, но пока что нет.
  • При работе с фермами использование глобальных аватаров на одних вики, а локальных — на других должно быть относительно безопасным, поскольку глобальные аватары используют глобальный ключ кеша, а не локальный. Однако это ещё не было протестировано.

Хуки

UserProfileV2 provides one hook:

PHP

public static function onUserProfileV2ProfileAfterMasthead(User $user, &$html) {}

You have access to the $user, which corresponds to the user profile of the person you are viewing, and the $html, which you can use to add html to the output. The Html will appear below the user masthead and before the content of the page, such as:

public static function onUserProfileV2ProfileAfterMasthead(User $user, &$html): void {
		$html .= Html::warningBox(
			"This is {$user->getName()} user profile"
		);
	}

Configurations

Parameter Default Comment
$wgUserProfileV2Color #E1E1E1 The accent/secondary colour used for the extension. This is used as a background colour for the user group tags and the avatar edit button.
$wgUserProfileV2AvatarBorderRadius "50%" The border-radius applied to the user avatar.
$wgUserProfileV2Backend "" The backend that should be used for uploading avatars. Should correspond to a defined backend in $wgFileBackends
$wgUserProfileV2UseGlobalAvatars false Whether or not to signal that global avatars are being used. When set to true, the extension will construct a global cache key with a user id from CentralAuth instead of a local cache key. Do not set to true if you are not using CentralAuth as it will just throw exceptions.
$wgUserProfileGlobalUploadBaseUrl "" The base url for uploads if you are using a different backend (defined by $wgUserProfileV2Backend), or if you are using a backend like Amazon S3 via the AWS extension
$wgUserProfileV2CacheType "" The cache that UserProfileV2 should store generated paths to avatars. Should correspond to a key in $wgObjectCaches. If not set it will use ObjectCache::getLocalClusterInstance()

Avatars backend

UserProfileV2 will use the backend defined in $wgUserProfileV2Backend if it is set, which allows you to use a backend such as S3 or Swift. This must correspond to a backend registered with $wgFileBackends such as

$wgFileBackends[] = [
	'class'              => SwiftFileBackend::class,
	'name'               => 'userprofilev2',
	'wikiId'             => $wgDBname,
	// more configuration here
];

It is possible to have global avatars (instead of each wiki using its own avatars) if you set $wgFileBackends to something like:

$wgFileBackends[] = [
	'class' => 'AmazonS3FileBackend',
	'name' => 'telepedia-userprofile',
	'region' => 'eu-west-2',
	'wikiId' => 'global',
	'lockManager' => 'nullLockManager',
	'connTimeout' => 10,
	'reqTimeout' => 900,
	'containerPaths' => [
		"global-upv2avatars" => "static-test.telepedia.net/upv2avatars"
	],
];

The AWS extension is recommended. You also need to set $wgAWSBucketName and other configs required for the extension. When using global avatars you must provide the base URL for use in constructing the avatars, ie: $wgUserProfileGlobalUploadBaseUrl = 'https://s3.eu-west-2.amazonaws.com/static-test.telepedia.net'; as the path to the file will be appended automatically. (The extension purposefully does not use $wgUploadPath if you use a different backend because most will have this set with .../$wgDBname which will not work if you are using global avatars that all need to be read from one URL/directory independent of wiki context.

If you do not provide $wgUserProfileV2Backend then the extension will construct a new FSFileBackend([]) with configuration for individual wiki avatars.

See also