Spaces:
Sleeping
Sleeping
Commit
·
a59b358
1
Parent(s):
f6ba86d
Refactored and built build_section_entry_block and added Security section. Modified css and did some styling, created subtitle-textarea class in css.
Browse files- block_builder.py +60 -35
- storeUI.html +25 -2
block_builder.py
CHANGED
|
@@ -38,7 +38,6 @@ def build_blocks(user_input, block_id):
|
|
| 38 |
owner_title_block = f"""<h2 id="owner">{owner_title}</h2>"""
|
| 39 |
|
| 40 |
for owner in user_input['store_owners']:
|
| 41 |
-
|
| 42 |
owner_image_block = build_image_block(owner['sd_prompt'], block_id)
|
| 43 |
block_id = block_id + 1
|
| 44 |
list_of_blocks.append(owner_image_block)
|
|
@@ -54,6 +53,7 @@ def build_blocks(user_input, block_id):
|
|
| 54 |
employee_title = "Employees"
|
| 55 |
employee_title_block = f"""<h2 id="employee">{employee_title}</h2>"""
|
| 56 |
for employee in user_input['store_employees']:
|
|
|
|
| 57 |
employee_image_block = build_image_block(employee['sd_prompt'], block_id)
|
| 58 |
block_id = block_id + 1
|
| 59 |
list_of_blocks.append(employee_image_block)
|
|
@@ -64,11 +64,39 @@ def build_blocks(user_input, block_id):
|
|
| 64 |
|
| 65 |
customer_id = 1
|
| 66 |
for customer in user_input['store_customers']:
|
| 67 |
-
customers_block =
|
| 68 |
block_id = block_id + 1
|
| 69 |
customer_id += 1
|
| 70 |
list_of_blocks.append(customers_block)
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
return list_of_blocks
|
| 74 |
|
|
@@ -159,7 +187,8 @@ def build_store_properties_block(store_type,
|
|
| 159 |
store_reputation,
|
| 160 |
store_rumors,
|
| 161 |
block_id):
|
| 162 |
-
|
|
|
|
| 163 |
store_properties_base_html = f"""
|
| 164 |
<div class="block-item" data-block-id="{block_id}">
|
| 165 |
<div class="block classTable frame decoration">
|
|
@@ -258,9 +287,9 @@ def build_owner_block(owner, owner_id, owner_title_block, block_id):
|
|
| 258 |
owner_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
| 259 |
if owner_id == 1:
|
| 260 |
owner_block_html+= owner_title_block
|
| 261 |
-
owner_block_html += f"""<h3 id="owner_{owner_id}"><textarea class="
|
| 262 |
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
| 263 |
-
title="Owner Name">{owner['name']}</textarea
|
| 264 |
owner_block_html += f"""<table>
|
| 265 |
<thead>
|
| 266 |
<tr>
|
|
@@ -296,7 +325,10 @@ def build_employee_block(employee, employee_id, employee_title_block, block_id):
|
|
| 296 |
employee_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
| 297 |
if employee_id == 1:
|
| 298 |
employee_block_html += employee_title_block
|
| 299 |
-
employee_block_html += f"""<h3 id="
|
|
|
|
|
|
|
|
|
|
| 300 |
<table>
|
| 301 |
<thead>
|
| 302 |
<tr>
|
|
@@ -316,36 +348,29 @@ def build_employee_block(employee, employee_id, employee_title_block, block_id):
|
|
| 316 |
"""
|
| 317 |
return employee_block_html
|
| 318 |
|
| 319 |
-
#
|
| 320 |
-
def
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
if
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
quests_block_html += f"""<h1 id="store-quests">Store Quests</h1> """
|
| 341 |
|
| 342 |
-
|
| 343 |
-
<div class="Block_10">
|
| 344 |
-
|
| 345 |
-
<h3 id="the-basilisk-bounty">The Basilisk Bounty</h3>
|
| 346 |
-
<p>Morgor needs fresh basilisk meat and offers a handsome reward for those brave enough to hunt one.</p>
|
| 347 |
-
<p>500 gold coins and choice cuts of meat.</p>
|
| 348 |
-
</div>"""
|
| 349 |
|
| 350 |
#Text Area Template
|
| 351 |
"""<textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
|
|
|
| 38 |
owner_title_block = f"""<h2 id="owner">{owner_title}</h2>"""
|
| 39 |
|
| 40 |
for owner in user_input['store_owners']:
|
|
|
|
| 41 |
owner_image_block = build_image_block(owner['sd_prompt'], block_id)
|
| 42 |
block_id = block_id + 1
|
| 43 |
list_of_blocks.append(owner_image_block)
|
|
|
|
| 53 |
employee_title = "Employees"
|
| 54 |
employee_title_block = f"""<h2 id="employee">{employee_title}</h2>"""
|
| 55 |
for employee in user_input['store_employees']:
|
| 56 |
+
|
| 57 |
employee_image_block = build_image_block(employee['sd_prompt'], block_id)
|
| 58 |
block_id = block_id + 1
|
| 59 |
list_of_blocks.append(employee_image_block)
|
|
|
|
| 64 |
|
| 65 |
customer_id = 1
|
| 66 |
for customer in user_input['store_customers']:
|
| 67 |
+
customers_block = build_section_entry_block('Customers',customer, customer_id, block_id)
|
| 68 |
block_id = block_id + 1
|
| 69 |
customer_id += 1
|
| 70 |
list_of_blocks.append(customers_block)
|
| 71 |
|
| 72 |
+
quest_id = 1
|
| 73 |
+
for quest in user_input['store_quests']:
|
| 74 |
+
quests_block = build_section_entry_block('Store Quests', quest, quest_id, block_id)
|
| 75 |
+
block_id = block_id + 1
|
| 76 |
+
quest_id += 1
|
| 77 |
+
list_of_blocks.append(quests_block)
|
| 78 |
+
|
| 79 |
+
services_id = 1
|
| 80 |
+
for service in user_input['store_services']:
|
| 81 |
+
services_block = build_section_entry_block('Services', service, services_id, block_id)
|
| 82 |
+
block_id = block_id + 1
|
| 83 |
+
services_id += 1
|
| 84 |
+
list_of_blocks.append(services_block)
|
| 85 |
+
|
| 86 |
+
specialties_id = 1
|
| 87 |
+
for specialty in user_input['store_specialties']:
|
| 88 |
+
specialty_block = build_section_entry_block('Specialties', specialty, specialties_id, block_id)
|
| 89 |
+
block_id = block_id + 1
|
| 90 |
+
specialties_id += 1
|
| 91 |
+
list_of_blocks.append(specialty_block)
|
| 92 |
+
|
| 93 |
+
security_id = 1
|
| 94 |
+
for security in user_input['store_security']:
|
| 95 |
+
security_block = build_section_entry_block('Security', security, security_id, block_id)
|
| 96 |
+
block_id = block_id + 1
|
| 97 |
+
security_id += 1
|
| 98 |
+
list_of_blocks.append(security_block)
|
| 99 |
+
|
| 100 |
|
| 101 |
return list_of_blocks
|
| 102 |
|
|
|
|
| 187 |
store_reputation,
|
| 188 |
store_rumors,
|
| 189 |
block_id):
|
| 190 |
+
|
| 191 |
+
# This could be the iterable block function with additional flexibility
|
| 192 |
store_properties_base_html = f"""
|
| 193 |
<div class="block-item" data-block-id="{block_id}">
|
| 194 |
<div class="block classTable frame decoration">
|
|
|
|
| 287 |
owner_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
| 288 |
if owner_id == 1:
|
| 289 |
owner_block_html+= owner_title_block
|
| 290 |
+
owner_block_html += f"""<h3 id="owner_{owner_id}"><textarea class="subtitle-textarea" id="user-store-rumors-{block_id}"
|
| 291 |
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
| 292 |
+
title="Owner Name">{owner['name']}</textarea></h3>"""
|
| 293 |
owner_block_html += f"""<table>
|
| 294 |
<thead>
|
| 295 |
<tr>
|
|
|
|
| 325 |
employee_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
| 326 |
if employee_id == 1:
|
| 327 |
employee_block_html += employee_title_block
|
| 328 |
+
employee_block_html += f"""<h3 id="owner_{employee_id}"><textarea class="subtitle-textarea" id="user-store-rumors-{block_id}"
|
| 329 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
| 330 |
+
title="Owner Name">{employee['name']}</textarea>
|
| 331 |
+
</h3>
|
| 332 |
<table>
|
| 333 |
<thead>
|
| 334 |
<tr>
|
|
|
|
| 348 |
"""
|
| 349 |
return employee_block_html
|
| 350 |
|
| 351 |
+
# Section to take in a section name, entry, entry_id, and block_id and return the html for that section
|
| 352 |
+
def build_section_entry_block(section, entry, entry_id, block_id):
|
| 353 |
+
section_block_html = f""""""
|
| 354 |
+
section_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
| 355 |
+
if entry_id == 1:
|
| 356 |
+
section_block_html += f"""<h1 id="store-quests">{section}</h1> """
|
| 357 |
+
entry_features_list = list(entry.keys())
|
| 358 |
+
for feature in entry_features_list:
|
| 359 |
+
if feature == 'name':
|
| 360 |
+
section_block_html += f"""<h3 id="quest={entry_id}">
|
| 361 |
+
<textarea class="subtitle-textarea" id="user-store-rumors-{block_id}"
|
| 362 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
| 363 |
+
title={section}>{entry['name']}</textarea>
|
| 364 |
+
</h3>"""
|
| 365 |
+
else:
|
| 366 |
+
feature_name = feature[0].upper() + feature[1:]
|
| 367 |
+
section_block_html += f"""<p>
|
| 368 |
+
<textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
| 369 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
| 370 |
+
title={section}>{feature_name}: {entry[feature]}</textarea>
|
| 371 |
+
</p>"""
|
|
|
|
| 372 |
|
| 373 |
+
return section_block_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
|
| 375 |
#Text Area Template
|
| 376 |
"""<textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
storeUI.html
CHANGED
|
@@ -106,6 +106,9 @@
|
|
| 106 |
.page .monster hr:last-of-type + * {
|
| 107 |
margin-top: .1cm;
|
| 108 |
}
|
|
|
|
|
|
|
|
|
|
| 109 |
.page * + h4 {
|
| 110 |
margin-top: .1cm;
|
| 111 |
}
|
|
@@ -253,7 +256,28 @@ input[type="text"]:focus, textarea:focus {
|
|
| 253 |
}
|
| 254 |
.title-textarea{
|
| 255 |
height:30px;
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
column-span: all;
|
| 258 |
font-size: .89cm;
|
| 259 |
line-height: 1em;
|
|
@@ -724,7 +748,6 @@ div[contenteditable="true"] p::first-letter {
|
|
| 724 |
// Initial run on page load
|
| 725 |
initializeTextareaResizing();
|
| 726 |
|
| 727 |
-
|
| 728 |
async function extractBlocks() {
|
| 729 |
|
| 730 |
try {
|
|
|
|
| 106 |
.page .monster hr:last-of-type + * {
|
| 107 |
margin-top: .1cm;
|
| 108 |
}
|
| 109 |
+
.page * + h3 {
|
| 110 |
+
margin-top: .05cm;
|
| 111 |
+
}
|
| 112 |
.page * + h4 {
|
| 113 |
margin-top: .1cm;
|
| 114 |
}
|
|
|
|
| 256 |
}
|
| 257 |
.title-textarea{
|
| 258 |
height:30px;
|
| 259 |
+
width: 100%;
|
| 260 |
+
margin-bottom: 5px;
|
| 261 |
+
column-span: all;
|
| 262 |
+
font-size: .89cm;
|
| 263 |
+
line-height: 1em;
|
| 264 |
+
font-family: "MrEavesRemake";
|
| 265 |
+
font-weight: 800;
|
| 266 |
+
color: var(--HB_Color_HeaderText);
|
| 267 |
+
border: 0;
|
| 268 |
+
font: inherit;
|
| 269 |
+
background: none;
|
| 270 |
+
padding: 0;
|
| 271 |
+
resize: none; /* Prevents the textarea from being resizable */
|
| 272 |
+
overflow: hidden; /* Prevents scrollbars */
|
| 273 |
+
outline: none; /* Removes the focus outline */
|
| 274 |
+
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
.subtitle-textarea{
|
| 278 |
+
height:20px;
|
| 279 |
+
width: 100%;
|
| 280 |
+
margin-bottom: 5px;
|
| 281 |
column-span: all;
|
| 282 |
font-size: .89cm;
|
| 283 |
line-height: 1em;
|
|
|
|
| 748 |
// Initial run on page load
|
| 749 |
initializeTextareaResizing();
|
| 750 |
|
|
|
|
| 751 |
async function extractBlocks() {
|
| 752 |
|
| 753 |
try {
|