Attachments as TML, available programmatically
If attachments could have an alternate rendering handler we might get a clean way of supporting FunkyNewActions on them. e.g. attached excel files could be pushed through
CPAN:Spreadsheet::ParseExcel
to produce a TXT,
XML,
HTML or
TML rendering.
So this could allow someone to upload an excel file and for TWiki to get a
TML representation of it.
This would be like a dynamic version of the
BeforeAttachmentSaveHandler, dynamic in the sense that (1) the alternate representation is not stored and (2) extra renderers can retrospectively apply to attachments loaded in the past.
A process could suck a
TML rendering from the attachment and push that
TML representation through the TWiki::Data::DelimitedFile class. As well as allowing
BulkRegistration to occur from a native excel tile this would facilitate conversion of spreadsheets of data into pages containing the data.
--
MartinCleaver - 13 Jul 2005
Good idea
--
CrawfordCurrie - 14 Jul 2005
Ok, what would the API look like? Is there an object on a particular attachment?
I'm thinking something like:
topic("web.topic")->attachment("tables.xls")->worksheet(1)->asTML()
--
MartinCleaver - 15 Jul 2005
Why can't you use the document MIME type, in the same way as the browser does? Register renderers for different MIME types? Have a mapping for standard document types based on extension? Allow that mapping to be overridden using a meta-data setting in %META:FILEATTACHMENT?
--
CrawfordCurrie - 15 Jul 2005
Hmm. I didn't think of that.
View::_suffixToMimeType seems to be the only MIME hook at the moment. Am I correct?
--
MartinCleaver - 15 Jul 2005
AFAIK yes
--
CrawfordCurrie - 15 Jul 2005
Ok, so we'd like plugins to register what pairs of conversions they are capable of providing. e.g. during plugin registration of ExcelToTmlPlugin:
registerConverter("application/x-excel", "TML", &ExcelToTmlPlugin::convertXexcel);
registerConverter("application/x-excel", "XML", &ExcelToTmlPlugin::convertXexcel);
ContentAccessSyntax could be extended for allow for attachment renderings too:
Web.Topic.Attachments{attachmentName}.AsHtml or similar.
The registration of handlers for rendering would be extremely simple and fairly quick to to implement. The
MsOfficeAttachmentsAsHTMLPluginDev beta has a converters hash that illustrates the principle.
--
MartinCleaver - 18 Jul 2005