Fossil SCM

Remove the now-superfluous /chat-search page. Preliminarily switch to long-format time strings in /chat messages, but that's up for reworking as we decide how we want to handle those.

stephan 2024-07-01 08:11 fts5-chat-search
Commit e1f6c7f589b47ab89c17f98fe8ae73252983bf21ac17608791dba349dd8eed59
+8 -43
--- src/chat.c
+++ src/chat.c
@@ -147,11 +147,11 @@
147147
**
148148
** Start up a browser-based chat session.
149149
**
150150
** This is the main page that humans use to access the chatroom. Simply
151151
** point a web-browser at /chat and the screen fills with the latest
152
-** chat messages, and waits for new one.
152
+** chat messages, and waits for new ones.
153153
**
154154
** Other /chat-OP pages are used by XHR requests from this page to
155155
** send new chat message, delete older messages, or poll for changes.
156156
*/
157157
void chat_webpage(void){
@@ -244,13 +244,16 @@
244244
@ <div id='chat-config-options'></div>
245245
/* ^^^populated client-side */
246246
@ <div class='button-bar'><button class='action-close'>Close Settings</button></div>
247247
@ </div>
248248
@ <div id='chat-search' class='hidden chat-view'>
249
- @ <div class='message-widget-content'></div>
250
- /* ^^^populated client-side */
251
- @ <div class='button-bar'><button class='action-close'>Close Search</button></div>
249
+ @ <div class='message-widget-content'></div>
250
+ /* ^^^populated client-side */
251
+ @ <div class='button-bar'>
252
+ @ <button class='action-clear'>Clear results</button>
253
+ @ <button class='action-close'>Close Search</button>
254
+ @ </div>
252255
@ </div>
253256
@ <div id='chat-messages-wrapper' class='chat-view'>
254257
/* New chat messages get inserted immediately after this element */
255258
@ <span id='message-inject-point'></span>
256259
@ </div>
@@ -279,49 +282,11 @@
279282
builtin_request_js("fossil.page.chat.js");
280283
style_finish_page();
281284
}
282285
283286
/*
284
-** WEBPAGE: chat-search hidden loadavg-exempt
285
-**
286
-** Webpage allowing users to search the archive of chat messages using fts5.
287
-*/
288
-void chat_search_webpage(void){
289
- login_check_credentials();
290
- if( !g.perm.Chat ){
291
- login_needed(g.anon.Chat);
292
- return;
293
- }
294
-
295
- style_set_current_feature("chat");
296
- style_set_current_page("chat") /* so that we use style.chat.css */;
297
- style_header("Chat Search");
298
- @
299
- @ <div id=results>
300
- @ </div>
301
- @ <div class='searchForm'>
302
- @ <input id=textinput type="text" name="s" size="40">
303
- @ <input id=searchbutton type="submit" value="Search">
304
- @ </div>
305
- builtin_fossil_js_bundle_or("popupwidget", "storage", "fetch",
306
- "pikchr", "confirmer", "copybutton",
307
- NULL);
308
- /* Always in-line the javascript for the chat page */
309
- @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
310
- /* We need an onload handler to ensure that window.fossil is
311
- initialized before the chat init code runs. */
312
- @ window.addEventListener('load', function(){
313
- @ document.body.classList.add('chat');
314
- @ /*^^^for skins which add their own BODY tag */;
315
- @ }, false);
316
- @ </script>
317
-
318
- builtin_request_js("fossil.page.chatsearch.js");
319
- style_finish_page();
320
-}
321
-
322
-/* Definition of repository tables used by chat
287
+** Definition of repository tables used by chat
323288
*/
324289
static const char zChatSchema1[] =
325290
@ CREATE TABLE repository.chat(
326291
@ msgid INTEGER PRIMARY KEY AUTOINCREMENT,
327292
@ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
328293
--- src/chat.c
+++ src/chat.c
@@ -147,11 +147,11 @@
147 **
148 ** Start up a browser-based chat session.
149 **
150 ** This is the main page that humans use to access the chatroom. Simply
151 ** point a web-browser at /chat and the screen fills with the latest
152 ** chat messages, and waits for new one.
153 **
154 ** Other /chat-OP pages are used by XHR requests from this page to
155 ** send new chat message, delete older messages, or poll for changes.
156 */
157 void chat_webpage(void){
@@ -244,13 +244,16 @@
244 @ <div id='chat-config-options'></div>
245 /* ^^^populated client-side */
246 @ <div class='button-bar'><button class='action-close'>Close Settings</button></div>
247 @ </div>
248 @ <div id='chat-search' class='hidden chat-view'>
249 @ <div class='message-widget-content'></div>
250 /* ^^^populated client-side */
251 @ <div class='button-bar'><button class='action-close'>Close Search</button></div>
 
 
 
252 @ </div>
253 @ <div id='chat-messages-wrapper' class='chat-view'>
254 /* New chat messages get inserted immediately after this element */
255 @ <span id='message-inject-point'></span>
256 @ </div>
@@ -279,49 +282,11 @@
279 builtin_request_js("fossil.page.chat.js");
280 style_finish_page();
281 }
282
283 /*
284 ** WEBPAGE: chat-search hidden loadavg-exempt
285 **
286 ** Webpage allowing users to search the archive of chat messages using fts5.
287 */
288 void chat_search_webpage(void){
289 login_check_credentials();
290 if( !g.perm.Chat ){
291 login_needed(g.anon.Chat);
292 return;
293 }
294
295 style_set_current_feature("chat");
296 style_set_current_page("chat") /* so that we use style.chat.css */;
297 style_header("Chat Search");
298 @
299 @ <div id=results>
300 @ </div>
301 @ <div class='searchForm'>
302 @ <input id=textinput type="text" name="s" size="40">
303 @ <input id=searchbutton type="submit" value="Search">
304 @ </div>
305 builtin_fossil_js_bundle_or("popupwidget", "storage", "fetch",
306 "pikchr", "confirmer", "copybutton",
307 NULL);
308 /* Always in-line the javascript for the chat page */
309 @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
310 /* We need an onload handler to ensure that window.fossil is
311 initialized before the chat init code runs. */
312 @ window.addEventListener('load', function(){
313 @ document.body.classList.add('chat');
314 @ /*^^^for skins which add their own BODY tag */;
315 @ }, false);
316 @ </script>
317
318 builtin_request_js("fossil.page.chatsearch.js");
319 style_finish_page();
320 }
321
322 /* Definition of repository tables used by chat
323 */
324 static const char zChatSchema1[] =
325 @ CREATE TABLE repository.chat(
326 @ msgid INTEGER PRIMARY KEY AUTOINCREMENT,
327 @ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
328
--- src/chat.c
+++ src/chat.c
@@ -147,11 +147,11 @@
147 **
148 ** Start up a browser-based chat session.
149 **
150 ** This is the main page that humans use to access the chatroom. Simply
151 ** point a web-browser at /chat and the screen fills with the latest
152 ** chat messages, and waits for new ones.
153 **
154 ** Other /chat-OP pages are used by XHR requests from this page to
155 ** send new chat message, delete older messages, or poll for changes.
156 */
157 void chat_webpage(void){
@@ -244,13 +244,16 @@
244 @ <div id='chat-config-options'></div>
245 /* ^^^populated client-side */
246 @ <div class='button-bar'><button class='action-close'>Close Settings</button></div>
247 @ </div>
248 @ <div id='chat-search' class='hidden chat-view'>
249 @ <div class='message-widget-content'></div>
250 /* ^^^populated client-side */
251 @ <div class='button-bar'>
252 @ <button class='action-clear'>Clear results</button>
253 @ <button class='action-close'>Close Search</button>
254 @ </div>
255 @ </div>
256 @ <div id='chat-messages-wrapper' class='chat-view'>
257 /* New chat messages get inserted immediately after this element */
258 @ <span id='message-inject-point'></span>
259 @ </div>
@@ -279,49 +282,11 @@
282 builtin_request_js("fossil.page.chat.js");
283 style_finish_page();
284 }
285
286 /*
287 ** Definition of repository tables used by chat
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288 */
289 static const char zChatSchema1[] =
290 @ CREATE TABLE repository.chat(
291 @ msgid INTEGER PRIMARY KEY AUTOINCREMENT,
292 @ mtime JULIANDAY, -- Time for this entry - Julianday Zulu
293
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -926,20 +926,34 @@
926926
/* Map of Date.getDay() values to weekday names. */
927927
0: "Sunday", 1: "Monday", 2: "Tuesday",
928928
3: "Wednesday", 4: "Thursday", 5: "Friday",
929929
6: "Saturday"
930930
};
931
- /* Given a Date, returns the timestamp string used in the
932
- "tab" part of message widgets. */
933
- const theTime = function(d){
934
- return [
935
- //d.getFullYear(),'-',pad2(d.getMonth()+1/*sigh*/),
936
- //'-',pad2(d.getDate()), ' ',
937
- d.getHours(),":",
938
- (d.getMinutes()+100).toString().slice(1,3),
939
- ' ', dowMap[d.getDay()]
940
- ].join('');
931
+ /* Given a Date, returns the timestamp string used in the "tab"
932
+ part of message widgets. If longFmt is true then a verbose
933
+ format is used, else a brief format is used. The returned string
934
+ is in client-local time. */
935
+ const theTime = function(d, longFmt=true){
936
+ const li = [];
937
+ if( longFmt ){
938
+ //li.push( d.toISOString() );
939
+ li.push(
940
+ d.getFullYear(),
941
+ '-', pad2(d.getMonth()+1/*sigh*/),
942
+ '-', pad2(d.getDate()),
943
+ ' ',
944
+ d.getHours(), ":",
945
+ (d.getMinutes()+100).toString().slice(1,3)
946
+ );
947
+ }else{
948
+ li.push(
949
+ d.getHours(),":",
950
+ (d.getMinutes()+100).toString().slice(1,3),
951
+ ' ', dowMap[d.getDay()]
952
+ );
953
+ }
954
+ return li.join('');
941955
};
942956
943957
/**
944958
Returns true if this page believes it can embed a view of the
945959
file wrapped by the given message object, else returns false.
@@ -1037,11 +1051,11 @@
10371051
var eXFrom /* element holding xfrom name */;
10381052
if(m.xfrom){
10391053
eXFrom = D.append(D.addClass(D.span(), 'xfrom'), m.xfrom);
10401054
const wrapper = D.append(
10411055
D.span(), eXFrom,
1042
- D.text(" #",(m.msgid||'???'),' @ ',theTime(d)))
1056
+ D.text(" #",(m.msgid||'???'),' ',theTime(d)))
10431057
D.append(this.e.tab, wrapper);
10441058
}else{/*notification*/
10451059
D.addClass(this.e.body, 'notification');
10461060
if(m.isError){
10471061
D.addClass([contentTarget, this.e.tab], 'error');
@@ -2332,11 +2346,10 @@
23322346
"chat-query", {
23332347
urlParams: {q: term},
23342348
responseType: 'json',
23352349
onload:function(jx){
23362350
let previd = 0;
2337
- console.log("jx =",jx);
23382351
D.clearElement(eMsgTgt);
23392352
jx.msgs.forEach((m)=>{
23402353
const mw = new Chat.MessageWidget(m);
23412354
const spacer = new Chat.SearchCtxLoader({
23422355
first: jx.first,
23432356
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -926,20 +926,34 @@
926 /* Map of Date.getDay() values to weekday names. */
927 0: "Sunday", 1: "Monday", 2: "Tuesday",
928 3: "Wednesday", 4: "Thursday", 5: "Friday",
929 6: "Saturday"
930 };
931 /* Given a Date, returns the timestamp string used in the
932 "tab" part of message widgets. */
933 const theTime = function(d){
934 return [
935 //d.getFullYear(),'-',pad2(d.getMonth()+1/*sigh*/),
936 //'-',pad2(d.getDate()), ' ',
937 d.getHours(),":",
938 (d.getMinutes()+100).toString().slice(1,3),
939 ' ', dowMap[d.getDay()]
940 ].join('');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
941 };
942
943 /**
944 Returns true if this page believes it can embed a view of the
945 file wrapped by the given message object, else returns false.
@@ -1037,11 +1051,11 @@
1037 var eXFrom /* element holding xfrom name */;
1038 if(m.xfrom){
1039 eXFrom = D.append(D.addClass(D.span(), 'xfrom'), m.xfrom);
1040 const wrapper = D.append(
1041 D.span(), eXFrom,
1042 D.text(" #",(m.msgid||'???'),' @ ',theTime(d)))
1043 D.append(this.e.tab, wrapper);
1044 }else{/*notification*/
1045 D.addClass(this.e.body, 'notification');
1046 if(m.isError){
1047 D.addClass([contentTarget, this.e.tab], 'error');
@@ -2332,11 +2346,10 @@
2332 "chat-query", {
2333 urlParams: {q: term},
2334 responseType: 'json',
2335 onload:function(jx){
2336 let previd = 0;
2337 console.log("jx =",jx);
2338 D.clearElement(eMsgTgt);
2339 jx.msgs.forEach((m)=>{
2340 const mw = new Chat.MessageWidget(m);
2341 const spacer = new Chat.SearchCtxLoader({
2342 first: jx.first,
2343
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -926,20 +926,34 @@
926 /* Map of Date.getDay() values to weekday names. */
927 0: "Sunday", 1: "Monday", 2: "Tuesday",
928 3: "Wednesday", 4: "Thursday", 5: "Friday",
929 6: "Saturday"
930 };
931 /* Given a Date, returns the timestamp string used in the "tab"
932 part of message widgets. If longFmt is true then a verbose
933 format is used, else a brief format is used. The returned string
934 is in client-local time. */
935 const theTime = function(d, longFmt=true){
936 const li = [];
937 if( longFmt ){
938 //li.push( d.toISOString() );
939 li.push(
940 d.getFullYear(),
941 '-', pad2(d.getMonth()+1/*sigh*/),
942 '-', pad2(d.getDate()),
943 ' ',
944 d.getHours(), ":",
945 (d.getMinutes()+100).toString().slice(1,3)
946 );
947 }else{
948 li.push(
949 d.getHours(),":",
950 (d.getMinutes()+100).toString().slice(1,3),
951 ' ', dowMap[d.getDay()]
952 );
953 }
954 return li.join('');
955 };
956
957 /**
958 Returns true if this page believes it can embed a view of the
959 file wrapped by the given message object, else returns false.
@@ -1037,11 +1051,11 @@
1051 var eXFrom /* element holding xfrom name */;
1052 if(m.xfrom){
1053 eXFrom = D.append(D.addClass(D.span(), 'xfrom'), m.xfrom);
1054 const wrapper = D.append(
1055 D.span(), eXFrom,
1056 D.text(" #",(m.msgid||'???'),' ',theTime(d)))
1057 D.append(this.e.tab, wrapper);
1058 }else{/*notification*/
1059 D.addClass(this.e.body, 'notification');
1060 if(m.isError){
1061 D.addClass([contentTarget, this.e.tab], 'error');
@@ -2332,11 +2346,10 @@
2346 "chat-query", {
2347 urlParams: {q: term},
2348 responseType: 'json',
2349 onload:function(jx){
2350 let previd = 0;
 
2351 D.clearElement(eMsgTgt);
2352 jx.msgs.forEach((m)=>{
2353 const mw = new Chat.MessageWidget(m);
2354 const spacer = new Chat.SearchCtxLoader({
2355 first: jx.first,
2356
--- src/style.chat.css
+++ src/style.chat.css
@@ -623,19 +623,19 @@
623623
margin-left: 1ex;
624624
margin-right: 1ex;
625625
display: block;
626626
}
627627
628
-body.cpage-chat-search .spacer-widget-buttons .up {
629
- margin-top: -0.25em;
628
+body.chat .spacer-widget-buttons .up {
629
+ margin-top: 0.5em;
630630
margin-bottom: 1em;
631631
}
632
-body.cpage-chat-search .spacer-widget-buttons .down {
632
+body.chat .spacer-widget-buttons .down {
633633
margin-top: 1em;
634634
margin-bottom: 0.5em;
635635
}
636
-body.cpage-chat-search .spacer-widget-buttons .all {
636
+body.chat .spacer-widget-buttons .all {
637637
margin-bottom: 0.75em;
638638
}
639639
640640
641641
body.chat .anim-rotate-360 {
642642
--- src/style.chat.css
+++ src/style.chat.css
@@ -623,19 +623,19 @@
623 margin-left: 1ex;
624 margin-right: 1ex;
625 display: block;
626 }
627
628 body.cpage-chat-search .spacer-widget-buttons .up {
629 margin-top: -0.25em;
630 margin-bottom: 1em;
631 }
632 body.cpage-chat-search .spacer-widget-buttons .down {
633 margin-top: 1em;
634 margin-bottom: 0.5em;
635 }
636 body.cpage-chat-search .spacer-widget-buttons .all {
637 margin-bottom: 0.75em;
638 }
639
640
641 body.chat .anim-rotate-360 {
642
--- src/style.chat.css
+++ src/style.chat.css
@@ -623,19 +623,19 @@
623 margin-left: 1ex;
624 margin-right: 1ex;
625 display: block;
626 }
627
628 body.chat .spacer-widget-buttons .up {
629 margin-top: 0.5em;
630 margin-bottom: 1em;
631 }
632 body.chat .spacer-widget-buttons .down {
633 margin-top: 1em;
634 margin-bottom: 0.5em;
635 }
636 body.chat .spacer-widget-buttons .all {
637 margin-bottom: 0.75em;
638 }
639
640
641 body.chat .anim-rotate-360 {
642

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button