AutoLink Plugin for Movable Type

AutoLink provides users with a way of creating a list of "hot words." Whenever these words appear in a post, they are automatically linked to a designated URL. For example, if you were to frequently write about Movable Type, and anytime you mention the phrase "Movable Type" in a post you want it to be linked to http://www.movabletype.org/ without having to enter the link manually. This plugin will do that for you.

More advanced users could use AutoLink to setup linking rules that will turn Wiki formatted words into links into their internal/external wiki.

Prerequisites

Prior to installation, the following requirements must be satisfied:

  • User has MovableType 4.1 or later installed
    • it could work on 4.0, but it has not been tested

Download

Installation

To install this plugin follow the instructions found here:

http://tinyurl.com/easy-plugin-install

About AutoLink Rules

Users manage how AutoLink is to convert strings, phrases and patterns into linkified text through a set of "rules." Each rule has the following properties:

  • Label - a human readable description of the rule and its intention
  • Pattern - the string to convert into a link
  • Destination URL - the URL that the pattern will be linked to
  • Regular Expression? - Process the pattern specified as a regular expression, otherwise process it is a simple string or phrase
  • Link all occurrences? - Link all occurrences of the pattern, or just the first occurrence.
  • Case insensitive? - Make the pattern case insensitive.

Editing Your Rules

Each blog in your installation of Movable Type is allowed to manage its own unique set of AutoLink rules.

You can edit your list of AutoLink rules by clicking "AutoLink Rules" from the Manage menu in Movable Type.

Screenshots

AutoLink Rule Listing

Edit AutoLink Rule

See Also

43 Comments

Hi Byrne,

This looks awesome. I built something a little like this for WordPress years ago (Link Linker) but this is so much nicer!

What does the plugin do if "Link All Occurences" is unchecked?

--Steve

That's what I like to hear: Movable Type has quality plugins.

If "Link All Occurences" is unchecked, then AutoLink will link only the first occurrence.

While I'm at it, an idea: add active/inactive status so we can turn links on/off w/o deleting them.

Great idea. That will be in the next version. I need to also add support for link priorities and change AutoLink to apply only the first matching rule to the text.

My Todo list so far:

  • be able to disable/enable rules without deleting them
  • specify if you want links to go through a google redirect
  • specify if you want links to go through a google analytics click through tracker
  • specify rule priorities

Very nice!

Suggestion, though perhaps outside the scope of AutoLink: fold the Acronym plugin's functionality into this. Being able to easily edit the list of linked words is Acronym's shortcoming, and this may be a good solution to that.

@dan - that's a great idea re: acronyms, though I'd want the acronyms in a separate, managable list.

@byrne - how does AutoLink track clicks right now? (I noticed the "clicks" column in the manager...

It's a great plugin! Thank you!

Hi,

I receive an error message each time I save a posting:

Can't call method "stash" on an undefined value at /var/www/internet/yvesluther-name/live/cgi-bin/mt/plugins/AutoLink/lib/AutoLink/Plugin.pm line 102.

Any help is welcome!

Yves

Hey Byrne--just noticed something odd: The "created" time for any autolink rule is four hours off.

I noticed that too. I will be getting a new version out soon that will fix this, and also add support for dynamic publishing.

I had a problem as Yves Luther, besides, this plugins can't create Chinese character link automatically, I am not mean Chinese URL, but Chinese tags.

Good hint from @jackie: Though my blog is UTF-8 I use those pesky German special chars.

Maybe this is a valuable information for Byrne. Is it?

weird. i'm getting this error.

Publish error in template 'list.tmpl': Error in tag: No MT object class for type 'autolinkrules'.

I get this when i select "autolink rules" - i'm running the latest beta5

I need to use expression entered in "Pattern" to assembly a part of "Destination URL".

Is there a possibility?

Fantastic plugin, Byrne. If you're taking feature requests, I'd love for this to work on comments, too. And have the ability for rules to only target comments and not body text.

thanks boy.it is a good plugin

Fantastic plugin, Byrne.

Byrne,

Is there a way to include a href title in links as well (same text as anchor text)?

Thanks for the great plugin, Byrne! Just installed in and looking forward to using it.

I've got following error when using batch edit:

Can't call method "stash" on an undefined value at /var/www/vhosts/futurelab.net/cgi-bin/mt/plugins/AutoLink/lib/AutoLink/Plugin.pm line 103.

On a single entry everything's fine.

Hi Byrne,

This is a very worthy successor to QuickLink. The interface is much, much cleaner and easier to manage.

But QuickLink had one functionality that AutoLink seems to lack (or maybe I'm missing something).

In QuickLink, I could do this:

Text to replace:

\bxBBCx\b

Link:

<a href="http://www.bbc.co.uk/" title="BBC" target="_blank">British Broadcasting Corporation</a>

What this allowed me to do was:

  1. to expand a particular acronym used while writing ("BBC") to its full form ("British Broadcasting Corporation");

  2. Add the URL

  3. Specify a link title

  4. specify a target window/frame

Is there any way to do that with AutoLink? I found that functionality incredibly useful.

Thanks,

Gautam

I'm getting the same Can't call method of "Stash" error as others.

Did anyone find a fix to this?

Very nice!

Suggestion, though perhaps outside the scope of AutoLink: fold the Acronym plugin's functionality into this. Being able to easily edit the list of linked words is Acronym's shortcoming, and this may be a good solution to that

I'm having problem changing the display settings on the Autolink Rules page. I can set and save them but when the page redraws after the save the page appears the same and the settings are back to their defaults.

Any help would be appreciated. I would even be happy if someone could tell me how to tweak the database to alter the default 20 links per page to a bigger number.

Thanks - Neil

I love this plugin!

Is there anyway you can get AutoLink to work "globally". Instead of managing lists on individual blogs I could manage one master list and all blogs would use AutoLink?

I am afraid not. Not yet anyways. But that makes perfect sense, doesn't it. Let me add that to my list of things to do.

Is there anyway to make it so that an entry won't link to itself. For example, in an entry called 'Movable Type' I don't want to create links to every instance of the phrase 'Movable Type' in the Movable Type entry. I hope that makes sense.

Byrne

I'm getting a very unhelpful error:

"Can't call method "stash" on an undefined value "

Pity, as it sounded like it could have been really useful

Michele

Regarding "stash error", is it helpful to just replace the $ctx->stash('blog')->id with the real blog id, say 1, in my case?

This plugin is not support non-English characters, will it be updated?

Great Plugin! Important Notes:

1) The Plugin only works for new/existing entries that you edit in the Edit Entry Screen, then Save and Publish.

It does apply the links to already published entries by simply clicking Republish site. (I tried it.)

2) The URL displayed in the Auto-Link page is missing the "h" in the beginning of http. The "h" correctly appears when user clicks to edit the AutoLink Rule.

3) Rule-Created Time is 4 hours behind schedule (as noted by other Commenters).

1) CORRECTION: I meant to write-- It does NOT apply the links to already published entries by simply clicking Republish site. (I tried it.)

2) The STASH error is apparently not solved. Byrne, please help!

Just posted a few updates to AutoLink. 0.92 should fix the stash error and the date display error. Still working on how I could get this work when publishing directly from the listing screen.

Hi Bryne,

MT-Notifier died with: Can't call method "var" on an undefined value at /home/697/domains/design-ist.com/cgi-bin/mt/p lugins/AutoLink/lib/AutoLink/Plugin.pm line 103.

You may already know this issue but just in case, using mt4.25pro

I just released AutoLink 0.93 to fix this. Please let me know if it doesn't work.

Hello,

I have the latest version of Movable Type; however, after installation I can't access the admin area. I get redirected to /mt-upgrade.cgi ...

I tried to see if -- within the files -- there was a version limit setting ... but couldn't figure out how to get past this issue ...

Hey Byrne. I've made several attempts to get this plugin working but always failed. It only works in the "Preview Entry" mode (preview is generated statically, correct?).

  1. Is this plugin intended to work with dynamic templates also? (I use dynamic for all archive templates...)

  2. with Movable Type Pro version 4.31-en with: Community Pack 1.63, Professional Pack 1.3 -- I get a Smarty error: Fatal error: Smarty error: [plugin] modifier 'quicklink' is not implemented (core.load_plugins.php, line 118) in /home/path-to-mt/php/extlib/smarty/libs/Smarty.class.php on line 1095

Thanks for looking! I'm trying to build a semi-wiki using MT, this plugin would be a great help...

I read some of your articles and they are all wonderful. Thankyou! :-)

Thanks a lot I had a a nice read

This refers to my own post of August 17, 2008. Finally got back to this and figured it out, on the basis that Byrne probably has his hands full at the moment.

As I said, I wanted AutoLink to be what QuickLink was, a complete replacement alternative. I take text mytext and I get something like this:

My Expanded Text.

AutoLink doesn't do that. You have to make changes to: create.tmpl; CMS.pm and Plugin.pm to achieve this.

Create.tmpl

Located in mt/plugins/AutoLink/tmpl/dialog.

Go down to line 49. Where it says:

" class="full-width"/>

add the words encode_html="1" after the word "destination" so that it looks like this:

" class="full-width"/> CMS.pm Located in /mt/plugins/AutoLink/lib/AutoLink Comment out lines 89 to 94:
# my $uri_short = $rule->destination; # REMOVED BY GSP # if (length($uri_short) > 50) { # $uri_short =~ s/.*(.{50})$/\1/; # $row->{url} = $uri_short; # }

Plugin.pm

Located in /mt/plugins/AutoLink/lib/AutoLink

Remove lines 14 through 19

# sub remove_autolink_tags { # my ($txt) = @_; # REMOVED BY GSP # $txt =~ s!(.*)!$1!gm; # return $txt; # }

Lines 31 through 48 should be changed thus:

my $cmd = ""; # TODO - the text that is linked to needs to be tokenized and links added at the end if ($rule->regex) { # REMOVED # $cmd = '$text =~ s!('.$pattern.')!$1!'.$options; # ADDED $cmd = '$text =~ s!('.$pattern.')!'.$href.'!'.$options; } else { # REMOVED # $cmd = '$text =~ s!\b('.$pattern.')\b!$1!'.$options; # ADDED $cmd = '$text =~ s!\b('.$pattern.')\b!'.$href.'!'.$options; } eval $cmd; } return $text; }

and lines 57 to 60 should be commented out too:

# REMOVED # while ($text =~ s/(]*\>.*?)/"\${token-".++$count."}"/emi) { # $tokens{"token-$count"} = $1; # }

I'm not pretending this is any great program writing. It's not. I just tried to knock off anything that limited me only to entering URLs.

Now this works as a full-on replacement plugin: it can double up for acronyms, too, and will substitute any pattern or set of words with whatever you enter in the replacement text box, not just URLs. You can type in acronyms and have them expanded (or vice-versa) apart from Auto-Linking.

I believe this adds great flexibility to this superb plugin.

Ok, that didn't work so good. Another try.

This refers to my own post of August 17, 2008. Finally got back to this and figured it out, on the basis that Byrne probably has his hands full at the moment.

As I said, I wanted AutoLink to be what QuickLink was, a complete replacement alternative. I take text mytext and I get something like this:

<a href="someurl" title="URL Title" target="_blank">My Expanded Text</a>.

AutoLink doesn't do that. You have to make changes to: create.tmpl; CMS.pm and Plugin.pm to achieve this.

Create.tmpl

Located in mt/plugins/AutoLink/tmpl/dialog

Go down to line 49. Where it says:

<input id="url" type="text" name="url" value="<mt:var name="destination" />" class="full-width"/>

add the words encode_html="1" after the word "destination" so that it looks like this:

<input id="url" type="text" name="url" value=">mt:var name="destination" encode_html="1"/>" class="full-width"/>

CMS.pm

Located in /mt/plugins/AutoLink/lib/AutoLink

Comment out lines 89 to 94:

# my $uri_short = $rule->destination;
# if (length($uri_short) > 50) {
# $uri_short =~ s/.*(.{50})$/\1/;
# $row->{url} = $uri_short;
# }

Plugin.pm

Located in /mt/plugins/AutoLink/lib/AutoLink

Remove lines 14 through 19

# sub remove_autolink_tags {
# my ($txt) = @_;
# $txt =~ s!(.*)!$1!gm;
# return $txt;
# }

Lines 31 through 48 should be changed thus:

my $cmd = "";
# TODO - the text that is linked to needs to be tokenized and links added at the end
if ($rule->regex) {
# REMOVED
# $cmd = '$text =~ s!('.$pattern.')!$1!'.$options;
# ADDED
$cmd = '$text =~ s!('.$pattern.')!'.$href.'!'.$options;
} else {
# REMOVED
# $cmd = '$text =~ s!\b('.$pattern.')\b!$1!'.$options;
# ADDED
$cmd = '$text =~ s!\b('.$pattern.')\b!'.$href.'!'.$options;
}
eval $cmd;
}
return $text;
}

and lines 57 to 60 should be commented out too:

# REMOVED
# while ($text =~ s/(]*\>.*?)/"\${token-".++$count."}"/emi) {
# $tokens{"token-$count"} = $1;
# }

I'm not pretending this is any great program writing. It's not. I just tried to knock off anything that limited me only to entering URLs.

Now this works as a full-on replacement plugin: it can double up for acronyms, too, and will substitute any pattern or set of words with whatever you enter in the replacement text box, not just URLs. You can type in acronyms and have them expanded (or vice-versa) apart from Auto-Linking.

I believe this adds great flexibility to this superb plugin.

Leave a comment

what will you say?


Monthly Archives

Recent Comments

  • See the last half of this Melody mailing list message for a feature idea/implementation. ...

    https://www.google.com/accounts/o8/id?id=AItOawmyS3IJ5aAcOGD3cZEmIxKLmtoBgoPDp5k
    AutoLink Plugin for Movable Type
  • Ok, that didn't work so good. Another try. This refers to my own post of August 17, 2008. Finally got back to this and figured it out, on the basis that Byrne probably has his hands full at the moment. As I said, I wan...

  • This refers to my own post of August 17, 2008. Finally got back to this and figured it out, on the basis that Byrne probably has his hands full at the moment. As I said, I wanted AutoLink to be what QuickLink was, a com...

  • Thanks a lot I had a a nice read ...

  • I read some of your articles and they are all wonderful. Thankyou! :-) ...

    purple desktop wallpapers
    AutoLink Plugin for Movable Type
Close