You are here:
Foswiki
>
System Web
>
AttachContentPlugin
E
dit
A
ttach
Tags:
create new tag
,
view all tags
---+!! Attach Content Plugin Saves dynamic topic text to an attachment %TOC% ---++ Overview This plugin puts any text between a =%<nop>STARTATTACH{"filename"}%= and =%<nop>ENDATTACH%= into an attachment with the given filename. Pass filename, topic, web or comment as parameters. 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 Foswiki processing. The feature can be used for many other things where you want Foswiki to generate a plain text file a smart way. %BR% For example: write a =SEARCH= in a topic and save the search results to an XML file. The XML data can be used for efficient look-up. ---++ Syntax Rules Write: <pre> %<nop>STARTATTACH{"filename"}% content-to-be-saved %<nop>ENDATTACH% </pre> You can pass a number of parameters: ---+++ Parameters | *Parameter* | *Description* | *Default* | *Example* | | =topic= | Topic to save the attachment to. | - (the current topic is used) | =topic="WebHome"= | | =web= | Web where the save topic is located. | - (the current Web is used) | =web="Main"= | | =comment= | Attachment comment text. | the default ={AttachmentComment}= text in [[%SCRIPTURL{configure}%/#AttachContentPlugin$Extensions][configure]] | =comment="User data as of %<nop>DATE%"= | | =hide= | Use =hide="on"= to hide the attachment in normal topic view. | =off= | =hide="on"= | | =keeppars= | Keep paragraph =<p />= tags, =<nop>= tags, and square bracket type links | the default ={KeepPars}= text in [[%SCRIPTURL{configure}%/#AttachContentPlugin$Extensions][configure]] | =keeppars="on"= | | =hidecontent= | Hide content from view. | - (the "content-to-be-saved" is visible) | =hidecontent="on"= | ---++ Examples ---+++ Adding a Save button to the topic. These examples add a "Save" button to force a save of the topic and update the attachment. Note that with versions of Foswiki since 1.0.4, it is not possible to initiate a save from a simple HTML link - which causes a "GET". Save can only be initiated from a POST operation done using a HTML form. The following sample form is used to create the button: <verbatim> <form action="%SCRIPTURL{save}%/%WEB%/%TOPIC%" method="post"> <input type="hidden" name="action" value="action_save=1" /> <input type="submit" class="foswikiButton" value="Save the topic" /> </form> </verbatim> ---+++ Creating a color scheme See: PatternSkinColorSettings. This topic uses !AttachContentPlugin to write a CSS file for colors. Color values are set dynamically in the topic. On topic save the CSS file is attached to the topic and can be referred to using variable =USERCOLORSURL=. #UserDataXml ---+++ User data XML %IF{"context AttachContentPluginEnabled" then='<form action="%SCRIPTURL{save}%/%WEB%/%TOPIC%" method="post"><input type="hidden" name="action" value="action_save=1" /><input type="submit" class="foswikiButton" value="Save the topic" /></form> This will generate an [[%PUBURLPATH%/%WEB%/%TOPIC%/userdata.xml][attachment]] to this topic. Content will be a xml file of users registered to this installation.' else='Install !AttachContentPlugin to be able to save this topic. On saving, an attachment will be created to this topic.'}% <verbatim> %STARTATTACH{"userdata.xml" comment="User data as of %DATE%"}% <?xml version="1.0" encoding="ISO-8859-1"?> <users> %SEARCH{ "[F]irstName.*value=.*()" web="%MAINWEB%" type="regex" nonoise="on" excludetopic="UserForm,ProjectContributor,WikiGuest,UnknownUser" format="<user><firstname><![CDATA[$formfield(FirstName)]]></firstname><lastname><![CDATA[$formfield(LastName)]]></lastname><url><![CDATA[%SCRIPTURL{view}%/%WEB%/$topic]]></url></user>" }% </users> %ENDATTACH% </verbatim> %X% Note that the STARTATTACH and ENDATTACH macros are not shown, so the actual content of the above "live" Attach Content block (spaced out for easier readability) is: <pre> %START<nop>ATTACH{"userdata.xml" comment="User data as of %D<nop>ATE%"}% <?xml version="1.0" encoding="ISO-8859-1"?> <users> %S<nop>EARCH{ "[F]irstName.*value=.*()" web="%M<nop>AINWEB%" type="regex" nonoise="on" excludetopic="UserForm,ProjectContributor,WikiGuest,UnknownUser" format="<user><firstname><![CDATA[$formfield(FirstName)]]></firstname> <lastname><![CDATA[$formfield(LastName)]]></lastname> <url><![CDATA[%SC<nop>RIPTURL{view}%/%W<nop>EB%/$topic]]></url> </user>" }% </users> %END<nop>ATTACH% </pre> #PluginSettings ---++ Plugin Settings After installation, configure this plugin by changing settings in [[%SCRIPTURL{configure}%/#AttachContentPlugin$Extensions][configure]]. ---++ Plugin Installation Instructions You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server. Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install". If you have any problems, or if the extension isn't available in =configure=, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help. ---++ Plugin Info | Copyright: | © TWiki:Main.MeredithLesly, Foswiki:Main.KennethLavrsen, Foswiki:Main.ArthurClemens | | Version: | 8629 (2010-08-21) | | Release: | 2.3.3 | | Change History: | <!-- versions below in reverse order --> | | 21 Aug 2010 (2.3.3) | Created stub handlers =_startAttach= and =_endAttach=. | | 25 May 2010 (2.3.2) | Foswikitask:Item8579 - Fix example to resolve save errors | | 31 Aug 2009 (2.3) | Arthur Clemens: Added param =hidecontent=. Moved plugin settings to configure. | | 23 Nov 2008 (2.2.1) | Foswiki compatible. | | 16 Apr 2007 (2.2.0) | Kenneth Lavrsen: Add added =keeppars= parameter. Settings change to being plugin settings only. Removal of plugin tags fixed so text between is still visible. | | 15 Apr 2007 (2.1.0) | Arthur Clemens: added parameters =web=, =topic=, =comment= and =hide=. Plugin tags are removed from view. Added configurable default comment. | | 19 Oct 2006 (2.0) | Foswiki:Main.KennethLavrsen<br />Fixed major security issue. Original version allowed /../ in the filename so files could be stored everywhere<br />Plugin now cleans up the its work area and no longer leaves temporary files<br />Temporary filenames made pseudo random to avoid race condition<br />Plugin now also removed nops and TML square bracket links<br />Attachment is no longer saved when uploading other files and changing attributes. | | 09 Feb 2006 (1.0) | Initial version | | CPAN Dependencies: | none | | Other Dependencies: | none | | Perl Version: | 5.005 | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Plugin Home: | http://foswiki.org/Extensions/%TOPIC% | | Support: | http://foswiki.org/Support/%TOPIC% |
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r1 - 23 Sep 2005,
ProjectContributor
System
Log In
or
Register
Toolbox
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
User Reference
BeginnersStartHere
TextFormattingRules
Macros
FormattedSearch
QuerySearch
DocumentGraphics
SkinBrowser
InstalledPlugins
Admin Maintenance
Reference Manual
AdminToolsCategory
InterWikis
ManagingWebs
SiteTools
DefaultPreferences
WebPreferences
Categories
Admin Documentation
Admin Tools
Developer Doc
User Documentation
User Tools
Webs
Applications
ClassificationApp
Extensions
Main
System
Copyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki?
Send feedback