Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the /Admin/Chat page. Add settings to configure the initial history load size of /chat, and to configure purging of historical messages. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
15bc20f29db30502a3ddf5a34f3f5e9f |
| User & Date: | drh 2020-12-23 20:58:24.077 |
Context
|
2020-12-23
| ||
| 22:16 | Chat: disable pasting of text when then input field does NOT have focus and fix complete overwriting of input field when pasting and it DOES have focus. Whether or not we should paste to that field when it does not have focus is debatable and possibly violates the Principle of Least Surprise. ... (check-in: 87ff8fe357 user: stephan tags: trunk) | |
| 20:58 | Add the /Admin/Chat page. Add settings to configure the initial history load size of /chat, and to configure purging of historical messages. ... (check-in: 15bc20f29d user: drh tags: trunk) | |
| 19:55 | Turn off autocomplete on the chat entry form. ... (check-in: 5715978d9f user: drh tags: trunk) | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
** more elegant, but are not compatible with CGI, and would thus complicate
** configuration.
*/
#include "config.h"
#include <assert.h>
#include "chat.h"
/*
** WEBPAGE: chat
**
** Start up a browser-based chat session.
*/
void chat_webpage(void){
login_check_credentials();
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
** more elegant, but are not compatible with CGI, and would thus complicate
** configuration.
*/
#include "config.h"
#include <assert.h>
#include "chat.h"
/* Settings that can be used to control chat */
/*
** SETTING: chat-initial-history width=10 default=50
**
** If this setting has an integer value of N, then when /chat first
** starts up it initializes the screen with the N most recent chat
** messages. If N is zero, then all chat messages are loaded.
*/
/*
** SETTING: chat-keep-count width=10 default=50
**
** When /chat is cleaning up older messages, it will always keep
** the most recent chat-keep-count messages, even if some of those
** messages are older than the discard threshold. If this value
** is zero, then /chat is free to delete all historic messages once
** they are old enough.
*/
/*
** SETTING: chat-keep-days width=10 default=7
**
** The /chat subsystem will try to discard messages that are older then
** chat-keep-days. The value of chat-keep-days can be a floating point
** number. So, for example, if you only want to keep chat messages for
** 12 hours, set this value to 0.5.
**
** A value of 0.0 or less means that messages are retained forever.
*/
/*
** WEBPAGE: chat
**
** Start up a browser-based chat session.
*/
void chat_webpage(void){
login_check_credentials();
|
| ︙ | ︙ | |||
89 90 91 92 93 94 95 |
@ #chat-input-file-area > .help-buttonlet,
@ #chat-input-file {
@ align-self: flex-start;
@ margin-right: 0.5em;
@ flex: 0 1 auto;
@ }
@ #chat-input-file {
| | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
@ #chat-input-file-area > .help-buttonlet,
@ #chat-input-file {
@ align-self: flex-start;
@ margin-right: 0.5em;
@ flex: 0 1 auto;
@ }
@ #chat-input-file {
@ border:1px solid rgba(0,0,0,0);/*avoid UI shift during drop-targeting*/
@ border-radius: 0.25em;
@ }
@ #chat-input-file > input {
@ flex: 1 0 auto;
@ }
@ .chat-timestamp {
@ font-family: monospace;
|
| ︙ | ︙ | |||
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
/* New chat messages get inserted immediately after this element */
@ <span id='message-inject-point'></span>
builtin_fossil_js_bundle_or("popupwidget", NULL);
/* Always in-line the javascript for the chat page */
@ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
@ window.addEventListener('load', function(){
/* We need an onload handler to ensure that window.fossil is
loaded first. */
cgi_append_content(builtin_text("chat.js"),-1);
@ }, false);
@ </script>
| > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
/* New chat messages get inserted immediately after this element */
@ <span id='message-inject-point'></span>
builtin_fossil_js_bundle_or("popupwidget", NULL);
/* Always in-line the javascript for the chat page */
@ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
@ window.fossilChatInitSize = %d(db_get_int("chat-initial-history",50));
@ window.addEventListener('load', function(){
/* We need an onload handler to ensure that window.fossil is
loaded first. */
cgi_append_content(builtin_text("chat.js"),-1);
@ }, false);
@ </script>
|
| ︙ | ︙ |
Changes to src/chat.js.
1 2 3 4 5 6 7 8 9 10 |
(function(){
const form = document.querySelector('#chat-form');
let mxMsg = -50;
const F = window.fossil, D = F.dom;
const _me = F.user.name;
/* State for paste and drag/drop */
const BlobXferState = {
dropDetails: document.querySelector('#chat-drop-details'),
blob: undefined
};
| > | 1 2 3 4 5 6 7 8 9 10 11 |
(function(){
const form = document.querySelector('#chat-form');
let mxMsg = -50;
if( window.fossilChatInitSize ) mxMsg = -window.fossilChatInitSize;
const F = window.fossil, D = F.dom;
const _me = F.user.name;
/* State for paste and drag/drop */
const BlobXferState = {
dropDetails: document.querySelector('#chat-drop-details'),
blob: undefined
};
|
| ︙ | ︙ |
Changes to src/setup.c.
| ︙ | ︙ | |||
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
setup_menu_entry("Login-Group", "setup_login_group",
"Manage single sign-on between this repository and others"
" on the same server");
setup_menu_entry("Tickets", "tktsetup",
"Configure the trouble-ticketing system for this repository");
setup_menu_entry("Wiki", "setup_wiki",
"Configure the wiki for this repository");
}
setup_menu_entry("Search","srchsetup",
"Configure the built-in search engine");
setup_menu_entry("URL Aliases", "waliassetup",
"Configure URL aliases");
if( setup_user ){
setup_menu_entry("Notification", "setup_notification",
| > > | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
setup_menu_entry("Login-Group", "setup_login_group",
"Manage single sign-on between this repository and others"
" on the same server");
setup_menu_entry("Tickets", "tktsetup",
"Configure the trouble-ticketing system for this repository");
setup_menu_entry("Wiki", "setup_wiki",
"Configure the wiki for this repository");
setup_menu_entry("Chat", "setup_chat",
"Configure the chatroom");
}
setup_menu_entry("Search","srchsetup",
"Configure the built-in search engine");
setup_menu_entry("URL Aliases", "waliassetup",
"Configure URL aliases");
if( setup_user ){
setup_menu_entry("Notification", "setup_notification",
|
| ︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | @ enabling, <i>all</i> HTML tags and attributes are accepted in the wiki. @ No sanitization is done. This means that it is very possible for malicious @ users to inject dangerous HTML, CSS and JavaScript code into your wiki.</p> @ <p>This should <strong>only</strong> be enabled when wiki editing is limited @ to trusted users. It should <strong>not</strong> be used on a publicly @ editable wiki.</p> @ (Property: "wiki-use-html") @ <hr /> @ <p><input type="submit" name="submit" value="Apply Changes" /></p> @ </div></form> db_end_transaction(0); style_finish_page(); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
@ enabling, <i>all</i> HTML tags and attributes are accepted in the wiki.
@ No sanitization is done. This means that it is very possible for malicious
@ users to inject dangerous HTML, CSS and JavaScript code into your wiki.</p>
@ <p>This should <strong>only</strong> be enabled when wiki editing is limited
@ to trusted users. It should <strong>not</strong> be used on a publicly
@ editable wiki.</p>
@ (Property: "wiki-use-html")
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_finish_page();
}
/*
** WEBPAGE: setup_chat
**
** The "Admin/Chat" page. Requires Setup privilege.
*/
void setup_chat(void){
login_check_credentials();
if( !g.perm.Setup ){
login_needed(0);
return;
}
style_set_current_feature("setup");
style_header("Chat Configuration");
db_begin_transaction();
@ <form action="%R/setup_chat" method="post"><div>
login_insert_csrf_secret();
@ <input type="submit" name="submit" value="Apply Changes" /></p>
@ <hr />
entry_attribute("Initial Chat History Size", 10,
"chat-initial-history", "chatih", "50", 0);
@ <p>When /chat first starts up, it preloads up to this many historical
@ messages.
@ (Property: "chat-initial-history")</p>
@ <hr />
entry_attribute("Minimum Number Of Historical Messages To Retain", 10,
"chat-keep-count", "chatkc", "50", 0);
@ <p>The chat subsystem purges older messages. But it will always retain
@ the N most recent messages where N is the value of this setting.
@ (Property: "chat-keep-count")</p>
@ <hr />
entry_attribute("Maximum Message Age In Days", 10,
"chat-keep-days", "chatkd", "7", 0);
@ <p>Chat message are removed after N days, where N is the value of
@ this setting. N may be fractional. So, for example, to only keep
@ an historical record of chat messages for 12 hours, set this value
@ to 0.5.
@ (Property: "chat-keep-days")</p>
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_finish_page();
}
|
| ︙ | ︙ |