Re: what is missing to achieve automatic file size insertion into body text
Philip Bauer <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.devel |
|---|---|
| Message-ID | <[email protected]> |
All of this sound pretty complicated. Why not write a browser-view @@get_size_for_file to return human-readable file-sizes for context and some old-fashioned js to retrieve the information?
$("a[href$='.pdf']").each(function() {
obj_url = $(this).attr('href');
var filesize = $.get(obj_url + '/@@get_size_for_file');
$(this).append(filesize);
})
Philip
--
Starzel.de
Philip Bauer
Adlzreiterstr. 35
80337 München
Tel: 089 - 189 29 533
Fax: 089 - 189 29 535
[email protected]
www.starzel.de
Am 12.09.2014 um 07:10 schrieb Asko Soukka <[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
> _______________________________________________
> Plone-developers mailing list
> Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/plone-developers
------------------------------------------------------------------------------
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
_______________________________________________
Plone-developers mailing list
Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/plone-developers
signature.asc
(application/pgp-signature, 496 B)
-----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQEcBAEBCgAGBQJUEq1OAAoJEOeXgSbn9GtJQscH/iDnkqfX6vwlDCU6sTg/gpg4 hfRY1DBpYPxpabsP4cAAKX4SrQ5dx5XVqfmtt+tGl1p26RbcpOTzvR7wIOgCuBV2 CvdsVrBChZrHeISbK/lqCYECVHRdxKXXEbfY8xLpoV6M/N4ZxbEbu7SiFpaA3gzC z3LKdGxPtlYLMz7aCdhpdbd3qCRbK33H/TWHEo5ZSzvUiJWFFUX1ddl0lRr31uMa f1hN3AC0uy1YFzAfXwfoY80LKmMBVT5wwKZOimt6ojkcmlwDfj8vv6MI6DtmTRWy Omo+e/pR0ingRzt+/cIbiI1qHPsLVKBTFyR45LML+KustWjFYgfsnNKmkh892jM= =aS9c -----END PGP SIGNATURE-----