Fossil SCM

Add ?nojs URL flag check to the new forum JS, /forumnew, and /forumedit. In JS it supresses plugging-in of the JS and in C it suppresses the new-in-this-branch NOSCRIPT tags so that the legacy forms get rendered. We should probably remove the NOSCRIPT tag altogether and have JS remove that form if it exists, which would allow /forumnew and /forumedit to fall back gracefully, even in JS-aware browsers, without the ?nojs URL flag.

stephan 2026-06-10 10:24 UTC forum-editor-2026
Commit 133387b19da24cb03c40ae7824f30e2570000ad1403fa9f8a6a45f6eb0ebc6ce
+5 -5
--- src/forum.c
+++ src/forum.c
@@ -2038,11 +2038,11 @@
20382038
*/
20392039
void forumnew_page(void){
20402040
const char *zTitle = PDT("title","");
20412041
const char *zMimetype = PD("mimetype",DEFAULT_FORUM_MIMETYPE);
20422042
const char *zContent = PDT("content","");
2043
- const int bLegacy = PB("legacy"); /* True for legacy HTML form */
2043
+ const int bNoJs = PB("nojs"); /* True for legacy HTML form */
20442044
20452045
login_check_credentials();
20462046
if( !g.perm.WrForum ){
20472047
login_needed(g.anon.WrForum);
20482048
return;
@@ -2056,11 +2056,11 @@
20562056
forum_render(zTitle, zMimetype, zContent, "forumEdit", 1);
20572057
}
20582058
style_set_current_feature("forum");
20592059
style_header("New Forum Thread");
20602060
2061
- if( !bLegacy ){
2061
+ if( !bNoJs ){
20622062
@ <noscript>
20632063
}
20642064
@ <form action="%R/forume1" method="POST">
20652065
@ <h1>New Thread:</h1>
20662066
forum_from_line();
@@ -2074,11 +2074,11 @@
20742074
}
20752075
forum_render_debug_options();
20762076
login_insert_csrf_secret();
20772077
@ </form>
20782078
forum_render_attachment_notice();
2079
- if( !bLegacy ){
2079
+ if( !bNoJs ){
20802080
@ </noscript>
20812081
/* When JS is disabled the block above will work.
20822082
When it's enabled, the above won't do anything and
20832083
JS will render the editor form in the next element. */
20842084
@ <div hidden id='forumnew-placeholder'>
@@ -2106,20 +2106,20 @@
21062106
const char *zMimetype = 0;
21072107
const char *zContent = 0;
21082108
const char *zTitle = 0;
21092109
char *zDate = 0;
21102110
const char *zFpid = PD("fpid","");
2111
- const int bLegacy = 1 ? 1 : PB("legacy"); /* True for legacy HTML form */
2111
+ const int bNoJs = PB("nojs");
21122112
int isCsrfSafe;
21132113
int isDelete = 0;
21142114
int iClosed = 0;
21152115
int bSameUser; /* True if author is also the reader */
21162116
int bPreview; /* True in preview mode. */
21172117
int bPrivate; /* True if post is private (not yet moderated) */
21182118
int bReply; /* True if replying to a post */
21192119
2120
- if( !bLegacy ){
2120
+ if( !bNoJs ){
21212121
forumedit_page_v2();
21222122
return;
21232123
}
21242124
21252125
login_check_credentials();
21262126
--- src/forum.c
+++ src/forum.c
@@ -2038,11 +2038,11 @@
2038 */
2039 void forumnew_page(void){
2040 const char *zTitle = PDT("title","");
2041 const char *zMimetype = PD("mimetype",DEFAULT_FORUM_MIMETYPE);
2042 const char *zContent = PDT("content","");
2043 const int bLegacy = PB("legacy"); /* True for legacy HTML form */
2044
2045 login_check_credentials();
2046 if( !g.perm.WrForum ){
2047 login_needed(g.anon.WrForum);
2048 return;
@@ -2056,11 +2056,11 @@
2056 forum_render(zTitle, zMimetype, zContent, "forumEdit", 1);
2057 }
2058 style_set_current_feature("forum");
2059 style_header("New Forum Thread");
2060
2061 if( !bLegacy ){
2062 @ <noscript>
2063 }
2064 @ <form action="%R/forume1" method="POST">
2065 @ <h1>New Thread:</h1>
2066 forum_from_line();
@@ -2074,11 +2074,11 @@
2074 }
2075 forum_render_debug_options();
2076 login_insert_csrf_secret();
2077 @ </form>
2078 forum_render_attachment_notice();
2079 if( !bLegacy ){
2080 @ </noscript>
2081 /* When JS is disabled the block above will work.
2082 When it's enabled, the above won't do anything and
2083 JS will render the editor form in the next element. */
2084 @ <div hidden id='forumnew-placeholder'>
@@ -2106,20 +2106,20 @@
2106 const char *zMimetype = 0;
2107 const char *zContent = 0;
2108 const char *zTitle = 0;
2109 char *zDate = 0;
2110 const char *zFpid = PD("fpid","");
2111 const int bLegacy = 1 ? 1 : PB("legacy"); /* True for legacy HTML form */
2112 int isCsrfSafe;
2113 int isDelete = 0;
2114 int iClosed = 0;
2115 int bSameUser; /* True if author is also the reader */
2116 int bPreview; /* True in preview mode. */
2117 int bPrivate; /* True if post is private (not yet moderated) */
2118 int bReply; /* True if replying to a post */
2119
2120 if( !bLegacy ){
2121 forumedit_page_v2();
2122 return;
2123 }
2124
2125 login_check_credentials();
2126
--- src/forum.c
+++ src/forum.c
@@ -2038,11 +2038,11 @@
2038 */
2039 void forumnew_page(void){
2040 const char *zTitle = PDT("title","");
2041 const char *zMimetype = PD("mimetype",DEFAULT_FORUM_MIMETYPE);
2042 const char *zContent = PDT("content","");
2043 const int bNoJs = PB("nojs"); /* True for legacy HTML form */
2044
2045 login_check_credentials();
2046 if( !g.perm.WrForum ){
2047 login_needed(g.anon.WrForum);
2048 return;
@@ -2056,11 +2056,11 @@
2056 forum_render(zTitle, zMimetype, zContent, "forumEdit", 1);
2057 }
2058 style_set_current_feature("forum");
2059 style_header("New Forum Thread");
2060
2061 if( !bNoJs ){
2062 @ <noscript>
2063 }
2064 @ <form action="%R/forume1" method="POST">
2065 @ <h1>New Thread:</h1>
2066 forum_from_line();
@@ -2074,11 +2074,11 @@
2074 }
2075 forum_render_debug_options();
2076 login_insert_csrf_secret();
2077 @ </form>
2078 forum_render_attachment_notice();
2079 if( !bNoJs ){
2080 @ </noscript>
2081 /* When JS is disabled the block above will work.
2082 When it's enabled, the above won't do anything and
2083 JS will render the editor form in the next element. */
2084 @ <div hidden id='forumnew-placeholder'>
@@ -2106,20 +2106,20 @@
2106 const char *zMimetype = 0;
2107 const char *zContent = 0;
2108 const char *zTitle = 0;
2109 char *zDate = 0;
2110 const char *zFpid = PD("fpid","");
2111 const int bNoJs = PB("nojs");
2112 int isCsrfSafe;
2113 int isDelete = 0;
2114 int iClosed = 0;
2115 int bSameUser; /* True if author is also the reader */
2116 int bPreview; /* True in preview mode. */
2117 int bPrivate; /* True if post is private (not yet moderated) */
2118 int bReply; /* True if replying to a post */
2119
2120 if( !bNoJs ){
2121 forumedit_page_v2();
2122 return;
2123 }
2124
2125 login_check_credentials();
2126
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -989,17 +989,22 @@
989989
inline: 'nearest'
990990
});
991991
});
992992
};
993993
994
+ const plugInEditor =
995
+ (new URL(window.location).searchParams).get('nojs')===null;
996
+
994997
const eForumNew = (
995
- document.body.classList.contains('cpage-forumnew')
996
- || document.body.classList.contains('cpage-forume1')
997
- )
998
+ plugInEditor
999
+ && (
1000
+ document.body.classList.contains('cpage-forumnew')
1001
+ || document.body.classList.contains('cpage-forume1')
1002
+ ))
9981003
? document.querySelector('#forumnew-placeholder')
9991004
: null;
1000
- if( eForumNew ){
1005
+ if( plugInEditor && eForumNew ){
10011006
/* /forumnew and /forume2 */
10021007
const fpe = new F.ForumPostEditor({
10031008
draftKey: 'draft-forumnew',
10041009
hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'),
10051010
ondiscard: ()=>{
@@ -1011,12 +1016,13 @@
10111016
});
10121017
eForumNew.parentElement.insertBefore(fpe.widget, eForumNew);
10131018
eForumNew.remove();
10141019
fossil.page.fpe = fpe /* for testing via the console */;
10151020
}/*eForumNew*/
1016
- else if( (document.body.classList.contains('cpage-forumpost')
1017
- || document.body.classList.contains('cpage-forumthread'))){
1021
+ else if( plugInEditor
1022
+ && (document.body.classList.contains('cpage-forumpost')
1023
+ || document.body.classList.contains('cpage-forumthread')) ){
10181024
/* /forumpost and /forumthread. Take over the Edit/Reply buttons
10191025
to use a ForumPostEditor. */
10201026
10211027
const fetchPost = async (fpid)=>{
10221028
return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid))
@@ -1205,11 +1211,11 @@
12051211
to start hidden so that it does not show up for no-JS
12061212
clients. */
12071213
e.classList.remove('initially-hidden');
12081214
});
12091215
1210
- if( Date.now() % 17 === 0 ){
1216
+ if( plugInEditor && (Date.now() % 17 === 0) ){
12111217
/* Purge old drafts only every now and then. */
12121218
F.ForumPostEditor.purgeOldDrafts(/^draft-(reply|forumedit)-.*/)/*not purging forumnew*/;
12131219
}
12141220
})/*F.onPageLoad callback*/;
12151221
})(window.fossil);
12161222
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -989,17 +989,22 @@
989 inline: 'nearest'
990 });
991 });
992 };
993
 
 
 
994 const eForumNew = (
995 document.body.classList.contains('cpage-forumnew')
996 || document.body.classList.contains('cpage-forume1')
997 )
 
 
998 ? document.querySelector('#forumnew-placeholder')
999 : null;
1000 if( eForumNew ){
1001 /* /forumnew and /forume2 */
1002 const fpe = new F.ForumPostEditor({
1003 draftKey: 'draft-forumnew',
1004 hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'),
1005 ondiscard: ()=>{
@@ -1011,12 +1016,13 @@
1011 });
1012 eForumNew.parentElement.insertBefore(fpe.widget, eForumNew);
1013 eForumNew.remove();
1014 fossil.page.fpe = fpe /* for testing via the console */;
1015 }/*eForumNew*/
1016 else if( (document.body.classList.contains('cpage-forumpost')
1017 || document.body.classList.contains('cpage-forumthread'))){
 
1018 /* /forumpost and /forumthread. Take over the Edit/Reply buttons
1019 to use a ForumPostEditor. */
1020
1021 const fetchPost = async (fpid)=>{
1022 return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid))
@@ -1205,11 +1211,11 @@
1205 to start hidden so that it does not show up for no-JS
1206 clients. */
1207 e.classList.remove('initially-hidden');
1208 });
1209
1210 if( Date.now() % 17 === 0 ){
1211 /* Purge old drafts only every now and then. */
1212 F.ForumPostEditor.purgeOldDrafts(/^draft-(reply|forumedit)-.*/)/*not purging forumnew*/;
1213 }
1214 })/*F.onPageLoad callback*/;
1215 })(window.fossil);
1216
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -989,17 +989,22 @@
989 inline: 'nearest'
990 });
991 });
992 };
993
994 const plugInEditor =
995 (new URL(window.location).searchParams).get('nojs')===null;
996
997 const eForumNew = (
998 plugInEditor
999 && (
1000 document.body.classList.contains('cpage-forumnew')
1001 || document.body.classList.contains('cpage-forume1')
1002 ))
1003 ? document.querySelector('#forumnew-placeholder')
1004 : null;
1005 if( plugInEditor && eForumNew ){
1006 /* /forumnew and /forume2 */
1007 const fpe = new F.ForumPostEditor({
1008 draftKey: 'draft-forumnew',
1009 hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'),
1010 ondiscard: ()=>{
@@ -1011,12 +1016,13 @@
1016 });
1017 eForumNew.parentElement.insertBefore(fpe.widget, eForumNew);
1018 eForumNew.remove();
1019 fossil.page.fpe = fpe /* for testing via the console */;
1020 }/*eForumNew*/
1021 else if( plugInEditor
1022 && (document.body.classList.contains('cpage-forumpost')
1023 || document.body.classList.contains('cpage-forumthread')) ){
1024 /* /forumpost and /forumthread. Take over the Edit/Reply buttons
1025 to use a ForumPostEditor. */
1026
1027 const fetchPost = async (fpid)=>{
1028 return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid))
@@ -1205,11 +1211,11 @@
1211 to start hidden so that it does not show up for no-JS
1212 clients. */
1213 e.classList.remove('initially-hidden');
1214 });
1215
1216 if( plugInEditor && (Date.now() % 17 === 0) ){
1217 /* Purge old drafts only every now and then. */
1218 F.ForumPostEditor.purgeOldDrafts(/^draft-(reply|forumedit)-.*/)/*not purging forumnew*/;
1219 }
1220 })/*F.onPageLoad callback*/;
1221 })(window.fossil);
1222

Keyboard Shortcuts

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