Fossil SCM

Provide a "source" link on Wiki/Markdown forum pages that shows the original unformatted source text for that post.

drh 2020-03-13 18:09 trunk
Commit cc46524f484b39bb5ac5f0dc3435e945ad19a9eee8d51fa2b551816ce69b1b63
1 file changed +26 -1
+26 -1
--- src/forum.c
+++ src/forum.c
@@ -387,10 +387,13 @@
387387
@ %d(p->pLeaf->sid)</a>
388388
}
389389
if( p->fpid!=target ){
390390
@ %z(href("%R/forumpost/%S?t=c",p->zUuid))[link]</a>
391391
}
392
+ if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
393
+ @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a>
394
+ }
392395
isPrivate = content_is_private(p->fpid);
393396
sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
394397
if( isPrivate && !g.perm.ModForum && !sameUser ){
395398
@ <p><span class="modpending">Awaiting Moderator Approval</span></p>
396399
}else{
@@ -500,10 +503,13 @@
500503
manifest_destroy(pOPost);
501504
}
502505
if( fpid!=target ){
503506
@ %z(href("%R/forumpost/%S",zUuid))[link]</a>
504507
}
508
+ if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
509
+ @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a>
510
+ }
505511
if( p->firt ){
506512
ForumEntry *pIrt = p->pPrev;
507513
while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
508514
if( pIrt ){
509515
@ in reply to %z(href("%R/forumpost/%S?t=h",pIrt->zUuid))\
@@ -559,10 +565,12 @@
559565
** Query parameters:
560566
**
561567
** name=X REQUIRED. The hash of the post to display
562568
** t=MODE Display mode. MODE is 'c' for chronological or
563569
** 'h' for hierarchical, or 'a' for automatic.
570
+** raw If present, show only the post specified and
571
+** show its original unformatted source text.
564572
*/
565573
void forumpost_page(void){
566574
forumthread_page();
567575
}
568576
@@ -618,10 +626,11 @@
618626
void forumthread_page(void){
619627
int fpid;
620628
int froot;
621629
const char *zName = P("name");
622630
const char *zMode = PD("t","a");
631
+ int bRaw = PB("raw");
623632
login_check_credentials();
624633
if( !g.perm.RdForum ){
625634
login_needed(g.anon.RdForum);
626635
return;
627636
}
@@ -643,11 +652,27 @@
643652
}else{
644653
zMode = "h";
645654
}
646655
}
647656
forumthread_page_header(froot, fpid);
648
- if( zMode[0]=='c' ){
657
+ if( bRaw && fpid ){
658
+ Manifest *pPost;
659
+ pPost = manifest_get(fpid, CFTYPE_FORUM, 0);
660
+ if( pPost==0 ){
661
+ @ <p>No such forum post: %h(zName)
662
+ }else{
663
+ int isPrivate = content_is_private(fpid);
664
+ int notAnon = login_is_individual();
665
+ int sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
666
+ if( isPrivate && !g.perm.ModForum && !sameUser ){
667
+ @ <p><span class="modpending">Awaiting Moderator Approval</span></p>
668
+ }else{
669
+ forum_render(0, "text/plain", pPost->zWiki, 0);
670
+ }
671
+ manifest_destroy(pPost);
672
+ }
673
+ }else if( zMode[0]=='c' ){
649674
style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
650675
forum_display_chronological(froot, fpid);
651676
}else{
652677
style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
653678
forum_display_hierarchical(froot, fpid);
654679
--- src/forum.c
+++ src/forum.c
@@ -387,10 +387,13 @@
387 @ %d(p->pLeaf->sid)</a>
388 }
389 if( p->fpid!=target ){
390 @ %z(href("%R/forumpost/%S?t=c",p->zUuid))[link]</a>
391 }
 
 
 
392 isPrivate = content_is_private(p->fpid);
393 sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
394 if( isPrivate && !g.perm.ModForum && !sameUser ){
395 @ <p><span class="modpending">Awaiting Moderator Approval</span></p>
396 }else{
@@ -500,10 +503,13 @@
500 manifest_destroy(pOPost);
501 }
502 if( fpid!=target ){
503 @ %z(href("%R/forumpost/%S",zUuid))[link]</a>
504 }
 
 
 
505 if( p->firt ){
506 ForumEntry *pIrt = p->pPrev;
507 while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
508 if( pIrt ){
509 @ in reply to %z(href("%R/forumpost/%S?t=h",pIrt->zUuid))\
@@ -559,10 +565,12 @@
559 ** Query parameters:
560 **
561 ** name=X REQUIRED. The hash of the post to display
562 ** t=MODE Display mode. MODE is 'c' for chronological or
563 ** 'h' for hierarchical, or 'a' for automatic.
 
 
564 */
565 void forumpost_page(void){
566 forumthread_page();
567 }
568
@@ -618,10 +626,11 @@
618 void forumthread_page(void){
619 int fpid;
620 int froot;
621 const char *zName = P("name");
622 const char *zMode = PD("t","a");
 
623 login_check_credentials();
624 if( !g.perm.RdForum ){
625 login_needed(g.anon.RdForum);
626 return;
627 }
@@ -643,11 +652,27 @@
643 }else{
644 zMode = "h";
645 }
646 }
647 forumthread_page_header(froot, fpid);
648 if( zMode[0]=='c' ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
649 style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
650 forum_display_chronological(froot, fpid);
651 }else{
652 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
653 forum_display_hierarchical(froot, fpid);
654
--- src/forum.c
+++ src/forum.c
@@ -387,10 +387,13 @@
387 @ %d(p->pLeaf->sid)</a>
388 }
389 if( p->fpid!=target ){
390 @ %z(href("%R/forumpost/%S?t=c",p->zUuid))[link]</a>
391 }
392 if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
393 @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a>
394 }
395 isPrivate = content_is_private(p->fpid);
396 sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
397 if( isPrivate && !g.perm.ModForum && !sameUser ){
398 @ <p><span class="modpending">Awaiting Moderator Approval</span></p>
399 }else{
@@ -500,10 +503,13 @@
503 manifest_destroy(pOPost);
504 }
505 if( fpid!=target ){
506 @ %z(href("%R/forumpost/%S",zUuid))[link]</a>
507 }
508 if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){
509 @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a>
510 }
511 if( p->firt ){
512 ForumEntry *pIrt = p->pPrev;
513 while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
514 if( pIrt ){
515 @ in reply to %z(href("%R/forumpost/%S?t=h",pIrt->zUuid))\
@@ -559,10 +565,12 @@
565 ** Query parameters:
566 **
567 ** name=X REQUIRED. The hash of the post to display
568 ** t=MODE Display mode. MODE is 'c' for chronological or
569 ** 'h' for hierarchical, or 'a' for automatic.
570 ** raw If present, show only the post specified and
571 ** show its original unformatted source text.
572 */
573 void forumpost_page(void){
574 forumthread_page();
575 }
576
@@ -618,10 +626,11 @@
626 void forumthread_page(void){
627 int fpid;
628 int froot;
629 const char *zName = P("name");
630 const char *zMode = PD("t","a");
631 int bRaw = PB("raw");
632 login_check_credentials();
633 if( !g.perm.RdForum ){
634 login_needed(g.anon.RdForum);
635 return;
636 }
@@ -643,11 +652,27 @@
652 }else{
653 zMode = "h";
654 }
655 }
656 forumthread_page_header(froot, fpid);
657 if( bRaw && fpid ){
658 Manifest *pPost;
659 pPost = manifest_get(fpid, CFTYPE_FORUM, 0);
660 if( pPost==0 ){
661 @ <p>No such forum post: %h(zName)
662 }else{
663 int isPrivate = content_is_private(fpid);
664 int notAnon = login_is_individual();
665 int sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
666 if( isPrivate && !g.perm.ModForum && !sameUser ){
667 @ <p><span class="modpending">Awaiting Moderator Approval</span></p>
668 }else{
669 forum_render(0, "text/plain", pPost->zWiki, 0);
670 }
671 manifest_destroy(pPost);
672 }
673 }else if( zMode[0]=='c' ){
674 style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
675 forum_display_chronological(froot, fpid);
676 }else{
677 style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
678 forum_display_hierarchical(froot, fpid);
679

Keyboard Shortcuts

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