Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
$conf['delay'] = 0;
$conf['linkall_inclusions'] = '';
$conf['linkall_exclusions'] = '';
$conf['linkall_points_to'] = '';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably call this linkall_target_inclusions, and create a linkall_target_exclusions to match.

1 change: 1 addition & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
$meta['delay'] = array('numeric', '_min' => 0, '_max' => 10000);
$meta['linkall_inclusions'] = array('regex');
$meta['linkall_exclusions'] = array('regex');
$meta['linkall_points_to'] = array('regex');
1 change: 1 addition & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
$lang['delay'] = 'Time in miliseconds to wait before showing a tooltip';
$lang['linkall_inclusions'] = 'When using the renderer plugin to add tooltips to all links, this is a regular expression for pages or namespaces to include. For example, "^wiki:|^stuff:" inludes only links from the wiki and stuff namespaces. Leave blank to include all pages.';
$lang['linkall_exclusions'] = 'A regular expression for pages or namespaces to exclude. When combined with linkall_inclusions, this means "Include these pages, except those pages"';
$lang['linkall_points_to'] = 'A regular expression for pages or namespaces that links must be pointing towards. If a link does not match this expression, the tooltip will not be generated. For example, "^:wiki:|^[.]" would show tooltips on any links in an included/not-excluded page that links to the ":wiki" namespace or any relative page respectively';
10 changes: 9 additions & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class renderer_plugin_autotooltip extends Doku_Renderer_xhtml {
/** @type helper_plugin_autotooltip m_helper */
private $m_helper;
private $m_exclude;
private $m_points;

public function __construct() {
global $ID;
Expand All @@ -24,6 +25,13 @@ public function __construct() {
$this->m_exclude =
(!empty($inclusions) && !preg_match("/$inclusions/", $ID)) ||
(!empty($exclusions) && preg_match("/$exclusions/", $ID));

// Set the regex for filtering link destinations
$points = $this->getConf('linkall_points_to');
if (empty($points)) {
$points = ".*";
}
Comment on lines +31 to +33
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more efficient to leave this empty, and test empty() in internallink, rather than force an extra regex test every time.

$this->m_points = "/$points/";
}


Expand All @@ -48,7 +56,7 @@ function canRender($format) {
*/
function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') {
global $ID;
if (!$this->m_exclude && page_exists($id) && $id != $ID) {
if (!$this->m_exclude && page_exists($id) && $id != $ID && preg_match($this->m_points,$id)) {
$meta = $this->m_helper->read_meta_fast($id);
$abstract = $meta['abstract'];

Expand Down