Jump to content

Extension:UrlShortener

From mediawiki.org
This page is a translated version of the page Extension:UrlShortener and the translation is 49% complete.
Outdated translations are marked like this.
Şununla karıştırılmamalıdır:


MediaWiki manüel uzantıları
UrlShortener
Sürüm durumu: kararlı
Uygulama Özel sayfa , API , Vikim
Açıklama Provides a basic URL shortening service
Yazar(lar) YuviPandamesaj
En son sürüm Continuous updates
MediaWiki 1.25+
PHP 5.4+
Veritabanı değişiklikleri Evet
  • $wgUrlShortenerAllowArbitraryPorts
  • $wgUrlShortenerAllowedDomains
  • $wgUrlShortenerEnableQrCode
  • $wgUrlShortenerQrCodeShortenLimit
  • $wgUrlShortenerUrlSizeLimit
  • $wgUrlShortenerServer
  • $wgUrlShortenerEnableSidebar
  • $wgUrlShortenerIdMapping
  • $wgUrlShortenerAltPrefix
  • $wgUrlShortenerApprovedDomains
  • $wgUrlShortenerTemplate
  • $wgUrlShortenerReadOnly
  • $wgUrlShortenerIdSet
  • urlshortener-manage-url
  • urlshortener-create-url
  • urlshortener-view-log
Lisans Apache Lisansı 2.0
İndir
Translatewiki.net adresinde mevcutsa, UrlShortener uzantısını çevirin
Sorunlar Açık görevler · Hata bildir


UrlShortener uzantısı, MediaWiki uzantısı olarak temel bir URL kısaltma hizmeti sağlar. Düzgün çalışması için web sunucunuzun yapılandırmasında bazı değişiklikler yapmanız gerekecektir. Başlangıçta URL Shortener RfC uygulamak için tasarlanmıştır.

UrlShortener'ı Wikimedia projeleriyle kullanma talimatları için m:Wikimedia URL Shortener sayfasındaki bilgilere bakın.

Kurulum

  • Dosyaları indirin ve extensions/ klasörünüzdeki UrlShortener adlı dizine yerleştirin.
    Developers and code contributors should install the extension from Git instead, using:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UrlShortener
    
  • LocalSettings.php dosyanızın altına aşağıdaki kodu ekleyin:
    wfLoadExtension( 'UrlShortener' );
    
  • Bu uzantının ihtiyaç duyduğu gerekli veritabanı tablolarını otomatik olarak oluşturacak betik güncelleme komutunu çalıştırın.
  • Gerektiği gibi yapılandırın.
  • Gerektiği gibi uyarlayın.
  • Yes Yapıldı – Uzantının başarıyla yüklendiğini doğrulamak için vikinizde Special:Version seçeneğine gidin.


Vagrant kurulumu:

  • Vagrant kullanıyorsanız, vagrant roles enable urlshortener --provision ile yükleyin
//example.com/r/foo düzgün çalışmasını sağlamak için web sunucunuz için yeniden yazma kuralları oluşturmanız gerekecektir. Apache için örnek kurallar uzantı içinde [$url sağlanır] şeklindedir.

Yapılandırma

LocalSettings.php

URL yönlendirme yapılandırması

Kısaltılmış URL'yi oluştururken kullanılacak şablonu yapılandırır. Bu özelliği kullanmak mod_rewrite (veya eşdeğeri) gerektirir. false (varsayılan) olarak ayarlanırsa, kısa URL'ler çok kısa olmayan /wiki/Special:UrlRedirector/5234 kullanır, çünkü web sunucusu yapılandırmasından bağımsız olarak çalışacaktır.

Kısa URL'lerinizin example.com/r/5234 şeklinde olmasını istiyorsanız, şunları ayarlarsınız:

$wgUrlShortenerTemplate = '/r/$1';

Kısa alan adı

Özel bir kısa alan adınız varsa, bunu kullanarak ayarlayabilirsiniz:

$wgUrlShortenerServer = "short.wiki";

false (varsayılan) olarak ayarlanırsa, $wgServer kullanır.

Küresel veri tabanı

Viki çiftliğiniz için tek bir merkezi veritabanı kullanmak istiyorsanız, bunu bir veritabanı adına ayarlayın. false (varsayılan) olarak ayarlanırsa, vikinin normal veritabanını kullanır.

$wgVirtualDomainsMapping['virtual-urlshortener'] = [ 'db' => '<shared-db>' ]

Keyfi bağlantı noktalarına izin ver

Varsayılan olarak, yalnızca 80 ve 443 bağlantı noktalarına sahip URL'ler kabul edilir ve otomatik olarak kaldırılır. Vikiniz özel bir bağlantı noktası kullanılarak oluşturulmuşsa, keyfi bağlantı noktaları olan URL'lerin kısaltılmasına izin vermek için bunu true olarak ayarlayın.

$wgUrlShortenerAllowArbitraryPorts = true;

AllowedDomains düzenli ifadesi

Kullanıcıların bağlantı gönderebileceği kabul edilebilir alanları yapılandırır. Bu bir dizi normal ifadesi. false (varsayılan) olarak ayarlanırsa, mevcut etki alanı için bir izin listesi oluşturur ($wgServer kullanarak).

$wgUrlShortenerAllowedDomains = false;

Örneğin, yalnızca wikipedia.org veya wikimedia.org bağlantılarını beyaz listeye eklemek için aşağıdakileri kullanırız:

$wgUrlShortenerAllowedDomains = array(
	'(.*\.)?wikimedia\.org',
	'(.*\.)?wikipedia\.org',
);

Herhangi bir alana izin vermek istiyorsak:

$wgUrlShortenerAllowedDomains = array( '.*' );

ApprovedDomains belgelendirmesi

Bu, izin verilen alanların bir dizisidir, ancak insan tarafından okunabilir bir formdadır. Special:UrlShortener üzerinde görüntülenecektir.

false (varsayılan) olarak ayarlanırsa, $wgServer normalleştirilmiş bir sürümünü çıkarır.

$wgUrlShortenerApprovedDomains = false;

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

$wgUrlShortenerApprovedDomains = array(
	'*.wikimedia.org',
	'*.wikipedia.org',
);

Shortcode character set:

If you want to customize the character set the shortcodes use, you can override this setting. This should be done only once during the setup. Once changed thereafter, any existing short URLs will go to the wrong destination.

$wgUrlShortenerIdSet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz$';

The above string has been the default for many years, but could be problematic owing to the $ character which some social media platforms remove from URLs. New installations may wish to configure this to exclude $.

The first character in the list is treated as a leading zero; no shortcodes beginning with that character will be created, and it is ignored when used at the start of the shortcode in a URL (e.g. https://w.wiki/22222222w is the same as https://w.wiki/w).

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.

QR codes:

MediaWiki sürümü:
1.41

As of UrlShortener version 1.1.0, you can enable QR code sharing. This has two configurations settings. One is simply to enable QR code sharing.

$wgUrlShortenerEnableQrCode = true;

Note that currently, $wgUrlShortenerEnableSidebar must also be set if you want the "Karekodu indir" link to appear in the sidebar.

The link the QR codes point to is only shortened if it is very long. This is because users would prefer to see a familiar domain when scanning a QR code, but if the URL is too long then the pixel density of the QR code will be too difficult to scan. You can control the length of URLs that, when exceeded, will first be shortened before creating a QR code. The number here refers to the number of bytes, not characters.

$wgUrlShortenerQrCodeShortenLimit = 200;

VirtualHost veya .htaccess

To have truly short URLs, you will need to set up rewrite rules, using mod_rewrite or something similar. An example of what to put in your .htaccess file comes with the extension. If our template was set up to /r/$1, then we could use:

RewriteEngine On
RewriteRule ^r/(.*)$ /w/index.php?title=Special:UrlRedirector/$1 [PT]

If you are using nginx, you can add the following within a server directive:

location ~ ^/r/(.*) {
	return 301 /w/index.php?title=Special:UrlRedirector/$1;
}

This assumes your $wgScriptPath is set to /w.

Alternative URL

As the shortener will eventually start generating bad words in various languages, an alternative short URL beginning with _ is also created (see T230685).

To avoid this extra URL from being shown you can blank the page MediaWiki:Urlshortener-shortened-url-alt on your wiki.

API

This extension provides the API module action=shortenurl to get the shortened url for a given url, creating it if does not exist already. You can see the API documentation for help.

  • url - URL to shorten.

Yanıt:

{
    "shortenurl": {
        "shorturl": "http://127.0.0.1:8080/s/3"
    }
}

Special pages

  • Special:UrlShortener - Convert a full URL to a short URL.
  • Special:ManageShortUrls - Delete a short URL or restore a deleted one.
  • Special:UrlRedirector - With a short URL as parameter (e.g. Special:UrlRedirector/bb) this will redirect to the real URL.
  • Special:QrCode - See above.

Ayrıca bakınız