Fossil

Check-in [e36f693f]
Login

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

Overview
Comment:Add the "View" selector to the /finfo page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sticky-timeline-style
Files: files | file ages | folders
SHA3-256: e36f693f7afe35593caec99de8abe5869a25d1f582c627ef297e7536795f09e6
User & Date: drh 2017-11-29 13:25:34.035
Context
2017-11-29
14:02
All timelines use the "ss" display preferences cookie. ... (Closed-Leaf check-in: 6314b4ed user: drh tags: sticky-timeline-style)
13:25
Add the "View" selector to the /finfo page. ... (check-in: e36f693f user: drh tags: sticky-timeline-style)
11:46
Change the name of "Normal View" to "Modern View". Add the "View" modifier to all choices in the view mode selector, to help make it clear what the selector is for. ... (check-in: 2a8598f9 user: drh tags: sticky-timeline-style)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/finfo.c.
312
313
314
315
316
317
318
319
320
321
322
323


324
325
326
327
328











329
330
331
332
333
334


335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
  int brBg = P("brbg")!=0;
  int uBg = P("ubg")!=0;
  int fDebug = atoi(PD("debug","0"));
  int fShowId = P("showid")!=0;
  Stmt qparent;
  int iTableId = timeline_tableid();
  int bHashBeforeComment = 0; /* Show hash before the comment */
  int bHashAfterComment = 0;  /* Show hash after the comment */
  int bHashInDetail = 0;      /* Show the hash inside the detail section */
  int bShowDetail;            /* Show the detail section */
  int bSeparateDetail;        /* Detail section in a separate column */
  int eCommentFormat;         /* value for timeline-comment-format */



  login_check_credentials();
  if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
  style_header("File History");
  login_anonymous_available();











  url_initialize(&url, "finfo");
  if( brBg ) url_add_parameter(&url, "brbg", 0);
  if( uBg ) url_add_parameter(&url, "ubg", 0);
  baseCheckin = name_to_rid_www("ci");
  zPrevDate[0] = 0;
  zFilename = PD("name","");


  eCommentFormat = db_get_int("timeline-comment-format", 4);
  bShowDetail = (eCommentFormat & 1)==0;  /* Bit 0 suppresses the comment */
  bSeparateDetail = (eCommentFormat & 8)!=0; 
  switch( (eCommentFormat>>1)&3 ){
    case 1:  bHashAfterComment = 1;  break;
    case 2:  bHashInDetail = 1;      break;
    default: bHashBeforeComment = 1; break;
  }

  fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
  if( fnid==0 ){
    @ No such file: %h(zFilename)
    style_footer();
    return;
  }
  if( g.perm.Admin ){







<




>
>





>
>
>
>
>
>
>
>
>
>
>






>
>








>







312
313
314
315
316
317
318

319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
  int brBg = P("brbg")!=0;
  int uBg = P("ubg")!=0;
  int fDebug = atoi(PD("debug","0"));
  int fShowId = P("showid")!=0;
  Stmt qparent;
  int iTableId = timeline_tableid();
  int bHashBeforeComment = 0; /* Show hash before the comment */

  int bHashInDetail = 0;      /* Show the hash inside the detail section */
  int bShowDetail;            /* Show the detail section */
  int bSeparateDetail;        /* Detail section in a separate column */
  int eCommentFormat;         /* value for timeline-comment-format */
  int tmFlags = 0;            /* Viewing mode */
  const char *zStyle;         /* Viewing mode name */

  login_check_credentials();
  if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
  style_header("File History");
  login_anonymous_available();
  cookie_parse(DISPLAY_SETTINGS_COOKIE);
  tmFlags = timeline_ss_submenu();
  if( tmFlags & TIMELINE_COLUMNAR ){
    zStyle = "Columnar";
  }else if( tmFlags & TIMELINE_COMPACT ){
    zStyle = "Compact";
  }else if( tmFlags & TIMELINE_VERBOSE ){
    zStyle = "Verbose";
  }else{
    zStyle = "Modern";
  }
  url_initialize(&url, "finfo");
  if( brBg ) url_add_parameter(&url, "brbg", 0);
  if( uBg ) url_add_parameter(&url, "ubg", 0);
  baseCheckin = name_to_rid_www("ci");
  zPrevDate[0] = 0;
  zFilename = PD("name","");
  cookie_render();
#if 0
  eCommentFormat = db_get_int("timeline-comment-format", 4);
  bShowDetail = (eCommentFormat & 1)==0;  /* Bit 0 suppresses the comment */
  bSeparateDetail = (eCommentFormat & 8)!=0; 
  switch( (eCommentFormat>>1)&3 ){
    case 1:  bHashAfterComment = 1;  break;
    case 2:  bHashInDetail = 1;      break;
    default: bHashBeforeComment = 1; break;
  }
#endif
  fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
  if( fnid==0 ){
    @ No such file: %h(zFilename)
    style_footer();
    return;
  }
  if( g.perm.Admin ){
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
      fossil_free(zUuid);
    }
  }else{
    blob_appendf(&title, "History of ");
    hyperlinked_path(zFilename, &title, 0, "tree", "");
    if( fShowId ) blob_appendf(&title, " (%d)", fnid);
  }
  style_submenu_jsbutton("Advanced", STYLE_BASIC, "reclutter()");
  style_submenu_jsbutton("Basic", STYLE_CLUTTER, "declutter()");
  @ <h2>%b(&title)</h2>
  blob_reset(&title);
  pGraph = graph_init();
  @ <table id="timelineTable%d(iTableId)" class="timelineTable">
  if( baseCheckin ){
    db_prepare(&qparent,
      "SELECT DISTINCT pid FROM mlink"







<
<







458
459
460
461
462
463
464


465
466
467
468
469
470
471
      fossil_free(zUuid);
    }
  }else{
    blob_appendf(&title, "History of ");
    hyperlinked_path(zFilename, &title, 0, "tree", "");
    if( fShowId ) blob_appendf(&title, " (%d)", fnid);
  }


  @ <h2>%b(&title)</h2>
  blob_reset(&title);
  pGraph = graph_init();
  @ <table id="timelineTable%d(iTableId)" class="timelineTable">
  if( baseCheckin ){
    db_prepare(&qparent,
      "SELECT DISTINCT pid FROM mlink"
512
513
514
515
516
517
518

519
520
521
522




523
524


525
526
527
528
529
530
531

532
533
534
535


536
537
538
539
540
541
542


543

544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
    memcpy(zTime, &zDate[11], 5);
    zTime[5] = 0;
    @ <tr><td class="timelineTime">
    @ %z(href("%R/artifact/%!S",zUuid))%s(zTime)</a></td>
    @ <td class="timelineGraph"><div id="m%d(gidx)" class="tl-nodemark"></div>
    @ </td>
    if( zBgClr && zBgClr[0] ){

      @ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
    }else{
      @ <td class="timelineTableCell">
    }




    if( bHashBeforeComment && zUuid ){
      hyperlink_to_uuid(zUuid);


    }
    @ <span class="timelineComment timelineCheckinComment" \
    @  onclick='toggleDetail(%d(frid))'>
    @ %W(zCom)</span>
    if( bHashAfterComment && zUuid ){
      hyperlink_to_uuid(zUuid);
    }

    if( bShowDetail ){
      @ <span class='timelineEllipsis anticlutter' id='ellipsis-%d(frid)' \
      @  onclick='toggleDetail(%d(frid))'>...</span>
      if( bSeparateDetail ){


        if( zBgClr && zBgClr[0] ){
          @ <td class="timelineTableCell timelineDetailCell"
          @  style="background-color: %h(zBgClr);">
        }else{
          @ <td class="timelineTableCell timelineDetailCell">
        }
      }


      cgi_printf("<span class='clutter' id='detail-%d'>", frid);

      cgi_printf("<span class='timelineDetail timelineCheckinDetail'>(");
      if( zUuid && bHashInDetail ){
        @ file: %z(href("%R/artifact/%!S",zUuid))[%S(zUuid)]</a>
        if( fShowId ){
          int srcId = delta_source_rid(frid);
          if( srcId>0 ){
            @ id: %d(frid)&larr;%d(srcId)
          }else{
            @ id: %d(frid)
          }
        }
      }
      @ check-in:
      hyperlink_to_uuid(zCkin);
      if( fShowId ){
        @ (%d(fmid))
      }
      @ user:
      hyperlink_to_user(zUser, zDate, ",");
      @ branch: %z(href("%R/timeline?t=%T&n=200",zBr))%h(zBr)</a>,
      @ size: %d(szFile))
      if( zUuid && origCheckin==0 ){
        if( nParent==0 ){
          @ <b>Added</b>
        }else if( pfnid ){
          char *zPrevName = db_text(0,"SELECT name FROM filename WHERE fnid=%d",
                                    pfnid);
          @ <b>Renamed</b> from
          @ %z(href("%R/finfo?name=%t", zPrevName))%h(zPrevName)</a>
        }
      }
      if( zUuid==0 ){
        char *zNewName;
        zNewName = db_text(0,
          "SELECT name FROM filename WHERE fnid = "
          "   (SELECT fnid FROM mlink"
          "     WHERE mid=%d"
          "       AND pfnid IN (SELECT fnid FROM filename WHERE name=%Q))",
          fmid, zFilename);
        if( zNewName ){
          @ <b>Renamed</b> to
          @ %z(href("%R/finfo?name=%t",zNewName))%h(zNewName)</a>
          fossil_free(zNewName);
        }else{
          @ <b>Deleted</b>
        }
      }
    }
    if( g.perm.Hyperlink && zUuid ){
      const char *z = zFilename;
      @ <span id='links-%d(frid)'><span class='timelineExtraLinks'>
      @ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
      @ [annotate]</a>







>
|

|

>
>
>
>
|
|
>
>
|
<
<
<
<
<

>
|


|
>
>
|
<
|
|
|
<

>
>
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<







525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545





546
547
548
549
550
551
552
553
554

555
556
557

558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607

608
609
610
611
612
613
614
    memcpy(zTime, &zDate[11], 5);
    zTime[5] = 0;
    @ <tr><td class="timelineTime">
    @ %z(href("%R/artifact/%!S",zUuid))%s(zTime)</a></td>
    @ <td class="timelineGraph"><div id="m%d(gidx)" class="tl-nodemark"></div>
    @ </td>
    if( zBgClr && zBgClr[0] ){
      @ <td class="timeline%s(zStyle)Cell" \
      @  style="background-color: %h(zBgClr);">
    }else{
      @ <td class="timeline%s(zStyle)Cell">
    }
    if( tmFlags & TIMELINE_COMPACT ){
      @ <span class='timelineCompactComment' onclick='toggleDetail(%d(frid))'>
    }else{
      @ <span class='timeline%s(zStyle)Comment'>
      if( (tmFlags & TIMELINE_VERBOSE)!=0 && zUuid ){
        hyperlink_to_uuid(zUuid);
        @ part of check-in \
        hyperlink_to_uuid(zCkin);
      }





    }
    @ %W(zCom)</span>
    if( (tmFlags & TIMELINE_COMPACT)!=0 ){
      @ <span class='timelineEllipsis anticlutter' id='ellipsis-%d(frid)' \
      @  onclick='toggleDetail(%d(frid))'>...</span>
      @ <span class='clutter timelineCompactDetail'
    }
    if( tmFlags & TIMELINE_COLUMNAR ){
      if( zBgClr && zBgClr[0] ){

        @ <td class="timelineDetailCell" style="background-color: %h(zBgClr);">
      }else{
        @ <td class="timelineDetailCell">

      }
    }
    if( tmFlags & TIMELINE_COMPACT ){
      cgi_printf("<span class='clutter' id='detail-%d'>",frid);
    }
    cgi_printf("<span class='timeline%sDetail'>", zStyle);
    if( zUuid && (tmFlags & TIMELINE_VERBOSE)==0 ){
      @ file:&nbsp;%z(href("%R/artifact/%!S",zUuid))[%S(zUuid)]</a>
      if( fShowId ){
        int srcId = delta_source_rid(frid);
        if( srcId>0 ){
          @ id:&nbsp;%d(frid)&larr;%d(srcId)
        }else{
          @ id:&nbsp;%d(frid)
        }
      }
    }
    @ check-in:&nbsp;\
    hyperlink_to_uuid(zCkin);
    if( fShowId ){
      @ (%d(fmid))
    }
    @ user:&nbsp;\
    hyperlink_to_user(zUser, zDate, ",");
    @ branch:&nbsp;%z(href("%R/timeline?t=%T&n=200",zBr))%h(zBr)</a>,
    @ size:&nbsp;%d(szFile))
    if( zUuid && origCheckin==0 ){
      if( nParent==0 ){
        @ <b>Added</b>
      }else if( pfnid ){
        char *zPrevName = db_text(0,"SELECT name FROM filename WHERE fnid=%d",
                                  pfnid);
        @ <b>Renamed</b> from
        @ %z(href("%R/finfo?name=%t", zPrevName))%h(zPrevName)</a>
      }
    }
    if( zUuid==0 ){
      char *zNewName;
      zNewName = db_text(0,
        "SELECT name FROM filename WHERE fnid = "
        "   (SELECT fnid FROM mlink"
        "     WHERE mid=%d"
        "       AND pfnid IN (SELECT fnid FROM filename WHERE name=%Q))",
        fmid, zFilename);
      if( zNewName ){
        @ <b>Renamed</b> to
        @ %z(href("%R/finfo?name=%t",zNewName))%h(zNewName)</a>
        fossil_free(zNewName);
      }else{
        @ <b>Deleted</b>

      }
    }
    if( g.perm.Hyperlink && zUuid ){
      const char *z = zFilename;
      @ <span id='links-%d(frid)'><span class='timelineExtraLinks'>
      @ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
      @ [annotate]</a>
612
613
614
615
616
617
618
619

620


621
622
623
624
625
626
627
          @ %d(aParent[ii])
        }
      }
      zAncLink = href("%R/finfo?name=%T&ci=%!S&debug=1",zFilename,zCkin);
      @ %z(zAncLink)[ancestry]</a>
    }
    tag_private_status(frid);
    if( bShowDetail ){

      @ </span></span>


    }
    @ </td></tr>
  }
  db_finalize(&q);
  db_finalize(&qparent);
  if( pGraph ){
    graph_finish(pGraph, 1);







|
>

>
>







630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
          @ %d(aParent[ii])
        }
      }
      zAncLink = href("%R/finfo?name=%T&ci=%!S&debug=1",zFilename,zCkin);
      @ %z(zAncLink)[ancestry]</a>
    }
    tag_private_status(frid);
    /* End timelineDetail */
    if( tmFlags & TIMELINE_COMPACT ){
      @ </span></span>
    }else{
      @ </span>
    }
    @ </td></tr>
  }
  db_finalize(&q);
  db_finalize(&qparent);
  if( pGraph ){
    graph_finish(pGraph, 1);
Changes to src/timeline.c.
1322
1323
1324
1325
1326
1327
1328

























1329
1330
1331
1332
1333
1334
1335
    }
    assert( i<=count(az) );
  }
  if( i>2 ){
    style_submenu_multichoice("y", i/2, az, isDisabled);
  }
}


























/*
** If the zChng string is not NULL, then it should be a comma-separated
** list of glob patterns for filenames.  Add an term to the WHERE clause
** for the SQL statement under construction that excludes any check-in that
** does not modify one or more files matching the globs.
*/







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
    }
    assert( i<=count(az) );
  }
  if( i>2 ){
    style_submenu_multichoice("y", i/2, az, isDisabled);
  }
}

/*
** Add the select/option box to the timeline submenu that is used to
** set the ss= parameter that determines the viewing mode.
**
** Return the TIMELINE_* value appropriate for the view-style.
*/
int timeline_ss_submenu(void){
  static const char *azViewStyles[] = {
     "m", "Modern View",
     "c", "Compact View",
     "v", "Verbose View",
     "j", "Columnar View",
  };
  int tmFlags;
  cookie_link_parameter("ss","ss","m");
  style_submenu_multichoice("ss", 4, azViewStyles, 0);
  switch( PD("ss","m")[0] ){
    case 'c':  tmFlags = TIMELINE_COMPACT;  break;
    case 'v':  tmFlags = TIMELINE_VERBOSE;  break;
    case 'j':  tmFlags = TIMELINE_COLUMNAR; break;
    default:   tmFlags = TIMELINE_MODERN;   break;
  }    
  return tmFlags;
}

/*
** If the zChng string is not NULL, then it should be a comma-separated
** list of glob patterns for filenames.  Add an term to the WHERE clause
** for the SQL statement under construction that excludes any check-in that
** does not modify one or more files matching the globs.
*/
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
  int pd_rid;
  double rBefore, rAfter, rCirca;     /* Boundary times */
  const char *z;
  char *zOlderButton = 0;             /* URL for Older button at the bottom */
  char *zNewerButton = 0;             /* URL for Newer button at the top */
  int selectedRid = -9999999;         /* Show a highlight on this RID */
  int disableY = 0;                   /* Disable type selector on submenu */
  char cViewStyle;                    /* Overall style of the page */
  static const char *azViewStyles[] = {
     "m", "Modern View",
     "c", "Compact View",
     "v", "Verbose View",
     "j", "Columnar View",
  };

  /* Set number of rows to display */
  cookie_parse(DISPLAY_SETTINGS_COOKIE);
  cookie_read_parameter("n","n");
  z = P("n");
  if( z==0 ) z = db_get("timeline-default-length",0);
  if( z ){







<
<
<
<
<
<
<







1688
1689
1690
1691
1692
1693
1694







1695
1696
1697
1698
1699
1700
1701
  int pd_rid;
  double rBefore, rAfter, rCirca;     /* Boundary times */
  const char *z;
  char *zOlderButton = 0;             /* URL for Older button at the bottom */
  char *zNewerButton = 0;             /* URL for Newer button at the top */
  int selectedRid = -9999999;         /* Show a highlight on this RID */
  int disableY = 0;                   /* Disable type selector on submenu */








  /* Set number of rows to display */
  cookie_parse(DISPLAY_SETTINGS_COOKIE);
  cookie_read_parameter("n","n");
  z = P("n");
  if( z==0 ) z = db_get("timeline-default-length",0);
  if( z ){
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
    }
  }else{
    z = "50";
    nEntry = 50;
  }
  cgi_replace_query_parameter("n",z);
  cookie_write_parameter("n","n",0);
  cookie_link_parameter("ss","ss","n");
  cViewStyle = PD("ss","n")[0];
  style_submenu_multichoice("ss", 4, azViewStyles, 0);
  

  /* To view the timeline, must have permission to read project data.
  */
  pd_rid = name_to_typed_rid(P("dp"),"ci");
  if( pd_rid ){
    p_rid = d_rid = pd_rid;
  }







<
<
<
|







1710
1711
1712
1713
1714
1715
1716



1717
1718
1719
1720
1721
1722
1723
1724
    }
  }else{
    z = "50";
    nEntry = 50;
  }
  cgi_replace_query_parameter("n",z);
  cookie_write_parameter("n","n",0);



  tmFlags |= timeline_ss_submenu();  

  /* To view the timeline, must have permission to read project data.
  */
  pd_rid = name_to_typed_rid(P("dp"),"ci");
  if( pd_rid ){
    p_rid = d_rid = pd_rid;
  }
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
  }
  if( (zTagSql && db_int(0,"SELECT count(*) "
      "FROM tagxref NATURAL JOIN tag WHERE %s",zTagSql/*safe-for-%s*/)<=nEntry)
  ){
    nEntry = -1;
    zCirca = 0;
  }
  switch( cViewStyle ){
    case 'c':  tmFlags |= TIMELINE_COMPACT;  break;
    case 'v':  tmFlags |= TIMELINE_VERBOSE;  break;
    case 'j':  tmFlags |= TIMELINE_COLUMNAR; break;
    default:   tmFlags |= TIMELINE_MODERN;   break;
  }    
  if( zType[0]=='a' ){
    tmFlags |= TIMELINE_BRIEF | TIMELINE_GRAPH;
  }else{
    tmFlags |= TIMELINE_GRAPH;
  }
  if( PB("ng") || zSearch!=0 ){
    tmFlags &= ~TIMELINE_GRAPH;







<
<
<
<
<
<







1784
1785
1786
1787
1788
1789
1790






1791
1792
1793
1794
1795
1796
1797
  }
  if( (zTagSql && db_int(0,"SELECT count(*) "
      "FROM tagxref NATURAL JOIN tag WHERE %s",zTagSql/*safe-for-%s*/)<=nEntry)
  ){
    nEntry = -1;
    zCirca = 0;
  }






  if( zType[0]=='a' ){
    tmFlags |= TIMELINE_BRIEF | TIMELINE_GRAPH;
  }else{
    tmFlags |= TIMELINE_GRAPH;
  }
  if( PB("ng") || zSearch!=0 ){
    tmFlags &= ~TIMELINE_GRAPH;