Skip to content

Commit b202bc4

Browse files
author
moises.costa
committed
feat: init the project
0 parents  commit b202bc4

File tree

8 files changed

+1214
-0
lines changed

8 files changed

+1214
-0
lines changed

compile.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import re
3+
import datetime
4+
from io import open
5+
6+
# This script generates the page.html file.
7+
8+
# It removes script and style tags and replaces with the file content.
9+
10+
f = open('src/index.html', "r", encoding="utf-8")
11+
page = f.read()
12+
f.close()
13+
14+
15+
# Script tags
16+
17+
scriptsFinder = re.compile("""<script src="(.*)"></script>""")
18+
scripts = scriptsFinder.findall(page)
19+
20+
for script in scripts:
21+
filename = os.path.join("src", script)
22+
s = open(filename, "r", encoding="utf-8")
23+
scriptContent = "<script>%s</script>" % s.read()
24+
s.close()
25+
scriptTag = """<script src="%s"></script>""" % script
26+
page = page.replace(scriptTag, scriptContent)
27+
28+
29+
# Style tags
30+
31+
stylesFinder = re.compile("""<link rel="stylesheet" href="(.*)">""")
32+
styles = stylesFinder.findall(page)
33+
34+
for style in styles:
35+
filename = os.path.join("src", style)
36+
s = open(filename, "r", encoding="utf-8")
37+
styleContent = "<style>%s</style>" % s.read()
38+
s.close()
39+
styleTag = """<link rel="stylesheet" href="%s">""" % style
40+
page = page.replace(styleTag, styleContent)
41+
42+
43+
# Write the standalone file
44+
45+
f = open('dist/page.html', 'w', encoding="utf-8")
46+
f.write(page)
47+
f.close()
48+
49+
print("%s - DONE" % datetime.datetime.now())

0 commit comments

Comments
 (0)