コード例 #1
0
ファイル: assets.py プロジェクト: jnishiyama/h
 def replace_url(self, url):
     parsed = urlparse(url)
     if parsed.scheme:
         return url
     else:
         dirname = path.dirname(self.output_path)
         filepath = path.join(dirname, parsed.path)
         filepath = path.normpath(path.abspath(filepath))
         resolved = self.env.resolver.resolve_source_to_url(filepath, url)
         relative = urlpath.relpath(self.output_url, resolved)
         return relative
コード例 #2
0
ファイル: assets.py プロジェクト: davidmcclure/h
 def replace_url(self, url):
     parsed = urlparse(url)
     if parsed.scheme:
         return url
     else:
         dirname = path.dirname(self.output_path)
         filepath = path.join(dirname, parsed.path)
         filepath = path.normpath(path.abspath(filepath))
         resolved = self.env.resolver.resolve_source_to_url(filepath, url)
         relative = urlpath.relpath(self.output_url, resolved)
         return relative
コード例 #3
0
ファイル: webassets.py プロジェクト: tinkercnc/OctoPrint
def replace_url(source_url, output_url, url):
    # If path is an absolute one, keep it
    parsed = urlparse.urlparse(url)

    if not parsed.scheme and not parsed.path.startswith("/"):
        abs_source_url = urlparse.urljoin(source_url, url)

        # relpath() will not detect this case
        if urlparse.urlparse(abs_source_url).scheme:
            return abs_source_url

        # rewritten url: relative path from new location (output)
        # to location of referenced file (source + current url)
        url = urlpath.relpath(output_url, abs_source_url)

    return url
コード例 #4
0
ファイル: webassets.py プロジェクト: ByReaL/OctoPrint
def replace_url(source_url, output_url, url):
	# If path is an absolute one, keep it
	parsed = urlparse.urlparse(url)

	if not parsed.scheme and not parsed.path.startswith('/'):
		abs_source_url = urlparse.urljoin(source_url, url)

		# relpath() will not detect this case
		if urlparse.urlparse(abs_source_url).scheme:
			return abs_source_url

		# rewritten url: relative path from new location (output)
		# to location of referenced file (source + current url)
		url = urlpath.relpath(output_url, abs_source_url)

	return url