login: Don't show an empty / undefined code of conduct.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 10m26s

This commit is contained in:
2025-11-19 12:39:06 -05:00
parent 35f374047a
commit dae38bbd83
2 changed files with 9 additions and 3 deletions

View File

@@ -75,6 +75,10 @@
margin-bottom: 1em;
padding: 1em;
}
#code_of_conduct:has(>textarea:empty) {
display: none;
width: 100%;
}
</style>
<div style="display: flex; flex-direction: column; max-width: 1280px; margin: auto">
<h1 ?hidden=${this.name}>Welcome.</h1>
@@ -126,8 +130,10 @@
There is currently no administrator. You will be made administrator.
</div>
<h2>Code of Conduct</h2>
<textarea readonly rows="20" cols="80" style="resize: none">${this.code_of_conduct}</textarea>
<div id="code_of_conduct">
<h2>Code of Conduct</h2>
<textarea readonly rows="20" style="resize: none; width: 100%">${this.code_of_conduct}</textarea>
</div>
</div>
`;
}

View File

@@ -352,7 +352,7 @@ static void _httpd_endpoint_login_work(tf_ssb_t* ssb, void* user_data)
{
JSValue settings_value = JS_ParseJSON(context, login->settings, strlen(login->settings), NULL);
JSValue code_of_conduct_value = JS_GetPropertyStr(context, settings_value, "code_of_conduct");
const char* code_of_conduct = JS_ToCString(context, code_of_conduct_value);
const char* code_of_conduct = JS_IsString(code_of_conduct_value) ? JS_ToCString(context, code_of_conduct_value) : NULL;
const char* result = tf_strdup(code_of_conduct);
JS_FreeCString(context, code_of_conduct);
JS_FreeValue(context, code_of_conduct_value);