File size: 13,110 Bytes
0cd855b
c5d8552
0cd855b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
06a4b95
0cd855b
 
06a4b95
0cd855b
 
 
06a4b95
0cd855b
 
 
06a4b95
0cd855b
 
 
06a4b95
0cd855b
 
 
 
 
 
 
 
 
 
 
 
 
c5d8552
 
 
 
 
0cd855b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c36820b
0cd855b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
import gradio as gr
import tempfile

# HTML template with placeholders like {title_one}, {subtitle_one}, etc.
HTML_TEMPLATE = """<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width" />
		<title>Tesla</title>
		<link
			rel="stylesheet"
			href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.min.css"
			integrity="sha512-4rPgyv5iG0PZw8E+oRdfN/Gq+yilzt9rQ8Yci2jJ15rAyBmF0HBE4wFjBkoB72cxBeg63uobaj1UcNt/scV93w=="
			crossorigin="anonymous"
			referrerpolicy="no-referrer"
		/>
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/variable.css" />
		<link rel="stylesheet" href="css/header.css" />
		<link rel="stylesheet" href="css/navigation.css" />
		<link rel="stylesheet" href="css/section.css" />
		<link rel="stylesheet" href="css/footer.css" />
		<link rel="stylesheet" href="css/responsive.css" />
	</head>
	<body>
		<div class="blur__overlay"></div>

		<header class="header">
			<a class="header__left" href="signup.html">
				<img class="header__logo" src="media/tesla_logo.svg" alt="" />
			</a>

			<ul class="header__middle">
			<li>
				<li><a class="header__nav__btn" href="signup.html">Model S</a></li>
				<li><a class="header__nav__btn" href="signup.html">Model 3</a></li>
				<li><a class="header__nav__btn" href="signup.html">Model X</a></li>
				<li><a class="header__nav__btn" href="signup.html">Model Y</a></li>
				<li><a class="header__nav__btn" href="signup.html">solar roof</a></li>
				<li><a class="header__nav__btn" href="signup.html">solar panels</a></li>
			</li>
			</ul>

			<div class="header__right">
				<a class="header__nav__btn" href="signup.html">shop</a>
				<a class="header__nav__btn" href="signup.html">account</a>
				<a class="header__nav__btn menu__btn" href="signup.html">menu</a>
			</div>
		</header>

		<nav class="navigation">
			<div class="close__btn__container">
				<img class="navigation__close__btn" src="media/close_icon.svg" alt="" />
			</div>

			<ul>
				<li class="link__in__middle"><a class="nav__link" href="signup.html">Model S</a></li>
				<li class="link__in__middle"><a class="nav__link" href="signup.html">Model 3</a></li>
				<li class="link__in__middle"><a class="nav__link" href="signup.html">Model X</a></li>
				<li class="link__in__middle"><a class="nav__link" href="signup.html">Model Y</a></li>
				<li class="link__in__middle">
					<a class="nav__link" href="signup.html">Solar roofs</a>
				</li>
				<li class="link__in__middle">
					<a class="nav__link" href="signup.html">Solar panels</a>
				</li>
				<li><a class="nav__link" href="signup.html">Existing Inventory </a></li>
				<li><a class="nav__link" href="signup.html">Used Inventory </a></li>
				<li><a class="nav__link" href="signup.html">Trade-In </a></li>
				<li><a class="nav__link" href="signup.html">Test drive </a></li>
				<li><a class="nav__link" href="signup.html">Powerwall </a></li>
				<li><a class="nav__link" href="signup.html">Commercial Energy </a></li>
				<li><a class="nav__link" href="signup.html">utilities </a></li>
				<li><a class="nav__link" href="signup.html">Charging</a></li>
				<li><a class="nav__link" href="signup.html">Find us</a></li>
				<li><a class="nav__link" href="signup.html">Support</a></li>
				<li><a class="nav__link" href="signup.html">Investor Relations</a></li>
			</ul>
		</nav>

		<section id="fullpage">
			<section class="section one">
				<div class="section__content">
					<h1 class="section__content__title">{title_one}</h1>
					<h2 class="section__content__subtitle">
						{subtitle_one}
					</h2>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html"
						>{btn_primary_one}</a
					>
					<a class="section__action__btn action__btn__secondary" href="signup.html"
						>{btn_secondary_one}</a
					>
				</div>
			</section>

			<section class="section two">
				<div class="section__content">
					<h1 class="section__content__title">{title_two}</h1>
					<h2 class="section__content__subtitle">
						{subtitle_two}
					</h2>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html"
						>{btn_primary_two}</a
					>
					<a class="section__action__btn action__btn__secondary" href="signup.html"
						>{btn_secondary_two}</a
					>
				</div>
			</section>

			<section class="section three">
				<div class="section__content">
					<h1 class="section__content__title">{title_three}</h1>
					<h2 class="section__content__subtitle">
						{subtitle_three}
					</h2>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html"
						>{btn_primary_three}</a
					>
					<a class="section__action__btn action__btn__secondary" href="signup.html"
						>{btn_secondary_three}</a
					>
				</div>
			</section>

			<section class="section four">
				<div class="section__content">
					<h1 class="section__content__title">{title_four}</h1>
					<h2 class="section__content__subtitle">
						{subtitle_four}
					</h2>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html"
						>{btn_primary_four}</a
					>
					<a class="section__action__btn action__btn__secondary" href="signup.html"
						>{btn_secondary_four}</a
					>
				</div>
			</section>

			<section class="section five">
				<div class="section__content">
					<h1 class="section__content__title">{title_five}</h1>
					<h2 class="section__content__subtitle">
						{subtitle_five}
					</h2>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html">{btn_primary_five}</a>
					<a class="section__action__btn action__btn__secondary" href="signup.html"
						>{btn_secondary_five}</a
					>
				</div>
			</section>

			<section class="section six">
				<div class="section__content">
					<h1 class="section__content__title">{title_six}</h1>
					<h2 class="section__content__subtitle">
						{subtitle_six}
					</h2>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html">{btn_primary_six}</a>
					<a class="section__action__btn action__btn__secondary" href="signup.html"
						>{btn_secondary_six}</a
					>
				</div>
			</section>

			<section class="section seven">
				<div class="section__content">
					<h1 class="section__content__title">{title_seven}</h1>
				</div>

				<div class="section__action__container">
					<a class="section__action__btn action__btn__primary" href="signup.html">{btn_primary_seven}</a>
				</div>

				<footer class="footer">
					<ul>
						<li><a href="signup.html">Tesla © 2021</a></li>
						<li><a href="signup.html"> Privacy &amp; Legal </a></li>
						<li><a href="signup.html"> contact </a></li>
						<li><a href="signup.html">careers</a></li>
						<li><a href="signup.html">news</a></li>
						<li><a href="signup.html">engage</a></li>
						<li><a href="signup.html">locations</a></li>
					</ul>
				</footer>
			</section>
		</section>

		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.min.js"
			integrity="sha512-gSf3NCgs6wWEdztl1e6vUqtRP884ONnCNzCpomdoQ0xXsk06lrxJsR7jX5yM/qAGkPGsps+4bLV5IEjhOZX+gg=="
			crossorigin="anonymous"
			referrerpolicy="no-referrer"
		></script>

		<script src="js/script.js"></script>
	</body>
</html>"""

def generate_html(
    title_one, subtitle_one, btn_primary_one, btn_secondary_one,
    title_two, subtitle_two, btn_primary_two, btn_secondary_two,
    title_three, subtitle_three, btn_primary_three, btn_secondary_three,
    title_four, subtitle_four, btn_primary_four, btn_secondary_four,
    title_five, subtitle_five, btn_primary_five, btn_secondary_five,
    title_six, subtitle_six, btn_primary_six, btn_secondary_six,
    title_seven, btn_primary_seven
):
    # Inject values into template
    html = HTML_TEMPLATE.format(
        title_one=title_one,
        subtitle_one=subtitle_one,
        btn_primary_one=btn_primary_one,
        btn_secondary_one=btn_secondary_one,
        title_two=title_two,
        subtitle_two=subtitle_two,
        btn_primary_two=btn_primary_two,
        btn_secondary_two=btn_secondary_two,
        title_three=title_three,
        subtitle_three=subtitle_three,
        btn_primary_three=btn_primary_three,
        btn_secondary_three=btn_secondary_three,
        title_four=title_four,
        subtitle_four=subtitle_four,
        btn_primary_four=btn_primary_four,
        btn_secondary_four=btn_secondary_four,
        title_five=title_five,
        subtitle_five=subtitle_five,
        btn_primary_five=btn_primary_five,
        btn_secondary_five=btn_secondary_five,
        title_six=title_six,
        subtitle_six=subtitle_six,
        btn_primary_six=btn_primary_six,
        btn_secondary_six=btn_secondary_six,
        title_seven=title_seven,
        btn_primary_seven=btn_primary_seven
    )
    # Create a temporary file for the HTML
    with tempfile.NamedTemporaryFile(mode='w+', suffix='.html', delete=False, encoding='utf-8') as tmp_file:
        tmp_file.write(html)
        tmp_path = tmp_file.name
    return tmp_path, html

with gr.Blocks(title="Tesla Page Editor") as demo:
    gr.Markdown("# Tesla Page Text Editor\nEdit texts below to customize sections for visitor engagement. Preview scrolls like the original!")

    with gr.Row():
        with gr.Column(scale=1):
            gr.Markdown("### Section 1 (Model S)")
            title_one = gr.Textbox("Model S", label="Title")
            subtitle_one = gr.Textbox("order online for <a href='signup.html'>Touchless delivery</a>", label="Subtitle (HTML OK)")
            btn_primary_one = gr.Textbox("Custom Order", label="Primary Button")
            btn_secondary_one = gr.Textbox("Existing inventory", label="Secondary Button")

            gr.Markdown("### Section 2 (Model Y)")
            title_two = gr.Textbox("Model y", label="Title")
            subtitle_two = gr.Textbox("order online for <a href='signup.html'>Touchless delivery</a>", label="Subtitle")
            btn_primary_two = gr.Textbox("Custom Order", label="Primary Button")
            btn_secondary_two = gr.Textbox("Existing inventory", label="Secondary Button")

            gr.Markdown("### Section 3 (Model 3)")
            title_three = gr.Textbox("Model 3", label="Title")
            subtitle_three = gr.Textbox("order online for <a href='signup.html'>Touchless delivery</a>", label="Subtitle")
            btn_primary_three = gr.Textbox("Custom Order", label="Primary Button")
            btn_secondary_three = gr.Textbox("Existing inventory", label="Secondary Button")

            gr.Markdown("### Section 4 (Model X)")
            title_four = gr.Textbox("Model x", label="Title")
            subtitle_four = gr.Textbox("order online for <a href='signup.html'>Touchless delivery</a>", label="Subtitle")
            btn_primary_four = gr.Textbox("Custom Order", label="Primary Button")
            btn_secondary_four = gr.Textbox("Existing inventory", label="Secondary Button")

            gr.Markdown("### Section 5 (Solar Panels)")
            title_five = gr.Textbox("solar panels", label="Title")
            subtitle_five = gr.Textbox("Lowest Cost Solar Panels In America", label="Subtitle")
            btn_primary_five = gr.Textbox("Order now", label="Primary Button")
            btn_secondary_five = gr.Textbox("Learn more", label="Secondary Button")

            gr.Markdown("### Section 6 (Solar Roofs)")
            title_six = gr.Textbox("Solar roofs", label="Title")
            subtitle_six = gr.Textbox("Produce Clean Energy From Your Roof", label="Subtitle")
            btn_primary_six = gr.Textbox("Order now", label="Primary Button")
            btn_secondary_six = gr.Textbox("Learn more", label="Secondary Button")

            gr.Markdown("### Section 7 (Accessories)")
            title_seven = gr.Textbox("Accessories", label="Title")
            btn_primary_seven = gr.Textbox("Shop now", label="Primary Button")

            generate_btn = gr.Button("Generate & Preview", variant="primary")

        with gr.Column(scale=2):
            preview = gr.HTML(label="Live Preview")
            download = gr.File(label="Download Updated index.html")

    generate_btn.click(
        generate_html,
        inputs=[
            title_one, subtitle_one, btn_primary_one, btn_secondary_one,
            title_two, subtitle_two, btn_primary_two, btn_secondary_two,
            title_three, subtitle_three, btn_primary_three, btn_secondary_three,
            title_four, subtitle_four, btn_primary_four, btn_secondary_four,
            title_five, subtitle_five, btn_primary_five, btn_secondary_five,
            title_six, subtitle_six, btn_primary_six, btn_secondary_six,
            title_seven, btn_primary_seven
        ],
        outputs=[download, preview]
    )

if __name__ == "__main__":
    demo.launch()