%STARTATTACH{"filename"}%
and %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. SEARCH
in a topic and save the search results to an XML file. The XML data can be used for efficient look-up.
%STARTATTACH{"filename"}% content-to-be-saved %ENDATTACH%You can pass a number of 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 configure |
comment="User data as of %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 configure |
keeppars="on" |
hidecontent |
Hide content from view. | - (the "content-to-be-saved" is visible) | hidecontent="on" |
<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>
USERCOLORSURL
.
%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%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:
%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%
cd /path/to/foswiki perl tools/extension_installer <NameOfExtension> installIf you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Name | Version | Description |
---|---|---|
File::Temp | >0 | Required |
Digest::MD5 | >=2.36 | Required |
14 Jan 2024 (2.43) | Foswikitask:Item15244 - code improvements such as use of strict and warnings in perl |
03 Feb 2021 (2.42) | Foswikitask:Item15015 - fixed escape the removal of bracket links |
13 Jun 2016 (2.41) | Foswikitask:Item14095 - fixed saving attachments with unicode chars in it |
03 May 2016 (2.40) | Foswikitask:Item14062 - only attach content when it actually changed; Foswikitask:Item11782 - make sure the file is proper utf8 on unicode Foswiki |
25 Sep 2015 (2.34) | Foswikitask:Item13747 - fixed unescaped left braces; use CPAN:File::Temp for temporary files; check access rights before saving auto-created attachment to prevent an unnecessary error condition; check access rights before saving auto-created attachment to prevent an unnecessary error condition; remove SVN tags to make plugin releasable again; use floats for version tags; normalize web,topic params to STARTATTACH; remove use of deprecated saveTopicText api |
21 Aug 2010 (2.33) | Created stub handlers _startAttach and _endAttach . |
25 May 2010 (2.32) | 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.21) | Foswiki compatible. |
16 Apr 2007 (2.20) | 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.10) | 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 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 |
Author | ProjectContributor |
Version | 2.43 |
Release | 21 Jan 2024 |
Description | Saves dynamic topic text to an attachment |
Copyright | © TWiki:Main.MeredithLesly, Foswiki:Main.KennethLavrsen, Foswiki:Main.ArthurClemens |
License | GPL (GNU General Public License) |
Home | Foswiki:Extensions/AttachContentPlugin |
Support | Foswiki:Support/AttachContentPlugin |
Repository | https://github.com/foswiki/AttachContentPlugin |
ExtensionClassification | Data and Files |
ExtensionType | PluginPackage |
Compatibility | Foswiki 1.0 |
IncompatibleWith | |
ImageUrl | |
DemoUrl | http:// |
SupportUrl | AttachContentPlugin |
ModificationPolicy | PleaseFeelFreeToModify |
I | Attachment | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|
md5 | AttachContentPlugin.md5 | manage | 180 bytes | 21 Jan 2024 - 12:05 | MichaelDaum | |
sha1 | AttachContentPlugin.sha1 | manage | 204 bytes | 21 Jan 2024 - 12:05 | MichaelDaum | |
tgz | AttachContentPlugin.tgz | manage | 8 K | 21 Jan 2024 - 12:05 | MichaelDaum | |
zip | AttachContentPlugin.zip | manage | 10 K | 21 Jan 2024 - 12:05 | MichaelDaum | |
EXT | AttachContentPlugin_installer | manage | 4 K | 21 Jan 2024 - 12:05 | MichaelDaum |