-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport.py
More file actions
executable file
·59 lines (47 loc) · 1.43 KB
/
export.py
File metadata and controls
executable file
·59 lines (47 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import sys, os
import shutil
import re
#config file
s = ''
with open('config/config.json') as f:
s = f.read()
s = re.sub(r'("user":").*?(")',r'\g<1>xxx\g<2>', s)
s = re.sub(r'("pwd":").*?(")',r'\g<1>xxx\g<2>', s)
s = re.sub(r'("enable":).*?(,)',r'\g<1>false\g<2>', s)
with open('config/config.json','w') as f:
f.write(s)
#genpage.tpl
s = ''
with open('config/genpage.tpl') as f:
s = f.read()
s = re.sub(r'伊谢尔伦的一角',r'xxx', s)
s = re.sub(r'zzbalabala.com',r'xxx.com', s)
s = re.sub(r'chris zz',r'xxx', s)
s = re.sub(r'<li>.*?>About</a></li>',r'<li><a href="const_About.html">About</a></li>', s)
with open('config/genpage.tpl','w') as f:
f.write(s)
#vimwiki.tpl
s = ''
with open('config/vimwiki.tpl') as f:
s = f.read()
s = re.sub(r'伊谢尔伦的一角',r'Blog name', s)
s = re.sub(r'zzbalabala.com',r'xxx.com', s)
s = re.sub(r'chris zz',r'xxx', s)
s = re.sub(r'<li>.*?>About</a></li>',r'<li><a href="const_About.html">About</a></li>', s)
with open('config/vimwiki.tpl','w') as f:
f.write(s)
#disqus
s = ''
with open('site/js/disqus.js') as f:
s = f.read()
s = re.sub(r"(var disqus_shortname = ').*?(')",r'\g<1>xxx\g<2>', s)
with open('site/js/disqus.js','w') as f:
f.write(s)
#google-analytics
s = ''
with open('site/js/ga.js') as f:
s = f.read()
s = re.sub(r"(ga\('create', ').*?(', ').*?(')",r'\g<1>xxx\g<2>xxx.com\g<3>', s)
with open('site/js/ga.js','w') as f:
f.write(s)