Index: src/forum.c ================================================================== --- src/forum.c +++ src/forum.c @@ -530,10 +530,52 @@ ** '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. @@ -561,11 +603,10 @@ } 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; @@ -574,10 +615,11 @@ 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);