Fossil SCM

Add the option to show an entire forum thread as "unformatted" text.

drh 2020-03-14 15:43 trunk
Commit b41b39018fa69dc673ce8efb6b4c7e930c270b87f50035423ea2138897dad651
1 file changed +25 -12
+25 -12
--- src/forum.c
+++ src/forum.c
@@ -339,14 +339,15 @@
339339
}
340340
341341
/*
342342
** Display all posts in a forum thread in chronological order
343343
*/
344
-static void forum_display_chronological(int froot, int target){
344
+static void forum_display_chronological(int froot, int target, int bRawMode){
345345
ForumThread *pThread = forumthread_create(froot, 0);
346346
ForumEntry *p;
347347
int notAnon = login_is_individual();
348
+ char cMode = bRawMode ? 'r' : 'c';
348349
for(p=pThread->pFirst; p; p=p->pNext){
349350
char *zDate;
350351
Manifest *pPost;
351352
int isPrivate; /* True for posts awaiting moderation */
352353
int sameUser; /* True if author is also the reader */
@@ -366,11 +367,11 @@
366367
}
367368
zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate);
368369
@ <h3 class='forumPostHdr'>(%d(p->sid)) By %h(pPost->zUser) on %h(zDate)
369370
fossil_free(zDate);
370371
if( p->pEdit ){
371
- @ edit of %z(href("%R/forumpost/%S?t=c",p->pEdit->zUuid))\
372
+ @ edit of %z(href("%R/forumpost/%S?t=%c",p->pEdit->zUuid,cMode))\
372373
@ %d(p->pEdit->sid)</a>
373374
}
374375
if( g.perm.Debug ){
375376
@ <span class="debug">\
376377
@ <a href="%R/artifact/%h(p->zUuid)">(artifact)</a></span>
@@ -377,33 +378,33 @@
377378
}
378379
if( p->firt ){
379380
ForumEntry *pIrt = p->pPrev;
380381
while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
381382
if( pIrt ){
382
- @ in reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))\
383
+ @ in reply to %z(href("%R/forumpost/%S?t=%c",pIrt->zUuid,cMode))\
383384
@ %d(pIrt->sid)</a>
384385
}
385386
}
386387
zUuid = p->zUuid;
387388
if( p->pLeaf ){
388
- @ updated by %z(href("%R/forumpost/%S?t=c",p->pLeaf->zUuid))\
389
+ @ updated by %z(href("%R/forumpost/%S?t=%c",p->pLeaf->zUuid,cMode))\
389390
@ %d(p->pLeaf->sid)</a>
390391
zUuid = p->pLeaf->zUuid;
391392
}
392393
if( p->fpid!=target ){
393
- @ %z(href("%R/forumpost/%S?t=c",zUuid))[link]</a>
394
+ @ %z(href("%R/forumpost/%S?t=%c",zUuid,cMode))[link]</a>
394395
}
395
- if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
396
+ if( !bRawMode && fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
396397
@ %z(href("%R/forumpost/%S?raw",zUuid))[source]</a>
397398
}
398399
isPrivate = content_is_private(p->fpid);
399400
sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
400401
@ </h3>
401402
if( isPrivate && !g.perm.ModForum && !sameUser ){
402403
@ <p><span class="modpending">Awaiting Moderator Approval</span></p>
403404
}else{
404
- forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
405
+ forum_render(0, bRawMode?"text/plain":pPost->zMimetype, pPost->zWiki, 0);
405406
}
406407
if( g.perm.WrForum && p->pLeaf==0 ){
407408
int sameUser = login_is_individual()
408409
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
409410
@ <p><form action="%R/forumedit" method="POST">
@@ -569,12 +570,15 @@
569570
** selected posting into view after the page loads.
570571
**
571572
** Query parameters:
572573
**
573574
** name=X REQUIRED. The hash of the post to display
574
-** t=MODE Display mode. MODE is 'c' for chronological or
575
-** 'h' for hierarchical, or 'a' for automatic.
575
+** t=MODE Display mode.
576
+** 'c' for chronological
577
+** 'h' for hierarchical
578
+** 'a' for automatic
579
+** 'r' for raw
576580
** raw If present, show only the post specified and
577581
** show its original unformatted source text.
578582
*/
579583
void forumpost_page(void){
580584
forumthread_page();
@@ -608,12 +612,15 @@
608612
** the postings in the thread are selected.
609613
**
610614
** Query parameters:
611615
**
612616
** name=X REQUIRED. The hash of any post of the thread.
613
-** t=MODE Display mode. MODE is 'c' for chronological or
614
-** 'h' for hierarchical, or 'a' for automatic.
617
+** t=MODE Display mode. MODE is...
618
+** 'c' for chronological, or
619
+** 'h' for hierarchical, or
620
+** 'a' for automatic, or
621
+** 'r' for raw.
615622
*/
616623
void forumthread_page(void){
617624
int fpid;
618625
int froot;
619626
const char *zName = P("name");
@@ -660,13 +667,19 @@
660667
}
661668
manifest_destroy(pPost);
662669
}
663670
}else if( zMode[0]=='c' ){
664671
style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
665
- forum_display_chronological(froot, fpid);
672
+ style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
673
+ forum_display_chronological(froot, fpid, 0);
674
+ }else if( zMode[0]=='r' ){
675
+ style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
676
+ style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
677
+ forum_display_chronological(froot, fpid, 1);
666678
}else{
667679
style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
680
+ style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
668681
forum_display_hierarchical(froot, fpid);
669682
}
670683
style_load_js("forum.js");
671684
style_footer();
672685
}
673686
--- src/forum.c
+++ src/forum.c
@@ -339,14 +339,15 @@
339 }
340
341 /*
342 ** Display all posts in a forum thread in chronological order
343 */
344 static void forum_display_chronological(int froot, int target){
345 ForumThread *pThread = forumthread_create(froot, 0);
346 ForumEntry *p;
347 int notAnon = login_is_individual();
 
348 for(p=pThread->pFirst; p; p=p->pNext){
349 char *zDate;
350 Manifest *pPost;
351 int isPrivate; /* True for posts awaiting moderation */
352 int sameUser; /* True if author is also the reader */
@@ -366,11 +367,11 @@
366 }
367 zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate);
368 @ <h3 class='forumPostHdr'>(%d(p->sid)) By %h(pPost->zUser) on %h(zDate)
369 fossil_free(zDate);
370 if( p->pEdit ){
371 @ edit of %z(href("%R/forumpost/%S?t=c",p->pEdit->zUuid))\
372 @ %d(p->pEdit->sid)</a>
373 }
374 if( g.perm.Debug ){
375 @ <span class="debug">\
376 @ <a href="%R/artifact/%h(p->zUuid)">(artifact)</a></span>
@@ -377,33 +378,33 @@
377 }
378 if( p->firt ){
379 ForumEntry *pIrt = p->pPrev;
380 while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
381 if( pIrt ){
382 @ in reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))\
383 @ %d(pIrt->sid)</a>
384 }
385 }
386 zUuid = p->zUuid;
387 if( p->pLeaf ){
388 @ updated by %z(href("%R/forumpost/%S?t=c",p->pLeaf->zUuid))\
389 @ %d(p->pLeaf->sid)</a>
390 zUuid = p->pLeaf->zUuid;
391 }
392 if( p->fpid!=target ){
393 @ %z(href("%R/forumpost/%S?t=c",zUuid))[link]</a>
394 }
395 if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
396 @ %z(href("%R/forumpost/%S?raw",zUuid))[source]</a>
397 }
398 isPrivate = content_is_private(p->fpid);
399 sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
400 @ </h3>
401 if( isPrivate && !g.perm.ModForum && !sameUser ){
402 @ <p><span class="modpending">Awaiting Moderator Approval</span></p>
403 }else{
404 forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
405 }
406 if( g.perm.WrForum && p->pLeaf==0 ){
407 int sameUser = login_is_individual()
408 && fossil_strcmp(pPost->zUser, g.zLogin)==0;
409 @ <p><form action="%R/forumedit" method="POST">
@@ -569,12 +570,15 @@
569 ** selected posting into view after the page loads.
570 **
571 ** Query parameters:
572 **
573 ** name=X REQUIRED. The hash of the post to display
574 ** t=MODE Display mode. MODE is 'c' for chronological or
575 ** 'h' for hierarchical, or 'a' for automatic.
 
 
 
576 ** raw If present, show only the post specified and
577 ** show its original unformatted source text.
578 */
579 void forumpost_page(void){
580 forumthread_page();
@@ -608,12 +612,15 @@
608 ** the postings in the thread are selected.
609 **
610 ** Query parameters:
611 **
612 ** name=X REQUIRED. The hash of any post of the thread.
613 ** t=MODE Display mode. MODE is 'c' for chronological or
614 ** 'h' for hierarchical, or 'a' for automatic.
 
 
 
615 */
616 void forumthread_page(void){
617 int fpid;
618 int froot;
619 const char *zName = P("name");
@@ -660,13 +667,19 @@
660 }
661 manifest_destroy(pPost);
662 }
663 }else if( zMode[0]=='c' ){
664 style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
665 forum_display_chronological(froot, fpid);
 
 
 
 
 
666 }else{
667 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
 
668 forum_display_hierarchical(froot, fpid);
669 }
670 style_load_js("forum.js");
671 style_footer();
672 }
673
--- src/forum.c
+++ src/forum.c
@@ -339,14 +339,15 @@
339 }
340
341 /*
342 ** Display all posts in a forum thread in chronological order
343 */
344 static void forum_display_chronological(int froot, int target, int bRawMode){
345 ForumThread *pThread = forumthread_create(froot, 0);
346 ForumEntry *p;
347 int notAnon = login_is_individual();
348 char cMode = bRawMode ? 'r' : 'c';
349 for(p=pThread->pFirst; p; p=p->pNext){
350 char *zDate;
351 Manifest *pPost;
352 int isPrivate; /* True for posts awaiting moderation */
353 int sameUser; /* True if author is also the reader */
@@ -366,11 +367,11 @@
367 }
368 zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate);
369 @ <h3 class='forumPostHdr'>(%d(p->sid)) By %h(pPost->zUser) on %h(zDate)
370 fossil_free(zDate);
371 if( p->pEdit ){
372 @ edit of %z(href("%R/forumpost/%S?t=%c",p->pEdit->zUuid,cMode))\
373 @ %d(p->pEdit->sid)</a>
374 }
375 if( g.perm.Debug ){
376 @ <span class="debug">\
377 @ <a href="%R/artifact/%h(p->zUuid)">(artifact)</a></span>
@@ -377,33 +378,33 @@
378 }
379 if( p->firt ){
380 ForumEntry *pIrt = p->pPrev;
381 while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
382 if( pIrt ){
383 @ in reply to %z(href("%R/forumpost/%S?t=%c",pIrt->zUuid,cMode))\
384 @ %d(pIrt->sid)</a>
385 }
386 }
387 zUuid = p->zUuid;
388 if( p->pLeaf ){
389 @ updated by %z(href("%R/forumpost/%S?t=%c",p->pLeaf->zUuid,cMode))\
390 @ %d(p->pLeaf->sid)</a>
391 zUuid = p->pLeaf->zUuid;
392 }
393 if( p->fpid!=target ){
394 @ %z(href("%R/forumpost/%S?t=%c",zUuid,cMode))[link]</a>
395 }
396 if( !bRawMode && fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
397 @ %z(href("%R/forumpost/%S?raw",zUuid))[source]</a>
398 }
399 isPrivate = content_is_private(p->fpid);
400 sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
401 @ </h3>
402 if( isPrivate && !g.perm.ModForum && !sameUser ){
403 @ <p><span class="modpending">Awaiting Moderator Approval</span></p>
404 }else{
405 forum_render(0, bRawMode?"text/plain":pPost->zMimetype, pPost->zWiki, 0);
406 }
407 if( g.perm.WrForum && p->pLeaf==0 ){
408 int sameUser = login_is_individual()
409 && fossil_strcmp(pPost->zUser, g.zLogin)==0;
410 @ <p><form action="%R/forumedit" method="POST">
@@ -569,12 +570,15 @@
570 ** selected posting into view after the page loads.
571 **
572 ** Query parameters:
573 **
574 ** name=X REQUIRED. The hash of the post to display
575 ** t=MODE Display mode.
576 ** 'c' for chronological
577 ** 'h' for hierarchical
578 ** 'a' for automatic
579 ** 'r' for raw
580 ** raw If present, show only the post specified and
581 ** show its original unformatted source text.
582 */
583 void forumpost_page(void){
584 forumthread_page();
@@ -608,12 +612,15 @@
612 ** the postings in the thread are selected.
613 **
614 ** Query parameters:
615 **
616 ** name=X REQUIRED. The hash of any post of the thread.
617 ** t=MODE Display mode. MODE is...
618 ** 'c' for chronological, or
619 ** 'h' for hierarchical, or
620 ** 'a' for automatic, or
621 ** 'r' for raw.
622 */
623 void forumthread_page(void){
624 int fpid;
625 int froot;
626 const char *zName = P("name");
@@ -660,13 +667,19 @@
667 }
668 manifest_destroy(pPost);
669 }
670 }else if( zMode[0]=='c' ){
671 style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
672 style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
673 forum_display_chronological(froot, fpid, 0);
674 }else if( zMode[0]=='r' ){
675 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
676 style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
677 forum_display_chronological(froot, fpid, 1);
678 }else{
679 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
680 style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
681 forum_display_hierarchical(froot, fpid);
682 }
683 style_load_js("forum.js");
684 style_footer();
685 }
686

Keyboard Shortcuts

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