r1 - 19 Oct 2006 - 07:16:18 - TWikiGuestYou are here: TWiki >  TWiki Web  > AttachContentPlugin

AttachContentPlugin

This plugin puts any text between a %STARTATTACH{"filename"}% and %ENDATTACH% into an attachment with the given filename.

The current version only refreshes the attachment when the topic is saved. Obviously this means that the attachment can get out of synch if, for example, it explicitly or implicitly refers to other topics.

This plugin is written specifically to be able to put css into topic(s) and still be able to have efficient stylesheets: i.e., without the overhead of TWiki processing. The feature can be used for many other things where you want TWiki to generate a plain text file a smart way.


Syntax Rules

Put in a %STARTATTACH{"filename"}% before the content you want in the attached textfile, and %ENDATTACH% after it, and the contents in between will be attached to the topic, for easy reference by other pages.

Examples

This example sets backgroup color using a variable. The variable is expanded when the content is rendered, and resulting text is saved to "mycolors.css".

This example will change the background to grey once the file is saved, if you are using PatternSkin - refreshing your browser cache between tries might be necessarry, typically this is done by pressing CTRL-F5.

Set color:

  • Set BG = eeeeee

%STARTATTACH{"mycolors.css"}%
#patternTopBar {
	background-color:#eeeeee;
	border-color:#ccc;
}
#patternOuter {
	background-color:#eeeeee;
	border-color:#ccc;
}
#patternBottomBar {
	background-color:#eeeeee;
	border-color:#ccc;
}
html body {
	background-color:#eeeeee;
}
%ENDATTACH%

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %CACHECONTENTPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Caches portions of a topic in attachments to that topic

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

  • Keep paragraph <p /> tags, <nop> tags, and square bracket type links.
    • Set KEEPPARS = 0

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.

  • Download the ZIP file from the Plugin web (see below)
  • Unzip AttachContentPlugin.zip in your twiki installation directory. Content:
    File: Description:down
    lib/TWiki/Plugins/AttachContentPlugin.pm Plugin Perl module
    data/TWiki/AttachContentPlugin.txt Plugin topic
    data/TWiki/AttachContentPlugin.txt,v Plugin topic repository
  • Test if the installation was successful:

Plugin Info

Plugin Author: TWiki:Main.MeredithLesly, TWiki:Main.KennethLavrsen
Plugin Version: 19 Oct 2006 (V2.0)
Change History:  
19 Oct 2006 (2.0) TWiki:Main.KennethLavrsen
Fixed major security issue. Original version allowed /../ in the filename so files could be stored everywhere
Plugin now cleans up the its work area and no longer leaves temporary files
Temporary filenames made pseudo random to avoid race condition
Plugin now also removed nops and TML square bracket links
Attachment is no longer saved when uploading other files and changing attributes.
09 Feb 2006 (1.0) Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
License: GPL (GNU General Public License)
Benchmarks: GoodStyle nn%, FormattedSearch nn%, AttachContentPlugin nn%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/AttachContentPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/AttachContentPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/AttachContentPluginAppraisal

Related Topics: TWikiPreferences, TWikiPlugins

-- TWiki:Main.KennethLavrsen - 19 Oct 2006

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.AttachContentPlugin