/
TopicInteractionPlugin.txt
300 lines (247 loc) · 16.6 KB
/
TopicInteractionPlugin.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
%META:TOPICINFO{author="ProjectContributor" comment="" date="1541499354" format="1.1" version="1"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%
%TOC%
---++ Description
This plugin redesigns the way how users interact with topics and attachments in various ways:
* improved attachment handling
* improved visuals displaying !DataForms
* improved integration of Foswiki:Extensions/MetaCommentPlugin and Foswiki:Extensions/FlexPaperPlugin
Other features are:
* cross-browser compatible bulk upload of multiple files
* bulk actions on attachments: delete, move, hide, download as zip archive, create image gallery, insert links
* thumbnail and lightbox preview of image attachments
* easy renaming of attachments using modal dialogs
* easy access to previous revisions of attachments
* loading the list of attachments via ajax not to slow down display of topics with lots of attachments
* filtering and pagination for topics with a lot of attachments
* drag & drop upload for browsers supporting it (currently firefox and chrome only)
---++ Screenshots
<a href='%ATTACHURLPATH%/TopicInteractionPluginSnap1.png' class='foswikiImage'><img src='%ATTACHURLPATH%/TopicInteractionPluginSnap1.png' width='500' /></a>
<a href='%ATTACHURLPATH%/TopicInteractionPluginSnap2.png' class='foswikiImage'><img src='%ATTACHURLPATH%/TopicInteractionPluginSnap2.png' width='500' /></a>
<a href='%ATTACHURLPATH%/TopicInteractionPluginSnap3.png' class='foswikiImage'><img src='%ATTACHURLPATH%/TopicInteractionPluginSnap3.png' width='500' /></a>
<a href='%ATTACHURLPATH%/TopicInteractionPluginSnap4.png' class='foswikiImage'><img src='%ATTACHURLPATH%/TopicInteractionPluginSnap4.png' width='500' /></a>
<a href='%ATTACHURLPATH%/TopicInteractionPluginSnap5.png' class='foswikiImage'><img src='%ATTACHURLPATH%/TopicInteractionPluginSnap5.png' width='500' /></a>
---++ Settings
To activate you'll need to add =topicinteraction= to your SKIN path setting in your !SitePreferences, like
<verbatim>
* Set SKIN = topicinteraction, pattern
</verbatim>
Use the =insidetab= setting of !MetaCommentPlugin to render comments inside a tab at the bottom of the page:
<verbatim>
* Set SKIN = topicinteraction, metacomment, pattern
* Set DISPLAYCOMMENTS = on
* Set COMMENTFORMAT = insidetab
</verbatim>
Note you won't need using Foswiki:Extensions/NatSkin as that's integrated automatically.
---++ Creating a link to an attachment
!TopicInteractionPlugin extens the standard way of inserting links to an attachment. Instead of only distinguishing between images and other kinds
of attachments you may now specify different code to be inserted into the topic based on the mime type of an attachment. You may specify a set of
various preference settings. The actual setting being used is chosen in the given precedence:
1 =ATTACHED_<file-extension>_FORMAT=
1 =ATTACHED_<mime-type>_FORMAT=
1 =ATTACHEDIMAGEFORMAT= (provided for compatibility, left out in below examples)
1 =ATTACHED_FILE_FORMAT=
1 =ATTACHEDFILELINKFORMAT= (provided for compatibility, left out in below examples)
(=<file-extension>= and =<mime-type>= are uppercase). For example, when inserting a link to an attachment named =screenshot.png= the following
settings are looked up:
1 =ATTACHED_PNG_FORMAT=
1 =ATTACHED_IMAGE_FORMAT=
1 =ATTACHED_FILE_FORMAT=
The one first found is used. When looking up the link format based on the mime type, the actual _mime type group_ is used, such as
=IMAGE=, =VIDEO=, =TEXT=, =AUDIO= etc just to name the most interesting ones. There are a couple of more mime types that are grouped together
in a meaningful way to form the group =DOCUMENT= which are =application/.*(document|msword|msexcel|rtf).*=, as well as =PDF= which are =application/pdf=
and =application/postscript=.
For example the following settings might be quite useful:
Using [[Foswiki:Extensions/DocumentViewerPlugin][DocumentViewerPlugin]]:
<verbatim class="tml">
* Set ATTACHED_ODT_FORMAT = $percntDOCUMENTVIEWER{"$filename"}$percnt
* Set ATTACHED_PDF_FORMAT = $percntDOCUMENTVIEWER{"$filename"}$percnt
</verbatim>
Using [[Foswiki:Extensions/ImagePlugin][ImagePlugin]]:
<verbatim class="tml">
* Set ATTACHED_IMAGE_FORMAT = $percntIMAGE{"$filename" size="200" caption="$comment"}$percnt
</verbatim>
Using [[Foswiki:Extensions/MediaElementPlugin][MediaElementPlugin]]:
<verbatim class="tml">
* Set ATTACHED_VIDEO_FORMAT = $percntVIDEO{"$filename"}$percnt
* Set ATTACHED_AUDIO_FORMAT = $percntAUDIO{"$filename"}$percnt
</verbatim>
Using !WebDAVContrib (please adjust the webdav://wiki/dav prefix to your needs):
<verbatim class="tml">
* Set OFFICELINK = <a href='webdav://wiki/dav/%WEB%/%TOPIC%/%DEFAULT{default=""}%' class='jqWebDAVLink' title='Edit Office Attachment' rel='nofollow'>%DEFAULT{default=""}%</a>
* Set ATTACHED_DOCUMENT_FORMAT = $percntOFFICELINK{"$filename"}$percnt
</verbatim>
The =..._FORMAT= strings support the following variables:
* =$filename=: the name of the file
* =$fileext=: the filename extension (string following the last period, if present) or an empty string.
* =$fileurl=: URL encoded version of the filename
* =$comment=: the file comment from the upload dialog
* =$size=: the filesize (=%<nop>ATTACHEDIMAGEFORMAT%= only)
* =$width=: image width
* =$height=: image width
* =$date=: modification date of attachment
* Any standard [[FormatTokens][formatting tokens]]: =$percnt=, =$dollar=, etc.
---+++ Incompatibilities
There is a significant difference how Foswiki's natively processes =ATTACHEDFILEFORMAT= settings and the way !TopicInteractionPlugin does.
* Any macro expression __must always be escaped__ using standard format tokens =$percnt= and =$dollar=. As such previous settings might be incompatible with !TopicInteractionPlugin
settings of the same kind.
* The __time format specifiers are not supported__. Use =$date= instead.
---++ Syntax
!TopicInteractionPlugin implements some macros to actually implement the user interface. These macros can be used for other purposes too of course.
---+++ ATTACHMENTS
List all attachments of a given topic. Without any parameters it displays a
table of attachments similar to the one generated by the templates at the bottom
of a topic. There are a couple of parameters that take regular expressions to
limit the number of attachments to be listed.
*Syntax:*
| *%<nop>ATTACHMENTS%, %<nop>ATTACHMENTS{"<topic>" ...}%* ||
| ="<topic>"= | topic whos attachments we want to query |
| =attr="..."= | match the attachments' attribute |
| =autoattached="yes,no,undef"= | limit attachments to those that are (not) autoattached |
| =casesensitive="on/off"= | specify string comparison mode when filtering attachments, defaults to =on= |
| =comment="..."= | match the attachments' comment |
| =maxdate="..."= | specify latest attachment |
| =maxsize="..."= | specify biggest attachment |
| =mindate="..."= | specify earliest attachment |
| =minsize="..."= | specify smallest attachment |
| =names="..."= | match the name of attachments to be include in the list |
| =user="..."= | match the attachments' user who uploaded it |
| =footer="..."= | format string appended to the result |
| =format="..."= | how to format each attachment |
| =header="..."= | format string prefixing the resulting output |
| =separator="..."= | format string put between each formatted attachment |
| =hidenull="on,off"= | hide/display the empty result; only the header and the footer are included \
if set to "off" and there's no attachment at the given topic |
| =nullformat="..."= | format string to be used when no attachments have been found and =hidenull= is switched off |
| =nullheader="..."= | header string to be used when no attachments have been found and =hidenull= is switched off |
| =nullfooter="..."= | footer string to be used when no attachments have been found and =hidenull= is switched off |
| =sort="name,date,size,user,comment,comment:name,random"= | sort results by specified property |
| =reverse="on/off"= | enable reverse sorting |
| =limit="..."= | limit the number of attachments to the given number; by default show all |
The following variables can be used in the format parameter:
* $attr: the attributes
* $autoattached: the autoattach flag
* $comment: the comment field
* $date(<format>): the attachment date using <format> to format the date
* $date: the attachment date
* $delete: the action to delete the current attachment
* $deleteUrl: the url used in the delete action
* $icon: img tag representing the filetype
* $iconUrl: the url pointing to the icon used in the img tag
* $index: the position index of the attachment in the result
* $move: the action to move the current attachment
* $moveUrl: the url used in the move action
* $name: the name of the attachment
* $path: the path property of the attachment
* $props: the action to change the properties of the current attachment
* $propsUrl: the url used in the props action
* $size: the size in bytes
* $sizeH: file size in a humanized display (using KB, MB, GB, etc) as needed
* $sizeK: the size in kilo bytes
* $sizeM: the size in mega bytes
* $sizeG: the size in giga bytes
* $topic: the name of the topic of whose attachments are listed
* $url: the attachments url
* $urlpath: the attachments urlpath
* $user: the user that uploaded the attachment
* $web: the web name of the current topic
* $webdav: the action to edit the current attachment using the Foswiki:Extensions/WebDavPlugin
* $webdavUrl: the url used in the webdav action
* $wikiuser: the user's home topic that recently changed the current attachment
The header and footer format strings may only contain
* $count: the number of attachments found
The format, header and footer may contain the standard escape sequences:
* $dollar: $ sign
* $n: newline
* $percnt: % sign
* $quot: " sign
Example:
<verbatim>
%ATTACHMENTS{
header="| * * | *Name* | *Url* | *Size* | *Author* | $n"
format="| $idnex | $name: | $url | $sizeK |"
}%
</verbatim>
generates:
<noautolink>
%ATTACHMENTS{
header="| *#* | *Icon* | *Name* | *Size* | *Author* | *Date* |$n"
format="| $index | $percntMIMEICON{\"$name\" size=\"48\"}$percnt | <a href='$url'>$name</a> | $sizeK | $user | $date |"
}%
</noautolink>
---++ Installation Instructions
%$INSTALL_INSTRUCTIONS%
---++ Dependencies
%$DEPENDENCIES%
---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 06 Nov 2018: | removed excess div in templates; moved progress bar into js land |
| 24 Oct 2018: | improved "insert link" action; added "create link & hide file" action; performance improvements to other actions |
| 05 Mar 2018: | fixed selecting attachments with brackets in its filename |
| 16 Feb 2018: | added a legacy uploader to be somewhat backwards compatible to the old plupload just enough to please natedit |
| 16 Jan 2018: | check access permissions in %ATTACHMENTS makro; fixed url encoding of unicode files |
| 13 Sep 2017: | replace outdated plupload uploader with jquery-file-upload |
| 18 Nov 2016: | oo-ified core; \
added humanized file size display, removed flash backend from default; \
improved webdav integration for one-click editing office documents; \
fixed sanitizing attachemnt names during upload using the standard mechanism again; \
removed (optional) dependency on <nop>FlexPaperPlugin (flash) in favour of <nop>DocumentViewerPlugin (html5); \
fixed url construction in javascript land; \
add support for <nop>JQPhotoSwipeContrib, a much nicer lightbox image preview; \
added support for <nop>LikePlugin to rate attachments; \
replaced famfamfam icons with fontawsome ones; \
added registry entry to use register <nop>LibreOffice to be used for one-click edits on windows |
| 11 Oct 2016: | using jquery-i18n for translations now |
| 17 Jul 2015: | added support for Foswiki-2.0; added support for Foswiki:Extensions/WebDAVContrib |
| 16 Dec 2014: | add support for Foswiki:Extensions/MediaElementPlugin to preview audio and video attachments |
| 29 Aug 2014: | fully specify rest security |
| 28 May 2014: | improve performance on bulk operations on attachments; fixed tooltip poping up automatically |
| 04 Apr 2014: | flag rest handlers that don't require authentication |
| 18 Mar 2014: | render correct form data when displaying an old revision |
| 20 Feb 2014: | fixed permission checking of actions; added one-click editing of office documents |
| 08 Jan 2014: | fixed file corruption under Windows; fixed too aggressive renaming of files during upload |
| 12 Dec 2013: | fixed initialization of defaults |
| 07 Nov 2013: | fixed malformed JSON on some remote procedures |
| 01 Nov 2013: | have a checkbox in the properties dialog to mark an image attachment to be used as a thumbnail in search results; \
better support for !WebDavContrib: one-click edit of office attachments; \
jslinting javascript code (excluding 3rd party upstream code) |
| 08 Apr 2013: | fixed html error |
| 14 Mar 2013: | default to chunked upload; \
fixed handling of attachments with commas in their name |
| 01 Feb 2013: | fixed error handling; \
hiding access to edit actions when not authorized anyway; \
fixed uploading files with special chars in their name; \
fixed initialization of flash backend; \
fixed reading foswiki preference settings; \
fixed uploading files with commas in their name |
| 31 Jan 2013: | using ATTACHLINKBOX to control the default state of the "create link" checkbox |
| 25 Jan 2013: | fixed auto-start feature; fixed registration of uploader component |
| 18 Jan 2013: | improved compatibility with !PatternSkin; \
fixed =configure= barfing on an undef value |
| 24 Sep 2012: | updated to latest plupload version; \
allow to add arbitary properties, not only comments, createlink, hide-file flags |
| 10 Jul 2012: | replaced all simplemodals with jquery-ui dialogs; \
added nullformat,nullheader,nullfooter to %ATTACHMENTS macro; \
removed dependency on !WebDAVLinkPlugin to render webdav-enabled urls |
| 08 May 2012: | fixed silent dependency on !DBCachePlugin; \
fixed integration with !PatternSkin; \
fixed dependency on Foswiki:Extensions/RenderPlugin; \
fixed interaction with Foswiki:Extensions/MetaCommentPlugin |
| 26 Apr 2012: | initial release |
%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="© 2010-2018 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%25TOPIC%25"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25TOPIC%25"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%25TOPIC%25"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap5.png" attachment="TopicInteractionPluginSnap5.png" attr="" comment="" date="1541499354" size="36218" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap4.png" attachment="TopicInteractionPluginSnap4.png" attr="" comment="" date="1541499354" size="45039" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap3.png" attachment="TopicInteractionPluginSnap3.png" attr="" comment="" date="1541499354" size="99574" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap2.png" attachment="TopicInteractionPluginSnap2.png" attr="" comment="" date="1541499354" size="111026" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TopicInteractionPluginSnap1.png" attachment="TopicInteractionPluginSnap1.png" attr="" comment="" date="1541499354" size="16199" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="LibreOfficeWebDAV.reg" attachment="LibreOfficeWebDAV.reg" attr="" comment="" date="1541499354" moveby="micha" movedto="System.TopicInteractionPlugin.LibreOfficeWebDAV.reg" movedwhen="1470922302" movefrom="Sandbox.OpenToEditTest.LibreOfficeWebDAV.reg" size="1126" user="ProjectContributor" version="1"}%