Fossil SCM
Allow websites to specify a default viewing style other than Modern in the /Admin/Timeline setup page.
Commit
895eac4feb428783f331a58e4c88d882424a078c4abe4c0bd96152ce1e831830
Parent
7a585153b1a83d9…
2 files changed
+7
+21
-11
+7
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -733,10 +733,17 @@ | ||
| 733 | 733 | @ %s(zTmDiff) hours behind UTC.</p> |
| 734 | 734 | }else{ |
| 735 | 735 | @ %s(zTmDiff) hours ahead of UTC.</p> |
| 736 | 736 | } |
| 737 | 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 | + | |
| 738 | 745 | @ <hr /> |
| 739 | 746 | multiple_choice_attribute("Per-Item Time Format", "timeline-date-format", |
| 740 | 747 | "tdf", "0", count(azTimeFormats)/2, azTimeFormats); |
| 741 | 748 | @ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown |
| 742 | 749 | @ in a separate box (using CSS class "timelineDate") whenever the date |
| 743 | 750 |
| --- 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 @@ | ||
| 1207 | 1207 | ** Convert the current "ss" display preferences cookie into an |
| 1208 | 1208 | ** appropriate TIMELINE_* flag |
| 1209 | 1209 | */ |
| 1210 | 1210 | int timeline_ss_cookie(void){ |
| 1211 | 1211 | 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] ){ | |
| 1213 | 1215 | case 'c': tmFlags = TIMELINE_COMPACT; break; |
| 1214 | 1216 | case 'v': tmFlags = TIMELINE_VERBOSE; break; |
| 1215 | 1217 | case 'j': tmFlags = TIMELINE_COLUMNAR; break; |
| 1216 | 1218 | case 'x': tmFlags = TIMELINE_CLASSIC; break; |
| 1217 | 1219 | default: tmFlags = TIMELINE_MODERN; break; |
| 1218 | 1220 | } |
| 1219 | 1221 | return tmFlags; |
| 1220 | 1222 | } |
| 1221 | 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 | + | |
| 1222 | 1238 | /* |
| 1223 | 1239 | ** Add the select/option box to the timeline submenu that is used to |
| 1224 | 1240 | ** set the ss= parameter that determines the viewing mode. |
| 1225 | 1241 | ** |
| 1226 | 1242 | ** Return the TIMELINE_* value appropriate for the view-style. |
| 1227 | 1243 | */ |
| 1228 | 1244 | 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); | |
| 1239 | 1249 | return timeline_ss_cookie(); |
| 1240 | 1250 | } |
| 1241 | 1251 | |
| 1242 | 1252 | /* |
| 1243 | 1253 | ** If the zChng string is not NULL, then it should be a comma-separated |
| 1244 | 1254 |
| --- 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 |