def setUp(self): super(CssAbsolutizingTestCase, self).setUp() settings.COMPRESS = True settings.MEDIA_URL = '/media/' self.css = """ <link rel="stylesheet" href="/media/css/url/url1.css" type="text/css"> <link rel="stylesheet" href="/media/css/url/2/url2.css" type="text/css"> """ self.url1_hash = get_file_hash(u'css/url/url1.css') self.url2_hash = get_file_hash(u'css/url/2/url2.css') self.cssNode = CssCompressor(self.css)
def input(self, filename=None, media_url=None, **kwargs): media_url = media_url or settings.MEDIA_URL media_root = os.path.abspath(settings.MEDIA_ROOT) if filename is not None: filename = os.path.abspath(filename) if not filename: return self.content self.media_path = filename.split(media_url)[1] self.media_path = self.media_path.lstrip('/') self.media_url = media_url.rstrip('/') self.mtime = get_file_hash(filename) self.has_http = False if self.media_url.startswith('http://') or self.media_url.startswith('https://'): self.has_http = True parts = self.media_url.split('/') self.media_url = '/'.join(parts[2:]) self.protocol = '%s/' % '/'.join(parts[:2]) self.directory_name = '/'.join([self.media_url, os.path.dirname(self.media_path)]) output = URL_PATTERN.sub(self.url_converter, self.content) return output
def input(self, filename=None, media_url=None, **kwargs): media_url = media_url or settings.MEDIA_URL media_root = os.path.abspath(settings.MEDIA_ROOT) if filename is not None: filename = os.path.abspath(filename) if not filename or not filename.startswith(media_root): return self.content self.media_path = filename[len(media_root):] self.media_path = self.media_path.lstrip('/') self.media_url = media_url.rstrip('/') self.mtime = get_file_hash(filename) self.has_http = False if self.media_url.startswith('http://') or self.media_url.startswith( 'https://'): self.has_http = True parts = self.media_url.split('/') self.media_url = '/'.join(parts[2:]) self.protocol = '%s/' % '/'.join(parts[:2]) self.directory_name = '/'.join( [self.media_url, os.path.dirname(self.media_path)]) output = URL_PATTERN.sub(self.url_converter, self.content) return output