Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Elide the chat-timeline-user's entries from /chat-search results. We would ideally elide those from the fts index altogether, but that name can be changed at any time and such a change would leave the fts update trigger out of sync. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | fts5-chat-search |
| Files: | files | file ages | folders |
| SHA3-256: |
1d64640ec753387b719a129399858312 |
| User & Date: | stephan 2024-06-30 09:25:28.530 |
Context
|
2024-06-30
| ||
| 09:59 | Extend test-chat-formatter to be able to render both wiki and markdown. ... (check-in: 09ee2c8e71 user: stephan tags: fts5-chat-search) | |
| 09:25 | Elide the chat-timeline-user's entries from /chat-search results. We would ideally elide those from the fts index altogether, but that name can be changed at any time and such a change would leave the fts update trigger out of sync. ... (check-in: 1d64640ec7 user: stephan tags: fts5-chat-search) | |
|
2024-06-24
| ||
| 20:52 | Add new page /chat-search, for searching chat history. ... (check-in: 89f82e6603 user: dan tags: fts5-chat-search) | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
300 301 302 303 304 305 306 |
/* Always in-line the javascript for the chat page */
@ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
/* We need an onload handler to ensure that window.fossil is
initialized before the chat init code runs. */
@ window.addEventListener('load', function(){
@ document.body.classList.add('chat');
@ /*^^^for skins which add their own BODY tag */;
| < < | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
/* Always in-line the javascript for the chat page */
@ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
/* We need an onload handler to ensure that window.fossil is
initialized before the chat init code runs. */
@ window.addEventListener('load', function(){
@ document.body.classList.add('chat');
@ /*^^^for skins which add their own BODY tag */;
@ }, false);
@ </script>
builtin_request_js("fossil.page.chatsearch.js");
style_finish_page();
}
|
| ︙ | ︙ | |||
341 342 343 344 345 346 347 |
if( !db_table_has_column("repository","chat","mdel") ){
db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
}
db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT");
}
if( !db_table_exists("repository", "chatfts1") ){
| | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
if( !db_table_has_column("repository","chat","mdel") ){
db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
}
db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT");
}
if( !db_table_exists("repository", "chatfts1") ){
db_multi_exec(
"CREATE VIRTUAL TABLE chatfts1 USING fts5("
" xmsg, content=chat, content_rowid=msgid, tokenize=porter"
");"
"CREATE TRIGGER chat_ai AFTER INSERT ON chat BEGIN "
" INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);"
"END;"
"CREATE TRIGGER chat_ad AFTER DELETE ON chat BEGIN "
|
| ︙ | ︙ | |||
788 789 790 791 792 793 794 795 796 797 798 799 |
chat_emit_permissions_error(1);
return;
}
chat_create_tables();
cgi_set_content_type("application/json");
if( zQuery[0] ){
iMax = db_int64(0, "SELECT max(msgid) FROM chat");
iMin = db_int64(0, "SELECT min(msgid) FROM chat");
blob_append_sql(&sql,
"SELECT * FROM ("
"SELECT c.msgid, datetime(c.mtime), c.xfrom, "
| > | | > > > > > > > > > | | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 |
chat_emit_permissions_error(1);
return;
}
chat_create_tables();
cgi_set_content_type("application/json");
if( zQuery[0] ){
char *zChatRobot = db_get("chat-timeline-user", 0);
iMax = db_int64(0, "SELECT max(msgid) FROM chat");
iMin = db_int64(0, "SELECT min(msgid) FROM chat");
blob_append_sql(&sql,
"SELECT * FROM ("
"SELECT c.msgid, datetime(c.mtime), c.xfrom, "
" highlight(chatfts1, 0, '<span class=\"match\">', '</span>'), "
" octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime"
" FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid ",
zQuery
);
if( zChatRobot!=0 ){
if( zChatRobot[0]!=0 ){
blob_append_sql(&sql, "AND c.xfrom IS NOT %Q ", zChatRobot);
}
fossil_free( zChatRobot );
}
blob_append_sql(&sql,
" ORDER BY f.rowid DESC LIMIT %d"
") ORDER BY 1 ASC", nLimit
);
}else{
blob_append_sql(&sql,
"SELECT msgid, datetime(mtime), xfrom, "
" xmsg, octet_length(file), fname, fmime, mdel, lmtime"
" FROM chat WHERE msgid>=%d LIMIT %d",
iFirst, nLimit
|
| ︙ | ︙ |
Changes to src/fossil.page.chatsearch.js.
1 | /* | | | 1 2 3 4 5 6 7 8 9 |
/*
** This file contains the client-side implementation of fossil's
** /chat-search application.
*/
window.fossil.onPageLoad(function(){
const F = window.fossil, D = F.dom;
const E1 = function(selector){
const e = document.querySelector(selector);
|
| ︙ | ︙ | |||
110 111 112 113 114 115 116 |
const isHidden = iframe.classList.contains('hidden');
if(isHidden) D.removeClass(iframe, 'hidden');
iframe.style.maxHeight = iframe.style.height
= iframe.contentWindow.document.documentElement.scrollHeight + 'px';
if(isHidden) D.addClass(iframe, 'hidden');
}
};
| | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
const isHidden = iframe.classList.contains('hidden');
if(isHidden) D.removeClass(iframe, 'hidden');
iframe.style.maxHeight = iframe.style.height
= iframe.contentWindow.document.documentElement.scrollHeight + 'px';
if(isHidden) D.addClass(iframe, 'hidden');
}
};
cf.prototype = {
scrollIntoView: function(){
this.e.content.scrollIntoView();
},
setMessage: function(m){
const ds = this.e.body.dataset;
ds.timestamp = m.mtime;
|
| ︙ | ︙ | |||
386 387 388 389 390 391 392 |
onerror:function(err){
console.error(err);
alert(err.toString());
},
onload:function(jx){
| < | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
onerror:function(err){
console.error(err);
alert(err.toString());
},
onload:function(jx){
const firstChildOfBelow = e.below.firstChild;
jx.msgs.forEach((m) => {
var mw = new MessageWidget(m);
if( bDown ){
e.below.insertBefore(mw.e.body, firstChildOfBelow);
}else{
D.append(e.above, mw.e.body);
|
| ︙ | ︙ | |||
409 410 411 412 413 414 415 |
ms.set_button_visibility();
ms.bIgnoreClick = false;
}
});
}
};
| | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
ms.set_button_visibility();
ms.bIgnoreClick = false;
}
});
}
};
return cf;
})(); /* MessageSpacer */
/* This is called to submit a search - because the user clicked the
** search button or pressed Enter in the input box.
*/
const submit_search = function() {
|
| ︙ | ︙ | |||
468 469 470 471 472 473 474 |
window.scrollTo(0, E1('body').scrollHeight);
}
});
}
/* Add event listeners to call submit_search() if the user presses Enter
** or clicks the search button.
| | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
window.scrollTo(0, E1('body').scrollHeight);
}
});
}
/* Add event listeners to call submit_search() if the user presses Enter
** or clicks the search button.
*/
E1('#searchbutton').addEventListener('click', function(){
submit_search();
});
E1('#textinput').addEventListener('keydown', function(ev){
if( 13==ev.keyCode ){
/* If the key pressed was Enter */
submit_search();
|
| ︙ | ︙ |