Tags:
create new tag
, view all tags

Question

I want to load a html file inside a twiki topic, using an iframe. This is easy to do simply attaching the html file (ex: test.html) to the topic and then using this code:

<iframe src="%ATTACHURL%/test.html" width="800" height="580"></iframe>

But what if the html file loads a local png file, for example? If the img tag inside the html file references to a png file in the same folder (ex: <img src="image.png" />), I can just attach image.png to the same topic and it works.

The problem is when the img tag references to "folder/image.png", for example. This doesn't work inside twiki, because I can't create a folder inside this topic's pub directory.

Is this possible? I'm trying to hack twiki to make this work. I attached test.html and image.png files to some topic, then manually (through command line) updated the topic META::FILEATTACHMENT for image.png, changing name and attachment values with folder/image.png. Then I created a pub/Support/HowToCreateAttachmentsInFolders/folder directory and moved image.png and image.png,v to this directory.

After that, the attachment list shows the image file name as "folder/image.png", but when I try to view/download this file, I get a "file image.png not found" message. I found out that when viewfile script runs, it calls sanitizeAttachmentName function, which removes every illegal character from filename param - which includes "/".

I tried simply commenting out this line inside viewfile function (inside lib/TWiki/UI/View.pm file):

$fileName = TWiki::Sandbox::sanitizeAttachmentName( $fileName );

Now I can not only view folder/image.png, but also my iframe can find it!

Finally, my question is: which is the best approach to do this? Is it recommended? Are there any other possible problems? I didn't test the attachment move and delete operations...

Another question is how would I create the folders for attachments. I'm thinking about using BatchUploadPlugin for that - I would create a zip file with my html file and its subfolders, and BatchUploadPlugin would respect the subfolders, instead of attaching files on the topic's pub folder.

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: CentOS 4.4
Web server: Apache 2.0.52
Perl version: 5.8.5
Client OS: Ubuntu 7.10
Web Browser: Firefox 2.0.0.11
Categories: Missing functionality

-- GuilhermeGarnier - 23 Jan 2008

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

Sorry, closing this question after more than 30 days of inactivity. Feel free to re-open if needed.

-- PeterThoeny - 02 Mar 2008

 
Change status to:
Topic revision: r2 - 2008-03-02 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.