Fossil

Check-in [9757488a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixes to the forum hierarchical display algorithm.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | forum-v2
Files: files | file ages | folders
SHA3-256: 9757488a5dc0edc899cc5fca0c78b73dc43a5f808cb6b5189edf722fe771a1ca
User & Date: drh 2018-07-26 01:02:58
Context
2018-07-26
01:33
Automatic scroll to the specific message of the thread when calling /info on a forum message. check-in: 8f0e18f4 user: drh tags: forum-v2
01:02
Fixes to the forum hierarchical display algorithm. check-in: 9757488a user: drh tags: forum-v2
2018-07-25
22:34
Begin adding style to the forum display. check-in: 8eccd9a2 user: drh tags: forum-v2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/default_css.txt.

   685    685   }
   686    686   div.forumHier, div.forumTime {
   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  +}

Changes to src/forum.c.

   101    101   static void forumthread_display_order(
   102    102     ForumThread *pThread,
   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;
   114    114     }
   115    115   }
................................................................................
   146    146     /* Establish which entries are the latest edit.  After this loop
   147    147     ** completes, entries that have non-NULL pLeaf should not be
   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 */
   167    167     pEntry = pThread->pFirst;
   168    168     pEntry->nIndent = 1;
................................................................................
   268    268       int fpid = db_column_int(&q, 0);
   269    269       int fprev = db_column_int(&q, 1);
   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 ){
   281    285         @ edit of %d(fprev)
   282    286       }
................................................................................
   322    326   
   323    327   /*
   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;
   360    396         int isPrivate = content_is_private(fpid);
   361    397         @ <p><form action="%R/forumedit" method="POST">
................................................................................
   380    416         }
   381    417         @ </form></p>
   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   ** WEBPAGE: forumthread
   399    429   **