Fossil SCM

Allow websites to specify a default viewing style other than Modern in the /Admin/Timeline setup page.

drh 2020-02-11 19:47 trunk
Commit 895eac4feb428783f331a58e4c88d882424a078c4abe4c0bd96152ce1e831830
2 files changed +7 +21 -11
--- src/setup.c
+++ src/setup.c
@@ -733,10 +733,17 @@
733733
@ %s(zTmDiff) hours behind UTC.</p>
734734
}else{
735735
@ %s(zTmDiff) hours ahead of UTC.</p>
736736
}
737737
@ <p>(Property: "timeline-utc")
738
+
739
+ @ <hr />
740
+ multiple_choice_attribute("Style", "timeline-default-style",
741
+ "tdss", "0", N_TIMELINE_VIEW_STYLE, timeline_view_styles);
742
+ @ <p>The default timeline viewing style, for when the user has not
743
+ @ specified an alternative. (Property: "timeline-default-style")</p>
744
+
738745
@ <hr />
739746
multiple_choice_attribute("Per-Item Time Format", "timeline-date-format",
740747
"tdf", "0", count(azTimeFormats)/2, azTimeFormats);
741748
@ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
742749
@ in a separate box (using CSS class "timelineDate") whenever the date
743750
--- src/setup.c
+++ src/setup.c
@@ -733,10 +733,17 @@
733 @ %s(zTmDiff) hours behind UTC.</p>
734 }else{
735 @ %s(zTmDiff) hours ahead of UTC.</p>
736 }
737 @ <p>(Property: "timeline-utc")
 
 
 
 
 
 
 
738 @ <hr />
739 multiple_choice_attribute("Per-Item Time Format", "timeline-date-format",
740 "tdf", "0", count(azTimeFormats)/2, azTimeFormats);
741 @ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
742 @ in a separate box (using CSS class "timelineDate") whenever the date
743
--- src/setup.c
+++ src/setup.c
@@ -733,10 +733,17 @@
733 @ %s(zTmDiff) hours behind UTC.</p>
734 }else{
735 @ %s(zTmDiff) hours ahead of UTC.</p>
736 }
737 @ <p>(Property: "timeline-utc")
738
739 @ <hr />
740 multiple_choice_attribute("Style", "timeline-default-style",
741 "tdss", "0", N_TIMELINE_VIEW_STYLE, timeline_view_styles);
742 @ <p>The default timeline viewing style, for when the user has not
743 @ specified an alternative. (Property: "timeline-default-style")</p>
744
745 @ <hr />
746 multiple_choice_attribute("Per-Item Time Format", "timeline-date-format",
747 "tdf", "0", count(azTimeFormats)/2, azTimeFormats);
748 @ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
749 @ in a separate box (using CSS class "timelineDate") whenever the date
750
+21 -11
--- src/timeline.c
+++ src/timeline.c
@@ -1207,37 +1207,47 @@
12071207
** Convert the current "ss" display preferences cookie into an
12081208
** appropriate TIMELINE_* flag
12091209
*/
12101210
int timeline_ss_cookie(void){
12111211
int tmFlags;
1212
- switch( cookie_value("ss","m")[0] ){
1212
+ const char *v = cookie_value("ss",0);
1213
+ if( v==0 ) v = db_get("timeline-default-style","m");
1214
+ switch( v[0] ){
12131215
case 'c': tmFlags = TIMELINE_COMPACT; break;
12141216
case 'v': tmFlags = TIMELINE_VERBOSE; break;
12151217
case 'j': tmFlags = TIMELINE_COLUMNAR; break;
12161218
case 'x': tmFlags = TIMELINE_CLASSIC; break;
12171219
default: tmFlags = TIMELINE_MODERN; break;
12181220
}
12191221
return tmFlags;
12201222
}
12211223
1224
+/* Available timeline display styles, together with their y= query
1225
+** parameter names.
1226
+*/
1227
+const char *const timeline_view_styles[] = {
1228
+ "m", "Modern View",
1229
+ "j", "Columnar View",
1230
+ "c", "Compact View",
1231
+ "v", "Verbose View",
1232
+ "x", "Classic View",
1233
+};
1234
+#if INTERFACE
1235
+# define N_TIMELINE_VIEW_STYLE 5
1236
+#endif
1237
+
12221238
/*
12231239
** Add the select/option box to the timeline submenu that is used to
12241240
** set the ss= parameter that determines the viewing mode.
12251241
**
12261242
** Return the TIMELINE_* value appropriate for the view-style.
12271243
*/
12281244
int timeline_ss_submenu(void){
1229
- static const char *const azViewStyles[] = {
1230
- "m", "Modern View",
1231
- "j", "Columnar View",
1232
- "c", "Compact View",
1233
- "v", "Verbose View",
1234
- "x", "Classic View",
1235
- };
1236
- cookie_link_parameter("ss","ss","m");
1237
- style_submenu_multichoice("ss", sizeof(azViewStyles)/(2*sizeof(azViewStyles[0])),
1238
- azViewStyles, 0);
1245
+ cookie_link_parameter("ss","ss",db_get("timeline-default-style","m"));
1246
+ style_submenu_multichoice("ss",
1247
+ N_TIMELINE_VIEW_STYLE,
1248
+ timeline_view_styles, 0);
12391249
return timeline_ss_cookie();
12401250
}
12411251
12421252
/*
12431253
** If the zChng string is not NULL, then it should be a comma-separated
12441254
--- src/timeline.c
+++ src/timeline.c
@@ -1207,37 +1207,47 @@
1207 ** Convert the current "ss" display preferences cookie into an
1208 ** appropriate TIMELINE_* flag
1209 */
1210 int timeline_ss_cookie(void){
1211 int tmFlags;
1212 switch( cookie_value("ss","m")[0] ){
 
 
1213 case 'c': tmFlags = TIMELINE_COMPACT; break;
1214 case 'v': tmFlags = TIMELINE_VERBOSE; break;
1215 case 'j': tmFlags = TIMELINE_COLUMNAR; break;
1216 case 'x': tmFlags = TIMELINE_CLASSIC; break;
1217 default: tmFlags = TIMELINE_MODERN; break;
1218 }
1219 return tmFlags;
1220 }
1221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222 /*
1223 ** Add the select/option box to the timeline submenu that is used to
1224 ** set the ss= parameter that determines the viewing mode.
1225 **
1226 ** Return the TIMELINE_* value appropriate for the view-style.
1227 */
1228 int timeline_ss_submenu(void){
1229 static const char *const azViewStyles[] = {
1230 "m", "Modern View",
1231 "j", "Columnar View",
1232 "c", "Compact View",
1233 "v", "Verbose View",
1234 "x", "Classic View",
1235 };
1236 cookie_link_parameter("ss","ss","m");
1237 style_submenu_multichoice("ss", sizeof(azViewStyles)/(2*sizeof(azViewStyles[0])),
1238 azViewStyles, 0);
1239 return timeline_ss_cookie();
1240 }
1241
1242 /*
1243 ** If the zChng string is not NULL, then it should be a comma-separated
1244
--- src/timeline.c
+++ src/timeline.c
@@ -1207,37 +1207,47 @@
1207 ** Convert the current "ss" display preferences cookie into an
1208 ** appropriate TIMELINE_* flag
1209 */
1210 int timeline_ss_cookie(void){
1211 int tmFlags;
1212 const char *v = cookie_value("ss",0);
1213 if( v==0 ) v = db_get("timeline-default-style","m");
1214 switch( v[0] ){
1215 case 'c': tmFlags = TIMELINE_COMPACT; break;
1216 case 'v': tmFlags = TIMELINE_VERBOSE; break;
1217 case 'j': tmFlags = TIMELINE_COLUMNAR; break;
1218 case 'x': tmFlags = TIMELINE_CLASSIC; break;
1219 default: tmFlags = TIMELINE_MODERN; break;
1220 }
1221 return tmFlags;
1222 }
1223
1224 /* Available timeline display styles, together with their y= query
1225 ** parameter names.
1226 */
1227 const char *const timeline_view_styles[] = {
1228 "m", "Modern View",
1229 "j", "Columnar View",
1230 "c", "Compact View",
1231 "v", "Verbose View",
1232 "x", "Classic View",
1233 };
1234 #if INTERFACE
1235 # define N_TIMELINE_VIEW_STYLE 5
1236 #endif
1237
1238 /*
1239 ** Add the select/option box to the timeline submenu that is used to
1240 ** set the ss= parameter that determines the viewing mode.
1241 **
1242 ** Return the TIMELINE_* value appropriate for the view-style.
1243 */
1244 int timeline_ss_submenu(void){
1245 cookie_link_parameter("ss","ss",db_get("timeline-default-style","m"));
1246 style_submenu_multichoice("ss",
1247 N_TIMELINE_VIEW_STYLE,
1248 timeline_view_styles, 0);
 
 
 
 
 
 
1249 return timeline_ss_cookie();
1250 }
1251
1252 /*
1253 ** If the zChng string is not NULL, then it should be a comma-separated
1254

Keyboard Shortcuts

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