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

Dylan Jay <djay-n0pU0XVUApFWk0Htik3J/[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Message-ID <CANyGbvdV5M8m1MN2bw=h523kGMXXPBxGh6wNLKtQ8npvGoqocQ@mail.gmail.com>
Good point Phillip. I hadn't thought of  ajax. That would work and be
simple but I'm not sure I'd use it. There are a few con's like content
readjusting after page load, users who turn off js, and performance of
those extra requests.

Thanks for the help Asko. I guess the question I'm asking is not so much
how to do it technically as I know that all of those ways are possible.  I
think what I'm saying is I think there should be some kind of simple way to
do this kind of thing in plone. As easily as the ajax example. I'll come up
with something.
On 12 Sep 2014 15:23, "Philip Bauer" <[email protected]> wrote:

> 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
>
>

------------------------------------------------------------------------------
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
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.