FAQ
I'm supposing that there must be something in the request object that lets me know if
I'm serving to particular browsers, in particular to whatever version of IE. Then, in
some single place in the app, automatically digest that and stick a flag in the stash.
Now, the TT files can test for that flag and skip advanced features or serve alternative
content.

Has this already been swept up into a nice module of some kind?

If not, can you give me some pointers on those two things: how to tell what the browser
is, and where to put the code so it's executed on every action?

Thanks.

Search Discussions

  • Tobias Kremer at Mar 6, 2011 at 11:00 am

    On 06.03.2011, at 11:56, John M. Dlugosz wrote:
    I'm supposing that there must be something in the request object that lets me know if I'm serving to particular browsers, in particular to whatever version of IE. Then, in some single place in the app, automatically digest that and stick a flag in the stash. Now, the TT files can test for that flag and skip advanced features or serve alternative content.
    Has this already been swept up into a nice module of some kind?

    Let me CPAN this for you:
    http://search.cpan.org/dist/Catalyst-TraitFor-Request-BrowserDetect/

    --Toby
  • John M. Dlugosz at Mar 6, 2011 at 11:36 am
    Thanks. I guess everything is easy if you know what you're looking for!

    I'd like to set flags based on what that contains, like "send SVG images". Where would I
    put that in MyApp so it gets called some time before rendering the view?
    On 3/6/2011 5:00 AM, Tobias Kremer tobias.kremer-at-gmail.com |Catalyst/Allow to home| wrote:
    On 06.03.2011, at 11:56, John M. Dlugosz wrote:
    I'm supposing that there must be something in the request object that lets me know if I'm serving to particular browsers, in particular to whatever version of IE. Then, in some single place in the app, automatically digest that and stick a flag in the stash. Now, the TT files can test for that flag and skip advanced features or serve alternative content.
    Has this already been swept up into a nice module of some kind?
    Let me CPAN this for you:
    http://search.cpan.org/dist/Catalyst-TraitFor-Request-BrowserDetect/

    --Toby
    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Charlie Garrison at Mar 6, 2011 at 2:06 pm
    Good morning,

    On 6/03/11 at 5:36 AM -0600, John M. Dlugosz
    wrote:
    I'd like to set flags based on what that contains, like "send
    SVG images". Where would I put that in MyApp so it gets called
    some time before rendering the view?
    I do browser detection (checking) in the `auto` method (so I can
    redirect to 'upgrade browser' page). But it could also be done
    in the `end` method if you just want to put stuff in stash for
    the view. If you've got a base method that all other actions
    chain from (which seems to be current best practices) then you
    could put it there too.


    Charlie

    --
    ? Charlie Garrison ? <garrison@zeta.org.au>

    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
    ? http://www.ietf.org/rfc/rfc1855.txt
  • John M. Dlugosz at Mar 6, 2011 at 2:45 pm

    On 3/6/2011 8:06 AM, Charlie Garrison garrison-at-zeta.org.au |Catalyst/Allow to home| wrote:
    Good morning,
    On 6/03/11 at 5:36 AM -0600, John M. Dlugosz wrote:

    I'd like to set flags based on what that contains, like "send SVG images". Where would
    I put that in MyApp so it gets called some time before rendering the view?
    I do browser detection (checking) in the `auto` method (so I can redirect to 'upgrade
    browser' page). But it could also be done in the `end` method if you just want to put
    stuff in stash for the view. If you've got a base method that all other actions chain
    from (which seems to be current best practices) then you could put it there too.


    Charlie
    Ah, I see: the 'end' is the end of the controller phase and is still done before calling TT.

    My general policy is not to forbid older browsers, but to withhold the CSS and add a
    banner. So, I did that in the page-wrapping template for the site. I also plan to start
    using SVG, so a flag that tells the TT template to give the IMG or the OBJECT, based on
    whether the browser is on the list of those chosen to get SVG.

    Looking toward the future, I'm hoping that IE9 will be a sea-change. So as with normal
    programming languages, I'm thinking that a new project should use up-to-date features.

    By chaining actions, you mean how http://site.com/foo/bar/baz will have a base action at
    foo, then more action at bar, etc? I don't think my current project works well for that.
    Is the current trend to chain back to the root? I don't see how that adds anything over
    'auto', but I'll re-read that section carefully.
  • Mike Raynham at Mar 6, 2011 at 3:14 pm

    On 06/03/11 14:45, John M. Dlugosz wrote:
    On 3/6/2011 8:06 AM, Charlie Garrison garrison-at-zeta.org.au
    Catalyst/Allow to home| wrote:
    Good morning,

    On 6/03/11 at 5:36 AM -0600, John M. Dlugosz <wxju46gefd@snkmail.com>
    wrote:
    I'd like to set flags based on what that contains, like "send SVG
    images". Where would I put that in MyApp so it gets called some time
    before rendering the view?
    I do browser detection (checking) in the `auto` method (so I can
    redirect to 'upgrade browser' page). But it could also be done in the
    `end` method if you just want to put stuff in stash for the view. If
    you've got a base method that all other actions chain from (which
    seems to be current best practices) then you could put it there too.


    Charlie
    Ah, I see: the 'end' is the end of the controller phase and is still
    done before calling TT.

    My general policy is not to forbid older browsers, but to withhold the
    CSS and add a banner. So, I did that in the page-wrapping template for
    the site. I also plan to start using SVG, so a flag that tells the TT
    template to give the IMG or the OBJECT, based on whether the browser is
    on the list of those chosen to get SVG.

    Looking toward the future, I'm hoping that IE9 will be a sea-change. So
    as with normal programming languages, I'm thinking that a new project
    should use up-to-date features.

    By chaining actions, you mean how http://site.com/foo/bar/baz will have
    a base action at foo, then more action at bar, etc? I don't think my
    current project works well for that. Is the current trend to chain back
    to the root? I don't see how that adds anything over 'auto', but I'll
    re-read that section carefully.



    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    It may be worth noting that browser detection is often considered to be
    a bad idea. The thought being that if you want to affect content
    delivery based on browser capability, then it is browser capability that
    you should detect.

    As far as I know, you usually need Javascript for this, as user agent
    strings can be unreliable. Of course, using Javascript precludes
    detection where the user has Javascript disabled.

    Here's some more information for you:

    http://css-tricks.com/browser-detection-is-bad/
    http://www.quirksmode.org/js/detect.html
    http://www.quirksmode.org/js/support.html

    Depending on your needs, another approach may be to use IE conditional
    comments to wrap a fake get request to your app, which your app can then
    use to determine the version of IE. Something like the image tracker
    method used by Piwik:

    http://piwik.org/docs/tracking-api/#toc-two-tracking-method-image-tracking-or-using-the-api

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMar 6, '11 at 10:56a
activeMar 6, '11 at 3:14p
posts6
users4
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase