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).

stephan 2020-12-23 05:44 chatroom-dev
Commit 4e832e9f400243873e8e6909e8768ed0538c4866498c71292b4a310f25f11641
--- src/builtin.c
+++ src/builtin.c
@@ -636,10 +636,13 @@
636636
CX("isDark: %s"
637637
"/*true if the current skin has the 'white-foreground' detail*/",
638638
skin_detail_boolean("white-foreground") ? "true" : "false");
639639
CX("}\n"/*fossil.config.skin*/);
640640
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*/);
641644
CX("if(fossil.config.skin.isDark) "
642645
"document.body.classList.add('fossil-dark-style');\n");
643646
#if 0
644647
/* Is it safe to emit the CSRF token here? Some pages add it
645648
** as a hidden form field. */
646649
--- 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 @@
106106
@ <hr>
107107
108108
/* New chat messages get inserted immediately after this element */
109109
@ <span id='message-inject-point'></span>
110110
111
+ builtin_fossil_js_bundle_or("popupwidget", NULL);
111112
/* Always in-line the javascript for the chat page */
112113
@ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
113114
@ let _me = "%j(g.zLogin)";
114115
cgi_append_content(builtin_text("chat.js"),-1);
115116
@ </script>
116117
--- 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 @@
11
(function(){
22
const form = document.querySelector('#chat-form');
33
let mxMsg = 0;
44
// let _me = "%string($me)";
5
-let me = "drh"; // FIX ME
5
+ let me = window.fossil.user.name;
66
form.addEventListener('submit',(e)=>{
77
e.preventDefault();
88
if( form.msg.value.length>0 || form.file.value.length>0 ){
99
fetch("chat-send",{
1010
method: 'POST',
1111
--- 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

Keyboard Shortcuts

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