Fossil SCM
In the forum, omit unnecessary query parameters on generated URLs, so that it is easier to copy/paste URLs into commit messages or chat windows.
Commit
168eb71643a47549b901243a5061df5e1afcd683dd7731f05e7bcafa397ed37a
Parent
890b49f8e00f908…
1 file changed
+41
-12
+41
-12
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -500,21 +500,21 @@ | ||
| 500 | 500 | } |
| 501 | 501 | zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", p->rDate); |
| 502 | 502 | if( p->pEditPrev ){ |
| 503 | 503 | zPosterName = forum_post_display_name(p->pEditHead, 0); |
| 504 | 504 | zEditorName = forum_post_display_name(p, pManifest); |
| 505 | - zHist = bHist ? "" : "&hist"; | |
| 505 | + zHist = bHist ? "" : zQuery[0]==0 ? "?hist" : "&hist"; | |
| 506 | 506 | @ <h3 class='forumPostHdr'>(%d(p->sid)\ |
| 507 | 507 | @ .%0*d(fossil_num_digits(p->nEdit))(p->rev)) \ |
| 508 | 508 | if( fossil_strcmp(zPosterName, zEditorName)==0 ){ |
| 509 | 509 | @ By %s(zPosterName) on %h(zDate) edited from \ |
| 510 | 510 | @ %z(href("%R/forumpost/%S?%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ |
| 511 | 511 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 512 | 512 | }else{ |
| 513 | 513 | @ Originally by %s(zPosterName) \ |
| 514 | 514 | @ with edits by %s(zEditorName) on %h(zDate) from \ |
| 515 | - @ %z(href("%R/forumpost/%S?%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ | |
| 515 | + @ %z(href("%R/forumpost/%S%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ | |
| 516 | 516 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 517 | 517 | } |
| 518 | 518 | }else{ |
| 519 | 519 | zPosterName = forum_post_display_name(p, pManifest); |
| 520 | 520 | @ <h3 class='forumPostHdr'>(%d(p->sid)) \ |
| @@ -529,28 +529,28 @@ | ||
| 529 | 529 | @ <a href="%R/artifact/%h(p->zUuid)">(artifact-%d(p->fpid))</a></span> |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /* If this is a reply, refer back to the parent post. */ |
| 533 | 533 | if( p->pIrt ){ |
| 534 | - @ in reply to %z(href("%R/forumpost/%S?%s",p->pIrt->zUuid,zQuery))\ | |
| 534 | + @ in reply to %z(href("%R/forumpost/%S%s",p->pIrt->zUuid,zQuery))\ | |
| 535 | 535 | @ %d(p->pIrt->sid)\ |
| 536 | 536 | if( p->pIrt->nEdit ){ |
| 537 | 537 | @ .%0*d(fossil_num_digits(p->pIrt->nEdit))(p->pIrt->rev)\ |
| 538 | 538 | } |
| 539 | 539 | @ </a> |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /* If this post was later edited, refer forward to the next edit. */ |
| 543 | 543 | if( p->pEditNext ){ |
| 544 | - @ updated by %z(href("%R/forumpost/%S?%s",p->pEditNext->zUuid,zQuery))\ | |
| 544 | + @ updated by %z(href("%R/forumpost/%S%s",p->pEditNext->zUuid,zQuery))\ | |
| 545 | 545 | @ %d(p->pEditNext->sid)\ |
| 546 | 546 | @ .%0*d(fossil_num_digits(p->nEdit))(p->pEditNext->rev)</a> |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /* Provide a link to select the individual post. */ |
| 550 | 550 | if( !bSelect ){ |
| 551 | - @ %z(href("%R/forumpost/%!S?%s",p->zUuid,zQuery))[link]</a> | |
| 551 | + @ %z(href("%R/forumpost/%!S%s",p->zUuid,zQuery))[link]</a> | |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /* Provide a link to the raw source code. */ |
| 555 | 555 | if( !bUnf ){ |
| 556 | 556 | @ %z(href("%R/forumpost/%!S?raw",p->zUuid))[source]</a> |
| @@ -632,19 +632,21 @@ | ||
| 632 | 632 | */ |
| 633 | 633 | static void forum_display_thread( |
| 634 | 634 | int froot, /* Forum thread root post ID */ |
| 635 | 635 | int fpid, /* Selected forum post ID, or 0 if none selected */ |
| 636 | 636 | int mode, /* Forum display mode, one of the FD_* enumerations */ |
| 637 | + int autoMode, /* mode was selected automatically */ | |
| 637 | 638 | int bUnf, /* True if rendering unformatted */ |
| 638 | 639 | int bHist /* True if showing edit history, ignored for FD_RAW */ |
| 639 | 640 | ){ |
| 640 | 641 | ForumThread *pThread; /* Thread structure */ |
| 641 | 642 | ForumPost *pSelect; /* Currently selected post, or NULL if none */ |
| 642 | 643 | ForumPost *p; /* Post iterator pointer */ |
| 643 | - char *zQuery; /* Common query string */ | |
| 644 | + char zQuery[30]; /* Common query string */ | |
| 644 | 645 | int iIndentScale = 4; /* Indent scale factor, measured in "ex" units */ |
| 645 | 646 | int sid; /* Comparison serial ID */ |
| 647 | + int i; | |
| 646 | 648 | |
| 647 | 649 | /* In raw mode, force unformatted display and disable history. */ |
| 648 | 650 | if( mode == FD_RAW ){ |
| 649 | 651 | bUnf = 1; |
| 650 | 652 | bHist = 0; |
| @@ -675,13 +677,39 @@ | ||
| 675 | 677 | if( !pSelect && (mode==FD_RAW || mode==FD_SINGLE) ){ |
| 676 | 678 | return; |
| 677 | 679 | } |
| 678 | 680 | |
| 679 | 681 | /* Create the common query string to append to nearly all post links. */ |
| 680 | - zQuery = mode==FD_RAW ? 0 : mprintf("t=%c%s%s", | |
| 681 | - mode==FD_SINGLE ? 's' : mode==FD_CHRONO ? 'c' : 'h', | |
| 682 | - bUnf ? "&unf" : "", bHist ? "&hist" : ""); | |
| 682 | + i = 0; | |
| 683 | + if( !autoMode ){ | |
| 684 | + char m = 'a'; | |
| 685 | + switch( mode ){ | |
| 686 | + case FD_RAW: m = 'r'; break; | |
| 687 | + case FD_CHRONO: m = 'c'; break; | |
| 688 | + case FD_HIER: m = 'h'; break; | |
| 689 | + case FD_SINGLE: m = 's'; break; | |
| 690 | + } | |
| 691 | + zQuery[i++] = '?'; | |
| 692 | + zQuery[i++] = 't'; | |
| 693 | + zQuery[i++] = '='; | |
| 694 | + zQuery[i++] = m; | |
| 695 | + } | |
| 696 | + if( bUnf ){ | |
| 697 | + zQuery[i] = i==0 ? '?' : '&'; i++; | |
| 698 | + zQuery[i++] = 'u'; | |
| 699 | + zQuery[i++] = 'n'; | |
| 700 | + zQuery[i++] = 'f'; | |
| 701 | + } | |
| 702 | + if( bHist ){ | |
| 703 | + zQuery[i] = i==0 ? '?' : '&'; i++; | |
| 704 | + zQuery[i++] = 'h'; | |
| 705 | + zQuery[i++] = 'i'; | |
| 706 | + zQuery[i++] = 's'; | |
| 707 | + zQuery[i++] = 't'; | |
| 708 | + } | |
| 709 | + assert( i<sizeof(zQuery) ); | |
| 710 | + zQuery[i] = 0; | |
| 683 | 711 | |
| 684 | 712 | /* Identify which post to display first. If history is shown, start with the |
| 685 | 713 | ** original, unedited post. Otherwise advance to the post's latest edit. */ |
| 686 | 714 | if( mode==FD_RAW || mode==FD_SINGLE ){ |
| 687 | 715 | p = pSelect; |
| @@ -744,11 +772,10 @@ | ||
| 744 | 772 | @ </table> |
| 745 | 773 | } |
| 746 | 774 | |
| 747 | 775 | /* Clean up. */ |
| 748 | 776 | forumthread_delete(pThread); |
| 749 | - fossil_free(zQuery); | |
| 750 | 777 | } |
| 751 | 778 | |
| 752 | 779 | /* |
| 753 | 780 | ** Emit Forum Javascript which applies (or optionally can apply) |
| 754 | 781 | ** to all forum-related pages. It does not include page-specific |
| @@ -813,10 +840,11 @@ | ||
| 813 | 840 | const char *zMode = PD("t","a"); |
| 814 | 841 | int bRaw = PB("raw"); |
| 815 | 842 | int bUnf = PB("unf"); |
| 816 | 843 | int bHist = PB("hist"); |
| 817 | 844 | int mode = 0; |
| 845 | + int autoMode = 0; | |
| 818 | 846 | login_check_credentials(); |
| 819 | 847 | if( !g.perm.RdForum ){ |
| 820 | 848 | login_needed(g.anon.RdForum); |
| 821 | 849 | return; |
| 822 | 850 | } |
| @@ -846,11 +874,12 @@ | ||
| 846 | 874 | cgi_replace_query_parameter("unf", "on"); |
| 847 | 875 | cgi_delete_query_parameter("hist"); |
| 848 | 876 | cgi_delete_query_parameter("raw"); |
| 849 | 877 | }else{ |
| 850 | 878 | switch( *zMode ){ |
| 851 | - case 'a': mode = cgi_from_mobile() ? FD_CHRONO : FD_HIER; break; | |
| 879 | + case 'a': mode = cgi_from_mobile() ? FD_CHRONO : FD_HIER; | |
| 880 | + autoMode=1; break; | |
| 852 | 881 | case 'c': mode = FD_CHRONO; break; |
| 853 | 882 | case 'h': mode = FD_HIER; break; |
| 854 | 883 | case 's': mode = FD_SINGLE; break; |
| 855 | 884 | case 'r': mode = FD_CHRONO; break; |
| 856 | 885 | case 'y': mode = FD_SINGLE; break; |
| @@ -887,11 +916,11 @@ | ||
| 887 | 916 | } |
| 888 | 917 | style_submenu_checkbox("unf", "Unformatted", 0, 0); |
| 889 | 918 | style_submenu_checkbox("hist", "History", 0, 0); |
| 890 | 919 | |
| 891 | 920 | /* Display the thread. */ |
| 892 | - forum_display_thread(froot, fpid, mode, bUnf, bHist); | |
| 921 | + forum_display_thread(froot, fpid, mode, autoMode, bUnf, bHist); | |
| 893 | 922 | |
| 894 | 923 | /* Emit Forum Javascript. */ |
| 895 | 924 | builtin_request_js("forum.js"); |
| 896 | 925 | forum_emit_js(); |
| 897 | 926 | |
| 898 | 927 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -500,21 +500,21 @@ | |
| 500 | } |
| 501 | zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", p->rDate); |
| 502 | if( p->pEditPrev ){ |
| 503 | zPosterName = forum_post_display_name(p->pEditHead, 0); |
| 504 | zEditorName = forum_post_display_name(p, pManifest); |
| 505 | zHist = bHist ? "" : "&hist"; |
| 506 | @ <h3 class='forumPostHdr'>(%d(p->sid)\ |
| 507 | @ .%0*d(fossil_num_digits(p->nEdit))(p->rev)) \ |
| 508 | if( fossil_strcmp(zPosterName, zEditorName)==0 ){ |
| 509 | @ By %s(zPosterName) on %h(zDate) edited from \ |
| 510 | @ %z(href("%R/forumpost/%S?%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ |
| 511 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 512 | }else{ |
| 513 | @ Originally by %s(zPosterName) \ |
| 514 | @ with edits by %s(zEditorName) on %h(zDate) from \ |
| 515 | @ %z(href("%R/forumpost/%S?%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ |
| 516 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 517 | } |
| 518 | }else{ |
| 519 | zPosterName = forum_post_display_name(p, pManifest); |
| 520 | @ <h3 class='forumPostHdr'>(%d(p->sid)) \ |
| @@ -529,28 +529,28 @@ | |
| 529 | @ <a href="%R/artifact/%h(p->zUuid)">(artifact-%d(p->fpid))</a></span> |
| 530 | } |
| 531 | |
| 532 | /* If this is a reply, refer back to the parent post. */ |
| 533 | if( p->pIrt ){ |
| 534 | @ in reply to %z(href("%R/forumpost/%S?%s",p->pIrt->zUuid,zQuery))\ |
| 535 | @ %d(p->pIrt->sid)\ |
| 536 | if( p->pIrt->nEdit ){ |
| 537 | @ .%0*d(fossil_num_digits(p->pIrt->nEdit))(p->pIrt->rev)\ |
| 538 | } |
| 539 | @ </a> |
| 540 | } |
| 541 | |
| 542 | /* If this post was later edited, refer forward to the next edit. */ |
| 543 | if( p->pEditNext ){ |
| 544 | @ updated by %z(href("%R/forumpost/%S?%s",p->pEditNext->zUuid,zQuery))\ |
| 545 | @ %d(p->pEditNext->sid)\ |
| 546 | @ .%0*d(fossil_num_digits(p->nEdit))(p->pEditNext->rev)</a> |
| 547 | } |
| 548 | |
| 549 | /* Provide a link to select the individual post. */ |
| 550 | if( !bSelect ){ |
| 551 | @ %z(href("%R/forumpost/%!S?%s",p->zUuid,zQuery))[link]</a> |
| 552 | } |
| 553 | |
| 554 | /* Provide a link to the raw source code. */ |
| 555 | if( !bUnf ){ |
| 556 | @ %z(href("%R/forumpost/%!S?raw",p->zUuid))[source]</a> |
| @@ -632,19 +632,21 @@ | |
| 632 | */ |
| 633 | static void forum_display_thread( |
| 634 | int froot, /* Forum thread root post ID */ |
| 635 | int fpid, /* Selected forum post ID, or 0 if none selected */ |
| 636 | int mode, /* Forum display mode, one of the FD_* enumerations */ |
| 637 | int bUnf, /* True if rendering unformatted */ |
| 638 | int bHist /* True if showing edit history, ignored for FD_RAW */ |
| 639 | ){ |
| 640 | ForumThread *pThread; /* Thread structure */ |
| 641 | ForumPost *pSelect; /* Currently selected post, or NULL if none */ |
| 642 | ForumPost *p; /* Post iterator pointer */ |
| 643 | char *zQuery; /* Common query string */ |
| 644 | int iIndentScale = 4; /* Indent scale factor, measured in "ex" units */ |
| 645 | int sid; /* Comparison serial ID */ |
| 646 | |
| 647 | /* In raw mode, force unformatted display and disable history. */ |
| 648 | if( mode == FD_RAW ){ |
| 649 | bUnf = 1; |
| 650 | bHist = 0; |
| @@ -675,13 +677,39 @@ | |
| 675 | if( !pSelect && (mode==FD_RAW || mode==FD_SINGLE) ){ |
| 676 | return; |
| 677 | } |
| 678 | |
| 679 | /* Create the common query string to append to nearly all post links. */ |
| 680 | zQuery = mode==FD_RAW ? 0 : mprintf("t=%c%s%s", |
| 681 | mode==FD_SINGLE ? 's' : mode==FD_CHRONO ? 'c' : 'h', |
| 682 | bUnf ? "&unf" : "", bHist ? "&hist" : ""); |
| 683 | |
| 684 | /* Identify which post to display first. If history is shown, start with the |
| 685 | ** original, unedited post. Otherwise advance to the post's latest edit. */ |
| 686 | if( mode==FD_RAW || mode==FD_SINGLE ){ |
| 687 | p = pSelect; |
| @@ -744,11 +772,10 @@ | |
| 744 | @ </table> |
| 745 | } |
| 746 | |
| 747 | /* Clean up. */ |
| 748 | forumthread_delete(pThread); |
| 749 | fossil_free(zQuery); |
| 750 | } |
| 751 | |
| 752 | /* |
| 753 | ** Emit Forum Javascript which applies (or optionally can apply) |
| 754 | ** to all forum-related pages. It does not include page-specific |
| @@ -813,10 +840,11 @@ | |
| 813 | const char *zMode = PD("t","a"); |
| 814 | int bRaw = PB("raw"); |
| 815 | int bUnf = PB("unf"); |
| 816 | int bHist = PB("hist"); |
| 817 | int mode = 0; |
| 818 | login_check_credentials(); |
| 819 | if( !g.perm.RdForum ){ |
| 820 | login_needed(g.anon.RdForum); |
| 821 | return; |
| 822 | } |
| @@ -846,11 +874,12 @@ | |
| 846 | cgi_replace_query_parameter("unf", "on"); |
| 847 | cgi_delete_query_parameter("hist"); |
| 848 | cgi_delete_query_parameter("raw"); |
| 849 | }else{ |
| 850 | switch( *zMode ){ |
| 851 | case 'a': mode = cgi_from_mobile() ? FD_CHRONO : FD_HIER; break; |
| 852 | case 'c': mode = FD_CHRONO; break; |
| 853 | case 'h': mode = FD_HIER; break; |
| 854 | case 's': mode = FD_SINGLE; break; |
| 855 | case 'r': mode = FD_CHRONO; break; |
| 856 | case 'y': mode = FD_SINGLE; break; |
| @@ -887,11 +916,11 @@ | |
| 887 | } |
| 888 | style_submenu_checkbox("unf", "Unformatted", 0, 0); |
| 889 | style_submenu_checkbox("hist", "History", 0, 0); |
| 890 | |
| 891 | /* Display the thread. */ |
| 892 | forum_display_thread(froot, fpid, mode, bUnf, bHist); |
| 893 | |
| 894 | /* Emit Forum Javascript. */ |
| 895 | builtin_request_js("forum.js"); |
| 896 | forum_emit_js(); |
| 897 | |
| 898 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -500,21 +500,21 @@ | |
| 500 | } |
| 501 | zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", p->rDate); |
| 502 | if( p->pEditPrev ){ |
| 503 | zPosterName = forum_post_display_name(p->pEditHead, 0); |
| 504 | zEditorName = forum_post_display_name(p, pManifest); |
| 505 | zHist = bHist ? "" : zQuery[0]==0 ? "?hist" : "&hist"; |
| 506 | @ <h3 class='forumPostHdr'>(%d(p->sid)\ |
| 507 | @ .%0*d(fossil_num_digits(p->nEdit))(p->rev)) \ |
| 508 | if( fossil_strcmp(zPosterName, zEditorName)==0 ){ |
| 509 | @ By %s(zPosterName) on %h(zDate) edited from \ |
| 510 | @ %z(href("%R/forumpost/%S?%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ |
| 511 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 512 | }else{ |
| 513 | @ Originally by %s(zPosterName) \ |
| 514 | @ with edits by %s(zEditorName) on %h(zDate) from \ |
| 515 | @ %z(href("%R/forumpost/%S%s%s",p->pEditPrev->zUuid,zQuery,zHist))\ |
| 516 | @ %d(p->sid).%0*d(fossil_num_digits(p->nEdit))(p->pEditPrev->rev)</a> |
| 517 | } |
| 518 | }else{ |
| 519 | zPosterName = forum_post_display_name(p, pManifest); |
| 520 | @ <h3 class='forumPostHdr'>(%d(p->sid)) \ |
| @@ -529,28 +529,28 @@ | |
| 529 | @ <a href="%R/artifact/%h(p->zUuid)">(artifact-%d(p->fpid))</a></span> |
| 530 | } |
| 531 | |
| 532 | /* If this is a reply, refer back to the parent post. */ |
| 533 | if( p->pIrt ){ |
| 534 | @ in reply to %z(href("%R/forumpost/%S%s",p->pIrt->zUuid,zQuery))\ |
| 535 | @ %d(p->pIrt->sid)\ |
| 536 | if( p->pIrt->nEdit ){ |
| 537 | @ .%0*d(fossil_num_digits(p->pIrt->nEdit))(p->pIrt->rev)\ |
| 538 | } |
| 539 | @ </a> |
| 540 | } |
| 541 | |
| 542 | /* If this post was later edited, refer forward to the next edit. */ |
| 543 | if( p->pEditNext ){ |
| 544 | @ updated by %z(href("%R/forumpost/%S%s",p->pEditNext->zUuid,zQuery))\ |
| 545 | @ %d(p->pEditNext->sid)\ |
| 546 | @ .%0*d(fossil_num_digits(p->nEdit))(p->pEditNext->rev)</a> |
| 547 | } |
| 548 | |
| 549 | /* Provide a link to select the individual post. */ |
| 550 | if( !bSelect ){ |
| 551 | @ %z(href("%R/forumpost/%!S%s",p->zUuid,zQuery))[link]</a> |
| 552 | } |
| 553 | |
| 554 | /* Provide a link to the raw source code. */ |
| 555 | if( !bUnf ){ |
| 556 | @ %z(href("%R/forumpost/%!S?raw",p->zUuid))[source]</a> |
| @@ -632,19 +632,21 @@ | |
| 632 | */ |
| 633 | static void forum_display_thread( |
| 634 | int froot, /* Forum thread root post ID */ |
| 635 | int fpid, /* Selected forum post ID, or 0 if none selected */ |
| 636 | int mode, /* Forum display mode, one of the FD_* enumerations */ |
| 637 | int autoMode, /* mode was selected automatically */ |
| 638 | int bUnf, /* True if rendering unformatted */ |
| 639 | int bHist /* True if showing edit history, ignored for FD_RAW */ |
| 640 | ){ |
| 641 | ForumThread *pThread; /* Thread structure */ |
| 642 | ForumPost *pSelect; /* Currently selected post, or NULL if none */ |
| 643 | ForumPost *p; /* Post iterator pointer */ |
| 644 | char zQuery[30]; /* Common query string */ |
| 645 | int iIndentScale = 4; /* Indent scale factor, measured in "ex" units */ |
| 646 | int sid; /* Comparison serial ID */ |
| 647 | int i; |
| 648 | |
| 649 | /* In raw mode, force unformatted display and disable history. */ |
| 650 | if( mode == FD_RAW ){ |
| 651 | bUnf = 1; |
| 652 | bHist = 0; |
| @@ -675,13 +677,39 @@ | |
| 677 | if( !pSelect && (mode==FD_RAW || mode==FD_SINGLE) ){ |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | /* Create the common query string to append to nearly all post links. */ |
| 682 | i = 0; |
| 683 | if( !autoMode ){ |
| 684 | char m = 'a'; |
| 685 | switch( mode ){ |
| 686 | case FD_RAW: m = 'r'; break; |
| 687 | case FD_CHRONO: m = 'c'; break; |
| 688 | case FD_HIER: m = 'h'; break; |
| 689 | case FD_SINGLE: m = 's'; break; |
| 690 | } |
| 691 | zQuery[i++] = '?'; |
| 692 | zQuery[i++] = 't'; |
| 693 | zQuery[i++] = '='; |
| 694 | zQuery[i++] = m; |
| 695 | } |
| 696 | if( bUnf ){ |
| 697 | zQuery[i] = i==0 ? '?' : '&'; i++; |
| 698 | zQuery[i++] = 'u'; |
| 699 | zQuery[i++] = 'n'; |
| 700 | zQuery[i++] = 'f'; |
| 701 | } |
| 702 | if( bHist ){ |
| 703 | zQuery[i] = i==0 ? '?' : '&'; i++; |
| 704 | zQuery[i++] = 'h'; |
| 705 | zQuery[i++] = 'i'; |
| 706 | zQuery[i++] = 's'; |
| 707 | zQuery[i++] = 't'; |
| 708 | } |
| 709 | assert( i<sizeof(zQuery) ); |
| 710 | zQuery[i] = 0; |
| 711 | |
| 712 | /* Identify which post to display first. If history is shown, start with the |
| 713 | ** original, unedited post. Otherwise advance to the post's latest edit. */ |
| 714 | if( mode==FD_RAW || mode==FD_SINGLE ){ |
| 715 | p = pSelect; |
| @@ -744,11 +772,10 @@ | |
| 772 | @ </table> |
| 773 | } |
| 774 | |
| 775 | /* Clean up. */ |
| 776 | forumthread_delete(pThread); |
| 777 | } |
| 778 | |
| 779 | /* |
| 780 | ** Emit Forum Javascript which applies (or optionally can apply) |
| 781 | ** to all forum-related pages. It does not include page-specific |
| @@ -813,10 +840,11 @@ | |
| 840 | const char *zMode = PD("t","a"); |
| 841 | int bRaw = PB("raw"); |
| 842 | int bUnf = PB("unf"); |
| 843 | int bHist = PB("hist"); |
| 844 | int mode = 0; |
| 845 | int autoMode = 0; |
| 846 | login_check_credentials(); |
| 847 | if( !g.perm.RdForum ){ |
| 848 | login_needed(g.anon.RdForum); |
| 849 | return; |
| 850 | } |
| @@ -846,11 +874,12 @@ | |
| 874 | cgi_replace_query_parameter("unf", "on"); |
| 875 | cgi_delete_query_parameter("hist"); |
| 876 | cgi_delete_query_parameter("raw"); |
| 877 | }else{ |
| 878 | switch( *zMode ){ |
| 879 | case 'a': mode = cgi_from_mobile() ? FD_CHRONO : FD_HIER; |
| 880 | autoMode=1; break; |
| 881 | case 'c': mode = FD_CHRONO; break; |
| 882 | case 'h': mode = FD_HIER; break; |
| 883 | case 's': mode = FD_SINGLE; break; |
| 884 | case 'r': mode = FD_CHRONO; break; |
| 885 | case 'y': mode = FD_SINGLE; break; |
| @@ -887,11 +916,11 @@ | |
| 916 | } |
| 917 | style_submenu_checkbox("unf", "Unformatted", 0, 0); |
| 918 | style_submenu_checkbox("hist", "History", 0, 0); |
| 919 | |
| 920 | /* Display the thread. */ |
| 921 | forum_display_thread(froot, fpid, mode, autoMode, bUnf, bHist); |
| 922 | |
| 923 | /* Emit Forum Javascript. */ |
| 924 | builtin_request_js("forum.js"); |
| 925 | forum_emit_js(); |
| 926 | |
| 927 |