Fossil SCM
Add the option to show an entire forum thread as "unformatted" text.
Commit
b41b39018fa69dc673ce8efb6b4c7e930c270b87f50035423ea2138897dad651
Parent
33dc88c417799ea…
1 file changed
+25
-12
+25
-12
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -339,14 +339,15 @@ | ||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /* |
| 342 | 342 | ** Display all posts in a forum thread in chronological order |
| 343 | 343 | */ |
| 344 | -static void forum_display_chronological(int froot, int target){ | |
| 344 | +static void forum_display_chronological(int froot, int target, int bRawMode){ | |
| 345 | 345 | ForumThread *pThread = forumthread_create(froot, 0); |
| 346 | 346 | ForumEntry *p; |
| 347 | 347 | int notAnon = login_is_individual(); |
| 348 | + char cMode = bRawMode ? 'r' : 'c'; | |
| 348 | 349 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 349 | 350 | char *zDate; |
| 350 | 351 | Manifest *pPost; |
| 351 | 352 | int isPrivate; /* True for posts awaiting moderation */ |
| 352 | 353 | int sameUser; /* True if author is also the reader */ |
| @@ -366,11 +367,11 @@ | ||
| 366 | 367 | } |
| 367 | 368 | zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); |
| 368 | 369 | @ <h3 class='forumPostHdr'>(%d(p->sid)) By %h(pPost->zUser) on %h(zDate) |
| 369 | 370 | fossil_free(zDate); |
| 370 | 371 | 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))\ | |
| 372 | 373 | @ %d(p->pEdit->sid)</a> |
| 373 | 374 | } |
| 374 | 375 | if( g.perm.Debug ){ |
| 375 | 376 | @ <span class="debug">\ |
| 376 | 377 | @ <a href="%R/artifact/%h(p->zUuid)">(artifact)</a></span> |
| @@ -377,33 +378,33 @@ | ||
| 377 | 378 | } |
| 378 | 379 | if( p->firt ){ |
| 379 | 380 | ForumEntry *pIrt = p->pPrev; |
| 380 | 381 | while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; |
| 381 | 382 | 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))\ | |
| 383 | 384 | @ %d(pIrt->sid)</a> |
| 384 | 385 | } |
| 385 | 386 | } |
| 386 | 387 | zUuid = p->zUuid; |
| 387 | 388 | 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))\ | |
| 389 | 390 | @ %d(p->pLeaf->sid)</a> |
| 390 | 391 | zUuid = p->pLeaf->zUuid; |
| 391 | 392 | } |
| 392 | 393 | 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> | |
| 394 | 395 | } |
| 395 | - if( fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){ | |
| 396 | + if( !bRawMode && fossil_strcmp(pPost->zMimetype,"text/plain")!=0 ){ | |
| 396 | 397 | @ %z(href("%R/forumpost/%S?raw",zUuid))[source]</a> |
| 397 | 398 | } |
| 398 | 399 | isPrivate = content_is_private(p->fpid); |
| 399 | 400 | sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| 400 | 401 | @ </h3> |
| 401 | 402 | if( isPrivate && !g.perm.ModForum && !sameUser ){ |
| 402 | 403 | @ <p><span class="modpending">Awaiting Moderator Approval</span></p> |
| 403 | 404 | }else{ |
| 404 | - forum_render(0, pPost->zMimetype, pPost->zWiki, 0); | |
| 405 | + forum_render(0, bRawMode?"text/plain":pPost->zMimetype, pPost->zWiki, 0); | |
| 405 | 406 | } |
| 406 | 407 | if( g.perm.WrForum && p->pLeaf==0 ){ |
| 407 | 408 | int sameUser = login_is_individual() |
| 408 | 409 | && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| 409 | 410 | @ <p><form action="%R/forumedit" method="POST"> |
| @@ -569,12 +570,15 @@ | ||
| 569 | 570 | ** selected posting into view after the page loads. |
| 570 | 571 | ** |
| 571 | 572 | ** Query parameters: |
| 572 | 573 | ** |
| 573 | 574 | ** 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 | |
| 576 | 580 | ** raw If present, show only the post specified and |
| 577 | 581 | ** show its original unformatted source text. |
| 578 | 582 | */ |
| 579 | 583 | void forumpost_page(void){ |
| 580 | 584 | forumthread_page(); |
| @@ -608,12 +612,15 @@ | ||
| 608 | 612 | ** the postings in the thread are selected. |
| 609 | 613 | ** |
| 610 | 614 | ** Query parameters: |
| 611 | 615 | ** |
| 612 | 616 | ** 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. | |
| 615 | 622 | */ |
| 616 | 623 | void forumthread_page(void){ |
| 617 | 624 | int fpid; |
| 618 | 625 | int froot; |
| 619 | 626 | const char *zName = P("name"); |
| @@ -660,13 +667,19 @@ | ||
| 660 | 667 | } |
| 661 | 668 | manifest_destroy(pPost); |
| 662 | 669 | } |
| 663 | 670 | }else if( zMode[0]=='c' ){ |
| 664 | 671 | 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); | |
| 666 | 678 | }else{ |
| 667 | 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); | |
| 668 | 681 | forum_display_hierarchical(froot, fpid); |
| 669 | 682 | } |
| 670 | 683 | style_load_js("forum.js"); |
| 671 | 684 | style_footer(); |
| 672 | 685 | } |
| 673 | 686 |
| --- 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 |