Fossil SCM
Import fossil bootstrapping JS into the chat app, add current login name to window.fossil.user.name, and use that name as the initial 'me' value in chat.js (resolves the FIXME in that latter part).
Commit
4e832e9f400243873e8e6909e8768ed0538c4866498c71292b4a310f25f11641
Parent
5744428bfa8778a…
3 files changed
+3
+1
+1
-1
+3
| --- src/builtin.c | ||
| +++ src/builtin.c | ||
| @@ -636,10 +636,13 @@ | ||
| 636 | 636 | CX("isDark: %s" |
| 637 | 637 | "/*true if the current skin has the 'white-foreground' detail*/", |
| 638 | 638 | skin_detail_boolean("white-foreground") ? "true" : "false"); |
| 639 | 639 | CX("}\n"/*fossil.config.skin*/); |
| 640 | 640 | CX("};\n"/* fossil.config */); |
| 641 | + CX("window.fossil.user = {"); | |
| 642 | + CX("name: %!j", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest"); | |
| 643 | + CX("};\n"/*fossil.user*/); | |
| 641 | 644 | CX("if(fossil.config.skin.isDark) " |
| 642 | 645 | "document.body.classList.add('fossil-dark-style');\n"); |
| 643 | 646 | #if 0 |
| 644 | 647 | /* Is it safe to emit the CSRF token here? Some pages add it |
| 645 | 648 | ** as a hidden form field. */ |
| 646 | 649 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -636,10 +636,13 @@ | |
| 636 | CX("isDark: %s" |
| 637 | "/*true if the current skin has the 'white-foreground' detail*/", |
| 638 | skin_detail_boolean("white-foreground") ? "true" : "false"); |
| 639 | CX("}\n"/*fossil.config.skin*/); |
| 640 | CX("};\n"/* fossil.config */); |
| 641 | CX("if(fossil.config.skin.isDark) " |
| 642 | "document.body.classList.add('fossil-dark-style');\n"); |
| 643 | #if 0 |
| 644 | /* Is it safe to emit the CSRF token here? Some pages add it |
| 645 | ** as a hidden form field. */ |
| 646 |
| --- src/builtin.c | |
| +++ src/builtin.c | |
| @@ -636,10 +636,13 @@ | |
| 636 | CX("isDark: %s" |
| 637 | "/*true if the current skin has the 'white-foreground' detail*/", |
| 638 | skin_detail_boolean("white-foreground") ? "true" : "false"); |
| 639 | CX("}\n"/*fossil.config.skin*/); |
| 640 | CX("};\n"/* fossil.config */); |
| 641 | CX("window.fossil.user = {"); |
| 642 | CX("name: %!j", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest"); |
| 643 | CX("};\n"/*fossil.user*/); |
| 644 | CX("if(fossil.config.skin.isDark) " |
| 645 | "document.body.classList.add('fossil-dark-style');\n"); |
| 646 | #if 0 |
| 647 | /* Is it safe to emit the CSRF token here? Some pages add it |
| 648 | ** as a hidden form field. */ |
| 649 |
+1
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -106,10 +106,11 @@ | ||
| 106 | 106 | @ <hr> |
| 107 | 107 | |
| 108 | 108 | /* New chat messages get inserted immediately after this element */ |
| 109 | 109 | @ <span id='message-inject-point'></span> |
| 110 | 110 | |
| 111 | + builtin_fossil_js_bundle_or("popupwidget", NULL); | |
| 111 | 112 | /* Always in-line the javascript for the chat page */ |
| 112 | 113 | @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */ |
| 113 | 114 | @ let _me = "%j(g.zLogin)"; |
| 114 | 115 | cgi_append_content(builtin_text("chat.js"),-1); |
| 115 | 116 | @ </script> |
| 116 | 117 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -106,10 +106,11 @@ | |
| 106 | @ <hr> |
| 107 | |
| 108 | /* New chat messages get inserted immediately after this element */ |
| 109 | @ <span id='message-inject-point'></span> |
| 110 | |
| 111 | /* Always in-line the javascript for the chat page */ |
| 112 | @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */ |
| 113 | @ let _me = "%j(g.zLogin)"; |
| 114 | cgi_append_content(builtin_text("chat.js"),-1); |
| 115 | @ </script> |
| 116 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -106,10 +106,11 @@ | |
| 106 | @ <hr> |
| 107 | |
| 108 | /* New chat messages get inserted immediately after this element */ |
| 109 | @ <span id='message-inject-point'></span> |
| 110 | |
| 111 | builtin_fossil_js_bundle_or("popupwidget", NULL); |
| 112 | /* Always in-line the javascript for the chat page */ |
| 113 | @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */ |
| 114 | @ let _me = "%j(g.zLogin)"; |
| 115 | cgi_append_content(builtin_text("chat.js"),-1); |
| 116 | @ </script> |
| 117 |
+1
-1
| --- src/chat.js | ||
| +++ src/chat.js | ||
| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | (function(){ |
| 2 | 2 | const form = document.querySelector('#chat-form'); |
| 3 | 3 | let mxMsg = 0; |
| 4 | 4 | // let _me = "%string($me)"; |
| 5 | -let me = "drh"; // FIX ME | |
| 5 | + let me = window.fossil.user.name; | |
| 6 | 6 | form.addEventListener('submit',(e)=>{ |
| 7 | 7 | e.preventDefault(); |
| 8 | 8 | if( form.msg.value.length>0 || form.file.value.length>0 ){ |
| 9 | 9 | fetch("chat-send",{ |
| 10 | 10 | method: 'POST', |
| 11 | 11 |
| --- src/chat.js | |
| +++ src/chat.js | |
| @@ -1,10 +1,10 @@ | |
| 1 | (function(){ |
| 2 | const form = document.querySelector('#chat-form'); |
| 3 | let mxMsg = 0; |
| 4 | // let _me = "%string($me)"; |
| 5 | let me = "drh"; // FIX ME |
| 6 | form.addEventListener('submit',(e)=>{ |
| 7 | e.preventDefault(); |
| 8 | if( form.msg.value.length>0 || form.file.value.length>0 ){ |
| 9 | fetch("chat-send",{ |
| 10 | method: 'POST', |
| 11 |
| --- src/chat.js | |
| +++ src/chat.js | |
| @@ -1,10 +1,10 @@ | |
| 1 | (function(){ |
| 2 | const form = document.querySelector('#chat-form'); |
| 3 | let mxMsg = 0; |
| 4 | // let _me = "%string($me)"; |
| 5 | let me = window.fossil.user.name; |
| 6 | form.addEventListener('submit',(e)=>{ |
| 7 | e.preventDefault(); |
| 8 | if( form.msg.value.length>0 || form.file.value.length>0 ){ |
| 9 | fetch("chat-send",{ |
| 10 | method: 'POST', |
| 11 |