Fossil SCM
In the hierarchical display of the forum, go back to strict hierarchical indentation. But, reduce the width of indentation for deeply nested discussions.
Commit
0cec52e08eef79ddbfee0ed9e8a8165fbab70a72caf81f4636929a664e09b555
Parent
e878d54dcc27d88…
1 file changed
+12
-2
+12
-2
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -36,10 +36,11 @@ | ||
| 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 | 40 | int nReply; /* Number of replies to this entry */ |
| 41 | + int sid; /* Serial ID number */ | |
| 41 | 42 | char *zUuid; /* Artifact hash */ |
| 42 | 43 | ForumEntry *pLeaf; /* Most recent edit for this entry */ |
| 43 | 44 | ForumEntry *pEdit; /* This entry is an edit of pEdit */ |
| 44 | 45 | ForumEntry *pNext; /* Next in chronological order */ |
| 45 | 46 | ForumEntry *pPrev; /* Previous in chronological order */ |
| @@ -53,10 +54,11 @@ | ||
| 53 | 54 | struct ForumThread { |
| 54 | 55 | ForumEntry *pFirst; /* First entry in chronological order */ |
| 55 | 56 | ForumEntry *pLast; /* Last entry in chronological order */ |
| 56 | 57 | ForumEntry *pDisplay; /* Entries in display order */ |
| 57 | 58 | ForumEntry *pTail; /* Last on the display list */ |
| 59 | + int mxIndent; /* Maximum indentation level */ | |
| 58 | 60 | }; |
| 59 | 61 | #endif /* INTERFACE */ |
| 60 | 62 | |
| 61 | 63 | /* |
| 62 | 64 | ** Delete a complete ForumThread and all its entries. |
| @@ -122,11 +124,12 @@ | ||
| 122 | 124 | pBase->nReply++; |
| 123 | 125 | pPrev = p; |
| 124 | 126 | } |
| 125 | 127 | } |
| 126 | 128 | if( pPrev ){ |
| 127 | - pPrev->nIndent = pBase->nIndent + (pBase->nReply>1); | |
| 129 | + pPrev->nIndent = pBase->nIndent + 1; | |
| 130 | + if( pPrev->nIndent>pThread->mxIndent ) pThread->mxIndent = pPrev->nIndent; | |
| 128 | 131 | forumentry_add_to_display(pThread, pPrev); |
| 129 | 132 | forumthread_display_order(pThread, pPrev); |
| 130 | 133 | } |
| 131 | 134 | } |
| 132 | 135 | |
| @@ -135,10 +138,11 @@ | ||
| 135 | 138 | */ |
| 136 | 139 | static ForumThread *forumthread_create(int froot, int computeHierarchy){ |
| 137 | 140 | ForumThread *pThread; |
| 138 | 141 | ForumEntry *pEntry; |
| 139 | 142 | Stmt q; |
| 143 | + int sid = 1; | |
| 140 | 144 | pThread = fossil_malloc( sizeof(*pThread) ); |
| 141 | 145 | memset(pThread, 0, sizeof(*pThread)); |
| 142 | 146 | db_prepare(&q, |
| 143 | 147 | "SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)" |
| 144 | 148 | " FROM forumpost" |
| @@ -151,10 +155,11 @@ | ||
| 151 | 155 | pEntry->fpid = db_column_int(&q, 0); |
| 152 | 156 | pEntry->firt = db_column_int(&q, 1); |
| 153 | 157 | pEntry->fprev = db_column_int(&q, 2); |
| 154 | 158 | pEntry->zUuid = fossil_strdup(db_column_text(&q,3)); |
| 155 | 159 | pEntry->mfirt = pEntry->firt; |
| 160 | + pEntry->sid = sid++; | |
| 156 | 161 | pEntry->pPrev = pThread->pLast; |
| 157 | 162 | pEntry->pNext = 0; |
| 158 | 163 | if( pThread->pLast==0 ){ |
| 159 | 164 | pThread->pFirst = pEntry; |
| 160 | 165 | }else{ |
| @@ -186,10 +191,11 @@ | ||
| 186 | 191 | |
| 187 | 192 | if( computeHierarchy ){ |
| 188 | 193 | /* Compute the hierarchical display order */ |
| 189 | 194 | pEntry = pThread->pFirst; |
| 190 | 195 | pEntry->nIndent = 1; |
| 196 | + pThread->mxIndent = 1; | |
| 191 | 197 | forumentry_add_to_display(pThread, pEntry); |
| 192 | 198 | forumthread_display_order(pThread, pEntry); |
| 193 | 199 | } |
| 194 | 200 | |
| 195 | 201 | /* Return the result */ |
| @@ -405,18 +411,22 @@ | ||
| 405 | 411 | const char *zUuid; |
| 406 | 412 | char *zDate; |
| 407 | 413 | const char *zSel; |
| 408 | 414 | int notAnon = login_is_individual(); |
| 409 | 415 | int iPrev = -1; |
| 416 | + int iIndentScale = 4; | |
| 410 | 417 | |
| 411 | 418 | pThread = forumthread_create(froot, 1); |
| 412 | 419 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 413 | 420 | if( p->fpid==target ){ |
| 414 | 421 | while( p->pEdit ) p = p->pEdit; |
| 415 | 422 | target = p->fpid; |
| 416 | 423 | break; |
| 417 | 424 | } |
| 425 | + } | |
| 426 | + while( iIndentScale>1 && iIndentScale*pThread->mxIndent>25 ){ | |
| 427 | + iIndentScale--; | |
| 418 | 428 | } |
| 419 | 429 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 420 | 430 | int isPrivate; /* True for posts awaiting moderation */ |
| 421 | 431 | int sameUser; /* True if reader is also the poster */ |
| 422 | 432 | pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); |
| @@ -432,11 +442,11 @@ | ||
| 432 | 442 | zSel = p->fpid==target ? " forumSel" : ""; |
| 433 | 443 | if( p->nIndent==1 ){ |
| 434 | 444 | @ <div id='forum%d(fpid)' class='forumHierRoot%s(zSel)'> |
| 435 | 445 | }else{ |
| 436 | 446 | @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \ |
| 437 | - @ style='margin-left: %d((p->nIndent-1)*3)ex;'> | |
| 447 | + @ style='margin-left: %d((p->nIndent-1)*iIndentScale)ex;'> | |
| 438 | 448 | } |
| 439 | 449 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 440 | 450 | if( pPost==0 ) continue; |
| 441 | 451 | if( pPost->zThreadTitle ){ |
| 442 | 452 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 443 | 453 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -36,10 +36,11 @@ | |
| 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 */ |
| @@ -53,10 +54,11 @@ | |
| 53 | struct ForumThread { |
| 54 | ForumEntry *pFirst; /* First entry in chronological order */ |
| 55 | ForumEntry *pLast; /* Last entry in chronological order */ |
| 56 | ForumEntry *pDisplay; /* Entries in display order */ |
| 57 | ForumEntry *pTail; /* Last on the display list */ |
| 58 | }; |
| 59 | #endif /* INTERFACE */ |
| 60 | |
| 61 | /* |
| 62 | ** Delete a complete ForumThread and all its entries. |
| @@ -122,11 +124,12 @@ | |
| 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 | |
| @@ -135,10 +138,11 @@ | |
| 135 | */ |
| 136 | static ForumThread *forumthread_create(int froot, int computeHierarchy){ |
| 137 | ForumThread *pThread; |
| 138 | ForumEntry *pEntry; |
| 139 | Stmt q; |
| 140 | pThread = fossil_malloc( sizeof(*pThread) ); |
| 141 | memset(pThread, 0, sizeof(*pThread)); |
| 142 | db_prepare(&q, |
| 143 | "SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)" |
| 144 | " FROM forumpost" |
| @@ -151,10 +155,11 @@ | |
| 151 | pEntry->fpid = db_column_int(&q, 0); |
| 152 | pEntry->firt = db_column_int(&q, 1); |
| 153 | pEntry->fprev = db_column_int(&q, 2); |
| 154 | pEntry->zUuid = fossil_strdup(db_column_text(&q,3)); |
| 155 | pEntry->mfirt = pEntry->firt; |
| 156 | pEntry->pPrev = pThread->pLast; |
| 157 | pEntry->pNext = 0; |
| 158 | if( pThread->pLast==0 ){ |
| 159 | pThread->pFirst = pEntry; |
| 160 | }else{ |
| @@ -186,10 +191,11 @@ | |
| 186 | |
| 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 */ |
| @@ -405,18 +411,22 @@ | |
| 405 | const char *zUuid; |
| 406 | char *zDate; |
| 407 | const char *zSel; |
| 408 | int notAnon = login_is_individual(); |
| 409 | int iPrev = -1; |
| 410 | |
| 411 | pThread = forumthread_create(froot, 1); |
| 412 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 413 | if( p->fpid==target ){ |
| 414 | while( p->pEdit ) p = p->pEdit; |
| 415 | target = p->fpid; |
| 416 | break; |
| 417 | } |
| 418 | } |
| 419 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 420 | int isPrivate; /* True for posts awaiting moderation */ |
| 421 | int sameUser; /* True if reader is also the poster */ |
| 422 | pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); |
| @@ -432,11 +442,11 @@ | |
| 432 | zSel = p->fpid==target ? " forumSel" : ""; |
| 433 | if( p->nIndent==1 ){ |
| 434 | @ <div id='forum%d(fpid)' class='forumHierRoot%s(zSel)'> |
| 435 | }else{ |
| 436 | @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \ |
| 437 | @ style='margin-left: %d((p->nIndent-1)*3)ex;'> |
| 438 | } |
| 439 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 440 | if( pPost==0 ) continue; |
| 441 | if( pPost->zThreadTitle ){ |
| 442 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 443 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -36,10 +36,11 @@ | |
| 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 | int sid; /* Serial ID number */ |
| 42 | char *zUuid; /* Artifact hash */ |
| 43 | ForumEntry *pLeaf; /* Most recent edit for this entry */ |
| 44 | ForumEntry *pEdit; /* This entry is an edit of pEdit */ |
| 45 | ForumEntry *pNext; /* Next in chronological order */ |
| 46 | ForumEntry *pPrev; /* Previous in chronological order */ |
| @@ -53,10 +54,11 @@ | |
| 54 | struct ForumThread { |
| 55 | ForumEntry *pFirst; /* First entry in chronological order */ |
| 56 | ForumEntry *pLast; /* Last entry in chronological order */ |
| 57 | ForumEntry *pDisplay; /* Entries in display order */ |
| 58 | ForumEntry *pTail; /* Last on the display list */ |
| 59 | int mxIndent; /* Maximum indentation level */ |
| 60 | }; |
| 61 | #endif /* INTERFACE */ |
| 62 | |
| 63 | /* |
| 64 | ** Delete a complete ForumThread and all its entries. |
| @@ -122,11 +124,12 @@ | |
| 124 | pBase->nReply++; |
| 125 | pPrev = p; |
| 126 | } |
| 127 | } |
| 128 | if( pPrev ){ |
| 129 | pPrev->nIndent = pBase->nIndent + 1; |
| 130 | if( pPrev->nIndent>pThread->mxIndent ) pThread->mxIndent = pPrev->nIndent; |
| 131 | forumentry_add_to_display(pThread, pPrev); |
| 132 | forumthread_display_order(pThread, pPrev); |
| 133 | } |
| 134 | } |
| 135 | |
| @@ -135,10 +138,11 @@ | |
| 138 | */ |
| 139 | static ForumThread *forumthread_create(int froot, int computeHierarchy){ |
| 140 | ForumThread *pThread; |
| 141 | ForumEntry *pEntry; |
| 142 | Stmt q; |
| 143 | int sid = 1; |
| 144 | pThread = fossil_malloc( sizeof(*pThread) ); |
| 145 | memset(pThread, 0, sizeof(*pThread)); |
| 146 | db_prepare(&q, |
| 147 | "SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)" |
| 148 | " FROM forumpost" |
| @@ -151,10 +155,11 @@ | |
| 155 | pEntry->fpid = db_column_int(&q, 0); |
| 156 | pEntry->firt = db_column_int(&q, 1); |
| 157 | pEntry->fprev = db_column_int(&q, 2); |
| 158 | pEntry->zUuid = fossil_strdup(db_column_text(&q,3)); |
| 159 | pEntry->mfirt = pEntry->firt; |
| 160 | pEntry->sid = sid++; |
| 161 | pEntry->pPrev = pThread->pLast; |
| 162 | pEntry->pNext = 0; |
| 163 | if( pThread->pLast==0 ){ |
| 164 | pThread->pFirst = pEntry; |
| 165 | }else{ |
| @@ -186,10 +191,11 @@ | |
| 191 | |
| 192 | if( computeHierarchy ){ |
| 193 | /* Compute the hierarchical display order */ |
| 194 | pEntry = pThread->pFirst; |
| 195 | pEntry->nIndent = 1; |
| 196 | pThread->mxIndent = 1; |
| 197 | forumentry_add_to_display(pThread, pEntry); |
| 198 | forumthread_display_order(pThread, pEntry); |
| 199 | } |
| 200 | |
| 201 | /* Return the result */ |
| @@ -405,18 +411,22 @@ | |
| 411 | const char *zUuid; |
| 412 | char *zDate; |
| 413 | const char *zSel; |
| 414 | int notAnon = login_is_individual(); |
| 415 | int iPrev = -1; |
| 416 | int iIndentScale = 4; |
| 417 | |
| 418 | pThread = forumthread_create(froot, 1); |
| 419 | for(p=pThread->pFirst; p; p=p->pNext){ |
| 420 | if( p->fpid==target ){ |
| 421 | while( p->pEdit ) p = p->pEdit; |
| 422 | target = p->fpid; |
| 423 | break; |
| 424 | } |
| 425 | } |
| 426 | while( iIndentScale>1 && iIndentScale*pThread->mxIndent>25 ){ |
| 427 | iIndentScale--; |
| 428 | } |
| 429 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 430 | int isPrivate; /* True for posts awaiting moderation */ |
| 431 | int sameUser; /* True if reader is also the poster */ |
| 432 | pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); |
| @@ -432,11 +442,11 @@ | |
| 442 | zSel = p->fpid==target ? " forumSel" : ""; |
| 443 | if( p->nIndent==1 ){ |
| 444 | @ <div id='forum%d(fpid)' class='forumHierRoot%s(zSel)'> |
| 445 | }else{ |
| 446 | @ <div id='forum%d(fpid)' class='forumHier%s(zSel)' \ |
| 447 | @ style='margin-left: %d((p->nIndent-1)*iIndentScale)ex;'> |
| 448 | } |
| 449 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| 450 | if( pPost==0 ) continue; |
| 451 | if( pPost->zThreadTitle ){ |
| 452 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 453 |