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.

drh 2019-07-17 21:23 trunk
Commit 0cec52e08eef79ddbfee0ed9e8a8165fbab70a72caf81f4636929a664e09b555
1 file changed +12 -2
+12 -2
--- src/forum.c
+++ src/forum.c
@@ -36,10 +36,11 @@
3636
int fpid; /* rid for this entry */
3737
int fprev; /* zero if initial entry. non-zero if an edit */
3838
int firt; /* This entry replies to firt */
3939
int mfirt; /* Root in-reply-to */
4040
int nReply; /* Number of replies to this entry */
41
+ int sid; /* Serial ID number */
4142
char *zUuid; /* Artifact hash */
4243
ForumEntry *pLeaf; /* Most recent edit for this entry */
4344
ForumEntry *pEdit; /* This entry is an edit of pEdit */
4445
ForumEntry *pNext; /* Next in chronological order */
4546
ForumEntry *pPrev; /* Previous in chronological order */
@@ -53,10 +54,11 @@
5354
struct ForumThread {
5455
ForumEntry *pFirst; /* First entry in chronological order */
5556
ForumEntry *pLast; /* Last entry in chronological order */
5657
ForumEntry *pDisplay; /* Entries in display order */
5758
ForumEntry *pTail; /* Last on the display list */
59
+ int mxIndent; /* Maximum indentation level */
5860
};
5961
#endif /* INTERFACE */
6062
6163
/*
6264
** Delete a complete ForumThread and all its entries.
@@ -122,11 +124,12 @@
122124
pBase->nReply++;
123125
pPrev = p;
124126
}
125127
}
126128
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;
128131
forumentry_add_to_display(pThread, pPrev);
129132
forumthread_display_order(pThread, pPrev);
130133
}
131134
}
132135
@@ -135,10 +138,11 @@
135138
*/
136139
static ForumThread *forumthread_create(int froot, int computeHierarchy){
137140
ForumThread *pThread;
138141
ForumEntry *pEntry;
139142
Stmt q;
143
+ int sid = 1;
140144
pThread = fossil_malloc( sizeof(*pThread) );
141145
memset(pThread, 0, sizeof(*pThread));
142146
db_prepare(&q,
143147
"SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)"
144148
" FROM forumpost"
@@ -151,10 +155,11 @@
151155
pEntry->fpid = db_column_int(&q, 0);
152156
pEntry->firt = db_column_int(&q, 1);
153157
pEntry->fprev = db_column_int(&q, 2);
154158
pEntry->zUuid = fossil_strdup(db_column_text(&q,3));
155159
pEntry->mfirt = pEntry->firt;
160
+ pEntry->sid = sid++;
156161
pEntry->pPrev = pThread->pLast;
157162
pEntry->pNext = 0;
158163
if( pThread->pLast==0 ){
159164
pThread->pFirst = pEntry;
160165
}else{
@@ -186,10 +191,11 @@
186191
187192
if( computeHierarchy ){
188193
/* Compute the hierarchical display order */
189194
pEntry = pThread->pFirst;
190195
pEntry->nIndent = 1;
196
+ pThread->mxIndent = 1;
191197
forumentry_add_to_display(pThread, pEntry);
192198
forumthread_display_order(pThread, pEntry);
193199
}
194200
195201
/* Return the result */
@@ -405,18 +411,22 @@
405411
const char *zUuid;
406412
char *zDate;
407413
const char *zSel;
408414
int notAnon = login_is_individual();
409415
int iPrev = -1;
416
+ int iIndentScale = 4;
410417
411418
pThread = forumthread_create(froot, 1);
412419
for(p=pThread->pFirst; p; p=p->pNext){
413420
if( p->fpid==target ){
414421
while( p->pEdit ) p = p->pEdit;
415422
target = p->fpid;
416423
break;
417424
}
425
+ }
426
+ while( iIndentScale>1 && iIndentScale*pThread->mxIndent>25 ){
427
+ iIndentScale--;
418428
}
419429
for(p=pThread->pDisplay; p; p=p->pDisplay){
420430
int isPrivate; /* True for posts awaiting moderation */
421431
int sameUser; /* True if reader is also the poster */
422432
pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0);
@@ -432,11 +442,11 @@
432442
zSel = p->fpid==target ? " forumSel" : "";
433443
if( p->nIndent==1 ){
434444
@ <div id='forum%d(fpid)' class='forumHierRoot%s(zSel)'>
435445
}else{
436446
@ <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;'>
438448
}
439449
pPost = manifest_get(fpid, CFTYPE_FORUM, 0);
440450
if( pPost==0 ) continue;
441451
if( pPost->zThreadTitle ){
442452
@ <h1>%h(pPost->zThreadTitle)</h1>
443453
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button