forked from GNUsocial/gnu-social
URL shortening can now be disabled for the 'maxurllength'
Also, URL shortening now consistently uses 'maxurllength'...
This commit is contained in:
parent
34a6624452
commit
87370f0cb1
10
CONFIGURE
10
CONFIGURE
@ -794,14 +794,14 @@ external: external links in notices. One of three values: 'sometimes',
|
|||||||
url
|
url
|
||||||
---
|
---
|
||||||
|
|
||||||
Everybody loves URL shorteners. These are some options for fine-tuning
|
These are some options for fine-tuning how and when the server will
|
||||||
how and when the server shortens URLs.
|
shorten URLs.
|
||||||
|
|
||||||
shortener: URL shortening service to use by default. Users can override
|
shortener: URL shortening service to use by default. Users can override
|
||||||
individually. 'ur1.ca' by default.
|
individually. 'internal' by default.
|
||||||
maxlength: If an URL is strictly longer than this limit, it will be
|
maxurllength: If an URL is strictly longer than this limit, it will be
|
||||||
shortened. Note that the URL shortener service may return an
|
shortened. Note that the URL shortener service may return an
|
||||||
URL longer than this limit. Defaults to 25. Users can
|
URL longer than this limit. Defaults to 100. Users can
|
||||||
override. If set to 0, all URLs will be shortened.
|
override. If set to 0, all URLs will be shortened.
|
||||||
maxnoticelength: If a notice is strictly longer than this limit, all
|
maxnoticelength: If a notice is strictly longer than this limit, all
|
||||||
URLs in the notice will be shortened. Users can override.
|
URLs in the notice will be shortened. Users can override.
|
||||||
|
@ -61,7 +61,7 @@ class ApiStatusnetConfigAction extends ApiAction
|
|||||||
'xmpp' => array('enabled', 'server', 'port', 'user'),
|
'xmpp' => array('enabled', 'server', 'port', 'user'),
|
||||||
'integration' => array('source'),
|
'integration' => array('source'),
|
||||||
'attachments' => array('uploads', 'file_quota'),
|
'attachments' => array('uploads', 'file_quota'),
|
||||||
'url' => array('maxlength', 'maxnoticelength'),
|
'url' => array('maxurllength', 'maxnoticelength'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +136,7 @@ class UrlsettingsAction extends SettingsAction
|
|||||||
(!is_null($this->arg('maxurllength'))) ?
|
(!is_null($this->arg('maxurllength'))) ?
|
||||||
$this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user),
|
$this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user),
|
||||||
// TRANS: Field title in URL settings in profile.
|
// TRANS: Field title in URL settings in profile.
|
||||||
_('URLs longer than this will be shortened, 0 means always shorten.'));
|
_('URLs longer than this will be shortened, -1 means never shorten because a URL is long.'));
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
$this->input('maxnoticelength',
|
$this->input('maxnoticelength',
|
||||||
@ -145,7 +145,7 @@ class UrlsettingsAction extends SettingsAction
|
|||||||
(!is_null($this->arg('maxnoticelength'))) ?
|
(!is_null($this->arg('maxnoticelength'))) ?
|
||||||
$this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user),
|
$this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user),
|
||||||
// TRANS: Field title in URL settings in profile.
|
// TRANS: Field title in URL settings in profile.
|
||||||
_('URLs in notices longer than this will always be shortened, -1 means shorten only if notice text exceeds maximum length.'));
|
_('URLs in notices longer than this will always be shortened, -1 means only shorten if the full post exceeds maximum length.'));
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
// TRANS: Button text for saving "Other settings" in profile.
|
// TRANS: Button text for saving "Other settings" in profile.
|
||||||
@ -183,7 +183,7 @@ class UrlsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
$maxurllength = $this->trimmed('maxurllength');
|
$maxurllength = $this->trimmed('maxurllength');
|
||||||
|
|
||||||
if (!Validate::number($maxurllength, array('min' => 0))) {
|
if (!Validate::number($maxurllength, array('min' => -1))) {
|
||||||
// TRANS: Client exception thrown when the maximum URL settings value is invalid in profile URL settings.
|
// TRANS: Client exception thrown when the maximum URL settings value is invalid in profile URL settings.
|
||||||
throw new ClientException(_('Invalid number for maximum URL length.'));
|
throw new ClientException(_('Invalid number for maximum URL length.'));
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class User_urlshortener_prefs extends Managed_DataObject
|
|||||||
|
|
||||||
static function maxUrlLength($user)
|
static function maxUrlLength($user)
|
||||||
{
|
{
|
||||||
$def = common_config('url', 'maxlength');
|
$def = common_config('url', 'maxurllength');
|
||||||
|
|
||||||
$prefs = self::getPrefs($user);
|
$prefs = self::getPrefs($user);
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ $default =
|
|||||||
'external' => 'sometimes'), // Options: 'sometimes', 'never', default = 'sometimes'
|
'external' => 'sometimes'), // Options: 'sometimes', 'never', default = 'sometimes'
|
||||||
'url' =>
|
'url' =>
|
||||||
array('shortener' => 'internal',
|
array('shortener' => 'internal',
|
||||||
'maxlength' => 100,
|
'maxurllength' => 100,
|
||||||
'maxnoticelength' => -1),
|
'maxnoticelength' => -1),
|
||||||
'http' => // HTTP client settings when contacting other sites
|
'http' => // HTTP client settings when contacting other sites
|
||||||
array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt')
|
array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt')
|
||||||
|
@ -2155,7 +2155,7 @@ function common_shorten_url($long_url, User $user=null, $force = false)
|
|||||||
// $force forces shortening even if it's not strictly needed
|
// $force forces shortening even if it's not strictly needed
|
||||||
// I doubt URL shortening is ever 'strictly' needed. - ESP
|
// I doubt URL shortening is ever 'strictly' needed. - ESP
|
||||||
|
|
||||||
if (mb_strlen($long_url) < $maxUrlLength && !$force) {
|
if (($maxUrlLength == -1 || mb_strlen($long_url) < $maxUrlLength) && !$force) {
|
||||||
return $long_url;
|
return $long_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user