Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | /chat now uses markdown, instead of its minimal custom markup. Chat messages are rendered at send-time, not save-time, so this retroactively affects all messages. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | chat-markdown |
| Files: | files | file ages | folders |
| SHA3-256: |
52d40548ed2a1176d4bc2fef710f11ae |
| User & Date: | stephan 2021-09-19 04:11:13.891 |
Context
|
2021-09-19
| ||
| 05:53 | Updated change log and chat.md for the /chat switch to markdown. ... (check-in: 32bd273ebf user: stephan tags: chat-markdown) | |
| 04:11 | /chat now uses markdown, instead of its minimal custom markup. Chat messages are rendered at send-time, not save-time, so this retroactively affects all messages. ... (check-in: 52d40548ed user: stephan tags: chat-markdown) | |
| 03:55 | Fixed a few minor errors in the new http-over-ssh.md doc and added a memorial to a fallen hero. ... (check-in: 9d4a132761 user: wyoung tags: trunk) | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
123 124 125 126 127 128 129 | ** For maximum efficiency, it is best to choose the longest delay that ** does not cause timeouts in intermediate proxies or web server. */ /* ** SETTING: chat-alert-sound width=10 ** ** This is the name of the builtin sound file to use for the alert tone. | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | ** For maximum efficiency, it is best to choose the longest delay that ** does not cause timeouts in intermediate proxies or web server. */ /* ** SETTING: chat-alert-sound width=10 ** ** This is the name of the builtin sound file to use for the alert tone. ** The value must be the name of a builtin WAV file. */ /* ** WEBPAGE: chat ** ** Start up a browser-based chat session. ** ** This is the main page that humans use to access the chatroom. Simply |
| ︙ | ︙ | |||
154 155 156 157 158 159 160 |
zProjectName = db_get("project-name","Unnamed project");
style_set_current_feature("chat");
style_header("Chat");
@ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
@ <div id='chat-input-area'>
@ <div id='chat-input-line'>
@ <input type="text" name="msg" id="chat-input-single" \
| | > | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
zProjectName = db_get("project-name","Unnamed project");
style_set_current_feature("chat");
style_header("Chat");
@ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
@ <div id='chat-input-area'>
@ <div id='chat-input-line'>
@ <input type="text" name="msg" id="chat-input-single" \
@ placeholder="Type markdown-formatted message for %h(zProjectName)." \
@ autocomplete="off">
@ <textarea rows="8" id="chat-input-multi" \
@ placeholder="Type markdown-formatted message for %h(zProjectName). Ctrl-Enter sends it." \
@ class="hidden"></textarea>
@ <input type="submit" value="Send" id="chat-message-submit">
@ <span id="chat-settings-button" class="settings-icon" \
@ aria-label="Settings..." aria-haspopup="true" ></span>
@ </div>
@ <div id='chat-input-file-area'>
@ <div class='file-selection-wrapper'>
|
| ︙ | ︙ | |||
292 293 294 295 296 297 298 |
}else{
CX("}");
}
fossil_free(zTime);
}
/*
| | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
}else{
CX("}");
}
fossil_free(zTime);
}
/*
** WEBPAGE: chat-send hidden
**
** This page receives (via XHR) a new chat-message and/or a new file
** to be entered into the chat history.
**
** On success it responds with an empty response: the new message
** should be fetched via /chat-poll. On error, e.g. login expiry,
** it emits a JSON response in the same form as described for
|
| ︙ | ︙ | |||
345 346 347 348 349 350 351 |
blob_reset(&b);
}
db_commit_transaction();
}
/*
** This routine receives raw (user-entered) message text and transforms
| | | < | < < < < < < < | < < < < < | < < < | < < < < < < | < < < < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
blob_reset(&b);
}
db_commit_transaction();
}
/*
** This routine receives raw (user-entered) message text and transforms
** it into HTML that is safe to insert using innerHTML. As of 2021-09-19,
** it does so by using markdown_to_html() to convert markdown-formatted
** zMsg to HTML.
**
** Space to hold the returned string is obtained from fossil_malloc()
** and must be freed by the caller.
*/
static char *chat_format_to_html(const char *zMsg){
Blob out;
blob_init(&out, "", 0);
if(*zMsg){
Blob bIn;
blob_init(&bIn, zMsg, (int)strlen(zMsg));
markdown_to_html(&bIn, NULL, &out);
}
return blob_str(&out);
}
/*
** COMMAND: test-chat-formatter
**
** Usage: %fossil test-chat-formatter STRING ...
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
zOut = chat_format_to_html(g.argv[i]);
fossil_print("[%d]: %s\n", i, zOut);
fossil_free(zOut);
}
}
/*
| | | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
zOut = chat_format_to_html(g.argv[i]);
fossil_print("[%d]: %s\n", i, zOut);
fossil_free(zOut);
}
}
/*
** WEBPAGE: chat-poll hidden
**
** The chat page generated by /chat using an XHR to this page to
** request new chat content. A typical invocation is:
**
** /chat-poll/N
** /chat-poll?name=N
**
|
| ︙ | ︙ | |||
649 650 651 652 653 654 655 | db_finalize(&q1); blob_append(&json, "\n]}", 3); cgi_set_content(&json); return; } /* | | | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | db_finalize(&q1); blob_append(&json, "\n]}", 3); cgi_set_content(&json); return; } /* ** WEBPAGE: chat-download hidden ** ** Download the CHAT.FILE attachment associated with a single chat ** entry. The "name" query parameter begins with an integer that ** identifies the particular chat message. The integer may be followed ** by a / and a filename, which will indicate to the browser to use ** the indicated name when saving the file. */ |
| ︙ | ︙ | |||
682 683 684 685 686 687 688 | db_blob(&r, "SELECT file FROM chat WHERE msgid=%d", msgid); cgi_set_content_type(zMime); cgi_set_content(&r); } /* | | | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
db_blob(&r, "SELECT file FROM chat WHERE msgid=%d", msgid);
cgi_set_content_type(zMime);
cgi_set_content(&r);
}
/*
** WEBPAGE: chat-delete hidden
**
** Delete the chat entry identified by the name query parameter.
** Invoking fetch("chat-delete/"+msgid) from javascript in the client
** will delete a chat entry from the CHAT table.
**
** This routine both deletes the identified chat entry and also inserts
** a new entry with the current timestamp and with:
|
| ︙ | ︙ |
Changes to src/default.css.
| ︙ | ︙ | |||
1627 1628 1629 1630 1631 1632 1633 |
border-radius: 0.25em;
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0.2em 0.2em 0.2em rgba(0, 0, 0, 0.29);
padding: 0.25em 0.5em;
margin-top: 0;
min-width: 9em /*avoid unsightly "underlap" with the neighboring
.message-widget-tab element*/;
| | > > > > > > > > > > | 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 |
border-radius: 0.25em;
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0.2em 0.2em 0.2em rgba(0, 0, 0, 0.29);
padding: 0.25em 0.5em;
margin-top: 0;
min-width: 9em /*avoid unsightly "underlap" with the neighboring
.message-widget-tab element*/;
white-space: normal;
}
body.chat.monospace-messages .message-widget-content,
body.chat.monospace-messages textarea,
body.chat.monospace-messages input[type=text]{
font-family: monospace;
}
body.chat .message-widget-content > .markdown {
margin: 0;
padding: 0;
}
body.chat .message-widget-content > .markdown > *:first-child {
margin-top: 0;
}
body.chat .message-widget-content > .markdown > *:last-child {
margin-bottom: 0;
}
/* User name and timestamp (a LEGEND-like element) */
body.chat .message-widget .message-widget-tab {
border-radius: 0.25em 0.25em 0 0;
margin: 0 0.25em 0em 0.15em;
padding: 0 0.5em 0.15em 0.5em;
cursor: pointer;
|
| ︙ | ︙ |