Fossil

Check-in [31b5dffa76]
Login

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

Overview
Comment:Enhance the "fileage" webpage so that it shows ages relative to current time rather than relative to the last checkin, so that it shows associated checkin comments, and so that it is styled using CSS.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 31b5dffa768db70cefd4a5c736582d70dcc698ce
User & Date: drh 2014-12-16 14:46:55.712
Context
2014-12-16
19:00
Fix a bug in the "fossil undo" command, introduced when the sqlite3_table_column_metadata() function was used to reimplement the db_table_exists() routine, just a few days ago. ... (check-in: b6ed6241e1 user: drh tags: trunk)
16:32
Show the ages of files in the file tree viewer. ... (check-in: f8d54372e7 user: drh tags: age-in-file-tree)
14:46
Enhance the "fileage" webpage so that it shows ages relative to current time rather than relative to the last checkin, so that it shows associated checkin comments, and so that it is styled using CSS. ... (check-in: 31b5dffa76 user: drh tags: trunk)
02:37
Improvements to HTTP redirect on sync. ... (check-in: 3a00b612d4 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/browse.c.
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859


860
861
862
863



864
865
866
867
868
869
870

871













872


873
874
875
876
877
878
879



880
881
882



883
884

885

886
887



888
889
890
891
892
893
894
895
896

897
898
**   name=VERSION   Selects the checkin version (default=tip).
**   glob=STRING    Only shows files matching this glob pattern
**                  (e.g. *.c or *.txt).
*/
void fileage_page(void){
  int rid;
  const char *zName;
  char *zBaseTime;
  const char *zGlob;
  Stmt q;
  double baseTime;
  int lastMid = -1;
  login_check_credentials();
  if( !g.perm.Read ){ login_needed(); return; }
  zName = P("name");
  if( zName==0 ) zName = "tip";
  rid = symbolic_name_to_rid(zName, "ci");
  if( rid==0 ){
    fossil_fatal("not a valid check-in: %s", zName);
  }
  style_submenu_element("Tree-View", "Tree-View", "%R/tree?ci=%T", zName);
  style_header("File Ages");
  zGlob = P("glob");
  compute_fileage(rid,zGlob);


  baseTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
  zBaseTime = db_text("","SELECT datetime(%.20g%s)", baseTime, timeline_utc());
  @ <h2>File Ages For Check-in
  @ %z(href("%R/info?name=%T",zName))%h(zName)</a></h2>



  @
  @ <p>The times given are relative to
  @ %z(href("%R/timeline?c=%T",zBaseTime))%s(zBaseTime)</a>, which is the
  @ check-in time for
  @ %z(href("%R/info?name=%T",zName))%h(zName)</a></p>
  @
  @ <table border=0 cellspacing=0 cellpadding=0>

  db_prepare(&q,













    "SELECT mtime, (SELECT uuid FROM blob WHERE rid=fid), mid, pathname"


    "  FROM fileage"
    " ORDER BY mtime DESC, mid, pathname"
  );
  while( db_step(&q)==SQLITE_ROW ){
    double age = baseTime - db_column_double(&q, 0);
    int mid = db_column_int(&q, 2);
    const char *zFUuid = db_column_text(&q, 1);



    char *zAge = 0;
    if( lastMid!=mid ){
      @ <tr><td colspan=3><hr></tr>



      lastMid = mid;
      zAge = human_readable_age(age);

    }

    @ <tr>
    @ <td>%s(zAge?zAge:"")



    @ <td width="25">
    @ <td>%z(href("%R/artifact/%s?ln", zFUuid))%h(db_column_text(&q, 3))</a>
    @ </tr>
    @
    fossil_free(zAge);
  }
  @ <tr><td colspan=3><hr></tr>
  @ </table>
  db_finalize(&q);

  style_footer();
}







<

|

<












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

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

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

>
|
|
>
>
>
|
|
|



<
|
|
>


836
837
838
839
840
841
842

843
844
845

846
847
848
849
850
851
852
853
854
855
856
857
858
859
860

861
862
863
864
865
866




867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887

888
889
890
891
892
893
894
895
896

897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916

917
918
919
920
921
**   name=VERSION   Selects the checkin version (default=tip).
**   glob=STRING    Only shows files matching this glob pattern
**                  (e.g. *.c or *.txt).
*/
void fileage_page(void){
  int rid;
  const char *zName;

  const char *zGlob;
  Stmt q1, q2;
  double baseTime;

  login_check_credentials();
  if( !g.perm.Read ){ login_needed(); return; }
  zName = P("name");
  if( zName==0 ) zName = "tip";
  rid = symbolic_name_to_rid(zName, "ci");
  if( rid==0 ){
    fossil_fatal("not a valid check-in: %s", zName);
  }
  style_submenu_element("Tree-View", "Tree-View", "%R/tree?ci=%T", zName);
  style_header("File Ages");
  zGlob = P("glob");
  compute_fileage(rid,zGlob);
  db_multi_exec("CREATE INDEX fileage_ix1 ON fileage(mid,pathname);");

  baseTime = db_double(0.0, "SELECT julianday('now');");

  @ <h2>Most recent change to files in checkin
  @ %z(href("%R/info?name=%T",zName))%h(zName)</a>
  if( zGlob && zGlob[0] ){
    @ that match "%h(zGlob)"
  }
  @</h2>




  @
  @ <div class='fileage'><table>
  @ <tr><th>Age</th><th>Files</th><th>Checkin</th></tr>
  db_prepare(&q1,
    "SELECT event.mtime, event.objid, blob.uuid,\n"
    "       coalesce(event.ecomment,event.comment),\n"
    "       coalesce(event.euser,event.user),\n"
    "       coalesce((SELECT value FROM tagxref\n"
    "                  WHERE tagtype>0 AND tagid=%d\n"
    "                    AND rid=event.objid),'trunk')\n"
    "  FROM event, blob\n"
    " WHERE event.objid IN (SELECT mid FROM fileage)\n"
    "   AND blob.rid=event.objid\n"
    " ORDER BY event.mtime DESC;",
    TAG_BRANCH
  );
  db_prepare(&q2,
    "SELECT blob.uuid, filename.name\n"
    "  FROM fileage, blob, filename\n"
    " WHERE fileage.mid=:mid AND filename.fnid=fileage.fnid"
    "   AND blob.rid=fileage.fid;"

  );
  while( db_step(&q1)==SQLITE_ROW ){
    double age = baseTime - db_column_double(&q1, 0);
    int mid = db_column_int(&q1, 1);
    const char *zUuid = db_column_text(&q1, 2);
    const char *zComment = db_column_text(&q1, 3);
    const char *zUser = db_column_text(&q1, 4);
    const char *zBranch = db_column_text(&q1, 5);
    char *zAge = human_readable_age(age);

    @ <tr><td>%s(zAge)</td>
    @ <td>
    db_bind_int(&q2, ":mid", mid);
    while( db_step(&q2)==SQLITE_ROW ){
      const char *zFUuid = db_column_text(&q2,0);
      const char *zFile = db_column_text(&q2,1);
      @ %z(href("%R/artifact/%s",zFUuid))%h(zFile)</a><br>
    }
    db_reset(&q2);
    @ </td>
    @ <td>
    @ %z(href("%R/info/%s",zUuid))[%S(zUuid)]</a>
    @ %W(zComment) (user:
    @ %z(href("%R/timeline?u=%t&c=%t&nd&n=200",zUser,zUuid))%h(zUser)</a>,
    @ branch:
    @ %z(href("%R/timeline?r=%t&c=%t&nd&n=200",zBranch,zUuid))%h(zBranch)</a>)
    @ </td></tr>
    @
    fossil_free(zAge);
  }

  @ </table></div>
  db_finalize(&q1);
  db_finalize(&q2);
  style_footer();
}
Changes to src/style.c.
1217
1218
1219
1220
1221
1222
1223



















1224
1225
1226
1227
1228
1229
1230
  },
  { ".adminLogTable .adminTime",
    "Class for the /admin_log table",
    @ text-align: left;
    @ vertical-align: top;
    @ white-space: nowrap;
  },



















  { 0,
    0,
    0
  }
};

/*







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







1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
  },
  { ".adminLogTable .adminTime",
    "Class for the /admin_log table",
    @ text-align: left;
    @ vertical-align: top;
    @ white-space: nowrap;
  },
  { ".fileage table",
    "The fileage table",
    @ border-spacing: 0;
  },
  { ".fileage td",
    "fileage table cells",
    @ vertical-align: top;
    @ text-align: left;
    @ border-top: 1px solid black;
  },
  { ".fileage td:first-child",
    "fileage first column (the age)",
    @ white-space: nowrap;
  },
  { ".fileage td:first-child + td",
    "fileage second column (the filename)",
    @ padding-left: 1em;
    @ padding-right: 1em;
  },
  { 0,
    0,
    0
  }
};

/*