mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +02:00
Merge branch 'release-4.1.0'
This commit is contained in:
10
NEWS
10
NEWS
@ -1,3 +1,13 @@
|
|||||||
|
Version 7.1.0 (2017-08-24)
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- New: Mark sections that are not to be automatically linked with the new `<noautolinks>..</noautolinks>` tag.
|
||||||
|
- New: Mark sections that are to be automatically linked with the new `<autolinks>..</autolinks>` tag. This tag only makes sense on pages with the `__NOAUTOLINKS__` magic word, or if both `$wgLinkTitlesParseOnEdit` and `$wgLinkTitlesParseOnRender` are set to false. Note that this tag is parsed when a page is rendered, not when it is saved. Therefore, the links will not appear in the page source.
|
||||||
|
- Fix: Properly handle templates that include other templates.
|
||||||
|
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
|
||||||
Version 4.0.9 (2017-03-21)
|
Version 4.0.9 (2017-03-21)
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ branch, as I follow Vincent Driessen's advice on [A successful Git branching
|
|||||||
model](http://nvie.com/git-model) (knowing that there are [alternative
|
model](http://nvie.com/git-model) (knowing that there are [alternative
|
||||||
workflows](http://scottchacon.com/2011/08/31/github-flow.html)).
|
workflows](http://scottchacon.com/2011/08/31/github-flow.html)).
|
||||||
|
|
||||||
|
The `master` branch contains stable releases only, so it is safe to pull the
|
||||||
|
master branch if you want to install the extension for your own wiki.
|
||||||
|
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
],
|
],
|
||||||
"type": "parserhook",
|
"type": "parserhook",
|
||||||
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
|
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
|
||||||
"version": "4.0.9",
|
"version": "4.1.0",
|
||||||
"license-name": "GPL-2.0+",
|
"license-name": "GPL-2.0+",
|
||||||
"descriptionmsg": "linktitles-desc",
|
"descriptionmsg": "linktitles-desc",
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -56,6 +56,9 @@
|
|||||||
],
|
],
|
||||||
"GetDoubleUnderscoreIDs": [
|
"GetDoubleUnderscoreIDs": [
|
||||||
"LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
|
"LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
|
||||||
|
],
|
||||||
|
"ParserFirstCallInit": [
|
||||||
|
"LinkTitles\\Extension::onParserFirstCallInit"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"callback": "LinkTitles\\Extension::setup",
|
"callback": "LinkTitles\\Extension::setup",
|
||||||
|
2
gh-pages
2
gh-pages
Submodule gh-pages updated: 2dec0ce8a6...076be774a2
@ -45,8 +45,8 @@ class Extension {
|
|||||||
/// A Title object for the target page currently being examined.
|
/// A Title object for the target page currently being examined.
|
||||||
private static $targetTitle;
|
private static $targetTitle;
|
||||||
|
|
||||||
// The TitleValue object of the target page
|
// The TitleValue object of the target page
|
||||||
private static $targetTitleValue;
|
private static $targetTitleValue;
|
||||||
|
|
||||||
/// The content object for the currently processed target page.
|
/// The content object for the currently processed target page.
|
||||||
/// This variable is necessary to be able to prevent loading the target
|
/// This variable is necessary to be able to prevent loading the target
|
||||||
@ -153,10 +153,10 @@ class Extension {
|
|||||||
// Escape certain special characters in the page title to prevent
|
// Escape certain special characters in the page title to prevent
|
||||||
// regexp compilation errors
|
// regexp compilation errors
|
||||||
self::$targetTitleText = self::$targetTitle->getText();
|
self::$targetTitleText = self::$targetTitle->getText();
|
||||||
$quotedTitle = preg_quote(self::$targetTitleText, '/');
|
$quotedTitle = preg_quote( self::$targetTitleText, '/' );
|
||||||
|
|
||||||
self::ltDebugLog('TargetTitle='. self::$targetTitleText,"private");
|
self::ltDebugLog( 'TargetTitle='. self::$targetTitleText, 'private' );
|
||||||
self::ltDebugLog('TargetTitleQuoted='. $quotedTitle,"private");
|
self::ltDebugLog( 'TargetTitleQuoted='. $quotedTitle, 'private' );
|
||||||
|
|
||||||
// Depending on the global configuration setting $wgCapitalLinks,
|
// Depending on the global configuration setting $wgCapitalLinks,
|
||||||
// the title has to be searched for either in a strictly case-sensitive
|
// the title has to be searched for either in a strictly case-sensitive
|
||||||
@ -247,6 +247,27 @@ class Extension {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function onParserFirstCallInit( \Parser $parser ) {
|
||||||
|
$parser->setHook( 'noautolinks', 'LinkTitles\Extension::doNoautolinksTag' );
|
||||||
|
$parser->setHook( 'autolinks', 'LinkTitles\Extension::doAutolinksTag' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the extra tag that this extension provides (<noautolinks>)
|
||||||
|
/// by simply returning the text between the tags (if any).
|
||||||
|
/// See https://www.mediawiki.org/wiki/Manual:Tag_extensions#Example
|
||||||
|
public static function doNoautolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
|
||||||
|
return htmlspecialchars( $input );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the extra tag that this extension provides (<noautolinks>)
|
||||||
|
/// by simply returning the text between the tags (if any).
|
||||||
|
/// See https://www.mediawiki.org/wiki/Manual:Tag_extensions#How_do_I_render_wikitext_in_my_extension.3F
|
||||||
|
public static function doAutolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
|
||||||
|
$withLinks = self::parseContent( $parser->getTitle(), $input );
|
||||||
|
$output = $parser->recursiveTagParse( $withLinks, $frame );
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
// Fetches the page titles from the database.
|
// Fetches the page titles from the database.
|
||||||
// @param $currentNamespace String holding the namespace of the page currently being processed.
|
// @param $currentNamespace String holding the namespace of the page currently being processed.
|
||||||
private static function fetchPageTitles( $currentNamespace ) {
|
private static function fetchPageTitles( $currentNamespace ) {
|
||||||
@ -424,10 +445,10 @@ class Extension {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds the delimiter that is used in a regexp to separate
|
/// Builds the delimiter that is used in a regexp to separate
|
||||||
/// text that should be parsed from text that should not be
|
/// text that should be parsed from text that should not be
|
||||||
/// parsed (e.g. inside existing links etc.)
|
/// parsed (e.g. inside existing links etc.)
|
||||||
private static function BuildDelimiters() {
|
private static function BuildDelimiters() {
|
||||||
// Configuration variables need to be defined here as globals.
|
// Configuration variables need to be defined here as globals.
|
||||||
global $wgLinkTitlesParseHeadings;
|
global $wgLinkTitlesParseHeadings;
|
||||||
global $wgLinkTitlesSkipTemplates;
|
global $wgLinkTitlesSkipTemplates;
|
||||||
@ -443,7 +464,9 @@ private static function BuildDelimiters() {
|
|||||||
|
|
||||||
if ( $wgLinkTitlesSkipTemplates )
|
if ( $wgLinkTitlesSkipTemplates )
|
||||||
{
|
{
|
||||||
$templatesDelimiter = '{{[^}]+}}|';
|
// Use recursive regex to balance curly braces;
|
||||||
|
// see http://www.regular-expressions.info/recurse.html
|
||||||
|
$templatesDelimiter = '{{(?>[^{}]|(?R))*}}|';
|
||||||
} else {
|
} else {
|
||||||
// Match template names (ignoring any piped [[]] links in them)
|
// Match template names (ignoring any piped [[]] links in them)
|
||||||
// along with the trailing pipe and parameter name or closing
|
// along with the trailing pipe and parameter name or closing
|
||||||
@ -478,28 +501,27 @@ private static function BuildDelimiters() {
|
|||||||
'<span.+?>|<\/span>|' . // attributes of span elements
|
'<span.+?>|<\/span>|' . // attributes of span elements
|
||||||
'<file>[^<]*<\/file>|' . // stuff inside file elements
|
'<file>[^<]*<\/file>|' . // stuff inside file elements
|
||||||
'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables)
|
'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables)
|
||||||
|
'<noautolinks>.*?<\/noautolinks>|' . // custom tag 'noautolinks'
|
||||||
'\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls
|
'\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls
|
||||||
'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
|
'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
|
||||||
')/ismS';
|
')/ismS';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Local Debugging output function which can send output to console as well
|
||||||
|
public static function ltDebugLog($text) {
|
||||||
|
if ( self::$ltConsoleOutputDebug ) {
|
||||||
|
print $text . "\n";
|
||||||
}
|
}
|
||||||
|
wfDebugLog( 'LinkTitles', $text , 'private' );
|
||||||
|
}
|
||||||
|
|
||||||
/// Local Debugging output function which can send output to console as well
|
/// Local Logging output function which can send output to console as well
|
||||||
public static function ltDebugLog($text) {
|
public static function ltLog($text) {
|
||||||
if (self::$ltConsoleOutputDebug)
|
if (self::$ltConsoleOutput) {
|
||||||
{
|
print $text . "\n";
|
||||||
print $text . "\n";
|
}
|
||||||
}
|
wfDebugLog( 'LinkTitles', $text , 'private' );
|
||||||
wfDebugLog('LinkTitles', $text , 'private');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Local Logging output function which can send output to console as well
|
|
||||||
public static function ltLog($text) {
|
|
||||||
if (self::$ltConsoleOutput)
|
|
||||||
{
|
|
||||||
print $text . "\n";
|
|
||||||
}
|
|
||||||
wfDebugLog('LinkTitles', $text , 'private');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2:sw=2:noet:comments^=\:///
|
// vim: ts=2:sw=2:noet:comments^=\:///
|
||||||
|
Reference in New Issue
Block a user