Fossil SCM

Revive the default-skin setting. I know think it will be useful after all, when used in combination with other changes that are planned.

drh 2024-02-23 18:18 trunk
Commit 18d76fffb1c99ff4a43445d96270d2c27c0c39643e6fd077a5163f5143a61d88
1 file changed +37 -5
+37 -5
--- src/skins.c
+++ src/skins.c
@@ -19,10 +19,17 @@
1919
*/
2020
#include "config.h"
2121
#include <assert.h>
2222
#include "skins.h"
2323
24
+/*
25
+** SETTING: default-skin width=16
26
+**
27
+** If the text value if this setting is the name of a built-in skin
28
+** then the named skin becomes the default skin for the repository.
29
+*/
30
+
2431
/*
2532
** An array of available built-in skins.
2633
**
2734
** To add new built-in skins:
2835
**
@@ -87,14 +94,16 @@
8794
#define SKIN_FROM_DRAFT 0 /* The "draftN" prefix on the PATH_INFO */
8895
#define SKIN_FROM_CMDLINE 1 /* --skin option to server command-line */
8996
#define SKIN_FROM_CGI 2 /* skin: parameter in CGI script */
9097
#define SKIN_FROM_QPARAM 3 /* skin= query parameter */
9198
#define SKIN_FROM_COOKIE 4 /* skin= from fossil_display_settings cookie*/
92
-#define SKIN_FROM_CUSTOM 5 /* Skin values in CONFIG table */
93
-#define SKIN_FROM_DEFAULT 6 /* The built-in named "default" */
99
+#define SKIN_FROM_SETTING 5 /* Built-in named by "default-skin" setting */
100
+#define SKIN_FROM_CUSTOM 6 /* Skin values in CONFIG table */
101
+#define SKIN_FROM_DEFAULT 7 /* The built-in named "default" */
102
+#define SKIN_FROM_UNKNOWN 8 /* Do not yet know which skin to use */
94103
#endif /* INTERFACE */
95
-static int iSkinSource = SKIN_FROM_DEFAULT;
104
+static int iSkinSource = SKIN_FROM_UNKNOWN;
96105
97106
98107
/*
99108
** Skin details are a set of key/value pairs that define display
100109
** attributes of the skin that cannot be easily specified using CSS
@@ -153,14 +162,17 @@
153162
** 2) The "skin" display setting cookie or URL argument, in that
154163
** order. If the "skin" URL argument is provided and refers to a legal
155164
** skin then that will update the display cookie. If the skin name is
156165
** illegal it is silently ignored.
157166
**
158
-** 3) Skin properties (settings "css", "details", "footer", "header",
167
+** 3) The built-in skin identfied by the "default-skin" setting, if such
168
+** a setting exists and matches one of the built-in skin names.
169
+**
170
+** 4) Skin properties (settings "css", "details", "footer", "header",
159171
** and "js") from the CONFIG db table
160172
**
161
-** 4) The built-in skin named "default"
173
+** 5) The built-in skin named "default"
162174
**
163175
** The iSource integer privides additional detail about where the skin
164176
**
165177
** As a special case, a NULL or empty name resets zAltSkinDir and
166178
** pAltSkin to 0 to indicate that the current config-side skin should
@@ -246,10 +258,24 @@
246258
blob_read_from_file(&x, z, ExtFILE);
247259
fossil_free(z);
248260
return blob_str(&x);
249261
}
250262
fossil_free(z);
263
+ }
264
+ if( iSkinSource==SKIN_FROM_UNKNOWN ){
265
+ const char *zDflt = db_get("default-skin", 0);
266
+ iSkinSource = SKIN_FROM_DEFAULT;
267
+ if( zDflt!=0 ){
268
+ int i;
269
+ for(i=0; i<count(aBuiltinSkin); i++){
270
+ if( fossil_strcmp(aBuiltinSkin[i].zLabel, zDflt)==0 ){
271
+ pAltSkin = &aBuiltinSkin[i];
272
+ iSkinSource = SKIN_FROM_SETTING;
273
+ break;
274
+ }
275
+ }
276
+ }
251277
}
252278
if( pAltSkin ){
253279
z = mprintf("skins/%s/%s.txt", pAltSkin->zLabel, zWhat);
254280
zOut = builtin_text(z);
255281
fossil_free(z);
@@ -692,10 +718,13 @@
692718
break;
693719
case SKIN_FROM_COOKIE:
694720
@ the "skin" value of the
695721
@ <a href='./fdscookie'>fossil_display_setting</a> cookie.
696722
break;
723
+ case SKIN_FROM_SETTING:
724
+ @ the "default-skin" setting.
725
+ break;
697726
default:
698727
@ reasons unknown. (Fix me!)
699728
break;
700729
}
701730
@ </tr>
@@ -1331,10 +1360,13 @@
13311360
break;
13321361
case SKIN_FROM_COOKIE:
13331362
@ the "skin" property in the
13341363
@ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie.
13351364
break;
1365
+ case SKIN_FROM_SETTING:
1366
+ @ the "default-skin" setting on the repository.
1367
+ break;
13361368
}
13371369
}
13381370
style_finish_page();
13391371
fossil_free(zBase);
13401372
}
13411373
--- src/skins.c
+++ src/skins.c
@@ -19,10 +19,17 @@
19 */
20 #include "config.h"
21 #include <assert.h>
22 #include "skins.h"
23
 
 
 
 
 
 
 
24 /*
25 ** An array of available built-in skins.
26 **
27 ** To add new built-in skins:
28 **
@@ -87,14 +94,16 @@
87 #define SKIN_FROM_DRAFT 0 /* The "draftN" prefix on the PATH_INFO */
88 #define SKIN_FROM_CMDLINE 1 /* --skin option to server command-line */
89 #define SKIN_FROM_CGI 2 /* skin: parameter in CGI script */
90 #define SKIN_FROM_QPARAM 3 /* skin= query parameter */
91 #define SKIN_FROM_COOKIE 4 /* skin= from fossil_display_settings cookie*/
92 #define SKIN_FROM_CUSTOM 5 /* Skin values in CONFIG table */
93 #define SKIN_FROM_DEFAULT 6 /* The built-in named "default" */
 
 
94 #endif /* INTERFACE */
95 static int iSkinSource = SKIN_FROM_DEFAULT;
96
97
98 /*
99 ** Skin details are a set of key/value pairs that define display
100 ** attributes of the skin that cannot be easily specified using CSS
@@ -153,14 +162,17 @@
153 ** 2) The "skin" display setting cookie or URL argument, in that
154 ** order. If the "skin" URL argument is provided and refers to a legal
155 ** skin then that will update the display cookie. If the skin name is
156 ** illegal it is silently ignored.
157 **
158 ** 3) Skin properties (settings "css", "details", "footer", "header",
 
 
 
159 ** and "js") from the CONFIG db table
160 **
161 ** 4) The built-in skin named "default"
162 **
163 ** The iSource integer privides additional detail about where the skin
164 **
165 ** As a special case, a NULL or empty name resets zAltSkinDir and
166 ** pAltSkin to 0 to indicate that the current config-side skin should
@@ -246,10 +258,24 @@
246 blob_read_from_file(&x, z, ExtFILE);
247 fossil_free(z);
248 return blob_str(&x);
249 }
250 fossil_free(z);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251 }
252 if( pAltSkin ){
253 z = mprintf("skins/%s/%s.txt", pAltSkin->zLabel, zWhat);
254 zOut = builtin_text(z);
255 fossil_free(z);
@@ -692,10 +718,13 @@
692 break;
693 case SKIN_FROM_COOKIE:
694 @ the "skin" value of the
695 @ <a href='./fdscookie'>fossil_display_setting</a> cookie.
696 break;
 
 
 
697 default:
698 @ reasons unknown. (Fix me!)
699 break;
700 }
701 @ </tr>
@@ -1331,10 +1360,13 @@
1331 break;
1332 case SKIN_FROM_COOKIE:
1333 @ the "skin" property in the
1334 @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie.
1335 break;
 
 
 
1336 }
1337 }
1338 style_finish_page();
1339 fossil_free(zBase);
1340 }
1341
--- src/skins.c
+++ src/skins.c
@@ -19,10 +19,17 @@
19 */
20 #include "config.h"
21 #include <assert.h>
22 #include "skins.h"
23
24 /*
25 ** SETTING: default-skin width=16
26 **
27 ** If the text value if this setting is the name of a built-in skin
28 ** then the named skin becomes the default skin for the repository.
29 */
30
31 /*
32 ** An array of available built-in skins.
33 **
34 ** To add new built-in skins:
35 **
@@ -87,14 +94,16 @@
94 #define SKIN_FROM_DRAFT 0 /* The "draftN" prefix on the PATH_INFO */
95 #define SKIN_FROM_CMDLINE 1 /* --skin option to server command-line */
96 #define SKIN_FROM_CGI 2 /* skin: parameter in CGI script */
97 #define SKIN_FROM_QPARAM 3 /* skin= query parameter */
98 #define SKIN_FROM_COOKIE 4 /* skin= from fossil_display_settings cookie*/
99 #define SKIN_FROM_SETTING 5 /* Built-in named by "default-skin" setting */
100 #define SKIN_FROM_CUSTOM 6 /* Skin values in CONFIG table */
101 #define SKIN_FROM_DEFAULT 7 /* The built-in named "default" */
102 #define SKIN_FROM_UNKNOWN 8 /* Do not yet know which skin to use */
103 #endif /* INTERFACE */
104 static int iSkinSource = SKIN_FROM_UNKNOWN;
105
106
107 /*
108 ** Skin details are a set of key/value pairs that define display
109 ** attributes of the skin that cannot be easily specified using CSS
@@ -153,14 +162,17 @@
162 ** 2) The "skin" display setting cookie or URL argument, in that
163 ** order. If the "skin" URL argument is provided and refers to a legal
164 ** skin then that will update the display cookie. If the skin name is
165 ** illegal it is silently ignored.
166 **
167 ** 3) The built-in skin identfied by the "default-skin" setting, if such
168 ** a setting exists and matches one of the built-in skin names.
169 **
170 ** 4) Skin properties (settings "css", "details", "footer", "header",
171 ** and "js") from the CONFIG db table
172 **
173 ** 5) The built-in skin named "default"
174 **
175 ** The iSource integer privides additional detail about where the skin
176 **
177 ** As a special case, a NULL or empty name resets zAltSkinDir and
178 ** pAltSkin to 0 to indicate that the current config-side skin should
@@ -246,10 +258,24 @@
258 blob_read_from_file(&x, z, ExtFILE);
259 fossil_free(z);
260 return blob_str(&x);
261 }
262 fossil_free(z);
263 }
264 if( iSkinSource==SKIN_FROM_UNKNOWN ){
265 const char *zDflt = db_get("default-skin", 0);
266 iSkinSource = SKIN_FROM_DEFAULT;
267 if( zDflt!=0 ){
268 int i;
269 for(i=0; i<count(aBuiltinSkin); i++){
270 if( fossil_strcmp(aBuiltinSkin[i].zLabel, zDflt)==0 ){
271 pAltSkin = &aBuiltinSkin[i];
272 iSkinSource = SKIN_FROM_SETTING;
273 break;
274 }
275 }
276 }
277 }
278 if( pAltSkin ){
279 z = mprintf("skins/%s/%s.txt", pAltSkin->zLabel, zWhat);
280 zOut = builtin_text(z);
281 fossil_free(z);
@@ -692,10 +718,13 @@
718 break;
719 case SKIN_FROM_COOKIE:
720 @ the "skin" value of the
721 @ <a href='./fdscookie'>fossil_display_setting</a> cookie.
722 break;
723 case SKIN_FROM_SETTING:
724 @ the "default-skin" setting.
725 break;
726 default:
727 @ reasons unknown. (Fix me!)
728 break;
729 }
730 @ </tr>
@@ -1331,10 +1360,13 @@
1360 break;
1361 case SKIN_FROM_COOKIE:
1362 @ the "skin" property in the
1363 @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie.
1364 break;
1365 case SKIN_FROM_SETTING:
1366 @ the "default-skin" setting on the repository.
1367 break;
1368 }
1369 }
1370 style_finish_page();
1371 fossil_free(zBase);
1372 }
1373

Keyboard Shortcuts

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