转到文件
Translation updater bot 6acfca8dde Localisation updates from https://translatewiki.net.
Change-Id: I126061c4da59a8b7c903d05a9f93485d5b3753a5
2024-05-13 09:28:13 +02:00
.phan Add phan 2019-04-28 20:38:40 +02:00
build Actually commit build/typos.json 2015-07-27 17:52:36 -07:00
i18n Localisation updates from https://translatewiki.net. 2024-05-13 09:28:13 +02:00
includes Inject service PermissionManager into ApiShortenUrl 2024-04-22 20:39:35 +00:00
maintenance Migrate to query builders and expression builders 2023-11-29 18:02:19 +01:00
modules Fix typo in qrCodeUiHandler function name 2024-01-31 13:14:25 +01:00
schemas Clean up some schema hooks 2024-01-02 11:26:49 +01:00
tests/phpunit Normalize URL before creating QR code 2024-02-13 15:47:13 -05:00
.eslintrc.json build: Update linters 2023-09-18 17:29:57 +01:00
.gitignore build: Update linters 2019-04-11 16:15:47 +01:00
.gitreview Whoops, track not trace 2016-10-24 17:04:01 -07:00
.phpcs.xml phpcs: Fix remaining rule exclusions 2023-05-11 15:23:04 +08:00
.stylelintrc.json build: Update linters 2023-09-18 17:29:57 +01:00
CODE_OF_CONDUCT.md build: Updating mediawiki/phan-taint-check-plugin to 1.3.0 2018-08-19 17:36:42 +00:00
COPYING Re-license using OSI-approved Apache 2.0 license 2016-03-11 13:07:56 -08:00
Gruntfile.js Add Special:QrCode page 2024-01-23 01:51:34 -05:00
README Add virtual- prefix to its virtual domain 2024-01-06 16:51:42 +00:00
UrlShortener.alias.php Translate special page names into Polish 2024-01-27 10:04:57 +00:00
UrlShortener.notranslate-alias.php Add phpcs and make pass 2017-06-02 22:49:13 +02:00
composer.json build: Updating composer dependencies 2024-05-08 10:20:09 +00:00
extension.json Inject service PermissionManager into ApiShortenUrl 2024-04-22 20:39:35 +00:00
package-lock.json build: Updating grunt-banana-checker to 0.12.0 2024-05-09 14:02:41 +00:00
package.json build: Updating grunt-banana-checker to 0.12.0 2024-05-09 14:02:41 +00:00
redirect.htaccess Use "/r/$1" in redirect.htaccess 2014-07-06 20:04:45 +00:00

README

The UrlShortener extension is a MediaWiki extension that accepts arbitrary urls
from a list of allowed domains and shortens them.

== Configuration ==

=== URL routing configuration ===

Configures the template to use when generating the shortened URL. Using this
feature will require mod_rewrite (or an equivalent). If set to false (default),
the short URLs will use the not-so-short
<code>/wiki/Special:UrlShortener/5234</code> since it will work regardless of
web server configuration.

If you wanted your short URLs in the form of <code>domain.org/r/5234</code>, you would set:

<source lang="php">
$wgUrlShortenerTemplate = '/r/$1';
</source>

=== Short domain name ===

If you have a custom short domain name, you can set it by using:

<source lang="php">
$wgUrlShortenerServer = "short.wiki";
</source>

If set to false (default), it will use $wgServer.

=== Global database ===

Set this to the name of a database if you wish to use one central database for your wiki farm.
<source lang="php">
$wgVirtualDomainsMapping['virtual-urlshortener'] = [ 'db' => 'wikishared' ];
</source>

If the database is on an external cluster, you will also need to configure that.
<source lang="php">
$wgVirtualDomainsMapping['virtual-urlshortener'] = [ 'cluster' => 'extension1', 'db' => 'wikishared' ];
</source>

=== Allow arbitrary ports ===

By default, only URLs with ports 80 and 443 are accepted and are automatically removed.
If your wiki is set up using a custom port, set this to true to allow shortening URLs
that have arbitrary ports.

<source lang="php">
$wgUrlShortenerAllowArbitraryPorts = true
</source>

=== AllowedDomains regex ===

Configures the acceptable domains that users can submit links for. This is an
array of regular expressions. If set to false (default), it will set up a allow-list for the current domain (using $wgServer).

<source lang="php">
$wgUrlShortenerAllowedDomains = false;
</source>

For example, to only allow links from wikipedia.org or wikimedia.org, we would use the following:

<source lang="php">
$wgUrlShortenerAllowedDomains = [
	'(.*\.)?wikimedia\.org',
	'(.*\.)?wikipedia\.org',
];
</source>

If we want to allow links from any domain:

<source lang="php">
$wgUrlShortenerAllowedDomains = [ '.*' ];
</source>

=== AllowedDomains documentation ===

To provide human-readable documentation of the list, this is an array of the allowed domains that will be displayed on Special:UrlShortener.

If set to false (default), it will output a normalized version of $wgServer.

<source lang="php">
$wgUrlShortenerApprovedDomains = false;
</source>

If you only allow wikipedia.org and wikimedia.org in the above example:

<source lang="php">
$wgUrlShortenerApprovedDomains = [
	'*.wikimedia.org',
	'*.wikipedia.org',
];
</source>

=== Shortcode character set ===

If you want to customize the character set the shortcodes use, you can override
this setting. If changed, any existing short URLs will go to the wrong
destination.

<source lang="php">
$wgUrlShortenerIdSet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz-';
</source>

In addition, for decoding a character mapping can be specified.
This can be used to map any symbol onto another and maintain
backwards-compatibility for previously generated URLs.
The following example maps the `$` symbol to `-`:

<source lang="php">
$wgUrlShortenerIdMapping = [ '$' => '-' ];
</source>

=== Read-only mode ===

Set $wgUrlShortenerReadOnly to true to prevent users from creating new
short URLs. This is mainly intended as a hack while deploying to Wikimedia sites
and will be removed once it is no longer needed.

== License ==

© 2014 Yuvaraj Pandian (yuvipanda@gmail.com) under the Apache 2.0 license,
see the COPYING file for the full license.