Fossil SCM
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.
Commit
1d64640ec753387b719a129399858312b5914f62ded24c6e7e13e0789000603f
Parent
89f82e660358400…
2 files changed
+14
-6
+4
-5
+14
-6
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -302,12 +302,10 @@ | ||
| 302 | 302 | /* We need an onload handler to ensure that window.fossil is |
| 303 | 303 | initialized before the chat init code runs. */ |
| 304 | 304 | @ window.addEventListener('load', function(){ |
| 305 | 305 | @ document.body.classList.add('chat'); |
| 306 | 306 | @ /*^^^for skins which add their own BODY tag */; |
| 307 | - // ajax_emit_js_preview_modes(0); | |
| 308 | - // chat_emit_alert_list(); | |
| 309 | 307 | @ }, false); |
| 310 | 308 | @ </script> |
| 311 | 309 | |
| 312 | 310 | builtin_request_js("fossil.page.chatsearch.js"); |
| 313 | 311 | style_finish_page(); |
| @@ -343,11 +341,11 @@ | ||
| 343 | 341 | } |
| 344 | 342 | db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT"); |
| 345 | 343 | } |
| 346 | 344 | |
| 347 | 345 | if( !db_table_exists("repository", "chatfts1") ){ |
| 348 | - db_multi_exec( | |
| 346 | + db_multi_exec( | |
| 349 | 347 | "CREATE VIRTUAL TABLE chatfts1 USING fts5(" |
| 350 | 348 | " xmsg, content=chat, content_rowid=msgid, tokenize=porter" |
| 351 | 349 | ");" |
| 352 | 350 | "CREATE TRIGGER chat_ai AFTER INSERT ON chat BEGIN " |
| 353 | 351 | " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" |
| @@ -790,20 +788,30 @@ | ||
| 790 | 788 | } |
| 791 | 789 | chat_create_tables(); |
| 792 | 790 | cgi_set_content_type("application/json"); |
| 793 | 791 | |
| 794 | 792 | if( zQuery[0] ){ |
| 793 | + char *zChatRobot = db_get("chat-timeline-user", 0); | |
| 795 | 794 | iMax = db_int64(0, "SELECT max(msgid) FROM chat"); |
| 796 | 795 | iMin = db_int64(0, "SELECT min(msgid) FROM chat"); |
| 797 | 796 | blob_append_sql(&sql, |
| 798 | 797 | "SELECT * FROM (" |
| 799 | 798 | "SELECT c.msgid, datetime(c.mtime), c.xfrom, " |
| 800 | - " highlight(chatfts1, 0, '<span class=match>', '</span>'), " | |
| 799 | + " highlight(chatfts1, 0, '<span class=\"match\">', '</span>'), " | |
| 801 | 800 | " octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime" |
| 802 | - " FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid " | |
| 801 | + " FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid ", | |
| 802 | + zQuery | |
| 803 | + ); | |
| 804 | + if( zChatRobot!=0 ){ | |
| 805 | + if( zChatRobot[0]!=0 ){ | |
| 806 | + blob_append_sql(&sql, "AND c.xfrom IS NOT %Q ", zChatRobot); | |
| 807 | + } | |
| 808 | + fossil_free( zChatRobot ); | |
| 809 | + } | |
| 810 | + blob_append_sql(&sql, | |
| 803 | 811 | " ORDER BY f.rowid DESC LIMIT %d" |
| 804 | - ") ORDER BY 1 ASC", zQuery, nLimit | |
| 812 | + ") ORDER BY 1 ASC", nLimit | |
| 805 | 813 | ); |
| 806 | 814 | }else{ |
| 807 | 815 | blob_append_sql(&sql, |
| 808 | 816 | "SELECT msgid, datetime(mtime), xfrom, " |
| 809 | 817 | " xmsg, octet_length(file), fname, fmime, mdel, lmtime" |
| 810 | 818 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -302,12 +302,10 @@ | |
| 302 | /* We need an onload handler to ensure that window.fossil is |
| 303 | initialized before the chat init code runs. */ |
| 304 | @ window.addEventListener('load', function(){ |
| 305 | @ document.body.classList.add('chat'); |
| 306 | @ /*^^^for skins which add their own BODY tag */; |
| 307 | // ajax_emit_js_preview_modes(0); |
| 308 | // chat_emit_alert_list(); |
| 309 | @ }, false); |
| 310 | @ </script> |
| 311 | |
| 312 | builtin_request_js("fossil.page.chatsearch.js"); |
| 313 | style_finish_page(); |
| @@ -343,11 +341,11 @@ | |
| 343 | } |
| 344 | db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT"); |
| 345 | } |
| 346 | |
| 347 | if( !db_table_exists("repository", "chatfts1") ){ |
| 348 | db_multi_exec( |
| 349 | "CREATE VIRTUAL TABLE chatfts1 USING fts5(" |
| 350 | " xmsg, content=chat, content_rowid=msgid, tokenize=porter" |
| 351 | ");" |
| 352 | "CREATE TRIGGER chat_ai AFTER INSERT ON chat BEGIN " |
| 353 | " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" |
| @@ -790,20 +788,30 @@ | |
| 790 | } |
| 791 | chat_create_tables(); |
| 792 | cgi_set_content_type("application/json"); |
| 793 | |
| 794 | if( zQuery[0] ){ |
| 795 | iMax = db_int64(0, "SELECT max(msgid) FROM chat"); |
| 796 | iMin = db_int64(0, "SELECT min(msgid) FROM chat"); |
| 797 | blob_append_sql(&sql, |
| 798 | "SELECT * FROM (" |
| 799 | "SELECT c.msgid, datetime(c.mtime), c.xfrom, " |
| 800 | " highlight(chatfts1, 0, '<span class=match>', '</span>'), " |
| 801 | " octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime" |
| 802 | " FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid " |
| 803 | " ORDER BY f.rowid DESC LIMIT %d" |
| 804 | ") ORDER BY 1 ASC", zQuery, nLimit |
| 805 | ); |
| 806 | }else{ |
| 807 | blob_append_sql(&sql, |
| 808 | "SELECT msgid, datetime(mtime), xfrom, " |
| 809 | " xmsg, octet_length(file), fname, fmime, mdel, lmtime" |
| 810 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -302,12 +302,10 @@ | |
| 302 | /* We need an onload handler to ensure that window.fossil is |
| 303 | initialized before the chat init code runs. */ |
| 304 | @ window.addEventListener('load', function(){ |
| 305 | @ document.body.classList.add('chat'); |
| 306 | @ /*^^^for skins which add their own BODY tag */; |
| 307 | @ }, false); |
| 308 | @ </script> |
| 309 | |
| 310 | builtin_request_js("fossil.page.chatsearch.js"); |
| 311 | style_finish_page(); |
| @@ -343,11 +341,11 @@ | |
| 341 | } |
| 342 | db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT"); |
| 343 | } |
| 344 | |
| 345 | if( !db_table_exists("repository", "chatfts1") ){ |
| 346 | db_multi_exec( |
| 347 | "CREATE VIRTUAL TABLE chatfts1 USING fts5(" |
| 348 | " xmsg, content=chat, content_rowid=msgid, tokenize=porter" |
| 349 | ");" |
| 350 | "CREATE TRIGGER chat_ai AFTER INSERT ON chat BEGIN " |
| 351 | " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" |
| @@ -790,20 +788,30 @@ | |
| 788 | } |
| 789 | chat_create_tables(); |
| 790 | cgi_set_content_type("application/json"); |
| 791 | |
| 792 | if( zQuery[0] ){ |
| 793 | char *zChatRobot = db_get("chat-timeline-user", 0); |
| 794 | iMax = db_int64(0, "SELECT max(msgid) FROM chat"); |
| 795 | iMin = db_int64(0, "SELECT min(msgid) FROM chat"); |
| 796 | blob_append_sql(&sql, |
| 797 | "SELECT * FROM (" |
| 798 | "SELECT c.msgid, datetime(c.mtime), c.xfrom, " |
| 799 | " highlight(chatfts1, 0, '<span class=\"match\">', '</span>'), " |
| 800 | " octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime" |
| 801 | " FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid ", |
| 802 | zQuery |
| 803 | ); |
| 804 | if( zChatRobot!=0 ){ |
| 805 | if( zChatRobot[0]!=0 ){ |
| 806 | blob_append_sql(&sql, "AND c.xfrom IS NOT %Q ", zChatRobot); |
| 807 | } |
| 808 | fossil_free( zChatRobot ); |
| 809 | } |
| 810 | blob_append_sql(&sql, |
| 811 | " ORDER BY f.rowid DESC LIMIT %d" |
| 812 | ") ORDER BY 1 ASC", nLimit |
| 813 | ); |
| 814 | }else{ |
| 815 | blob_append_sql(&sql, |
| 816 | "SELECT msgid, datetime(mtime), xfrom, " |
| 817 | " xmsg, octet_length(file), fname, fmime, mdel, lmtime" |
| 818 |
+4
-5
| --- src/fossil.page.chatsearch.js | ||
| +++ src/fossil.page.chatsearch.js | ||
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /* |
| 2 | -** This file contains the client-side implementation of fossil's | |
| 2 | +** This file contains the client-side implementation of fossil's | |
| 3 | 3 | ** /chat-search application. |
| 4 | 4 | */ |
| 5 | 5 | window.fossil.onPageLoad(function(){ |
| 6 | 6 | |
| 7 | 7 | const F = window.fossil, D = F.dom; |
| @@ -112,11 +112,11 @@ | ||
| 112 | 112 | iframe.style.maxHeight = iframe.style.height |
| 113 | 113 | = iframe.contentWindow.document.documentElement.scrollHeight + 'px'; |
| 114 | 114 | if(isHidden) D.addClass(iframe, 'hidden'); |
| 115 | 115 | } |
| 116 | 116 | }; |
| 117 | - | |
| 117 | + | |
| 118 | 118 | cf.prototype = { |
| 119 | 119 | scrollIntoView: function(){ |
| 120 | 120 | this.e.content.scrollIntoView(); |
| 121 | 121 | }, |
| 122 | 122 | setMessage: function(m){ |
| @@ -388,11 +388,10 @@ | ||
| 388 | 388 | console.error(err); |
| 389 | 389 | alert(err.toString()); |
| 390 | 390 | }, |
| 391 | 391 | |
| 392 | 392 | onload:function(jx){ |
| 393 | - | |
| 394 | 393 | const firstChildOfBelow = e.below.firstChild; |
| 395 | 394 | jx.msgs.forEach((m) => { |
| 396 | 395 | var mw = new MessageWidget(m); |
| 397 | 396 | if( bDown ){ |
| 398 | 397 | e.below.insertBefore(mw.e.body, firstChildOfBelow); |
| @@ -411,11 +410,11 @@ | ||
| 411 | 410 | ms.bIgnoreClick = false; |
| 412 | 411 | } |
| 413 | 412 | }); |
| 414 | 413 | } |
| 415 | 414 | }; |
| 416 | - | |
| 415 | + | |
| 417 | 416 | return cf; |
| 418 | 417 | })(); /* MessageSpacer */ |
| 419 | 418 | |
| 420 | 419 | /* This is called to submit a search - because the user clicked the |
| 421 | 420 | ** search button or pressed Enter in the input box. |
| @@ -470,11 +469,11 @@ | ||
| 470 | 469 | }); |
| 471 | 470 | } |
| 472 | 471 | |
| 473 | 472 | /* Add event listeners to call submit_search() if the user presses Enter |
| 474 | 473 | ** or clicks the search button. |
| 475 | - */ | |
| 474 | + */ | |
| 476 | 475 | E1('#searchbutton').addEventListener('click', function(){ |
| 477 | 476 | submit_search(); |
| 478 | 477 | }); |
| 479 | 478 | E1('#textinput').addEventListener('keydown', function(ev){ |
| 480 | 479 | if( 13==ev.keyCode ){ |
| 481 | 480 |
| --- src/fossil.page.chatsearch.js | |
| +++ src/fossil.page.chatsearch.js | |
| @@ -1,7 +1,7 @@ | |
| 1 | /* |
| 2 | ** This file contains the client-side implementation of fossil's |
| 3 | ** /chat-search application. |
| 4 | */ |
| 5 | window.fossil.onPageLoad(function(){ |
| 6 | |
| 7 | const F = window.fossil, D = F.dom; |
| @@ -112,11 +112,11 @@ | |
| 112 | iframe.style.maxHeight = iframe.style.height |
| 113 | = iframe.contentWindow.document.documentElement.scrollHeight + 'px'; |
| 114 | if(isHidden) D.addClass(iframe, 'hidden'); |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | cf.prototype = { |
| 119 | scrollIntoView: function(){ |
| 120 | this.e.content.scrollIntoView(); |
| 121 | }, |
| 122 | setMessage: function(m){ |
| @@ -388,11 +388,10 @@ | |
| 388 | console.error(err); |
| 389 | alert(err.toString()); |
| 390 | }, |
| 391 | |
| 392 | onload:function(jx){ |
| 393 | |
| 394 | const firstChildOfBelow = e.below.firstChild; |
| 395 | jx.msgs.forEach((m) => { |
| 396 | var mw = new MessageWidget(m); |
| 397 | if( bDown ){ |
| 398 | e.below.insertBefore(mw.e.body, firstChildOfBelow); |
| @@ -411,11 +410,11 @@ | |
| 411 | ms.bIgnoreClick = false; |
| 412 | } |
| 413 | }); |
| 414 | } |
| 415 | }; |
| 416 | |
| 417 | return cf; |
| 418 | })(); /* MessageSpacer */ |
| 419 | |
| 420 | /* This is called to submit a search - because the user clicked the |
| 421 | ** search button or pressed Enter in the input box. |
| @@ -470,11 +469,11 @@ | |
| 470 | }); |
| 471 | } |
| 472 | |
| 473 | /* Add event listeners to call submit_search() if the user presses Enter |
| 474 | ** or clicks the search button. |
| 475 | */ |
| 476 | E1('#searchbutton').addEventListener('click', function(){ |
| 477 | submit_search(); |
| 478 | }); |
| 479 | E1('#textinput').addEventListener('keydown', function(ev){ |
| 480 | if( 13==ev.keyCode ){ |
| 481 |
| --- src/fossil.page.chatsearch.js | |
| +++ src/fossil.page.chatsearch.js | |
| @@ -1,7 +1,7 @@ | |
| 1 | /* |
| 2 | ** This file contains the client-side implementation of fossil's |
| 3 | ** /chat-search application. |
| 4 | */ |
| 5 | window.fossil.onPageLoad(function(){ |
| 6 | |
| 7 | const F = window.fossil, D = F.dom; |
| @@ -112,11 +112,11 @@ | |
| 112 | iframe.style.maxHeight = iframe.style.height |
| 113 | = iframe.contentWindow.document.documentElement.scrollHeight + 'px'; |
| 114 | if(isHidden) D.addClass(iframe, 'hidden'); |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | cf.prototype = { |
| 119 | scrollIntoView: function(){ |
| 120 | this.e.content.scrollIntoView(); |
| 121 | }, |
| 122 | setMessage: function(m){ |
| @@ -388,11 +388,10 @@ | |
| 388 | console.error(err); |
| 389 | alert(err.toString()); |
| 390 | }, |
| 391 | |
| 392 | onload:function(jx){ |
| 393 | const firstChildOfBelow = e.below.firstChild; |
| 394 | jx.msgs.forEach((m) => { |
| 395 | var mw = new MessageWidget(m); |
| 396 | if( bDown ){ |
| 397 | e.below.insertBefore(mw.e.body, firstChildOfBelow); |
| @@ -411,11 +410,11 @@ | |
| 410 | ms.bIgnoreClick = false; |
| 411 | } |
| 412 | }); |
| 413 | } |
| 414 | }; |
| 415 | |
| 416 | return cf; |
| 417 | })(); /* MessageSpacer */ |
| 418 | |
| 419 | /* This is called to submit a search - because the user clicked the |
| 420 | ** search button or pressed Enter in the input box. |
| @@ -470,11 +469,11 @@ | |
| 469 | }); |
| 470 | } |
| 471 | |
| 472 | /* Add event listeners to call submit_search() if the user presses Enter |
| 473 | ** or clicks the search button. |
| 474 | */ |
| 475 | E1('#searchbutton').addEventListener('click', function(){ |
| 476 | submit_search(); |
| 477 | }); |
| 478 | E1('#textinput').addEventListener('keydown', function(ev){ |
| 479 | if( 13==ev.keyCode ){ |
| 480 |