add js and css
This commit is contained in:
parent
9e7e1b27fd
commit
7228911e68
@ -83,8 +83,24 @@ class WPChange:
|
||||
src = i.get("src")
|
||||
o = urlparse(src)
|
||||
if len(o.netloc) > 0:
|
||||
self._logger.info("{0} : Change source {1} /dists/img/{2}/{3}".format(self._name, src, o.netloc, o.path))
|
||||
content = content.replace(src, "/dists/img/{0}/{1}".format(o.netloc, o.path))
|
||||
self._logger.info("{0} : Change source image {1} /img/{2}/{3}".format(self._name, src, o.netloc, o.path))
|
||||
content = content.replace(src, "/img/{0}/{1}".format(o.netloc, o.path))
|
||||
script = soup.find_all("script", {"type": "text/javascript"})
|
||||
for i in script:
|
||||
src = i.get("src")
|
||||
if src is not None:
|
||||
o = urlparse(src)
|
||||
if len(o.netloc) > 0:
|
||||
self._logger.info("{0} : Change source js {1} /dists/js/{2}/{3}".format(self._name, src, o.netloc, o.path))
|
||||
content = content.replace(src, "/dists/js/{0}/{1}".format(o.netloc, o.path))
|
||||
link = soup.find_all("link", {"rel": "stylesheet"})
|
||||
for i in link:
|
||||
href = i.get("href")
|
||||
if href is not None:
|
||||
o = urlparse(href)
|
||||
if len(o.netloc) > 0:
|
||||
self._logger.info("{0} : Change source css {1} /dists/css/{2}/{3}".format(self._name, href, o.netloc, o.path))
|
||||
content = content.replace(href, "/dists/css/{0}/{1}".format(o.netloc, o.path))
|
||||
try:
|
||||
with open(file, "w") as f:
|
||||
self._logger.info("{0} : File write : {1}".format(self._name, file))
|
||||
|
Loading…
x
Reference in New Issue
Block a user