Fossil SCM
Provide a "source" link on Wiki/Markdown forum pages that shows the original unformatted source text for that post.
Commit
cc46524f484b39bb5ac5f0dc3435e945ad19a9eee8d51fa2b551816ce69b1b63
Parent
98270ad6135e0fd…
1 file changed
+26
-1
+26
-1
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -387,10 +387,13 @@ | ||
| 387 | 387 | @ %d(p->pLeaf->sid)</a> |
| 388 | 388 | } |
| 389 | 389 | if( p->fpid!=target ){ |
| 390 | 390 | @ %z(href("%R/forumpost/%S?t=c",p->zUuid))[link]</a> |
| 391 | 391 | } |
| 392 | + if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){ | |
| 393 | + @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a> | |
| 394 | + } | |
| 392 | 395 | isPrivate = content_is_private(p->fpid); |
| 393 | 396 | sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| 394 | 397 | if( isPrivate && !g.perm.ModForum && !sameUser ){ |
| 395 | 398 | @ <p><span class="modpending">Awaiting Moderator Approval</span></p> |
| 396 | 399 | }else{ |
| @@ -500,10 +503,13 @@ | ||
| 500 | 503 | manifest_destroy(pOPost); |
| 501 | 504 | } |
| 502 | 505 | if( fpid!=target ){ |
| 503 | 506 | @ %z(href("%R/forumpost/%S",zUuid))[link]</a> |
| 504 | 507 | } |
| 508 | + if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){ | |
| 509 | + @ %z(href("%R/forumpost/%S?raw",p->zUuid))[source]</a> | |
| 510 | + } | |
| 505 | 511 | if( p->firt ){ |
| 506 | 512 | ForumEntry *pIrt = p->pPrev; |
| 507 | 513 | while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; |
| 508 | 514 | if( pIrt ){ |
| 509 | 515 | @ in reply to %z(href("%R/forumpost/%S?t=h",pIrt->zUuid))\ |
| @@ -559,10 +565,12 @@ | ||
| 559 | 565 | ** Query parameters: |
| 560 | 566 | ** |
| 561 | 567 | ** name=X REQUIRED. The hash of the post to display |
| 562 | 568 | ** t=MODE Display mode. MODE is 'c' for chronological or |
| 563 | 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. | |
| 564 | 572 | */ |
| 565 | 573 | void forumpost_page(void){ |
| 566 | 574 | forumthread_page(); |
| 567 | 575 | } |
| 568 | 576 | |
| @@ -618,10 +626,11 @@ | ||
| 618 | 626 | void forumthread_page(void){ |
| 619 | 627 | int fpid; |
| 620 | 628 | int froot; |
| 621 | 629 | const char *zName = P("name"); |
| 622 | 630 | const char *zMode = PD("t","a"); |
| 631 | + int bRaw = PB("raw"); | |
| 623 | 632 | login_check_credentials(); |
| 624 | 633 | if( !g.perm.RdForum ){ |
| 625 | 634 | login_needed(g.anon.RdForum); |
| 626 | 635 | return; |
| 627 | 636 | } |
| @@ -643,11 +652,27 @@ | ||
| 643 | 652 | }else{ |
| 644 | 653 | zMode = "h"; |
| 645 | 654 | } |
| 646 | 655 | } |
| 647 | 656 | 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' ){ | |
| 649 | 674 | style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName); |
| 650 | 675 | forum_display_chronological(froot, fpid); |
| 651 | 676 | }else{ |
| 652 | 677 | style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName); |
| 653 | 678 | forum_display_hierarchical(froot, fpid); |
| 654 | 679 |
| --- 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 |