forked from thomaspark/bootswatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_bootswatch_mutara.py
145 lines (126 loc) · 7.79 KB
/
convert_bootswatch_mutara.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import re
import os
values = {
# 'uc': 'Grissom',
'lc': 'mutara',
'header': 'Michroma',
'body': 'Play',
'website': 'mavek_org',
# 'cl': '#116BB7',
}
def main():
src = 'cyborg'
cmd = 'cp -r {0}/* {1}'.format(src, values['lc'])
os.system(cmd)
infile = "{0}/bootswatch.less".format(src)
f = open(infile, 'r')
lines = f.readlines()
f.close()
outfile = values['lc'] + "/bootswatch.less"
f = open(outfile, 'w')
for line in lines:
line = re.sub(src.title(), values['lc'].title(), line)
if re.search("Roboto", line):
continue
if re.search("web-font-path", line):
line = '@web-font-path2: "https://fonts.googleapis.com/css?family={0}:400,700,400italic";\n'.format(values['body']) + line
line = '@web-font-path: "https://fonts.googleapis.com/css?family={0}:300italic,400italic,700italic,400,300,700";\n'.format(values['header']) + line
line = line + '.web-font(@web-font-path2);\n'
f.write(line)
f.close()
infile = "{0}/variables.less".format(src)
f = open(infile, 'r')
lines = f.readlines()
f.close()
swap_list = {
'@brand-primary:': '@brand-primary: #00ff00',
'@brand-success:': '@brand-success: #0000ff',
'@text-color:': '@text-color: #ffffff',
'@headings-color:': '@headings-color: #00ff00',
'@border-radius-base:': '@border-radius-base: 20px',
'@border-radius-large:': '@border-radius-large: 22px',
'@border-radius-small:': '@border-radius-small: 19px',
'@component-active-color:': '@component-active-color: #00ff00',
'@btn-default-color:': '@btn-default-color: #000',
'@btn-default-bg:': '@btn-default-bg: lighten(@gray-dark, 50%)',
'@input-bg:': '@input-bg: @gray-dark',
'@input-group-addon-bg:': '@input-group-addon-bg: @gray-lighter',
'@dropdown-border:': '@dropdown-border: rgba(0,255,0,0.1)',
'@dropdown-divider-bg:': '@dropdown-divider-bg: rgba(0,255,0,0.1)',
'@dropdown-link-color:': '@dropdown-link-color: #00ff00',
'@dropdown-link-hover-color:': '@dropdown-link-hover-color: #00ff00',
'@dropdown-link-active-color:': '@dropdown-link-active-color: #00ff00',
'@navbar-default-link-hover-color:': '@navbar-default-link-hover-color: #00ff00',
'@navbar-default-link-active-color:': '@navbar-default-link-active-color: #00ff00',
'@navbar-default-brand-color:': '@navbar-default-brand-color: #00ff00',
'@navbar-default-brand-hover-color:': '@navbar-default-brand-hover-color: #00ff00',
'@navbar-inverse-link-hover-color:': '@navbar-inverse-link-hover-color: #0000ff',
'@navbar-inverse-brand-color:': '@navbar-inverse-brand-color: #0000ff',
'@navbar-inverse-brand-hover-color:': '@navbar-inverse-brand-hover-color: #0000ff',
'@navbar-inverse-toggle-hover-bg:': '@navbar-inverse-toggle-hover-bg: #8080ff',
'@navbar-inverse-toggle-icon-bar-bg:': '@navbar-inverse-toggle-icon-bar-bg: #0000ff',
'@navbar-inverse-toggle-border-color:': '@navbar-inverse-toggle-border-color: #8080ff',
'@nav-tabs-active-link-hover-color:': '@nav-tabs-active-link-hover-color: #000',
'@pagination-color:': '@pagination-color: #000',
'@pagination-bg:': '@pagination-bg: @gray',
'@pagination-hover-color:': '@pagination-hover-color: #000',
'@pagination-active-color:': '@pagination-active-color: #000',
'@pagination-disabled-bg:': '@pagination-disabled-bg: @gray',
'@state-success-text:': '@state-success-text: #000',
'@state-info-text:': '@state-info-text: #000',
'@state-warning-text:': '@state-warning-text: #000',
'@state-danger-text:': '@state-danger-text: #000',
'@tooltip-bg:': '@tooltip-bg: #000',
'@popover-bg:': '@popover-bg: lighten(@body-bg, 10%)',
'@popover-fallback-border-color:': '@popover-fallback-border-color: #999',
'@popover-arrow-outer-color:': '@popover-arrow-outer-color: fadein(@popover-border-color, 5%)',
'@popover-arrow-outer-fallback-color:': '@popover-arrow-outer-fallback-color: darken(@popover-fallback-border-color, 20%)',
'@label-color:': '@label-color: #000',
'@label-link-hover-color:': '@label-link-hover-color: #000',
'@list-group-link-heading-color:': '@list-group-link-heading-color: #000',
'@panel-primary-text:': '@panel-primary-text: #000',
'@badge-color:': '@badge-color: #000',
'@badge-link-hover-color:': '@badge-link-hover-color: #000',
'@badge-active-bg:': '@badge-active-bg: #000',
'@breadcrumb-color:': '@breadcrumb-color: #00ff00',
'@carousel-control-color:': '@carousel-control-color: #000',
# '': '',
}
outfile = values['lc'] + "/variables.less"
f = open(outfile, 'w')
for line in lines:
line = re.sub(src.title(), values['lc'].title(), line)
line = re.sub(src, values['lc'], line)
#line = re.sub('Roboto', 'Michroma', line)
for s in swap_list.keys():
if re.search(s, line):
line = swap_list[s] + ";\n"
line = re.sub('headings-font-family: @font-family-base', 'headings-font-family: @font-family-header-sans-serif', line)
if re.search("Roboto", line):
line = re.sub('Roboto', '{0}'.format(values['body']), line)
line = '@font-family-header-sans-serif: "{0}", "Helvetica Neue", Helvetica, Arial, sans-serif;\n'.format(values['header']) + line
f.write(line)
f.close()
infile = "{0}/index.html".format(src)
f = open(infile, 'r')
lines = f.readlines()
f.close()
outfile = values['lc'] + "/index.html"
f = open(outfile, 'w')
for line in lines:
line = re.sub(src.title(), values['lc'].title(), line)
line = re.sub(src, values['lc'], line)
line = re.sub('UA-[0-9\-]+', '', line)
if re.search('bootstrap.css" media="screen"', line):
line = line + ' <link rel="stylesheet" href="./bootstrap_fixes.css" media="screen">\n'
f.write(line)
f.close()
grunt = "/cygdrive/c/Users/keeshand/AppData/Roaming/npm/grunt"
cmd = "{0} swatch:{1}".format(grunt, values['lc'])
os.system(cmd)
cmd = "cp {0}/bootstrap.min.css ../{1}/pelican-themes/bootstrap3/static/css/bootstrap.{0}.min.css".format(values['lc'], values['website'])
os.system(cmd)
cmd = "cp {0}/bootstrap_fixes.css ../{1}/pelican-themes/bootstrap3/static/css/bootstrap_fixes.{0}.css".format(values['lc'], values['website'])
os.system(cmd)
if __name__ == '__main__':
main()