Re: what is missing to achieve automatic file size insertion into body text

Asko Soukka <[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Message-ID <[email protected]>
Dylan Jay wrote:
> We have a requirement which doesn't seem to have any good solutions. That is when a user inserts a link to a pdf or word document the document size and type will get automatically inserted next to it (in a theme dependent format).

This sounds similar to how image captions are inserted.

You can look into plone.outputfilters on how to register a custom output 
filter.

Although, it would be equally ugly to Diazo transform version: you 
should parse the links manually from the output HTML string, resolve 
their objects and only then add the required extra HTML. Note that 
because filters have no order, UIDs may be already resolved before your 
filter. Probably the best way to look up the documents is just to do 
traverse, similarly to catalog brains' getObject.

https://github.com/plone/plone.outputfilters/blob/master/plone/outputfilters/filters/configure.zcml

https://github.com/plone/plone.outputfilters/blob/master/plone/outputfilters/interfaces.py

https://github.com/plone/plone.outputfilters/blob/master/plone/outputfilters/filters/example.py

> I was thinking using this might be a good usecase for Martins Diazo fragments idea
> https://github.com/plone/plone.app.theming/pull/10
...
> Fragments isn't really designed to take in arguments however. You'd have to do something tricky with XSLT I think

Fragments are alike to page template based views. You should be able to 
pass any querystring for them and look its values from request (in TAL). 
AFAIK, the only difference to .pt-based views is that fragments can be 
shipped with themes and are available only from the enabled theme.

So, you can also prototype this idea with just a normal add-on view, 
which gets the document url as its query string.

Regards,
Asko

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.