Fossil SCM
Include forum thread's title in its page title.
Commit
9559bdb69cea3e1b1617950483a15e6ee5077a9d92a582625e5ca6604b7ccbc0
Parent
33c4c9d266d9da5…
1 file changed
+30
-1
+30
-1
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -530,10 +530,39 @@ | ||
| 530 | 530 | ** 'h' for hierarchical, or 'a' for automatic. |
| 531 | 531 | */ |
| 532 | 532 | void forumpost_page(void){ |
| 533 | 533 | forumthread_page(); |
| 534 | 534 | } |
| 535 | + | |
| 536 | +/* | |
| 537 | +** Add an appropriate style_header() to include title of the | |
| 538 | +** given forum post. | |
| 539 | +*/ | |
| 540 | +static int forumthread_page_header(int froot, int fpid){ | |
| 541 | + Blob title; | |
| 542 | + int mxForumPostTitleLen = 50; | |
| 543 | + char *zThreadTitle = ""; | |
| 544 | + | |
| 545 | + zThreadTitle = db_text("", | |
| 546 | + "SELECT" | |
| 547 | + " substr(event.comment,instr(event.comment,':')+2)" | |
| 548 | + " FROM forumpost, event" | |
| 549 | + " WHERE event.objid=forumpost.fpid" | |
| 550 | + " AND forumpost.fpid=%d;", | |
| 551 | + fpid | |
| 552 | + ); | |
| 553 | + blob_set(&title, zThreadTitle); | |
| 554 | + /* truncate title when longer than max allowed */ | |
| 555 | + if ( mxForumPostTitleLen>0 && blob_size(&title)>mxForumPostTitleLen ) { | |
| 556 | + blob_resize(&title, mxForumPostTitleLen); | |
| 557 | + blob_append(&title, "...", 3); | |
| 558 | + } | |
| 559 | + style_header("%s%s", blob_str(&title), blob_size(&title) ? " - Forum" : "Forum"); | |
| 560 | + blob_reset(&title); | |
| 561 | + fossil_free(zThreadTitle); | |
| 562 | + return 0; | |
| 563 | +} | |
| 535 | 564 | |
| 536 | 565 | /* |
| 537 | 566 | ** WEBPAGE: forumthread |
| 538 | 567 | ** |
| 539 | 568 | ** Show all forum messages associated with a particular message thread. |
| @@ -561,11 +590,10 @@ | ||
| 561 | 590 | } |
| 562 | 591 | fpid = symbolic_name_to_rid(zName, "f"); |
| 563 | 592 | if( fpid<=0 ){ |
| 564 | 593 | webpage_error("Unknown or ambiguous forum id: \"%s\"", zName); |
| 565 | 594 | } |
| 566 | - style_header("Forum"); | |
| 567 | 595 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 568 | 596 | if( froot==0 ){ |
| 569 | 597 | webpage_error("Not a forum post: \"%s\"", zName); |
| 570 | 598 | } |
| 571 | 599 | if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0; |
| @@ -574,10 +602,11 @@ | ||
| 574 | 602 | zMode = "c"; /* Default to chronological on mobile */ |
| 575 | 603 | }else{ |
| 576 | 604 | zMode = "h"; |
| 577 | 605 | } |
| 578 | 606 | } |
| 607 | + forumthread_page_header(froot, fpid); | |
| 579 | 608 | if( zMode[0]=='c' ){ |
| 580 | 609 | style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName); |
| 581 | 610 | forum_display_chronological(froot, fpid); |
| 582 | 611 | }else{ |
| 583 | 612 | style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName); |
| 584 | 613 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -530,10 +530,39 @@ | |
| 530 | ** 'h' for hierarchical, or 'a' for automatic. |
| 531 | */ |
| 532 | void forumpost_page(void){ |
| 533 | forumthread_page(); |
| 534 | } |
| 535 | |
| 536 | /* |
| 537 | ** WEBPAGE: forumthread |
| 538 | ** |
| 539 | ** Show all forum messages associated with a particular message thread. |
| @@ -561,11 +590,10 @@ | |
| 561 | } |
| 562 | fpid = symbolic_name_to_rid(zName, "f"); |
| 563 | if( fpid<=0 ){ |
| 564 | webpage_error("Unknown or ambiguous forum id: \"%s\"", zName); |
| 565 | } |
| 566 | style_header("Forum"); |
| 567 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 568 | if( froot==0 ){ |
| 569 | webpage_error("Not a forum post: \"%s\"", zName); |
| 570 | } |
| 571 | if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0; |
| @@ -574,10 +602,11 @@ | |
| 574 | zMode = "c"; /* Default to chronological on mobile */ |
| 575 | }else{ |
| 576 | zMode = "h"; |
| 577 | } |
| 578 | } |
| 579 | if( zMode[0]=='c' ){ |
| 580 | style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName); |
| 581 | forum_display_chronological(froot, fpid); |
| 582 | }else{ |
| 583 | style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName); |
| 584 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -530,10 +530,39 @@ | |
| 530 | ** 'h' for hierarchical, or 'a' for automatic. |
| 531 | */ |
| 532 | void forumpost_page(void){ |
| 533 | forumthread_page(); |
| 534 | } |
| 535 | |
| 536 | /* |
| 537 | ** Add an appropriate style_header() to include title of the |
| 538 | ** given forum post. |
| 539 | */ |
| 540 | static int forumthread_page_header(int froot, int fpid){ |
| 541 | Blob title; |
| 542 | int mxForumPostTitleLen = 50; |
| 543 | char *zThreadTitle = ""; |
| 544 | |
| 545 | zThreadTitle = db_text("", |
| 546 | "SELECT" |
| 547 | " substr(event.comment,instr(event.comment,':')+2)" |
| 548 | " FROM forumpost, event" |
| 549 | " WHERE event.objid=forumpost.fpid" |
| 550 | " AND forumpost.fpid=%d;", |
| 551 | fpid |
| 552 | ); |
| 553 | blob_set(&title, zThreadTitle); |
| 554 | /* truncate title when longer than max allowed */ |
| 555 | if ( mxForumPostTitleLen>0 && blob_size(&title)>mxForumPostTitleLen ) { |
| 556 | blob_resize(&title, mxForumPostTitleLen); |
| 557 | blob_append(&title, "...", 3); |
| 558 | } |
| 559 | style_header("%s%s", blob_str(&title), blob_size(&title) ? " - Forum" : "Forum"); |
| 560 | blob_reset(&title); |
| 561 | fossil_free(zThreadTitle); |
| 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | /* |
| 566 | ** WEBPAGE: forumthread |
| 567 | ** |
| 568 | ** Show all forum messages associated with a particular message thread. |
| @@ -561,11 +590,10 @@ | |
| 590 | } |
| 591 | fpid = symbolic_name_to_rid(zName, "f"); |
| 592 | if( fpid<=0 ){ |
| 593 | webpage_error("Unknown or ambiguous forum id: \"%s\"", zName); |
| 594 | } |
| 595 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 596 | if( froot==0 ){ |
| 597 | webpage_error("Not a forum post: \"%s\"", zName); |
| 598 | } |
| 599 | if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0; |
| @@ -574,10 +602,11 @@ | |
| 602 | zMode = "c"; /* Default to chronological on mobile */ |
| 603 | }else{ |
| 604 | zMode = "h"; |
| 605 | } |
| 606 | } |
| 607 | forumthread_page_header(froot, fpid); |
| 608 | if( zMode[0]=='c' ){ |
| 609 | style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName); |
| 610 | forum_display_chronological(froot, fpid); |
| 611 | }else{ |
| 612 | style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName); |
| 613 |