Fossil SCM
Try to omit unnecessary indentation on the hierarchical forum display. Include an "in reply to" mark on the hierarchical display.
Commit
97697b7956d3ea443e246455fd76ccc3020e52f5cc0065ab53aa695fc1189fa8
Parent
9bb25a28627be06…
1 file changed
+37
-17
+37
-17
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -35,13 +35,14 @@ | ||
| 35 | 35 | struct ForumEntry { |
| 36 | 36 | int fpid; /* rid for this entry */ |
| 37 | 37 | int fprev; /* zero if initial entry. non-zero if an edit */ |
| 38 | 38 | int firt; /* This entry replies to firt */ |
| 39 | 39 | int mfirt; /* Root in-reply-to */ |
| 40 | + int nReply; /* Number of replies to this entry */ | |
| 40 | 41 | char *zUuid; /* Artifact hash */ |
| 41 | 42 | ForumEntry *pLeaf; /* Most recent edit for this entry */ |
| 42 | - ForumEntry *pEdit; /* This entry is an edit of pEditee */ | |
| 43 | + ForumEntry *pEdit; /* This entry is an edit of pEdit */ | |
| 43 | 44 | ForumEntry *pNext; /* Next in chronological order */ |
| 44 | 45 | ForumEntry *pPrev; /* Previous in chronological order */ |
| 45 | 46 | ForumEntry *pDisplay; /* Next in display order */ |
| 46 | 47 | int nIndent; /* Number of levels of indentation for this entry */ |
| 47 | 48 | }; |
| @@ -104,22 +105,30 @@ | ||
| 104 | 105 | ** Extend the display list for pThread by adding all entries that |
| 105 | 106 | ** reference fpid. The first such entry will be no earlier then |
| 106 | 107 | ** entry "p". |
| 107 | 108 | */ |
| 108 | 109 | static void forumthread_display_order( |
| 109 | - ForumThread *pThread, | |
| 110 | - ForumEntry *p, | |
| 111 | - int fpid, | |
| 112 | - int nIndent | |
| 110 | + ForumThread *pThread, /* The complete thread */ | |
| 111 | + ForumEntry *pBase /* Add replies to this entry */ | |
| 113 | 112 | ){ |
| 114 | - while( p ){ | |
| 115 | - if( p->fprev==0 && p->mfirt==fpid ){ | |
| 116 | - p->nIndent = nIndent; | |
| 117 | - forumentry_add_to_display(pThread, p); | |
| 118 | - forumthread_display_order(pThread, p->pNext, p->fpid, nIndent+1); | |
| 113 | + ForumEntry *p; | |
| 114 | + ForumEntry *pPrev = 0; | |
| 115 | + for(p=pBase->pNext; p; p=p->pNext){ | |
| 116 | + if( p->fprev==0 && p->mfirt==pBase->fpid ){ | |
| 117 | + if( pPrev ){ | |
| 118 | + pPrev->nIndent = pBase->nIndent + 1; | |
| 119 | + forumentry_add_to_display(pThread, pPrev); | |
| 120 | + forumthread_display_order(pThread, pPrev); | |
| 121 | + } | |
| 122 | + pBase->nReply++; | |
| 123 | + pPrev = p; | |
| 119 | 124 | } |
| 120 | - p = p->pNext; | |
| 125 | + } | |
| 126 | + if( pPrev ){ | |
| 127 | + pPrev->nIndent = pBase->nIndent + (pBase->nReply>1); | |
| 128 | + forumentry_add_to_display(pThread, pPrev); | |
| 129 | + forumthread_display_order(pThread, pPrev); | |
| 121 | 130 | } |
| 122 | 131 | } |
| 123 | 132 | |
| 124 | 133 | /* |
| 125 | 134 | ** Construct a ForumThread object given the root record id. |
| @@ -178,11 +187,11 @@ | ||
| 178 | 187 | if( computeHierarchy ){ |
| 179 | 188 | /* Compute the hierarchical display order */ |
| 180 | 189 | pEntry = pThread->pFirst; |
| 181 | 190 | pEntry->nIndent = 1; |
| 182 | 191 | forumentry_add_to_display(pThread, pEntry); |
| 183 | - forumthread_display_order(pThread, pEntry, pEntry->fpid, 2); | |
| 192 | + forumthread_display_order(pThread, pEntry); | |
| 184 | 193 | } |
| 185 | 194 | |
| 186 | 195 | /* Return the result */ |
| 187 | 196 | return pThread; |
| 188 | 197 | } |
| @@ -204,10 +213,13 @@ | ||
| 204 | 213 | db_find_and_open_repository(0,0); |
| 205 | 214 | verify_all_options(); |
| 206 | 215 | if( g.argc!=3 ) usage("THREADID"); |
| 207 | 216 | zName = g.argv[2]; |
| 208 | 217 | fpid = symbolic_name_to_rid(zName, "f"); |
| 218 | + if( fpid<=0 ){ | |
| 219 | + fpid = db_int(0, "SELECT rid FROM blob WHERE rid=%d", atoi(zName)); | |
| 220 | + } | |
| 209 | 221 | if( fpid<=0 ){ |
| 210 | 222 | fossil_fatal("Unknown or ambiguous forum id: \"%s\"", zName); |
| 211 | 223 | } |
| 212 | 224 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 213 | 225 | if( froot==0 ){ |
| @@ -215,15 +227,16 @@ | ||
| 215 | 227 | } |
| 216 | 228 | fossil_print("fpid = %d\n", fpid); |
| 217 | 229 | fossil_print("froot = %d\n", froot); |
| 218 | 230 | pThread = forumthread_create(froot, 1); |
| 219 | 231 | fossil_print("Chronological:\n"); |
| 220 | - /* 123456789 123456789 123456789 123456789 123456789 */ | |
| 221 | - fossil_print(" fpid firt fprev mfirt pLeaf\n"); | |
| 232 | + /* 123456789 123456789 123456789 123456789 123456789 123456789 */ | |
| 233 | + fossil_print(" fpid firt fprev mfirt pLeaf nReply\n"); | |
| 222 | 234 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 223 | - fossil_print("%9d %9d %9d %9d %9d\n", | |
| 224 | - p->fpid, p->firt, p->fprev, p->mfirt, p->pLeaf ? p->pLeaf->fpid : 0); | |
| 235 | + fossil_print("%9d %9d %9d %9d %9d %9d\n", | |
| 236 | + p->fpid, p->firt, p->fprev, p->mfirt, p->pLeaf ? p->pLeaf->fpid : 0, | |
| 237 | + p->nReply); | |
| 225 | 238 | } |
| 226 | 239 | fossil_print("\nDisplay\n"); |
| 227 | 240 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 228 | 241 | fossil_print("%*s", (p->nIndent-1)*3, ""); |
| 229 | 242 | if( p->pLeaf ){ |
| @@ -319,11 +332,11 @@ | ||
| 319 | 332 | } |
| 320 | 333 | if( p->firt ){ |
| 321 | 334 | ForumEntry *pIrt = p->pPrev; |
| 322 | 335 | while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; |
| 323 | 336 | if( pIrt ){ |
| 324 | - @ reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))%d(p->firt)</a> | |
| 337 | + @ in reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))%d(p->firt)</a> | |
| 325 | 338 | } |
| 326 | 339 | } |
| 327 | 340 | if( p->pLeaf ){ |
| 328 | 341 | @ updated by %z(href("%R/forumpost/%S?t=c",p->pLeaf->zUuid))\ |
| 329 | 342 | @ %d(p->pLeaf->fpid)</a> |
| @@ -441,10 +454,17 @@ | ||
| 441 | 454 | } |
| 442 | 455 | manifest_destroy(pOPost); |
| 443 | 456 | } |
| 444 | 457 | if( fpid!=target ){ |
| 445 | 458 | @ %z(href("%R/forumpost/%S",zUuid))[link]</a> |
| 459 | + } | |
| 460 | + if( p->firt ){ | |
| 461 | + ForumEntry *pIrt = p->pPrev; | |
| 462 | + while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; | |
| 463 | + if( pIrt ){ | |
| 464 | + @ in reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))%d(p->firt)</a> | |
| 465 | + } | |
| 446 | 466 | } |
| 447 | 467 | isPrivate = content_is_private(fpid); |
| 448 | 468 | sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| 449 | 469 | if( isPrivate && !g.perm.ModForum && !sameUser ){ |
| 450 | 470 | @ <p><span class="modpending">Awaiting Moderator Approval</span></p> |
| 451 | 471 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -35,13 +35,14 @@ | |
| 35 | struct ForumEntry { |
| 36 | int fpid; /* rid for this entry */ |
| 37 | int fprev; /* zero if initial entry. non-zero if an edit */ |
| 38 | int firt; /* This entry replies to firt */ |
| 39 | int mfirt; /* Root in-reply-to */ |
| 40 | char *zUuid; /* Artifact hash */ |
| 41 | ForumEntry *pLeaf; /* Most recent edit for this entry */ |
| 42 | ForumEntry *pEdit; /* This entry is an edit of pEditee */ |
| 43 | ForumEntry *pNext; /* Next in chronological order */ |
| 44 | ForumEntry *pPrev; /* Previous in chronological order */ |
| 45 | ForumEntry *pDisplay; /* Next in display order */ |
| 46 | int nIndent; /* Number of levels of indentation for this entry */ |
| 47 | }; |
| @@ -104,22 +105,30 @@ | |
| 104 | ** Extend the display list for pThread by adding all entries that |
| 105 | ** reference fpid. The first such entry will be no earlier then |
| 106 | ** entry "p". |
| 107 | */ |
| 108 | static void forumthread_display_order( |
| 109 | ForumThread *pThread, |
| 110 | ForumEntry *p, |
| 111 | int fpid, |
| 112 | int nIndent |
| 113 | ){ |
| 114 | while( p ){ |
| 115 | if( p->fprev==0 && p->mfirt==fpid ){ |
| 116 | p->nIndent = nIndent; |
| 117 | forumentry_add_to_display(pThread, p); |
| 118 | forumthread_display_order(pThread, p->pNext, p->fpid, nIndent+1); |
| 119 | } |
| 120 | p = p->pNext; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /* |
| 125 | ** Construct a ForumThread object given the root record id. |
| @@ -178,11 +187,11 @@ | |
| 178 | if( computeHierarchy ){ |
| 179 | /* Compute the hierarchical display order */ |
| 180 | pEntry = pThread->pFirst; |
| 181 | pEntry->nIndent = 1; |
| 182 | forumentry_add_to_display(pThread, pEntry); |
| 183 | forumthread_display_order(pThread, pEntry, pEntry->fpid, 2); |
| 184 | } |
| 185 | |
| 186 | /* Return the result */ |
| 187 | return pThread; |
| 188 | } |
| @@ -204,10 +213,13 @@ | |
| 204 | db_find_and_open_repository(0,0); |
| 205 | verify_all_options(); |
| 206 | if( g.argc!=3 ) usage("THREADID"); |
| 207 | zName = g.argv[2]; |
| 208 | fpid = symbolic_name_to_rid(zName, "f"); |
| 209 | if( fpid<=0 ){ |
| 210 | fossil_fatal("Unknown or ambiguous forum id: \"%s\"", zName); |
| 211 | } |
| 212 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 213 | if( froot==0 ){ |
| @@ -215,15 +227,16 @@ | |
| 215 | } |
| 216 | fossil_print("fpid = %d\n", fpid); |
| 217 | fossil_print("froot = %d\n", froot); |
| 218 | pThread = forumthread_create(froot, 1); |
| 219 | fossil_print("Chronological:\n"); |
| 220 | /* 123456789 123456789 123456789 123456789 123456789 */ |
| 221 | fossil_print(" fpid firt fprev mfirt pLeaf\n"); |
| 222 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 223 | fossil_print("%9d %9d %9d %9d %9d\n", |
| 224 | p->fpid, p->firt, p->fprev, p->mfirt, p->pLeaf ? p->pLeaf->fpid : 0); |
| 225 | } |
| 226 | fossil_print("\nDisplay\n"); |
| 227 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 228 | fossil_print("%*s", (p->nIndent-1)*3, ""); |
| 229 | if( p->pLeaf ){ |
| @@ -319,11 +332,11 @@ | |
| 319 | } |
| 320 | if( p->firt ){ |
| 321 | ForumEntry *pIrt = p->pPrev; |
| 322 | while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; |
| 323 | if( pIrt ){ |
| 324 | @ reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))%d(p->firt)</a> |
| 325 | } |
| 326 | } |
| 327 | if( p->pLeaf ){ |
| 328 | @ updated by %z(href("%R/forumpost/%S?t=c",p->pLeaf->zUuid))\ |
| 329 | @ %d(p->pLeaf->fpid)</a> |
| @@ -441,10 +454,17 @@ | |
| 441 | } |
| 442 | manifest_destroy(pOPost); |
| 443 | } |
| 444 | if( fpid!=target ){ |
| 445 | @ %z(href("%R/forumpost/%S",zUuid))[link]</a> |
| 446 | } |
| 447 | isPrivate = content_is_private(fpid); |
| 448 | sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| 449 | if( isPrivate && !g.perm.ModForum && !sameUser ){ |
| 450 | @ <p><span class="modpending">Awaiting Moderator Approval</span></p> |
| 451 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -35,13 +35,14 @@ | |
| 35 | struct ForumEntry { |
| 36 | int fpid; /* rid for this entry */ |
| 37 | int fprev; /* zero if initial entry. non-zero if an edit */ |
| 38 | int firt; /* This entry replies to firt */ |
| 39 | int mfirt; /* Root in-reply-to */ |
| 40 | int nReply; /* Number of replies to this entry */ |
| 41 | char *zUuid; /* Artifact hash */ |
| 42 | ForumEntry *pLeaf; /* Most recent edit for this entry */ |
| 43 | ForumEntry *pEdit; /* This entry is an edit of pEdit */ |
| 44 | ForumEntry *pNext; /* Next in chronological order */ |
| 45 | ForumEntry *pPrev; /* Previous in chronological order */ |
| 46 | ForumEntry *pDisplay; /* Next in display order */ |
| 47 | int nIndent; /* Number of levels of indentation for this entry */ |
| 48 | }; |
| @@ -104,22 +105,30 @@ | |
| 105 | ** Extend the display list for pThread by adding all entries that |
| 106 | ** reference fpid. The first such entry will be no earlier then |
| 107 | ** entry "p". |
| 108 | */ |
| 109 | static void forumthread_display_order( |
| 110 | ForumThread *pThread, /* The complete thread */ |
| 111 | ForumEntry *pBase /* Add replies to this entry */ |
| 112 | ){ |
| 113 | ForumEntry *p; |
| 114 | ForumEntry *pPrev = 0; |
| 115 | for(p=pBase->pNext; p; p=p->pNext){ |
| 116 | if( p->fprev==0 && p->mfirt==pBase->fpid ){ |
| 117 | if( pPrev ){ |
| 118 | pPrev->nIndent = pBase->nIndent + 1; |
| 119 | forumentry_add_to_display(pThread, pPrev); |
| 120 | forumthread_display_order(pThread, pPrev); |
| 121 | } |
| 122 | pBase->nReply++; |
| 123 | pPrev = p; |
| 124 | } |
| 125 | } |
| 126 | if( pPrev ){ |
| 127 | pPrev->nIndent = pBase->nIndent + (pBase->nReply>1); |
| 128 | forumentry_add_to_display(pThread, pPrev); |
| 129 | forumthread_display_order(pThread, pPrev); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | ** Construct a ForumThread object given the root record id. |
| @@ -178,11 +187,11 @@ | |
| 187 | if( computeHierarchy ){ |
| 188 | /* Compute the hierarchical display order */ |
| 189 | pEntry = pThread->pFirst; |
| 190 | pEntry->nIndent = 1; |
| 191 | forumentry_add_to_display(pThread, pEntry); |
| 192 | forumthread_display_order(pThread, pEntry); |
| 193 | } |
| 194 | |
| 195 | /* Return the result */ |
| 196 | return pThread; |
| 197 | } |
| @@ -204,10 +213,13 @@ | |
| 213 | db_find_and_open_repository(0,0); |
| 214 | verify_all_options(); |
| 215 | if( g.argc!=3 ) usage("THREADID"); |
| 216 | zName = g.argv[2]; |
| 217 | fpid = symbolic_name_to_rid(zName, "f"); |
| 218 | if( fpid<=0 ){ |
| 219 | fpid = db_int(0, "SELECT rid FROM blob WHERE rid=%d", atoi(zName)); |
| 220 | } |
| 221 | if( fpid<=0 ){ |
| 222 | fossil_fatal("Unknown or ambiguous forum id: \"%s\"", zName); |
| 223 | } |
| 224 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 225 | if( froot==0 ){ |
| @@ -215,15 +227,16 @@ | |
| 227 | } |
| 228 | fossil_print("fpid = %d\n", fpid); |
| 229 | fossil_print("froot = %d\n", froot); |
| 230 | pThread = forumthread_create(froot, 1); |
| 231 | fossil_print("Chronological:\n"); |
| 232 | /* 123456789 123456789 123456789 123456789 123456789 123456789 */ |
| 233 | fossil_print(" fpid firt fprev mfirt pLeaf nReply\n"); |
| 234 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 235 | fossil_print("%9d %9d %9d %9d %9d %9d\n", |
| 236 | p->fpid, p->firt, p->fprev, p->mfirt, p->pLeaf ? p->pLeaf->fpid : 0, |
| 237 | p->nReply); |
| 238 | } |
| 239 | fossil_print("\nDisplay\n"); |
| 240 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 241 | fossil_print("%*s", (p->nIndent-1)*3, ""); |
| 242 | if( p->pLeaf ){ |
| @@ -319,11 +332,11 @@ | |
| 332 | } |
| 333 | if( p->firt ){ |
| 334 | ForumEntry *pIrt = p->pPrev; |
| 335 | while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; |
| 336 | if( pIrt ){ |
| 337 | @ in reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))%d(p->firt)</a> |
| 338 | } |
| 339 | } |
| 340 | if( p->pLeaf ){ |
| 341 | @ updated by %z(href("%R/forumpost/%S?t=c",p->pLeaf->zUuid))\ |
| 342 | @ %d(p->pLeaf->fpid)</a> |
| @@ -441,10 +454,17 @@ | |
| 454 | } |
| 455 | manifest_destroy(pOPost); |
| 456 | } |
| 457 | if( fpid!=target ){ |
| 458 | @ %z(href("%R/forumpost/%S",zUuid))[link]</a> |
| 459 | } |
| 460 | if( p->firt ){ |
| 461 | ForumEntry *pIrt = p->pPrev; |
| 462 | while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev; |
| 463 | if( pIrt ){ |
| 464 | @ in reply to %z(href("%R/forumpost/%S?t=c",pIrt->zUuid))%d(p->firt)</a> |
| 465 | } |
| 466 | } |
| 467 | isPrivate = content_is_private(fpid); |
| 468 | sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| 469 | if( isPrivate && !g.perm.ModForum && !sameUser ){ |
| 470 | @ <p><span class="modpending">Awaiting Moderator Approval</span></p> |
| 471 |