Make CSS and JS path relative

This commit is contained in:
Kirill Kovalenko
2016-03-18 20:27:10 +01:00
parent 18531979e8
commit cee442b16b
2 changed files with 13 additions and 13 deletions
+4 -4
View File
@@ -13,7 +13,7 @@ f.close()
# Script tags
scriptsFinder = re.compile("""<script src="/(.*)"></script>""")
scriptsFinder = re.compile("""<script src="(.*)"></script>""")
scripts = scriptsFinder.findall(page)
for script in scripts:
@@ -21,13 +21,13 @@ for script in scripts:
s = open(filename)
scriptContent = "<script>%s</script>" % s.read()
s.close()
scriptTag = """<script src="/%s"></script>""" % script
scriptTag = """<script src="%s"></script>""" % script
page = page.replace(scriptTag, scriptContent)
# Style tags
stylesFinder = re.compile("""<link rel="stylesheet" href="/(.*)">""")
stylesFinder = re.compile("""<link rel="stylesheet" href="(.*)">""")
styles = stylesFinder.findall(page)
for style in styles:
@@ -35,7 +35,7 @@ for style in styles:
s = open(filename)
styleContent = "<style>%s</style>" % s.read()
s.close()
styleTag = """<link rel="stylesheet" href="/%s">""" % style
styleTag = """<link rel="stylesheet" href="%s">""" % style
page = page.replace(styleTag, styleContent)