Description
ResolveURLs is a Movable
Type plugin by Alexei Kosut to resolve
relative URLs in weblog entries. It adds a new global filter
resolve_urls
that can be used in any MT template tag.
Enabling this causes relative URLs to be resolved against your
weblog site URL, and output as absolute.
This is useful, as relative URLs are convenient to type, but unsafe, since weblog entries can be seen from a number of different pages (e.g., from the index or from an archive page), each of which might resolve a relative URL differently. RSS feeds make the problem of relative URLs even worse, since your links may end up on another site where relative URLs will not point to your pages at all.
Download
Current version: 1.0.2
Documentation
Requirements
- Movable Type. I have only tested with version 2.51, although others may work.
- URI. I think this is indirectly required by MT, though, so you probably already have it installed.
Installation
To install, copy ResolveURLs.pl
into your Movable
Type plugins
directory.
Use
Add resolve_urls="1"
to any template tag where you
want relative URLs expanded. For example, to display the body of an
entry with URLs expanded, you might use:
<$MTEntryBody resolve_urls=”1”$>
The filter will search for any HTML tags with href
or
src
attributes, and make sure the corresponding URLs are
absolute. Relative URLs are resolved against the weblog site URL, as
configured in Movable Type.
The resolve_urls
filter can be used in any template
tag where a weblog is in context. I use it in my weblog for all
<$MTEntryBody$>
and <$MTEntryMore$>
tags, to make sure no relative URLs sneak out.
Version History
Version 1.0.2
- Does not resolve fragment-only URLs (e.g.,
#foo
), since these usually refer to anchors inside the entry itself, and are “safe” for encapsulation.
Version 1.0.1
- Recognizes link attribute values delimited with single or no quotation marks as well as those with double quotation marks.
- Before resolving relative URLs, adds a trailing slash to the site URL if there isn’t one already.
Version 1.0
- Initial release
Known Bugs
- Currently, the HTML “parser” is not very smart, and it’s possible it might identify URLs that aren’t actually links that should be expanded.
Contact the Author
Please send any comments or suggestions to Alexei Kosut at akosut@cs.stanford.edu
or comment below.
View all comments / Post a new comment