changeset 13:ea1e3da31e1e

Don't use msie hacks for msie8 and later
author Radomir Dopieralski <devel@sheep.art.pl>
date Thu, 05 Jun 2008 11:37:55 +0200
parents c0f0d71bc89a
children dad63ce7aea9
files mfact.py
diffstat 1 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mfact.py	Thu Jun 05 11:28:47 2008 +0200
+++ b/mfact.py	Thu Jun 05 11:37:55 2008 +0200
@@ -143,6 +143,52 @@
             ]
         return u'\n'.join(html)
 
+    def html_stylesheets(self, d):
+        """ Assemble html head stylesheet links
+
+        @param d: parameter dictionary
+        @rtype: string
+        @return: stylesheets links
+        """
+        link = '<link rel="stylesheet" type="text/css" charset="%s" media="%s" href="%s">'
+
+        # Check mode
+        if d.get('print_mode'):
+            media = d.get('media', 'print')
+            stylesheets = getattr(self, 'stylesheets_' + media)
+        else:
+            stylesheets = self.stylesheets
+        usercss = self.request.user.valid and self.request.user.css_url
+
+        # Create stylesheets links
+        html = []
+        prefix = self.cfg.url_prefix_static
+        csshref = '%s/%s/css' % (prefix, self.name)
+        for media, basename in stylesheets:
+            href = '%s/%s.css' % (csshref, basename)
+            html.append(link % (self.stylesheetsCharset, media, href))
+
+            # Don't add user css url if it matches one of ours
+            if usercss and usercss == href:
+                usercss = None
+
+        # admin configurable additional css (farm or wiki level)
+        for media, csshref in self.request.cfg.stylesheets:
+            html.append(link % (self.stylesheetsCharset, media, csshref))
+
+        csshref = '%s/%s/css/msie.css' % (prefix, self.name)
+        html.append("""
+<!-- css only for MSIE browsers -->
+<!--[if IE lte 7]>
+   %s
+<![endif]-->
+""" % link % (self.stylesheetsCharset, 'all', csshref))
+
+        # Add user css url (assuming that user css uses same charset)
+        if usercss and usercss.lower() != "none":
+            html.append(link % (self.stylesheetsCharset, 'all', usercss))
+
+        return '\n'.join(html)
 
 def execute(request):
     """