GithubHelp home page GithubHelp logo

metrex / useragentcheck Goto Github PK

View Code? Open in Web Editor NEW

This project forked from omaroman/useragentcheck

1.0 2.0 0.0 245 KB

Play framework module to check browser version and display a non disruptive banner saying "You browser is no longer supported, please update"

Java 98.99% Python 1.01%

useragentcheck's Introduction

UserAgentCheck module for the play framework

What is UserAgentCheck ?

UserAgentCheck provides an easy way to notify users when their browser is outdated. It displays a non disruptive banner at the top of the page and drives the user to a page where he/she may download an upgrade. Optionally, it can block access to a browser if the version is older than the required one, e.g., html5 features needed.

screenshot

How does it work ?

It's no rocket science: the module provides a tag than may be included in your templates (typically main.html). In a nutshell, the module reads the user-agent header, figures the browser name/version and decides, based on your settings, if the banner should be displayed.

To avoid redoing the same process on every request, it then stores the result in the session (which in Play translates to a cookie).

Usage:

Configuration

By setting properties in conf/application.conf the developer can control when the warning banner should display.

useragentcheck.minInternetexplorerVersion = 7
useragentcheck.minOperaVersion = 10
useragentcheck.minFirefoxVersion = 5
useragentcheck.minChromeVersion = 13
useragentcheck.minSafariVersion = 5

With the sample lines above, the banner will show if you use IE6 or prior, Opera 9 or prior ...etc

By default, useragentcheck display a non disruptive banner. You may change this behavior by setting the following property:

useragentcheck.block = true

In blocking mode, the user is redirected to an upgrade page where he/she can pick from a selection of upgrades.

Tag

You should include the useragentcheck tag somewhere in your template. Preferable right at the top of the html body.

...   
<body>
#{useragentcheck /}
#{doLayout /}
</body>
...

Banner settings

The banner text and url may be configured using the standard conf/messages file. The default entries are

useragentcheck.label=Your browser is no longer supported. Please click here to update...
useragentcheck.url=http://www.google.com/chrome

Routes

If you're planning to use the Blocking feature, add the following route in conf/routes

# Import the default UserAgentCheck routes
*	/	module:useragentcheck

Override Block Template

If you want to customize Block Template, invoke the following command:

play useragentcheck:ov-blockview

Sample application

Two sample demos are part of the distribution.

Process as follows in order to run them.

  1. cd to useragentcheck
  2. run play dependencies .
  3. run play build-module .
  4. cd to samples-and-tests
  5. run play depenencies demo-blocking and play depenencies demo-banner
  6. finally run the demo of your choice with play run demo-xxx and open a blowser on http://localhost:9000

Credits

User Agent Utils - Harald Walker - http://user-agent-utils.java.net/

play-useragentcheck module - Olivier Refalo - https://github.com/orefalo

play-useragentcheck module (Blocking Page) - Omar O. Román - https://github.com/omaroman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.