Index: src/ajax.c ================================================================== --- src/ajax.c +++ src/ajax.c @@ -264,16 +264,18 @@ } return rc; } /* -** AJAX route /ajax/preview-wiki +** AJAX route /ajax/preview-text ** ** Required query parameters: ** ** filename=name of content, for use in determining the -** mimetype/render mode. content=text +** mimetype/render mode. +** +** content=text ** ** Optional query parameters: ** ** render_mode=integer (AJAX_RENDER_xxx) (default=AJAX_RENDER_GUESS) ** @@ -365,11 +367,11 @@ const AjaxRoute * rB = (const AjaxRoute*)b; return fossil_strcmp(rA->zName, rB->zName); } /* -** WEBPAGE: ajax +** WEBPAGE: ajax hidden ** ** The main dispatcher for shared ajax-served routes. Requires the ** 'name' parameter be the main route's name (as defined in a list in ** this function), noting that fossil automatically assigns all path ** parts after "ajax" to "name", e.g. /ajax/foo/bar assigns Index: src/chat.c ================================================================== --- src/chat.c +++ src/chat.c @@ -125,11 +125,11 @@ */ /* ** 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 one of a builtin WAV file. +** The value must be the name of a builtin WAV file. */ /* ** WEBPAGE: chat ** ** Start up a browser-based chat session. @@ -154,19 +154,25 @@ zProjectName = db_get("project-name","Unnamed project"); style_set_current_feature("chat"); style_header("Chat"); @
@
- @
+ @
@ + @ placeholder="Type markdown-formatted message for %h(zProjectName)." \ + @ autocomplete="off"> @ - @ - @ + @
+ @ + @ + @ + @
@
@
@
@
@ Select a file to upload, drag/drop a file into this spot, @@ -177,21 +183,27 @@ @
@
@
@
@ + @ @ @
/* New chat messages get inserted immediately after this element */ @ @
fossil_free(zProjectName); - builtin_fossil_js_bundle_or("popupwidget", "storage", "fetch", NULL); + builtin_fossil_js_bundle_or("popupwidget", "storage", + "fetch", "pikchr", NULL); /* Always in-line the javascript for the chat page */ @ @@ -294,11 +307,11 @@ } fossil_free(zTime); } /* -** WEBPAGE: chat-send +** 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 @@ -347,79 +360,25 @@ db_commit_transaction(); } /* ** This routine receives raw (user-entered) message text and transforms -** it into HTML that is safe to insert using innerHTML. -** -** * HTML in the original text is escaped. -** -** * Hyperlinks are identified and tagged. Hyperlinks are: -** -** - Undelimited text of the form https:... or http:... -** - Any text enclosed within [...] +** 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){ - char *zSafe = mprintf("%h", zMsg); - int i, j, k; Blob out; - char zClose[20]; - blob_init(&out, 0, 0); - for(i=j=0; zSafe[i]; i++){ - if( zSafe[i]=='[' ){ - for(k=i+1; zSafe[k] && zSafe[k]!=']'; k++){} - if( zSafe[k]==']' ){ - zSafe[k] = 0; - if( ji+7 ){ - char c = zSafe[k]; - if( !fossil_isalnum(zSafe[k-1]) && zSafe[k-1]!='/' ){ - k--; - c = zSafe[k]; - } - if( j