Fossil SCM

Improvements to the way that the chat alert sound is configured. Remove the /chat-alert webpage. Access the sound files directly using /builtin.

drh 2021-01-05 20:07 trunk
Commit 21a870d02d853ab09968d14321822c9541663e824fecd4814be166c52f960a50
2 files changed +4 -16 +1 -1
+4 -16
--- src/chat.c
+++ src/chat.c
@@ -144,15 +144,18 @@
144144
**
145145
** Other /chat-OP pages are used by XHR requests from this page to
146146
** send new chat message, delete older messages, or poll for changes.
147147
*/
148148
void chat_webpage(void){
149
+ char *zAlert;
149150
login_check_credentials();
150151
if( !g.perm.Chat ){
151152
login_needed(g.anon.Chat);
152153
return;
153154
}
155
+ zAlert = mprintf("%s/builtin/%s", g.zBaseURL,
156
+ db_get("chat-alert-sound","alerts/plunk.wav"));
154157
style_set_current_feature("chat");
155158
style_header("Chat");
156159
@ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
157160
@ <div id='chat-input-area'>
158161
@ <div id='chat-input-line'>
@@ -193,10 +196,11 @@
193196
@ window.addEventListener('load', function(){
194197
@ document.body.classList.add('chat')
195198
@ /*^^^for skins which add their own BODY tag */;
196199
@ window.fossil.config.chat = {
197200
@ fromcli: %h(PB("cli")?"true":"false"),
201
+ @ alertSound: "%h(zAlert)",
198202
@ initSize: %d(db_get_int("chat-initial-history",50)),
199203
@ imagesInline: !!%d(db_get_boolean("chat-inline-images",1))
200204
@ };
201205
chat_emit_alert_list();
202206
cgi_append_content(builtin_text("chat.js"),-1);
@@ -702,26 +706,10 @@
702706
"COMMIT;",
703707
mdel, g.zLogin, mdel
704708
);
705709
}
706710
707
-/*
708
-** WEBPAGE: chat-alert
709
-**
710
-** Return the sound file that should be played when a new chat message
711
-** arrives.
712
-*/
713
-void chat_audio_alert(void){
714
- Blob audio = empty_blob;
715
- int n = 0;
716
- const char *zName = db_get("chat-alert-sound", "alerts/plunk.wav");
717
- const char *zAudio = (const char*)builtin_file(zName, &n);
718
- blob_init(&audio, zAudio, n);
719
- cgi_set_content_type("audio/wav");
720
- cgi_set_content(&audio);
721
-}
722
-
723711
/*
724712
** COMMAND: chat
725713
**
726714
** Usage: %fossil chat [SUBCOMMAND] [--remote URL] [ARGS...]
727715
**
728716
--- src/chat.c
+++ src/chat.c
@@ -144,15 +144,18 @@
144 **
145 ** Other /chat-OP pages are used by XHR requests from this page to
146 ** send new chat message, delete older messages, or poll for changes.
147 */
148 void chat_webpage(void){
 
149 login_check_credentials();
150 if( !g.perm.Chat ){
151 login_needed(g.anon.Chat);
152 return;
153 }
 
 
154 style_set_current_feature("chat");
155 style_header("Chat");
156 @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
157 @ <div id='chat-input-area'>
158 @ <div id='chat-input-line'>
@@ -193,10 +196,11 @@
193 @ window.addEventListener('load', function(){
194 @ document.body.classList.add('chat')
195 @ /*^^^for skins which add their own BODY tag */;
196 @ window.fossil.config.chat = {
197 @ fromcli: %h(PB("cli")?"true":"false"),
 
198 @ initSize: %d(db_get_int("chat-initial-history",50)),
199 @ imagesInline: !!%d(db_get_boolean("chat-inline-images",1))
200 @ };
201 chat_emit_alert_list();
202 cgi_append_content(builtin_text("chat.js"),-1);
@@ -702,26 +706,10 @@
702 "COMMIT;",
703 mdel, g.zLogin, mdel
704 );
705 }
706
707 /*
708 ** WEBPAGE: chat-alert
709 **
710 ** Return the sound file that should be played when a new chat message
711 ** arrives.
712 */
713 void chat_audio_alert(void){
714 Blob audio = empty_blob;
715 int n = 0;
716 const char *zName = db_get("chat-alert-sound", "alerts/plunk.wav");
717 const char *zAudio = (const char*)builtin_file(zName, &n);
718 blob_init(&audio, zAudio, n);
719 cgi_set_content_type("audio/wav");
720 cgi_set_content(&audio);
721 }
722
723 /*
724 ** COMMAND: chat
725 **
726 ** Usage: %fossil chat [SUBCOMMAND] [--remote URL] [ARGS...]
727 **
728
--- src/chat.c
+++ src/chat.c
@@ -144,15 +144,18 @@
144 **
145 ** Other /chat-OP pages are used by XHR requests from this page to
146 ** send new chat message, delete older messages, or poll for changes.
147 */
148 void chat_webpage(void){
149 char *zAlert;
150 login_check_credentials();
151 if( !g.perm.Chat ){
152 login_needed(g.anon.Chat);
153 return;
154 }
155 zAlert = mprintf("%s/builtin/%s", g.zBaseURL,
156 db_get("chat-alert-sound","alerts/plunk.wav"));
157 style_set_current_feature("chat");
158 style_header("Chat");
159 @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off">
160 @ <div id='chat-input-area'>
161 @ <div id='chat-input-line'>
@@ -193,10 +196,11 @@
196 @ window.addEventListener('load', function(){
197 @ document.body.classList.add('chat')
198 @ /*^^^for skins which add their own BODY tag */;
199 @ window.fossil.config.chat = {
200 @ fromcli: %h(PB("cli")?"true":"false"),
201 @ alertSound: "%h(zAlert)",
202 @ initSize: %d(db_get_int("chat-initial-history",50)),
203 @ imagesInline: !!%d(db_get_boolean("chat-inline-images",1))
204 @ };
205 chat_emit_alert_list();
206 cgi_append_content(builtin_text("chat.js"),-1);
@@ -702,26 +706,10 @@
706 "COMMIT;",
707 mdel, g.zLogin, mdel
708 );
709 }
710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711 /*
712 ** COMMAND: chat
713 **
714 ** Usage: %fossil chat [SUBCOMMAND] [--remote URL] [ARGS...]
715 **
716
+1 -1
--- src/chat.js
+++ src/chat.js
@@ -375,11 +375,11 @@
375375
setting is true, else this is a no-op. Returns this.
376376
*/
377377
playNewMessageSound: function f(){
378378
if(f.uri){
379379
try{
380
- if(!f.audio) f.audio = new Audio(F.rootPath+"chat-alert");
380
+ if(!f.audio) f.audio = new Audio(window.fossil.config.chat.alertSound);
381381
f.audio.currentTime = 0;
382382
f.audio.play();
383383
}catch(e){
384384
console.error("Audio playblack failed.",e);
385385
}
386386
--- src/chat.js
+++ src/chat.js
@@ -375,11 +375,11 @@
375 setting is true, else this is a no-op. Returns this.
376 */
377 playNewMessageSound: function f(){
378 if(f.uri){
379 try{
380 if(!f.audio) f.audio = new Audio(F.rootPath+"chat-alert");
381 f.audio.currentTime = 0;
382 f.audio.play();
383 }catch(e){
384 console.error("Audio playblack failed.",e);
385 }
386
--- src/chat.js
+++ src/chat.js
@@ -375,11 +375,11 @@
375 setting is true, else this is a no-op. Returns this.
376 */
377 playNewMessageSound: function f(){
378 if(f.uri){
379 try{
380 if(!f.audio) f.audio = new Audio(window.fossil.config.chat.alertSound);
381 f.audio.currentTime = 0;
382 f.audio.play();
383 }catch(e){
384 console.error("Audio playblack failed.",e);
385 }
386

Keyboard Shortcuts

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