Fossil SCM
Fixes to the forum hierarchical display algorithm.
Commit
9757488a5dc0edc899cc5fca0c78b73dc43a5f808cb6b5189edf722fe771a1ca
Parent
8eccd9a221fd165…
2 files changed
+3
+48
-18
+3
| --- src/default_css.txt | ||
| +++ src/default_css.txt | ||
| @@ -687,5 +687,8 @@ | ||
| 687 | 687 | border: 1px solid black; |
| 688 | 688 | padding-left: 1ex; |
| 689 | 689 | padding-right: 1ex; |
| 690 | 690 | margin-top: 1ex; |
| 691 | 691 | } |
| 692 | +div.forumSel { | |
| 693 | + background-color: #cef; | |
| 694 | +} | |
| 692 | 695 |
| --- src/default_css.txt | |
| +++ src/default_css.txt | |
| @@ -687,5 +687,8 @@ | |
| 687 | border: 1px solid black; |
| 688 | padding-left: 1ex; |
| 689 | padding-right: 1ex; |
| 690 | margin-top: 1ex; |
| 691 | } |
| 692 |
| --- src/default_css.txt | |
| +++ src/default_css.txt | |
| @@ -687,5 +687,8 @@ | |
| 687 | border: 1px solid black; |
| 688 | padding-left: 1ex; |
| 689 | padding-right: 1ex; |
| 690 | margin-top: 1ex; |
| 691 | } |
| 692 | div.forumSel { |
| 693 | background-color: #cef; |
| 694 | } |
| 695 |
+48
-18
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -103,11 +103,11 @@ | ||
| 103 | 103 | ForumEntry *p, |
| 104 | 104 | int fpid, |
| 105 | 105 | int nIndent |
| 106 | 106 | ){ |
| 107 | 107 | while( p ){ |
| 108 | - if( p->pEdit==0 && p->mfirt==fpid ){ | |
| 108 | + if( p->fprev==0 && p->mfirt==fpid ){ | |
| 109 | 109 | p->nIndent = nIndent; |
| 110 | 110 | forumentry_add_to_display(pThread, p); |
| 111 | 111 | forumthread_display_order(pThread, p->pNext, p->fpid, nIndent+1); |
| 112 | 112 | } |
| 113 | 113 | p = p->pNext; |
| @@ -148,19 +148,19 @@ | ||
| 148 | 148 | ** displayed. |
| 149 | 149 | */ |
| 150 | 150 | for(pEntry=pThread->pFirst; pEntry; pEntry=pEntry->pNext){ |
| 151 | 151 | if( pEntry->fprev ){ |
| 152 | 152 | ForumEntry *pBase, *p; |
| 153 | - pBase = p = forumentry_backward(pEntry->pPrev, pEntry->fprev); | |
| 153 | + p = forumentry_backward(pEntry->pPrev, pEntry->fprev); | |
| 154 | 154 | pEntry->pEdit = p; |
| 155 | 155 | while( p ){ |
| 156 | 156 | pBase = p; |
| 157 | 157 | p->pLeaf = pEntry; |
| 158 | 158 | p = pBase->pEdit; |
| 159 | 159 | } |
| 160 | 160 | for(p=pEntry->pNext; p; p=p->pNext){ |
| 161 | - if( p->mfirt==pEntry->fpid ) p->mfirt = pBase->mfirt; | |
| 161 | + if( p->mfirt==pEntry->fpid ) p->mfirt = pBase->fpid; | |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /* Compute the display order */ |
| @@ -270,11 +270,15 @@ | ||
| 270 | 270 | int firt = db_column_int(&q, 2); |
| 271 | 271 | const char *zUuid = db_column_text(&q, 3); |
| 272 | 272 | const char *zDate = db_column_text(&q, 4); |
| 273 | 273 | Manifest *pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 274 | 274 | if( pPost==0 ) continue; |
| 275 | - @ <div id="forum%d(fpid)" class="forumTime"> | |
| 275 | + if( fpid==target ){ | |
| 276 | + @ <div id="forum%d(fpid)" class="forumTime forumSel"> | |
| 277 | + }else{ | |
| 278 | + @ <div id="forum%d(fpid)" class="forumTime"> | |
| 279 | + } | |
| 276 | 280 | if( pPost->zThreadTitle ){ |
| 277 | 281 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 278 | 282 | } |
| 279 | 283 | @ <p>By %h(pPost->zUser) on %h(zDate) (%d(fpid)) |
| 280 | 284 | if( fprev ){ |
| @@ -324,36 +328,68 @@ | ||
| 324 | 328 | ** Display all messages in a forumthread with indentation. |
| 325 | 329 | */ |
| 326 | 330 | static int forum_display_hierarchical(int froot, int target){ |
| 327 | 331 | ForumThread *pThread; |
| 328 | 332 | ForumEntry *p; |
| 329 | - Manifest *pPost; | |
| 333 | + Manifest *pPost, *pOPost; | |
| 330 | 334 | int fpid; |
| 331 | 335 | char *zDate; |
| 332 | 336 | char *zUuid; |
| 337 | + const char *zSel; | |
| 333 | 338 | |
| 334 | 339 | pThread = forumthread_create(froot); |
| 340 | + for(p=pThread->pFirst; p; p=p->pNext){ | |
| 341 | + if( p->fpid==target ){ | |
| 342 | + while( p->pEdit ) p = p->pEdit; | |
| 343 | + target = p->fpid; | |
| 344 | + break; | |
| 345 | + } | |
| 346 | + } | |
| 335 | 347 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 336 | - fpid = p->pLeaf ? p->pLeaf->fpid : p->fpid; | |
| 348 | + pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); | |
| 349 | + if( p->pLeaf ){ | |
| 350 | + fpid = p->pLeaf->fpid; | |
| 351 | + pPost = manifest_get(fpid, CFTYPE_FORUM, 0); | |
| 352 | + }else{ | |
| 353 | + fpid = p->fpid; | |
| 354 | + pPost = pOPost; | |
| 355 | + } | |
| 356 | + zSel = p->fpid==target ? " forumSel" : ""; | |
| 337 | 357 | if( p->nIndent==1 ){ |
| 338 | - @ <div id='forum(%d(fpid)' class='forumHierRoot'> | |
| 358 | + @ <div id='forum(%d(fpid)' class='forumHierRoot%s(zSel)'> | |
| 339 | 359 | }else{ |
| 340 | - @ <div id='forum%d(fpid)' class='forumHier' \ | |
| 360 | + @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \ | |
| 341 | 361 | @ style='margin-left: %d((p->nIndent-1)*3)ex;'> |
| 342 | 362 | } |
| 343 | 363 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 344 | 364 | if( pPost==0 ) continue; |
| 345 | 365 | if( pPost->zThreadTitle ){ |
| 346 | 366 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 347 | 367 | } |
| 348 | - zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); | |
| 349 | - @ <p>By %h(pPost->zUser) on %h(zDate) (%d(fpid)) | |
| 368 | + zDate = db_text(0, "SELECT datetime(%.17g)", pOPost->rDate); | |
| 369 | + @ <p>By %h(pOPost->zUser) on %h(zDate) | |
| 350 | 370 | fossil_free(zDate); |
| 351 | - zUuid = rid_to_uuid(fpid); | |
| 371 | + zUuid = rid_to_uuid(p->fpid); | |
| 352 | 372 | if( g.perm.Debug ){ |
| 353 | 373 | @ <span class="debug">\ |
| 354 | - @ <a href="%R/artifact/%h(zUuid)">artifact</a></span> | |
| 374 | + @ <a href="%R/artifact/%h(zUuid)">(%d(p->fpid))</a></span> | |
| 375 | + } | |
| 376 | + if( p->pLeaf ){ | |
| 377 | + zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); | |
| 378 | + if( fossil_strcmp(pOPost->zUser,pPost->zUser)==0 ){ | |
| 379 | + @ and edited on %h(zDate) | |
| 380 | + }else{ | |
| 381 | + @ as edited by %h(pPost->zUser) on %h(zDate) | |
| 382 | + } | |
| 383 | + fossil_free(zDate); | |
| 384 | + fossil_free(zUuid); | |
| 385 | + zUuid = rid_to_uuid(fpid); | |
| 386 | + if( g.perm.Debug ){ | |
| 387 | + @ <span class="debug">\ | |
| 388 | + @ <a href="%R/artifact/%h(zUuid)">(%d(fpid))</a></span> | |
| 389 | + } | |
| 390 | + manifest_destroy(pOPost); | |
| 355 | 391 | } |
| 356 | 392 | forum_render(0, pPost->zMimetype, pPost->zWiki, 0); |
| 357 | 393 | if( g.perm.WrForum ){ |
| 358 | 394 | int sameUser = login_is_individual() |
| 359 | 395 | && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| @@ -382,16 +418,10 @@ | ||
| 382 | 418 | } |
| 383 | 419 | manifest_destroy(pPost); |
| 384 | 420 | fossil_free(zUuid); |
| 385 | 421 | @ </div> |
| 386 | 422 | } |
| 387 | - for(p=pThread->pFirst; p; p=p->pNext){ | |
| 388 | - if( p->fpid==target ){ | |
| 389 | - if( p->pLeaf ) target = p->pLeaf->fpid; | |
| 390 | - break; | |
| 391 | - } | |
| 392 | - } | |
| 393 | 423 | forumthread_delete(pThread); |
| 394 | 424 | return target; |
| 395 | 425 | } |
| 396 | 426 | |
| 397 | 427 | /* |
| 398 | 428 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -103,11 +103,11 @@ | |
| 103 | ForumEntry *p, |
| 104 | int fpid, |
| 105 | int nIndent |
| 106 | ){ |
| 107 | while( p ){ |
| 108 | if( p->pEdit==0 && p->mfirt==fpid ){ |
| 109 | p->nIndent = nIndent; |
| 110 | forumentry_add_to_display(pThread, p); |
| 111 | forumthread_display_order(pThread, p->pNext, p->fpid, nIndent+1); |
| 112 | } |
| 113 | p = p->pNext; |
| @@ -148,19 +148,19 @@ | |
| 148 | ** displayed. |
| 149 | */ |
| 150 | for(pEntry=pThread->pFirst; pEntry; pEntry=pEntry->pNext){ |
| 151 | if( pEntry->fprev ){ |
| 152 | ForumEntry *pBase, *p; |
| 153 | pBase = p = forumentry_backward(pEntry->pPrev, pEntry->fprev); |
| 154 | pEntry->pEdit = p; |
| 155 | while( p ){ |
| 156 | pBase = p; |
| 157 | p->pLeaf = pEntry; |
| 158 | p = pBase->pEdit; |
| 159 | } |
| 160 | for(p=pEntry->pNext; p; p=p->pNext){ |
| 161 | if( p->mfirt==pEntry->fpid ) p->mfirt = pBase->mfirt; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /* Compute the display order */ |
| @@ -270,11 +270,15 @@ | |
| 270 | int firt = db_column_int(&q, 2); |
| 271 | const char *zUuid = db_column_text(&q, 3); |
| 272 | const char *zDate = db_column_text(&q, 4); |
| 273 | Manifest *pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 274 | if( pPost==0 ) continue; |
| 275 | @ <div id="forum%d(fpid)" class="forumTime"> |
| 276 | if( pPost->zThreadTitle ){ |
| 277 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 278 | } |
| 279 | @ <p>By %h(pPost->zUser) on %h(zDate) (%d(fpid)) |
| 280 | if( fprev ){ |
| @@ -324,36 +328,68 @@ | |
| 324 | ** Display all messages in a forumthread with indentation. |
| 325 | */ |
| 326 | static int forum_display_hierarchical(int froot, int target){ |
| 327 | ForumThread *pThread; |
| 328 | ForumEntry *p; |
| 329 | Manifest *pPost; |
| 330 | int fpid; |
| 331 | char *zDate; |
| 332 | char *zUuid; |
| 333 | |
| 334 | pThread = forumthread_create(froot); |
| 335 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 336 | fpid = p->pLeaf ? p->pLeaf->fpid : p->fpid; |
| 337 | if( p->nIndent==1 ){ |
| 338 | @ <div id='forum(%d(fpid)' class='forumHierRoot'> |
| 339 | }else{ |
| 340 | @ <div id='forum%d(fpid)' class='forumHier' \ |
| 341 | @ style='margin-left: %d((p->nIndent-1)*3)ex;'> |
| 342 | } |
| 343 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 344 | if( pPost==0 ) continue; |
| 345 | if( pPost->zThreadTitle ){ |
| 346 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 347 | } |
| 348 | zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); |
| 349 | @ <p>By %h(pPost->zUser) on %h(zDate) (%d(fpid)) |
| 350 | fossil_free(zDate); |
| 351 | zUuid = rid_to_uuid(fpid); |
| 352 | if( g.perm.Debug ){ |
| 353 | @ <span class="debug">\ |
| 354 | @ <a href="%R/artifact/%h(zUuid)">artifact</a></span> |
| 355 | } |
| 356 | forum_render(0, pPost->zMimetype, pPost->zWiki, 0); |
| 357 | if( g.perm.WrForum ){ |
| 358 | int sameUser = login_is_individual() |
| 359 | && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| @@ -382,16 +418,10 @@ | |
| 382 | } |
| 383 | manifest_destroy(pPost); |
| 384 | fossil_free(zUuid); |
| 385 | @ </div> |
| 386 | } |
| 387 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 388 | if( p->fpid==target ){ |
| 389 | if( p->pLeaf ) target = p->pLeaf->fpid; |
| 390 | break; |
| 391 | } |
| 392 | } |
| 393 | forumthread_delete(pThread); |
| 394 | return target; |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -103,11 +103,11 @@ | |
| 103 | ForumEntry *p, |
| 104 | int fpid, |
| 105 | int nIndent |
| 106 | ){ |
| 107 | while( p ){ |
| 108 | if( p->fprev==0 && p->mfirt==fpid ){ |
| 109 | p->nIndent = nIndent; |
| 110 | forumentry_add_to_display(pThread, p); |
| 111 | forumthread_display_order(pThread, p->pNext, p->fpid, nIndent+1); |
| 112 | } |
| 113 | p = p->pNext; |
| @@ -148,19 +148,19 @@ | |
| 148 | ** displayed. |
| 149 | */ |
| 150 | for(pEntry=pThread->pFirst; pEntry; pEntry=pEntry->pNext){ |
| 151 | if( pEntry->fprev ){ |
| 152 | ForumEntry *pBase, *p; |
| 153 | p = forumentry_backward(pEntry->pPrev, pEntry->fprev); |
| 154 | pEntry->pEdit = p; |
| 155 | while( p ){ |
| 156 | pBase = p; |
| 157 | p->pLeaf = pEntry; |
| 158 | p = pBase->pEdit; |
| 159 | } |
| 160 | for(p=pEntry->pNext; p; p=p->pNext){ |
| 161 | if( p->mfirt==pEntry->fpid ) p->mfirt = pBase->fpid; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /* Compute the display order */ |
| @@ -270,11 +270,15 @@ | |
| 270 | int firt = db_column_int(&q, 2); |
| 271 | const char *zUuid = db_column_text(&q, 3); |
| 272 | const char *zDate = db_column_text(&q, 4); |
| 273 | Manifest *pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 274 | if( pPost==0 ) continue; |
| 275 | if( fpid==target ){ |
| 276 | @ <div id="forum%d(fpid)" class="forumTime forumSel"> |
| 277 | }else{ |
| 278 | @ <div id="forum%d(fpid)" class="forumTime"> |
| 279 | } |
| 280 | if( pPost->zThreadTitle ){ |
| 281 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 282 | } |
| 283 | @ <p>By %h(pPost->zUser) on %h(zDate) (%d(fpid)) |
| 284 | if( fprev ){ |
| @@ -324,36 +328,68 @@ | |
| 328 | ** Display all messages in a forumthread with indentation. |
| 329 | */ |
| 330 | static int forum_display_hierarchical(int froot, int target){ |
| 331 | ForumThread *pThread; |
| 332 | ForumEntry *p; |
| 333 | Manifest *pPost, *pOPost; |
| 334 | int fpid; |
| 335 | char *zDate; |
| 336 | char *zUuid; |
| 337 | const char *zSel; |
| 338 | |
| 339 | pThread = forumthread_create(froot); |
| 340 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 341 | if( p->fpid==target ){ |
| 342 | while( p->pEdit ) p = p->pEdit; |
| 343 | target = p->fpid; |
| 344 | break; |
| 345 | } |
| 346 | } |
| 347 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 348 | pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); |
| 349 | if( p->pLeaf ){ |
| 350 | fpid = p->pLeaf->fpid; |
| 351 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 352 | }else{ |
| 353 | fpid = p->fpid; |
| 354 | pPost = pOPost; |
| 355 | } |
| 356 | zSel = p->fpid==target ? " forumSel" : ""; |
| 357 | if( p->nIndent==1 ){ |
| 358 | @ <div id='forum(%d(fpid)' class='forumHierRoot%s(zSel)'> |
| 359 | }else{ |
| 360 | @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \ |
| 361 | @ style='margin-left: %d((p->nIndent-1)*3)ex;'> |
| 362 | } |
| 363 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 364 | if( pPost==0 ) continue; |
| 365 | if( pPost->zThreadTitle ){ |
| 366 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 367 | } |
| 368 | zDate = db_text(0, "SELECT datetime(%.17g)", pOPost->rDate); |
| 369 | @ <p>By %h(pOPost->zUser) on %h(zDate) |
| 370 | fossil_free(zDate); |
| 371 | zUuid = rid_to_uuid(p->fpid); |
| 372 | if( g.perm.Debug ){ |
| 373 | @ <span class="debug">\ |
| 374 | @ <a href="%R/artifact/%h(zUuid)">(%d(p->fpid))</a></span> |
| 375 | } |
| 376 | if( p->pLeaf ){ |
| 377 | zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); |
| 378 | if( fossil_strcmp(pOPost->zUser,pPost->zUser)==0 ){ |
| 379 | @ and edited on %h(zDate) |
| 380 | }else{ |
| 381 | @ as edited by %h(pPost->zUser) on %h(zDate) |
| 382 | } |
| 383 | fossil_free(zDate); |
| 384 | fossil_free(zUuid); |
| 385 | zUuid = rid_to_uuid(fpid); |
| 386 | if( g.perm.Debug ){ |
| 387 | @ <span class="debug">\ |
| 388 | @ <a href="%R/artifact/%h(zUuid)">(%d(fpid))</a></span> |
| 389 | } |
| 390 | manifest_destroy(pOPost); |
| 391 | } |
| 392 | forum_render(0, pPost->zMimetype, pPost->zWiki, 0); |
| 393 | if( g.perm.WrForum ){ |
| 394 | int sameUser = login_is_individual() |
| 395 | && fossil_strcmp(pPost->zUser, g.zLogin)==0; |
| @@ -382,16 +418,10 @@ | |
| 418 | } |
| 419 | manifest_destroy(pPost); |
| 420 | fossil_free(zUuid); |
| 421 | @ </div> |
| 422 | } |
| 423 | forumthread_delete(pThread); |
| 424 | return target; |
| 425 | } |
| 426 | |
| 427 | /* |
| 428 |