Tags:
create new tag
, view all tags

AttachmentListPluginDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on AttachmentListPlugin contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please file bug reports in the AttachmentListPlugin bug database.

Development discussion for AttachmentListPlugin

Continued from FileListPluginDev.

-- ArthurClemens - 06 Dec 2007

Thanks for the sort feature! But why the change in name? Does the new plugin recognize the FILELIST varuable, or do I have to do a mass change of all topics using FILELIST?

-- JohnFitzpatrick - 06 Dec 2007

This plugin does not recognize files, it recognizes attachments (it reads the topic metadata). So FileListPlugin is a confusing name.

As of version 1.0.1 you can still (again) use FILELIST; I've deprecated the variable but it will work still for some time.

-- ArthurClemens - 06 Dec 2007

Thanks Arthur for maintaining this plugin, and thank you Rohan Moitra for contributing code to it!

-- PeterThoeny - 07 Dec 2007

The parameter header is not appearing in version 1.1.4 (TWiki 4.2)

-- CarlinhosCecconi - 19 Feb 2008

Tracked in Bugs:Item5376 and fixed. New plugin uploaded.

-- ArthurClemens - 19 Feb 2008

Thanks! But the version v.1.2.1 caused another error:

Bad index while coercing array into hash

And in the search:

Bad index while coercing array into hash at /usr/local/vhosts/portalead.redelivre.org.br/twiki/lib/TWiki/Plugins/AttachmentListPlugin.pm line 154. at /usr/local/vhosts/portalead.redelivre.org.br/twiki/lib/TWiki/Plugins/AttachmentListPlugin.pm line 154
...

-- CarlinhosCecconi - 21 Feb 2008

Could you show the code that causes this?

-- ArthurClemens - 21 Feb 2008

http://www.carlinhos.wiki.br/TWiki/AttachmentListPlugin

-- CarlinhosCecconi - 21 Feb 2008

log in warn.txt:

| 2008-02-21 - 14:09 | Bad index while coercing array into hash at  ....../twiki/lib/TWiki/Plugins/AttachmentListPlugin.pm line 154.
 at ....../twiki/lib/TWiki/Plugins/AttachmentListPlugin.pm line 154
        TWiki::Plugins::AttachmentListPlugin::handleFileList('TWiki=HASH(0x804db50)', 'TWiki::Attrs=HASH(0x94c7dfc)', 'AttachmentListPlugin', 'TWiki', 'TWiki::Meta=HASH(0x88e4020)') called at ....../twiki/lib/TWiki/Func.pm line 2232
        TWiki::Func::__ANON__('TWiki=HASH(0x804db50)', 'TWiki::Attrs=HASH(0x94c7dfc)', 'AttachmentListPlugin', 'TWiki', 'TWiki::Meta=HASH(0x88e4020)') called at ....../twiki/lib/TWiki.pm line 2660
        TWiki::_expandTagOnTopicRendering('TWiki=HASH(0x804db50)', 'ATTACHMENTLIST', '\x{a}web="TWiki"\x{a}topic="FileAttachment"\x{a}format="| $fileIcon | [[$...', 'AttachmentListPlugin', 'TWiki', 'TWiki::Meta=HASH(0x88e4020)') called at ....../twiki/lib/TWiki.pm line 2581
        TWiki::_processTags('TWiki=HASH(0x804db50)', '---+!! Attachment List Plugin\x{a}\x{a}*Displays a formattable list o...', 'CODE(0x82d8548)', 16, 'AttachmentListPlugin', 'TWiki', 'TWiki::Meta=HASH(0x88e4020)') called at ....../twiki/lib/TWiki.pm line 2505
        TWiki::expandAllTags('TWiki=HASH(0x804db50)', 'SCALAR(0x8747a30)', 'AttachmentListPlugin', 'TWiki', 'TWiki::Meta=HASH(0x88e4020)') called at ....../twiki/lib/TWiki.pm line 2857
        TWiki::handleCommonTags('TWiki=HASH(0x804db50)', '---+!! Attachment List Plugin\x{a}\x{a}*Displays a formattable list o...', 'TWiki', 'AttachmentListPlugin', 'TWiki::Meta=HASH(0x88e4020)') called at ....../twiki/lib/TWiki/UI/View.pm line 396
        TWiki::UI::View::_prepare('---+!! Attachment List Plugin\x{a}\x{a}*Displays a formattable list o...', 'TWiki=HASH(0x804db50)', 'TWiki', 'AttachmentListPlugin', 'TWiki::Meta=HASH(0x88e4020)', 0) called at ....../twiki/lib/TWiki/UI/View.pm line 377
        TWiki::UI::View::view('TWiki=HASH(0x804db50)') called at ....../twiki/lib/TWiki/UI.pm line 159
        TWiki::UI::__ANON__() called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 379
        eval {...} called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 371
        Error::subs::try('CODE(0x804db08)', 'HASH(0x88e4794)') called at ....../twiki/lib/TWiki/UI.pm line 197
        TWiki::UI::run('CODE(0x834ad84)', 'view', 1) called

-- CarlinhosCecconi - 21 Feb 2008

Please check if version 1.2.2 tackles this.

-- ArthurClemens - 21 Feb 2008

Not yet. In the Plugin Disgnostics (http://www.carlinhos.wiki.br/TWiki/InstalledPlugins) :

TWiki::Plugins::AttachmentListPlugin could not be loaded.  Errors were: 
Global symbol "@sortedFiles" requires explicit package name at /usr/local/vhosts/carlinhos/twiki/lib/TWiki/Plugins/AttachmentListPlugin.pm line 148.
Global symbol "@sortedFiles" requires explicit package name at /usr/local/vhosts/carlinhos/twiki/lib/TWiki/Plugins/AttachmentListPlugin.pm line 151.
Compilation failed in require at (eval 44) line 1.
BEGIN failed--compilation aborted at (eval 44) line 1.

----

-- CarlinhosCecconi - 21 Feb 2008

Very strange that I don't see any of this... This time it looks like a simple programming error.

-- ArthurClemens - 21 Feb 2008

Another try: version 1.2.3

-- ArthurClemens - 21 Feb 2008

Yes! Thank you, AC! The AttachmentListPlugin is very useful

-- CarlinhosCecconi - 21 Feb 2008

Hear, hear! This is a great plugin and an essential tool for any TWikiApplication developer!

-- JohnFitzpatrick - 22 Feb 2008

Hi all, I found a little problem in the AttachmentListPlugin:

Our organization write in Portuguese and some files has non english letters like "", "", "",...

I use $fileUrl to make a refer for files with this plugin, and the name is bed for the URL. The localized names must be scaped to work on the browser.

I correct the bug with this changes in AttachmentListPlugin.pm:

300,301c300,306
<         my $fileUrl =
<           $pubUrl . "/$attachmentTopicWeb/$attachmentTopic/$filename";
---
>         my $webEnc   =  $attachmentTopicWeb;
>            $webEnc   =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg;
>         my $topicEnc =  $attachmentTopic;
>            $topicEnc =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg;
>         my $fileEnc  =  $filename;
>            $fileEnc  =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg;
>         my $fileUrl  = "$pubUrl/$webEnc/$topicEnc/$fileEnc";

-- AurelioAHeckert - 27 Jun 2008

Hm, how can I control the $fileSize formatting? What if I don't want that the files size is shown in KB but in byte and without the K or whatever at the end? In other respects, that's a great plugin, thanks Arthur!

  • So you would need extra parameters around $fileSize. Any idea how it could look like? -- ArthurClemens - 30 Jul 2008
    • Either provide a new parameter unit with possible values according to Wikipedia:Byte or
      allow a parameter for $fileSize ala $fileSize(unit) with the following possible values for unit: decimal: k, M, G, T, P, E, Z, Y; IEC: Ki, Mi, Gi, Ti, Pi, Ei, Zi, Yi; resp. JEDEC: K, M, G or
      let SSP do all the formatting wizardry (thinking about the $fileDate parameter)

-- FranzJosefGigler - 30 Jul 2008

Dear all,
I met a problem with ATTACHMENTLIST plugin.
When I view pages in TWiki sub web (Hierarchical Webs) , like: (ParentWeb/SubWeb), I attach a file in this page
but click attachment URL in ATTACHMENT Table (ATTACHMENTLIST plugin) , donwload file fail.

I found out that attachment download URL is error.
I trace lib/TWiki/Plugins/AttachmentListPlugin.pm
In sub _formatFileData ,

        my $webEnc = $fileData->{web};
        $webEnc =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg;

correct download URL:
http://example.org/twiki/pub/ParentWeb/SubWeb/TopicPage/attachmentFile.txt

translate to error download URL
http://example.org/twiki/pub/ParentWeb%2fSubWeb/TopicPage/attachmentFile.txt

$webEnc (Web value) got error .
Web value like (ParentWeb/SubWeb) translate to (ParentWeb%2fSubWeb)
"/" (slash) translate to ASCII code "%2f"

so got "Not Found" message , donwload file fail.
so I fixed it in AttachmentListPlugin.pm

sub _formatFileData ,
        #Due to sub web ex: QualityKM/Practice translate to QualityKM%2fPractice
        # translate %2f back to /
        $webEnc =~ s/\%2f/\//g ;

Download file in sub web is ok now.

Is any better idea to fix it ?!

-- BretHuang - 2010-01-26

Thank you Bret for reporting this, with proposed fix! I created TWikibug:Item6391 to track this.

-- PeterThoeny - 2010-01-26

I think its better to use URI::Escape than just regular expression suggested above. Something like following fixes the issue

--- AttachmentListPlugin.pm     (revision 18314)
+++ AttachmentListPlugin.pm     (working copy)
@@ -414,6 +414,9 @@
         my $fileEnc = $fileData->{name};
         $fileEnc =~ s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg;
         my $fileUrl = "$pubUrl/$webEnc/$topicEnc/$fileEnc";
+  
+       use URI::Escape;
+       $fileUrl = uri_unescape($fileUrl);
 
         $s =~ s/\$fileUrl/$fileUrl/g;
         $s =~ s/\$fileTopic/$fileData->{topic}/g;

-- SopanShewale - 04 Feb 2010

Hi, I have two bugfixes for this plugin. One is a bugfix, and one is an enhancement. Take a look. TWikibug:Item6446 and TWikibug:Item6447

-- SeanLazar - 2010-05-06

Thank you Sean for contributing to the TWiki project!

This plugin has a PleaseFeelFreeToModify policy. I invite you to ask for SVN access to maintain TWiki extensions so that you can fix, commit, build and upload the plugin (build and upload are automated). More at ReadmeFirst and PluginsInSubversion.

-- PeterThoeny - 2010-05-06

It would be handy if the plugin understand standard wildcard syntax, e.g. excludetopic="Web*"

-- Vicki Brown - 2014-03-15

Edit | Attach | Watch | Print version | History: r27 < r26 < r25 < r24 < r23 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r27 - 2014-03-15 - VickiBrown
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.