"""
Inspired by Will Guaraldi's gecko-notice plugin.
This generates a notice for folks who are using M$ Internet Explorer telling them
to switch to a safer browser.
The notice will be available as the variable $noie_notice in head and foot templates.
To install:
1) Put noie.py in your plugin directory.
2) In config.py add noie to py['load_plugins']
3) Add the following optional variable to config.py:
# this is the default
py['noie_message'] = 'You should not be using Internet Explorer. Get a safer brower now.'
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright 2004 Steven Armstrong
Revisions:
$Log: noie.py,v $
Revision 1.1 2005/02/08 17:51:21 sar
cvs server update
Revision 1.3 2005/01/19 17:34:14 sar
cosmetics
Revision 1.2 2005/01/16 14:01:05 sar
fixed link in docstring
Revision 1.1 2004/12/01 04:12:42 sar
created
$Id: noie.py,v 1.1 2005/02/08 17:51:21 sar Exp $
"""
__author__ = "Steven Armstrong - sa at c-area dot ch"
__version__ = "$Revision: 1.1 $ $Date: 2005/02/08 17:51:21 $"
__url__ = "http://www.c-area.ch/code/"
__description__ = "Displays a notice for people who are using IE."
import os
from config import py as cfg
_notice_default = """You should not be using Internet Explorer. Get a safer brower now."""
def verify_installation(request):
config = request.getConfiguration()
if not "noie_message" in config:
print "missing optional config property 'noie_message'"
print "using the default of %s" % _notice_default
return 1
def generate_notice(http):
agent = http.get("HTTP_USER_AGENT", "")
if agent.lower().find("msie") != -1:
return cfg.get("noie_message", _notice_default)
return ""
def cb_head(args):
"""
This method gets called in the cb_story callback. Refer to
the documentation for that.
"""
http = args['request'].getHttp()
entry = args["entry"]
entry["user_agent"] = http.get("HTTP_USER_AGENT", "")
entry["noie_notice"] = generate_notice(http)
def cb_foot(args):
return cb_head(args)