Caches URLs referenced in the text.
Copy referenced webpages to the TWiki server to avoid broken links
Introduction
This is a plugin which will download a web page that is referenced in a topic and change the link to point to the cached page. The cached pages will have a date showing when it was cached, and a link to the original page.
There are two ways of caching a page, either as a new topic, or as a separate data file (similar to attachments). See below under
Syntax Rules for more information on how to define what type of caching is done. In either case clicking the link will open the page in the current browser window.
Please note that web pages are only cached the first time the are found, the link is then changed so it will not be re-cached.
Syntax Rules
Any string that begins with
http or
https and is at the beginning of a line or has a space before it will be cached. The URL is assumed to be everything from the beginning of the http(s) until a space or end of line is encountered. If you have a URL that includes a space you should replace the space with the code
%20.These pages will be downloaded with any style sheets and/or images as well, i.e. it attempts to make a exact copy of the original page.
If you add a + (plus sign) in front it will cache it as a new topic. The topic will use the URL minus the
http://
prefix as the name. In this case the page will only be stored as plain text, with some very basic formatting attempted.
The difference between caching as a standalone page or as a topic is that topics can be searched through the normal TWiki search engine.
To avoid having URLs cached you have three options:
- For single URLs just make sure it does not have spaces around it, you may use normal brackets: (http://mylink.com
) or a TWiki formatting code such as underscores for italic.
- For an entire page put the following code anywhere in the page: <!--NOCACHE--> this is in fact a hidden HTML comment and will not show up in the page itself.
- For an entire web (for instance the main TWiki web which has lots of pointers to live support information) add them to the IGNORE setting below. By default the TWiki web is there already.
Plugin Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%, i.e.
%URLCACHEPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Copy referenced webpages to the TWiki server to avoid broken links
- Stop these webs from being cached, list them as a comma separate list here
- Debug plugin: (See output in
data/debug.txt)
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.
- Or, follow these manual installation steps:
- Download the ZIP file from the Plugins home (see below).
- Unzip
URLCachePlugin.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/URLCachePlugin.txt | Plugin topic |
lib/TWiki/Plugins/URLCachePlugin.pm | Plugin Perl module |
- Set the ownership of the extracted directories and files to the webserver user.
- Plugin configuration and testing:
- Run the configure script and enable the plugin in the Plugins section.
- Test if the installation was successful: Create a page with a URL in the Sandbox web.
- If you have some webs that you do not want to use the cache for, set them in the
IGNORE setting in this topic.
Plugin Info
Related Topics: TWikiPreferences,
TWikiPlugins