~openerp-dev/openobject-server/trunk-staging-mat

« back to all changes in this revision

Viewing changes to openerp/addons/base/ir/ir_qweb.py

  • Committer: Antony Lesuisse
  • Date: 2014-05-01 19:05:44 UTC
  • Revision ID: al@openerp.com-20140501190544-egvc85ctdxs69cmr
[IMP] ir_qweb improve css minify

Show diffs side-by-side

added added

removed removed

Lines of Context:
1119
1119
class StylesheetAsset(WebAsset):
1120
1120
    rx_import = re.compile(r"""@import\s+('|")(?!'|"|/|https?://)""", re.U)
1121
1121
    rx_url = re.compile(r"""url\s*\(\s*('|"|)(?!'|"|/|https?://|data:)""", re.U)
1122
 
    rx_comments = re.compile(r"""/\*.*\*/""", re.S)
1123
1122
    rx_sourceMap = re.compile(r'(/\*# sourceMappingURL=.*)', re.U)
1124
1123
 
1125
1124
    def _get_content(self):
1156
1155
 
1157
1156
    def minify(self):
1158
1157
        # remove existing sourcemaps, make no sense after re-mini
1159
 
        return self.rx_sourceMap.sub('', self.content)
1160
 
        # return self.rx_comments.sub('', self.content)
 
1158
        content = self.rx_sourceMap.sub('', self.content)
 
1159
        # comments
 
1160
        content = re.sub(r'/\*.*?\*/', '', content, flags=re.S)
 
1161
        # space
 
1162
        content = re.sub(r'\s+', ' ', content)
 
1163
        content = re.sub(r' *([{}]) *', r'\1', content)
 
1164
        return content
1161
1165
 
1162
1166
def rjsmin(script):
1163
1167
    """ Minify js with a clever regex.