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
--
GuilhermeGarnier - 23 Jan 2008
Answer
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