Fossil SCM

Have the forum editor preview use /ajax/preview-text instead of /wikiajax/preview so that it does not require wiki-read permissions to use. Reported in [forum:87f2e5d3356beb10|forum post 2026-06-08T20:14:31Z].

stephan 2026-06-09 08:13 UTC forum-editor-2026
Commit 210435c0d115e7d16c3299cd93adff30a57dc3b3a6cc3a82afa82aa0dde15e4e
+5 -1
--- src/ajax.c
+++ src/ajax.c
@@ -459,11 +459,15 @@
459459
**
460460
** https://fossil-scm.org/forum/forumpost/ed4a762b3a557898
461461
**
462462
** This particular route is used by /fileedit and /chat, whereas
463463
** /wikiedit uses a simpler wiki-specific route.
464
- */ }
464
+ */
465
+ /* TODO (2026-06-09): preview.txt, preview.md, preview.wiki as
466
+ ** shorthand for preview-text?filename=X.(txt|md|wiki), noting that
467
+ ** the filename is only used for mimetype determination. */
468
+ }
465469
};
466470
467471
if(zName==0 || zName[0]==0){
468472
ajax_route_error(400,"Missing required [route] 'name' parameter.");
469473
return;
470474
--- src/ajax.c
+++ src/ajax.c
@@ -459,11 +459,15 @@
459 **
460 ** https://fossil-scm.org/forum/forumpost/ed4a762b3a557898
461 **
462 ** This particular route is used by /fileedit and /chat, whereas
463 ** /wikiedit uses a simpler wiki-specific route.
464 */ }
 
 
 
 
465 };
466
467 if(zName==0 || zName[0]==0){
468 ajax_route_error(400,"Missing required [route] 'name' parameter.");
469 return;
470
--- src/ajax.c
+++ src/ajax.c
@@ -459,11 +459,15 @@
459 **
460 ** https://fossil-scm.org/forum/forumpost/ed4a762b3a557898
461 **
462 ** This particular route is used by /fileedit and /chat, whereas
463 ** /wikiedit uses a simpler wiki-specific route.
464 */
465 /* TODO (2026-06-09): preview.txt, preview.md, preview.wiki as
466 ** shorthand for preview-text?filename=X.(txt|md|wiki), noting that
467 ** the filename is only used for mimetype determination. */
468 }
469 };
470
471 if(zName==0 || zName[0]==0){
472 ajax_route_error(400,"Missing required [route] 'name' parameter.");
473 return;
474
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -521,17 +521,22 @@
521521
}
522522
523523
async #fetchPreview(content){
524524
/* TODO: fetch preview */
525525
const e = this.#e;
526
- const fd = this.#newFormData(content);
526
+ const fd = /*no: this.#newFormData(content); */
527
+ new FormData;
528
+ let ext;
529
+ switch(this.mimetype){
530
+ case 'text/x-markdown': ext = 'md'; break;
531
+ case 'text/x-fossil-wiki': ext = 'wiki'; break;
532
+ default: ext = 'txt'; break;
533
+ }
534
+ fd.append('filename', 'x.'+ext/*for mimetype determination*/);
535
+ fd.append('content', this.editorContent.trim());
527536
return window
528
- .fetch(F.repoUrl(
529
- 'wikiajax/preview'
530
- /* ^^^ Maybe change to /ajax/preview-text, but it's
531
- ** got a more complicated interface */
532
- ), {
537
+ .fetch(F.repoUrl('ajax/preview-text'),{
533538
method: 'POST',
534539
body: fd
535540
})
536541
.then(r=>r.text())
537542
.then(t=>{
538543
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -521,17 +521,22 @@
521 }
522
523 async #fetchPreview(content){
524 /* TODO: fetch preview */
525 const e = this.#e;
526 const fd = this.#newFormData(content);
 
 
 
 
 
 
 
 
 
527 return window
528 .fetch(F.repoUrl(
529 'wikiajax/preview'
530 /* ^^^ Maybe change to /ajax/preview-text, but it's
531 ** got a more complicated interface */
532 ), {
533 method: 'POST',
534 body: fd
535 })
536 .then(r=>r.text())
537 .then(t=>{
538
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -521,17 +521,22 @@
521 }
522
523 async #fetchPreview(content){
524 /* TODO: fetch preview */
525 const e = this.#e;
526 const fd = /*no: this.#newFormData(content); */
527 new FormData;
528 let ext;
529 switch(this.mimetype){
530 case 'text/x-markdown': ext = 'md'; break;
531 case 'text/x-fossil-wiki': ext = 'wiki'; break;
532 default: ext = 'txt'; break;
533 }
534 fd.append('filename', 'x.'+ext/*for mimetype determination*/);
535 fd.append('content', this.editorContent.trim());
536 return window
537 .fetch(F.repoUrl('ajax/preview-text'),{
 
 
 
 
538 method: 'POST',
539 body: fd
540 })
541 .then(r=>r.text())
542 .then(t=>{
543

Keyboard Shortcuts

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