drakosfire
commited on
Commit
•
3ee2b47
1
Parent(s):
cd4a8f3
WIP: block_builder.py mid building of owner html functions
Browse files- block_builder.py +71 -12
block_builder.py
CHANGED
@@ -26,11 +26,27 @@ def build_blocks(user_input, block_id):
|
|
26 |
block_id= block_id)
|
27 |
block_id = block_id + 1
|
28 |
list_of_blocks.append(store_properties_block)
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
return list_of_blocks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
def build_title_block(title,description,backstory,reputation):
|
36 |
title_block_html = f"""<div class="block-item" data-block-id = {block_id}><h1><textarea class="title-textarea" id="user-store-title" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-name" hx-swap="outerHTML" title="Name of store">{title}</textarea></h1><div contenteditable="true" class="description-textarea" id="user-store-description"
|
@@ -119,17 +135,7 @@ def build_store_properties_block(store_type,
|
|
119 |
store_owners = []
|
120 |
store_employees = []
|
121 |
|
122 |
-
|
123 |
-
iterable_html = f""""""
|
124 |
-
for item in iterable:
|
125 |
-
item_html = f"""<tr>
|
126 |
-
<td align="left"><strong>{iterable_type}</strong></td>
|
127 |
-
<td align="right"><textarea class="string-action-description-textarea" id="user-store-owners-{block_id}"
|
128 |
-
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-{block_id}t" hx-swap="outerHTML"
|
129 |
-
title="Store Size">{item['name']}</textarea></td>
|
130 |
-
</tr>"""
|
131 |
-
iterable_html += item_html
|
132 |
-
return iterable_html
|
133 |
def process_rumors_into_html(rumors, block_id):
|
134 |
rumors_html = f""""""
|
135 |
for rumor in rumors:
|
@@ -146,7 +152,17 @@ def build_store_properties_block(store_type,
|
|
146 |
employees_html = process_iterable_into_html('Store Employees', store_employees, block_id)
|
147 |
store_specialties_html = process_iterable_into_html('Store Specialties', store_specialties, block_id)
|
148 |
store_services_html = process_iterable_into_html('Store Services', store_services, block_id)
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
store_iterables_html = f"""
|
152 |
{owners_html}
|
@@ -172,6 +188,49 @@ def build_store_properties_block(store_type,
|
|
172 |
{store_end_html}"""
|
173 |
return store_properties_block_html
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
def list_names_to_str(data):
|
176 |
list_of_names = []
|
177 |
for i in data:
|
|
|
26 |
block_id= block_id)
|
27 |
block_id = block_id + 1
|
28 |
list_of_blocks.append(store_properties_block)
|
29 |
+
# Iterate over owners and generate owner image and details block
|
30 |
+
for owner in user_input['store_owners']:
|
31 |
+
owner_block = build_owner_block(owner, block_id)
|
32 |
+
block_id = block_id + 1
|
33 |
+
list_of_blocks.append(owner_block)
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
return list_of_blocks
|
39 |
+
def process_iterable_into_html(iterable_type, iterable, block_id):
|
40 |
+
iterable_html = f""""""
|
41 |
+
for item in iterable:
|
42 |
+
item_html = f"""<tr>
|
43 |
+
<td align="left"><strong>{iterable_type}</strong></td>
|
44 |
+
<td align="right"><textarea class="string-action-description-textarea" id="user-store-owners-{block_id}"
|
45 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-{block_id}t" hx-swap="outerHTML"
|
46 |
+
title="Store Size">{item['name']}</textarea></td>
|
47 |
+
</tr>"""
|
48 |
+
iterable_html += item_html
|
49 |
+
return iterable_html
|
50 |
|
51 |
def build_title_block(title,description,backstory,reputation):
|
52 |
title_block_html = f"""<div class="block-item" data-block-id = {block_id}><h1><textarea class="title-textarea" id="user-store-title" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-name" hx-swap="outerHTML" title="Name of store">{title}</textarea></h1><div contenteditable="true" class="description-textarea" id="user-store-description"
|
|
|
135 |
store_owners = []
|
136 |
store_employees = []
|
137 |
|
138 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
def process_rumors_into_html(rumors, block_id):
|
140 |
rumors_html = f""""""
|
141 |
for rumor in rumors:
|
|
|
152 |
employees_html = process_iterable_into_html('Store Employees', store_employees, block_id)
|
153 |
store_specialties_html = process_iterable_into_html('Store Specialties', store_specialties, block_id)
|
154 |
store_services_html = process_iterable_into_html('Store Services', store_services, block_id)
|
155 |
+
def process_secrets_into_html(secrets, block_id):
|
156 |
+
secrets_html = f""""""
|
157 |
+
for secret in secrets:
|
158 |
+
secret_html = f"""<tr>
|
159 |
+
<td align="left"><strong>Secrets</strong></td>
|
160 |
+
<td align="right"><textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
161 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
162 |
+
title="Store Size">{secret}</textarea></td>
|
163 |
+
</tr>"""
|
164 |
+
secrets_html += secret_html
|
165 |
+
return secrets_html
|
166 |
|
167 |
store_iterables_html = f"""
|
168 |
{owners_html}
|
|
|
188 |
{store_end_html}"""
|
189 |
return store_properties_block_html
|
190 |
|
191 |
+
def build_owner_block(owner, owner_id,block_id):
|
192 |
+
# Owner block with values : Name, Race, Class, Description, Personality, Secrets, sd-prompt
|
193 |
+
owner_name_html = process_iterable_into_html('Owner', [owner['name']], block_id)
|
194 |
+
owner_race_html = process_iterable_into_html('Race', [owner['race']], block_id)
|
195 |
+
owner_class_html = process_iterable_into_html('Class', [owner['class']], block_id)
|
196 |
+
owner_description_html = process_iterable_into_html('Description', [owner['description']], block_id)
|
197 |
+
owner_personality_html = process_iterable_into_html('Personality', [owner['personality']], block_id)
|
198 |
+
owner_secrets_html = process_iterable_into_html('Secrets', [owner['secrets']], block_id)
|
199 |
+
owner_block_html = f"""
|
200 |
+
<div class="block-item" data-block-id="{block_id}">
|
201 |
+
<h3 id="owner_{owner_id}">F{owner['name']}</h3>
|
202 |
+
<table>
|
203 |
+
<thead>
|
204 |
+
<tr>
|
205 |
+
<th align="center"></th>
|
206 |
+
<th align="center"></th>
|
207 |
+
</tr>
|
208 |
+
</thead>
|
209 |
+
<tbody>
|
210 |
+
<tr>
|
211 |
+
<td align="center"><strong>Species</strong></td>
|
212 |
+
<td align="right">{owner['species']}</td>
|
213 |
+
</tr>
|
214 |
+
<tr>
|
215 |
+
<td align="center"><strong>Class</strong></td>
|
216 |
+
<td align="right">{owner['class']}</td>
|
217 |
+
</tr>
|
218 |
+
<tr>
|
219 |
+
<td align="center"><strong>Description</strong></td>
|
220 |
+
<td align="left">{}</td>
|
221 |
+
</tr>
|
222 |
+
<tr>
|
223 |
+
<td align="center"><strong>Personality</strong></td>
|
224 |
+
<td align="left">Joyful, playful, and a tad mischievous.</td>
|
225 |
+
</tr>
|
226 |
+
<tr>
|
227 |
+
<td align="center"><strong>Secrets</strong></td>
|
228 |
+
<td align="left">Fizzwidget once performed a jester act for the Queen of Faerun.<br> He has a hidden collection of practical jokes for special customers.</td>
|
229 |
+
</tr>
|
230 |
+
</tbody>
|
231 |
+
</table>
|
232 |
+
</div>
|
233 |
+
"""
|
234 |
def list_names_to_str(data):
|
235 |
list_of_names = []
|
236 |
for i in data:
|