Fossil SCM

Add the ability to control the timeline date and time format from the Admin/Timeline setup menu.

drh 2013-10-18 11:46 trunk
Commit 403d93728730587cf9a32025c495d5bee7a5ee51
+40
--- src/setup.c
+++ src/setup.c
@@ -850,10 +850,37 @@
850850
@ <span class="textareaLabel">%s(zLabel)</span>
851851
}
852852
}
853853
}
854854
855
+/*
856
+** Generate a text box for an attribute.
857
+*/
858
+static void multiple_choice_attribute(
859
+ const char *zLabel, /* The text label on the menu */
860
+ const char *zVar, /* The corresponding row in the VAR table */
861
+ const char *zQP, /* The query parameter */
862
+ const char *zDflt, /* Default value if VAR table entry does not exist */
863
+ int nChoice, /* Number of choices */
864
+ const char **azChoice /* Choices. 2 per choice: (VAR value, Display) */
865
+){
866
+ const char *z = db_get(zVar, (char*)zDflt);
867
+ const char *zQ = P(zQP);
868
+ int i;
869
+ if( zQ && fossil_strcmp(zQ,z)!=0){
870
+ login_verify_csrf_secret();
871
+ db_set(zVar, zQ, 0);
872
+ z = zQ;
873
+ }
874
+ @ <select size="1" name="%s(zQP)" id="id%s(zQP)">
875
+ for(i=0; i<nChoice*2; i+=2){
876
+ const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : "";
877
+ @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option>
878
+ }
879
+ @ </select>
880
+}
881
+
855882
856883
/*
857884
** WEBPAGE: setup_access
858885
*/
859886
void setup_access(void){
@@ -1124,10 +1151,15 @@
11241151
** WEBPAGE: setup_timeline
11251152
*/
11261153
void setup_timeline(void){
11271154
double tmDiff;
11281155
char zTmDiff[20];
1156
+ static const char *azTimeFormats[] = {
1157
+ "0", "HH:MM",
1158
+ "1", "HH:MM:SS",
1159
+ "2", "YYYY-MM-DD HH:MM"
1160
+ };
11291161
login_check_credentials();
11301162
if( !g.perm.Setup ){
11311163
login_needed();
11321164
}
11331165
@@ -1167,10 +1199,18 @@
11671199
@ %s(zTmDiff) hours behind UTC.</p>
11681200
}else{
11691201
@ %s(zTmDiff) hours ahead of UTC.</p>
11701202
}
11711203
1204
+ @ <hr />
1205
+ multiple_choice_attribute("Per-Item Time Format", "timeline-date-format", "tdf", "0",
1206
+ 3, azTimeFormats);
1207
+ @ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
1208
+ @ in a separate box (using CSS class "timelineDate") whenever the date changes.
1209
+ @ With the "YYYY-MM-DD&nbsp;HH:MM" format, the complete date and time is shown on
1210
+ @ every timeline entry (using the CSS class "timelineTime").</p>
1211
+
11721212
@ <hr />
11731213
onoff_attribute("Show version differences by default",
11741214
"show-version-diffs", "vdiff", 0, 0);
11751215
@ <p>On the version-information pages linked from the timeline can either
11761216
@ show complete diffs of all file changes, or can just list the names of
11771217
--- src/setup.c
+++ src/setup.c
@@ -850,10 +850,37 @@
850 @ <span class="textareaLabel">%s(zLabel)</span>
851 }
852 }
853 }
854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
856 /*
857 ** WEBPAGE: setup_access
858 */
859 void setup_access(void){
@@ -1124,10 +1151,15 @@
1124 ** WEBPAGE: setup_timeline
1125 */
1126 void setup_timeline(void){
1127 double tmDiff;
1128 char zTmDiff[20];
 
 
 
 
 
1129 login_check_credentials();
1130 if( !g.perm.Setup ){
1131 login_needed();
1132 }
1133
@@ -1167,10 +1199,18 @@
1167 @ %s(zTmDiff) hours behind UTC.</p>
1168 }else{
1169 @ %s(zTmDiff) hours ahead of UTC.</p>
1170 }
1171
 
 
 
 
 
 
 
 
1172 @ <hr />
1173 onoff_attribute("Show version differences by default",
1174 "show-version-diffs", "vdiff", 0, 0);
1175 @ <p>On the version-information pages linked from the timeline can either
1176 @ show complete diffs of all file changes, or can just list the names of
1177
--- src/setup.c
+++ src/setup.c
@@ -850,10 +850,37 @@
850 @ <span class="textareaLabel">%s(zLabel)</span>
851 }
852 }
853 }
854
855 /*
856 ** Generate a text box for an attribute.
857 */
858 static void multiple_choice_attribute(
859 const char *zLabel, /* The text label on the menu */
860 const char *zVar, /* The corresponding row in the VAR table */
861 const char *zQP, /* The query parameter */
862 const char *zDflt, /* Default value if VAR table entry does not exist */
863 int nChoice, /* Number of choices */
864 const char **azChoice /* Choices. 2 per choice: (VAR value, Display) */
865 ){
866 const char *z = db_get(zVar, (char*)zDflt);
867 const char *zQ = P(zQP);
868 int i;
869 if( zQ && fossil_strcmp(zQ,z)!=0){
870 login_verify_csrf_secret();
871 db_set(zVar, zQ, 0);
872 z = zQ;
873 }
874 @ <select size="1" name="%s(zQP)" id="id%s(zQP)">
875 for(i=0; i<nChoice*2; i+=2){
876 const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : "";
877 @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option>
878 }
879 @ </select>
880 }
881
882
883 /*
884 ** WEBPAGE: setup_access
885 */
886 void setup_access(void){
@@ -1124,10 +1151,15 @@
1151 ** WEBPAGE: setup_timeline
1152 */
1153 void setup_timeline(void){
1154 double tmDiff;
1155 char zTmDiff[20];
1156 static const char *azTimeFormats[] = {
1157 "0", "HH:MM",
1158 "1", "HH:MM:SS",
1159 "2", "YYYY-MM-DD HH:MM"
1160 };
1161 login_check_credentials();
1162 if( !g.perm.Setup ){
1163 login_needed();
1164 }
1165
@@ -1167,10 +1199,18 @@
1199 @ %s(zTmDiff) hours behind UTC.</p>
1200 }else{
1201 @ %s(zTmDiff) hours ahead of UTC.</p>
1202 }
1203
1204 @ <hr />
1205 multiple_choice_attribute("Per-Item Time Format", "timeline-date-format", "tdf", "0",
1206 3, azTimeFormats);
1207 @ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
1208 @ in a separate box (using CSS class "timelineDate") whenever the date changes.
1209 @ With the "YYYY-MM-DD&nbsp;HH:MM" format, the complete date and time is shown on
1210 @ every timeline entry (using the CSS class "timelineTime").</p>
1211
1212 @ <hr />
1213 onoff_attribute("Show version differences by default",
1214 "show-version-diffs", "vdiff", 0, 0);
1215 @ <p>On the version-information pages linked from the timeline can either
1216 @ show complete diffs of all file changes, or can just list the names of
1217
--- src/style.c
+++ src/style.c
@@ -686,10 +686,11 @@
686686
},
687687
{ "td.timelineTime",
688688
"the format for the timeline time display",
689689
@ vertical-align: top;
690690
@ text-align: right;
691
+ @ white-space: nowrap;
691692
},
692693
{ "td.timelineGraph",
693694
"the format for the grap placeholder cells in timelines",
694695
@ width: 20px;
695696
@ text-align: left;
696697
--- src/style.c
+++ src/style.c
@@ -686,10 +686,11 @@
686 },
687 { "td.timelineTime",
688 "the format for the timeline time display",
689 @ vertical-align: top;
690 @ text-align: right;
 
691 },
692 { "td.timelineGraph",
693 "the format for the grap placeholder cells in timelines",
694 @ width: 20px;
695 @ text-align: left;
696
--- src/style.c
+++ src/style.c
@@ -686,10 +686,11 @@
686 },
687 { "td.timelineTime",
688 "the format for the timeline time display",
689 @ vertical-align: top;
690 @ text-align: right;
691 @ white-space: nowrap;
692 },
693 { "td.timelineGraph",
694 "the format for the grap placeholder cells in timelines",
695 @ width: 20px;
696 @ text-align: left;
697
+15 -9
--- src/timeline.c
+++ src/timeline.c
@@ -246,16 +246,18 @@
246246
int fchngQueryInit = 0; /* True if fchngQuery is initialized */
247247
Stmt fchngQuery; /* Query for file changes on check-ins */
248248
static Stmt qbranch;
249249
int pendingEndTr = 0; /* True if a </td></tr> is needed */
250250
int vid = 0; /* Current checkout version */
251
+ int dateFormat = 0; /* 0: HH:MM 1: HH:MM:SS 2: YYYY-MM-DD HH:MM */
251252
252253
if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
253254
vid = db_lget_int("checkout", 0);
254255
}
255256
zPrevDate[0] = 0;
256257
mxWikiLen = db_get_int("timeline-max-comment", 0);
258
+ dateFormat = db_get_int("timeline-date-format", 0);
257259
if( tmFlags & TIMELINE_GRAPH ){
258260
pGraph = graph_init();
259261
/* style is not moved to css, because this is
260262
** a technical div for the timeline graph
261263
*/
@@ -282,11 +284,11 @@
282284
int tagid = db_column_int(pQuery, 9);
283285
const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
284286
const char *zBr = 0; /* Branch */
285287
int commentColumn = 3; /* Column containing comment text */
286288
int modPending; /* Pending moderation */
287
- char zTime[8];
289
+ char zTime[20];
288290
289291
modPending = moderation_pending(rid);
290292
if( tagid ){
291293
if( modPending ) tagid = -tagid;
292294
if( tagid==prevTagid ){
@@ -314,18 +316,22 @@
314316
}
315317
prevWasDivider = 1;
316318
continue;
317319
}
318320
prevWasDivider = 0;
319
- if( memcmp(zDate, zPrevDate, 10) ){
320
- sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
321
- @ <tr><td>
322
- @ <div class="divider timelineDate">%s(zPrevDate)</div>
323
- @ </td><td></td><td></td></tr>
324
- }
325
- memcpy(zTime, &zDate[11], 5);
326
- zTime[5] = 0;
321
+ if( dateFormat<2 ){
322
+ if( memcmp(zDate, zPrevDate, 10) ){
323
+ sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
324
+ @ <tr><td>
325
+ @ <div class="divider timelineDate">%s(zPrevDate)</div>
326
+ @ </td><td></td><td></td></tr>
327
+ }
328
+ memcpy(zTime, &zDate[11], 5+dateFormat*3);
329
+ zTime[5+dateFormat*3] = 0;
330
+ }else{
331
+ sqlite3_snprintf(sizeof(zTime), zTime, "%.16s", zDate);
332
+ }
327333
if( rid == vid ){
328334
@ <tr class="timelineCurrent">
329335
}else {
330336
@ <tr>
331337
}
332338
--- src/timeline.c
+++ src/timeline.c
@@ -246,16 +246,18 @@
246 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
247 Stmt fchngQuery; /* Query for file changes on check-ins */
248 static Stmt qbranch;
249 int pendingEndTr = 0; /* True if a </td></tr> is needed */
250 int vid = 0; /* Current checkout version */
 
251
252 if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
253 vid = db_lget_int("checkout", 0);
254 }
255 zPrevDate[0] = 0;
256 mxWikiLen = db_get_int("timeline-max-comment", 0);
 
257 if( tmFlags & TIMELINE_GRAPH ){
258 pGraph = graph_init();
259 /* style is not moved to css, because this is
260 ** a technical div for the timeline graph
261 */
@@ -282,11 +284,11 @@
282 int tagid = db_column_int(pQuery, 9);
283 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
284 const char *zBr = 0; /* Branch */
285 int commentColumn = 3; /* Column containing comment text */
286 int modPending; /* Pending moderation */
287 char zTime[8];
288
289 modPending = moderation_pending(rid);
290 if( tagid ){
291 if( modPending ) tagid = -tagid;
292 if( tagid==prevTagid ){
@@ -314,18 +316,22 @@
314 }
315 prevWasDivider = 1;
316 continue;
317 }
318 prevWasDivider = 0;
319 if( memcmp(zDate, zPrevDate, 10) ){
320 sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
321 @ <tr><td>
322 @ <div class="divider timelineDate">%s(zPrevDate)</div>
323 @ </td><td></td><td></td></tr>
324 }
325 memcpy(zTime, &zDate[11], 5);
326 zTime[5] = 0;
 
 
 
 
327 if( rid == vid ){
328 @ <tr class="timelineCurrent">
329 }else {
330 @ <tr>
331 }
332
--- src/timeline.c
+++ src/timeline.c
@@ -246,16 +246,18 @@
246 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
247 Stmt fchngQuery; /* Query for file changes on check-ins */
248 static Stmt qbranch;
249 int pendingEndTr = 0; /* True if a </td></tr> is needed */
250 int vid = 0; /* Current checkout version */
251 int dateFormat = 0; /* 0: HH:MM 1: HH:MM:SS 2: YYYY-MM-DD HH:MM */
252
253 if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
254 vid = db_lget_int("checkout", 0);
255 }
256 zPrevDate[0] = 0;
257 mxWikiLen = db_get_int("timeline-max-comment", 0);
258 dateFormat = db_get_int("timeline-date-format", 0);
259 if( tmFlags & TIMELINE_GRAPH ){
260 pGraph = graph_init();
261 /* style is not moved to css, because this is
262 ** a technical div for the timeline graph
263 */
@@ -282,11 +284,11 @@
284 int tagid = db_column_int(pQuery, 9);
285 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
286 const char *zBr = 0; /* Branch */
287 int commentColumn = 3; /* Column containing comment text */
288 int modPending; /* Pending moderation */
289 char zTime[20];
290
291 modPending = moderation_pending(rid);
292 if( tagid ){
293 if( modPending ) tagid = -tagid;
294 if( tagid==prevTagid ){
@@ -314,18 +316,22 @@
316 }
317 prevWasDivider = 1;
318 continue;
319 }
320 prevWasDivider = 0;
321 if( dateFormat<2 ){
322 if( memcmp(zDate, zPrevDate, 10) ){
323 sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
324 @ <tr><td>
325 @ <div class="divider timelineDate">%s(zPrevDate)</div>
326 @ </td><td></td><td></td></tr>
327 }
328 memcpy(zTime, &zDate[11], 5+dateFormat*3);
329 zTime[5+dateFormat*3] = 0;
330 }else{
331 sqlite3_snprintf(sizeof(zTime), zTime, "%.16s", zDate);
332 }
333 if( rid == vid ){
334 @ <tr class="timelineCurrent">
335 }else {
336 @ <tr>
337 }
338

Keyboard Shortcuts

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