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.
Commit
18d76fffb1c99ff4a43445d96270d2c27c0c39643e6fd077a5163f5143a61d88
Parent
9568091a9beee72…
1 file changed
+37
-5
+37
-5
| --- src/skins.c | ||
| +++ src/skins.c | ||
| @@ -19,10 +19,17 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include <assert.h> |
| 22 | 22 | #include "skins.h" |
| 23 | 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 | + | |
| 24 | 31 | /* |
| 25 | 32 | ** An array of available built-in skins. |
| 26 | 33 | ** |
| 27 | 34 | ** To add new built-in skins: |
| 28 | 35 | ** |
| @@ -87,14 +94,16 @@ | ||
| 87 | 94 | #define SKIN_FROM_DRAFT 0 /* The "draftN" prefix on the PATH_INFO */ |
| 88 | 95 | #define SKIN_FROM_CMDLINE 1 /* --skin option to server command-line */ |
| 89 | 96 | #define SKIN_FROM_CGI 2 /* skin: parameter in CGI script */ |
| 90 | 97 | #define SKIN_FROM_QPARAM 3 /* skin= query parameter */ |
| 91 | 98 | #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 */ | |
| 94 | 103 | #endif /* INTERFACE */ |
| 95 | -static int iSkinSource = SKIN_FROM_DEFAULT; | |
| 104 | +static int iSkinSource = SKIN_FROM_UNKNOWN; | |
| 96 | 105 | |
| 97 | 106 | |
| 98 | 107 | /* |
| 99 | 108 | ** Skin details are a set of key/value pairs that define display |
| 100 | 109 | ** attributes of the skin that cannot be easily specified using CSS |
| @@ -153,14 +162,17 @@ | ||
| 153 | 162 | ** 2) The "skin" display setting cookie or URL argument, in that |
| 154 | 163 | ** order. If the "skin" URL argument is provided and refers to a legal |
| 155 | 164 | ** skin then that will update the display cookie. If the skin name is |
| 156 | 165 | ** illegal it is silently ignored. |
| 157 | 166 | ** |
| 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", | |
| 159 | 171 | ** and "js") from the CONFIG db table |
| 160 | 172 | ** |
| 161 | -** 4) The built-in skin named "default" | |
| 173 | +** 5) The built-in skin named "default" | |
| 162 | 174 | ** |
| 163 | 175 | ** The iSource integer privides additional detail about where the skin |
| 164 | 176 | ** |
| 165 | 177 | ** As a special case, a NULL or empty name resets zAltSkinDir and |
| 166 | 178 | ** pAltSkin to 0 to indicate that the current config-side skin should |
| @@ -246,10 +258,24 @@ | ||
| 246 | 258 | blob_read_from_file(&x, z, ExtFILE); |
| 247 | 259 | fossil_free(z); |
| 248 | 260 | return blob_str(&x); |
| 249 | 261 | } |
| 250 | 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 | + } | |
| 251 | 277 | } |
| 252 | 278 | if( pAltSkin ){ |
| 253 | 279 | z = mprintf("skins/%s/%s.txt", pAltSkin->zLabel, zWhat); |
| 254 | 280 | zOut = builtin_text(z); |
| 255 | 281 | fossil_free(z); |
| @@ -692,10 +718,13 @@ | ||
| 692 | 718 | break; |
| 693 | 719 | case SKIN_FROM_COOKIE: |
| 694 | 720 | @ the "skin" value of the |
| 695 | 721 | @ <a href='./fdscookie'>fossil_display_setting</a> cookie. |
| 696 | 722 | break; |
| 723 | + case SKIN_FROM_SETTING: | |
| 724 | + @ the "default-skin" setting. | |
| 725 | + break; | |
| 697 | 726 | default: |
| 698 | 727 | @ reasons unknown. (Fix me!) |
| 699 | 728 | break; |
| 700 | 729 | } |
| 701 | 730 | @ </tr> |
| @@ -1331,10 +1360,13 @@ | ||
| 1331 | 1360 | break; |
| 1332 | 1361 | case SKIN_FROM_COOKIE: |
| 1333 | 1362 | @ the "skin" property in the |
| 1334 | 1363 | @ "%z(href("%R/fdscookie"))fossil_display_settings</a>" cookie. |
| 1335 | 1364 | break; |
| 1365 | + case SKIN_FROM_SETTING: | |
| 1366 | + @ the "default-skin" setting on the repository. | |
| 1367 | + break; | |
| 1336 | 1368 | } |
| 1337 | 1369 | } |
| 1338 | 1370 | style_finish_page(); |
| 1339 | 1371 | fossil_free(zBase); |
| 1340 | 1372 | } |
| 1341 | 1373 |
| --- 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 |