Index: extlink.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/extlink/extlink.js,v retrieving revision 1.4.2.4 diff -u -r1.4.2.4 extlink.js --- extlink.js 30 Sep 2008 01:55:59 -0000 1.4.2.4 +++ extlink.js 14 Mar 2009 04:54:59 -0000 @@ -17,6 +17,18 @@ // Build regular expressions that define an internal link. var internal_link = new RegExp("^https?://" + subdomains + host, "i"); + // Extra internal link matching. + var extInclude = false; + if (Drupal.settings.extlink.extInclude) { + extInclude = new RegExp(Drupal.settings.extlink.extInclude.replace(/\\/, '\\')); + } + + // Extra external link matching. + var extExclude = false; + if (Drupal.settings.extlink.extExclude) { + extExclude = new RegExp(Drupal.settings.extlink.extExclude.replace(/\\/, '\\')); + } + // Find all links which are NOT internal and begin with http (as opposed // to ftp://, javascript:, etc. other kinds of links. // When operating on the 'this' variable, the host has been appended to @@ -28,7 +40,7 @@ $("a", context).each(function(el) { try { var url = this.href.toLowerCase(); - if (url.indexOf('http') == 0 && !url.match(internal_link)) { + if (url.indexOf('http') == 0 && (!url.match(internal_link) || (extInclude && url.match(extInclude))) && !(extExclude && url.match(extExclude))) { external_links.push(this); } else if (url.indexOf('mailto:') == 0) { Index: extlink.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/extlink/extlink.module,v retrieving revision 1.3.2.2 diff -u -r1.3.2.2 extlink.module --- extlink.module 30 Apr 2008 02:58:24 -0000 1.3.2.2 +++ extlink.module 14 Mar 2009 04:54:59 -0000 @@ -24,6 +24,8 @@ 'extTarget' => variable_get('extlink_target', 0), 'extClass' => variable_get('extlink_class', 'ext'), 'extSubdomains' => variable_get('extlink_subdomains', 1), + 'extExclude' => variable_get('extlink_exclude', ''), + 'extInclude' => variable_get('extlink_include', ''), 'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'))), 'setting' ); if (variable_get('extlink_class', 'ext') == 'ext' || variable_get('extlink_mailto_class', 'mailto') == 'mailto') { @@ -64,6 +66,48 @@ '#default_value' => variable_get('extlink_target', 0), '#description' => t('Should all external links be opened in a new window?'), ); - + + $patterns = array( + '(example\.com) ' . t('Matches example.com.'), + '(example\.com)|(example.net) ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'), + '(links/goto/[0-9]+/[0-9]+) ' . t('Matches links that go through the Links module redirect.'), + ); + + $wildcards = array( + '. ' . t('Matches any character.'), + '? ' . t('The previous character or set is optional.'), + '\d ' . t('Matches any digit (0-9).'), + '[a-z] ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'), + ); + + $form['patterns'] = array( + '#tree' => FALSE, + '#type' => 'fieldset', + '#title' => t('Pattern matching'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#description' => + '

' . t('External links uses patterns (regular expressions) to match the "href" property of links.') . '

' . + t('Here are some common patterns.') . + theme('item_list', $patterns) . + t('Common special characters:') . + theme('item_list', $wildcards) . + '

' . t('All special characters (^ $ . ? ( ) | * +) must also be escaped with backslashes. Patterns are not case-sensitive. Any pattern supported by JavaScript may be used.') . '

', + ); + + $form['patterns']['extlink_exclude'] = array( + '#type' => 'textfield', + '#title' => t('Exclude links matching the pattern'), + '#default_value' => variable_get('extlink_exclude', ''), + '#description' => t('Enter a regular expression for links that you wish to exclude from being considered external.'), + ); + + $form['patterns']['extlink_include'] = array( + '#type' => 'textfield', + '#title' => t('Include links matching the pattern'), + '#default_value' => variable_get('extlink_include', ''), + '#description' => t('Enter a regular expression for internal links that you wish to be considered external.'), + ); + return system_settings_form($form); } \ No newline at end of file