Fossil

Changes On Branch forumthread-title
Login

Changes On Branch forumthread-title

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch forumthread-title Excluding Merge-Ins

This is equivalent to a diff from 0c374456 to 4b12ad0e

2020-03-02
12:50
When viewing a forum thread, use the title of the thread as the page title. ... (check-in: 59f126d9 user: drh tags: trunk)
2020-02-29
19:32
Properly truncate a forum thread's title when is UTF-8 encoded. ... (Closed-Leaf check-in: 4b12ad0e user: ashepilko tags: forumthread-title)
2020-02-28
21:53
Include forum thread's title in its page title. ... (check-in: 9559bdb6 user: ashepilko tags: forumthread-title)
21:51
Create new branch named "forumthread-title" ... (check-in: 33c4c9d2 user: ashepilko tags: forumthread-title)
2020-02-27
19:16
More information on Setup and in Security-Audit to help admins configure Public Pages with the correct capabilities. ... (check-in: 0c374456 user: drh tags: trunk)
17:07
Update the built-in SQLite to an early alpha for 3.32.0, for testing. ... (check-in: d239550e user: drh tags: trunk)

Changes to src/forum.c.

528
529
530
531
532
533
534










































535
536
537
538
539
540
541
**   name=X        REQUIRED.  The hash of the post to display
**   t=MODE        Display mode. MODE is 'c' for chronological or
**                   'h' for hierarchical, or 'a' for automatic.
*/
void forumpost_page(void){
  forumthread_page();
}











































/*
** WEBPAGE: forumthread
**
** Show all forum messages associated with a particular message thread.
** The result is basically the same as /forumpost except that none of
** the postings in the thread are selected.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
**   name=X        REQUIRED.  The hash of the post to display
**   t=MODE        Display mode. MODE is 'c' for chronological or
**                   'h' for hierarchical, or 'a' for automatic.
*/
void forumpost_page(void){
  forumthread_page();
}

/*
** Add an appropriate style_header() to include title of the
** given forum post.
*/
static int forumthread_page_header(int froot, int fpid){
  Blob title;
  int mxForumPostTitleLen = 50;
  char *zThreadTitle = "";

  zThreadTitle = db_text("",
    "SELECT"
    " substr(event.comment,instr(event.comment,':')+2)"
    " FROM forumpost, event"
    " WHERE event.objid=forumpost.fpid"
    "   AND forumpost.fpid=%d;",
    fpid
  );
  blob_set(&title, zThreadTitle);
  /* truncate the title when longer than max allowed;
   * in case of UTF-8 make sure the truncated string remains valid,
   * otherwise (different encoding?) pass as-is
   */
  if( mxForumPostTitleLen>0 && blob_size(&title)>mxForumPostTitleLen ){
    Blob truncated;
    int len;
    blob_copy(&truncated, &title);
    for( len = mxForumPostTitleLen; len; --len ){
      blob_truncate(&truncated, len);
      if( !invalid_utf8(&truncated) ) break;
    }
    if( len ){
      blob_append(&truncated, "...", 3);
      blob_copy(&title, &truncated);
    }
    blob_reset(&truncated);
  }
  style_header("%s%s", blob_str(&title), blob_size(&title) ? " - Forum" : "Forum");
  blob_reset(&title);
  fossil_free(zThreadTitle);
  return 0;
}

/*
** WEBPAGE: forumthread
**
** Show all forum messages associated with a particular message thread.
** The result is basically the same as /forumpost except that none of
** the postings in the thread are selected.
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578

579
580
581
582
583
584
585
  if( zName==0 ){
    webpage_error("Missing \"name=\" query parameter");
  }
  fpid = symbolic_name_to_rid(zName, "f");
  if( fpid<=0 ){
    webpage_error("Unknown or ambiguous forum id: \"%s\"", zName);
  }
  style_header("Forum");
  froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
  if( froot==0 ){
    webpage_error("Not a forum post: \"%s\"", zName);
  }
  if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
  if( zMode[0]=='a' ){
    if( cgi_from_mobile() ){
      zMode = "c";  /* Default to chronological on mobile */
    }else{
      zMode = "h";
    }
  }

  if( zMode[0]=='c' ){
    style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
    forum_display_chronological(froot, fpid);
  }else{
    style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
    forum_display_hierarchical(froot, fpid);
  }







<












>







601
602
603
604
605
606
607

608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
  if( zName==0 ){
    webpage_error("Missing \"name=\" query parameter");
  }
  fpid = symbolic_name_to_rid(zName, "f");
  if( fpid<=0 ){
    webpage_error("Unknown or ambiguous forum id: \"%s\"", zName);
  }

  froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
  if( froot==0 ){
    webpage_error("Not a forum post: \"%s\"", zName);
  }
  if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
  if( zMode[0]=='a' ){
    if( cgi_from_mobile() ){
      zMode = "c";  /* Default to chronological on mobile */
    }else{
      zMode = "h";
    }
  }
  forumthread_page_header(froot, fpid);
  if( zMode[0]=='c' ){
    style_submenu_element("Hierarchical", "%R/%s/%s?t=h", g.zPath, zName);
    forum_display_chronological(froot, fpid);
  }else{
    style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
    forum_display_hierarchical(froot, fpid);
  }