Olemis Lang avatar Olemis Lang committed 3aabad3

TracMac: Warning for unsupported browsers. MSIE & NetSurf in blacklist.

Comments (0)

Files changed (4)

 
 Outstanding tasks are :
 
-- Fix the problem with active mainnav item.
-+ Add styles for buttons.
++ Fix the problem with active mainnav item.
 - Add Mac (red | yellow | green) buttons to collapsible panels. 
 - Render .menu li(s) using display: block rule.
 - Add timeline icons.
 - Specify all images using config options.
 - Use single image (or reduce number) in styles.
 - Change style of focused input item (use blue).
-- Implement notice for Internet Explorer in filter.
++ Implement notice for Internet Explorer in filter.
 - Add images for metanav icons under `more` drop-down menu.
   * RPC (+ CSS rules)
 - Look for (main|meta)nav items @ TH.org and add icons 
   for each one of them (for toolbar, dock menu & metanav).
+- Document @ TH.org the tests performed using Ubuntu Lucid 
+  + Opera 10.61 (Build 6430) Linux i686, 2.6.32-24-generic
+  + Firefox 3.6.8 
+  + Google Chrome 5.0.375.99 (51029)
+  + Epiphany 2.30.2
+  + SeaMonkey 2.0.6 Mozilla/5.0 Gecko/20100722 
+  ~ Konqueror 4.4.2
+    - Metanav `more` menu item displayed under siblings.
+  ~ Midori GTK+ 2.19.6, WebKitGTK+ 1.1.21
+    - Toolbar `more` item displayed lower than expected.
+    - Toolbar state not persisted in cookies.
+  - Netsurf 1.2-1 build 1
+    - No JavaScript.
+    - No hover.
+    - Issues with hiding fake toolbar.
+- Repair issues found using NetSurf
+  - Show ctxtnav hidden by logo and header.
+  - Show metanav hidden by logo and header.
+  - Hide toolbar replacement shown at the bottom.
 
+
 
 setup(
   name = 'TracMacOSTheme',
-  version = '1.0.2',
+  version = '1.0.3',
   author = "Olemis Lang",
   author_email = 'olemis+trac@gmail.com',
   maintainer = 'Olemis Lang',

tracmacos/templates/mac_reject.html

+<!DOCTYPE html
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      py:strip="">
+  <head>
+    <title>Unsupported browser</title>
+  </head>
+
+  <body>
+    <h1>Unsupported browser</h1>
+    <img src="${req.abs_href.chrome('theme', 'dk_bug.png')}"
+         width="64px" style="float: left;" />
+    <p><a href="http://trac-hacks.org/wiki/TracMacTheme">Trac Mac OS theme</a>
+      is not compatible with this browser. 
+      Support for your browser should be added soon.
+    </p>
+    <p>
+      In the mean time please try another from the list shown 
+      below. You may use the links to visit their home sites
+      in order to look for the latest version, download links, 
+      as well as other installation and configuration instructions. 
+    </p>
+    <p>
+      For further details about supported browsers please consult 
+      <a href="http://trac-hacks.org/wiki/TracMacTheme">this page</a>.
+    </p>
+    <p>
+      Sorry if this caused you any trouble.
+    </p>
+    <ul>
+      <li py:for="b in supported">
+        <a href="${b[1]}">${b[0]}</a>
+      </li>
+    </ul>
+    <p>
+      <a href="http://trac-hacks.org/wiki/TracMacTheme">Trac Mac OS theme</a>
+      Copyright(c) 2010 
+      <a href="http://simelo-es.blogspot.com">Olemis Lang</a>
+    </p>
+  </body>
+</html>

tracmacos/theme.py

 from trac.core import *
 from trac.config import Option, IntOption, ListOption
 from trac.util.translation import _
+from trac.web.api import IRequestFilter, IRequestHandler, RequestDone
 from trac.web.chrome import add_script
-from trac.web.api import IRequestFilter
 
 from genshi.builder import Markup, Element, Fragment, tag
 from genshi.input import XML
+from genshi.template import MarkupTemplate
 from genshi.util import striptags
+from pkg_resources import resource_string
 
+from re import compile as c
 from themeengine.api import ThemeBase
 
 try :
 
 class MacTheme(ThemeBase):
     """A theme for Trac based on Mac OS appearance."""
-    implements(IRequestFilter)
+    implements(IRequestFilter, IRequestHandler)
     dock_images = MappingOption('docknav', 'images', 
                                 'wiki:/chrome/theme/dk_wiki.png,'
                                 'admin:/chrome/theme/dk_prefs.png,'
     
     template = htdocs = css = screenshot = True
     
+    BROWSER_REJECT_MESSAGE = resource_string('tracmacos', 
+            'templates/mac_reject.html')
+    BROWSER_BLACKLIST = [
+                        '; MSIE ',
+                        '; Dillo',
+                        'NetSurf',
+                        ]
+    BROWSER_BLACKLIST = '|'.join('(?:%s)' % x for x in BROWSER_BLACKLIST)
+    BROWSER_SUPPORTED = [
+                        ('Opera', 'http://www.opera.com'), 
+                        ('Firefox', 'http://www.mozilla.com/firefox'), 
+                        ('Google Chromium', 'http://code.google.com/chromium'), 
+                        ('Safari', 'http://www.apple.com/safari/'), 
+                        ('Epiphany', 'http://www.gnome.org/projects/epiphany'),
+                        ('SeaMonkey', 'http://www.seamonkey-project.org/releases'),
+                        ('Konqueror', 'http://konqueror.kde.org'),
+                        ('Midori', 'http://www.twotoasts.de/index.php?/pages/midori_summary.html'),
+#                        ('Netsurf', 'http://www.netsurf-browser.org'),
+                        ]
+    
     # IRequestFilter methods
     def pre_process_request(self, req, handler):
         self._prepare_request(req)
         self._prepare_chrome_for_fail(req)
-        return handler
+        
+        warn_no_support = self._match_blacklist(req)
+        if warn_no_support and \
+                not req.path_info.startswith('/chrome/'):
+            return self
+        else :
+            return handler
     
     def post_process_request(self, req, template, data, content_type):
 #        self._prepare_request(req)
         self._add_macos_scripts(req)
         return template, data, content_type
     
+    # IRequestHandler methods
+    def match_request(self, req):
+        # Impossible to get to this directly
+        return False
+    
+    def process_request(self, req):
+        tmpl = MarkupTemplate(self.BROWSER_REJECT_MESSAGE)
+        stream = tmpl.generate(req=req, supported=self.BROWSER_SUPPORTED)
+        req.send(stream.render('xhtml'))
+    
     # Internal methods
     def _add_macos_scripts(self, req):
         add_script(req, '/chrome/theme/jquery.jqDock.min.js')
             
         req.callbacks['chrome'] = macos_prepare_request
         
+    def _match_blacklist(self, req):
+        ua = dict(req._inheaders).get('user-agent')
+        if ua is not None :
+            return c(self.BROWSER_BLACKLIST).search(ua) is not None
+        else :
+            return False
+        
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.