Fossil SCM
Permit the 'favicon.ico' page to be customized via TH1.
Commit
ff735265175830b0073804b395b2f90e6f0869a5d4cbccde7c606a052eee116b
Parent
cd061779d2c192c…
2 files changed
+22
-5
+7
+22
-5
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -1132,12 +1132,16 @@ | ||
| 1132 | 1132 | |
| 1133 | 1133 | |
| 1134 | 1134 | /* |
| 1135 | 1135 | ** WEBPAGE: favicon.ico |
| 1136 | 1136 | ** |
| 1137 | -** Return the default favicon.ico image. The returned image is for the | |
| 1138 | -** Fossil lizard icon. | |
| 1137 | +** Return the configured favicon.ico image. If the TH1 style variables | |
| 1138 | +** "favicon_data" and "favicon_mimetype" exist, they must be the base64 | |
| 1139 | +** encoded data for the image to use and its associated MIME type, | |
| 1140 | +** respectively; otherwise, the returned image is for the Fossil lizard | |
| 1141 | +** icon. Since this page does not make use of the style header, these | |
| 1142 | +** TH1 variables should generally be set in the "th1-setup" script. | |
| 1139 | 1143 | ** |
| 1140 | 1144 | ** The intended use case here is to supply a favicon for the "fossil ui" |
| 1141 | 1145 | ** command. For a permanent website, the recommended process is for |
| 1142 | 1146 | ** the admin to set up a project-specific favicon and reference that |
| 1143 | 1147 | ** icon in the HTML header using a line like: |
| @@ -1145,15 +1149,28 @@ | ||
| 1145 | 1149 | ** <link rel="icon" href="URL-FOR-YOUR-ICON" type="MIMETYPE"/> |
| 1146 | 1150 | ** |
| 1147 | 1151 | */ |
| 1148 | 1152 | void favicon_page(void){ |
| 1149 | 1153 | Blob favicon; |
| 1154 | + const char *zMime = 0; | |
| 1155 | + const char *zData = Th_Fetch("favicon_data", 0); | |
| 1150 | 1156 | |
| 1157 | + if( zData ){ | |
| 1158 | + int nData = 0; | |
| 1159 | + zData = decode64(zData, &nData); | |
| 1160 | + blob_zero(&favicon); | |
| 1161 | + blob_append(&favicon, zData, nData); | |
| 1162 | + fossil_free((char*)zData); | |
| 1163 | + zMime = Th_Fetch("favicon_mimetype", 0); | |
| 1164 | + if( zMime==0 ) zMime = "image/x-icon"; | |
| 1165 | + }else{ | |
| 1166 | + blob_zero(&favicon); | |
| 1167 | + blob_init(&favicon, (char*)aLogo, sizeof(aLogo)); | |
| 1168 | + } | |
| 1151 | 1169 | etag_check(ETAG_CONFIG, 0); |
| 1152 | - blob_zero(&favicon); | |
| 1153 | - blob_init(&favicon, (char*)aLogo, sizeof(aLogo)); | |
| 1154 | - cgi_set_content_type("image/gif"); | |
| 1170 | + if( zMime==0 ) zMime = "image/gif"; | |
| 1171 | + cgi_set_content_type(zMime); | |
| 1155 | 1172 | cgi_set_content(&favicon); |
| 1156 | 1173 | } |
| 1157 | 1174 | |
| 1158 | 1175 | /* |
| 1159 | 1176 | ** WEBPAGE: docsrch |
| 1160 | 1177 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -1132,12 +1132,16 @@ | |
| 1132 | |
| 1133 | |
| 1134 | /* |
| 1135 | ** WEBPAGE: favicon.ico |
| 1136 | ** |
| 1137 | ** Return the default favicon.ico image. The returned image is for the |
| 1138 | ** Fossil lizard icon. |
| 1139 | ** |
| 1140 | ** The intended use case here is to supply a favicon for the "fossil ui" |
| 1141 | ** command. For a permanent website, the recommended process is for |
| 1142 | ** the admin to set up a project-specific favicon and reference that |
| 1143 | ** icon in the HTML header using a line like: |
| @@ -1145,15 +1149,28 @@ | |
| 1145 | ** <link rel="icon" href="URL-FOR-YOUR-ICON" type="MIMETYPE"/> |
| 1146 | ** |
| 1147 | */ |
| 1148 | void favicon_page(void){ |
| 1149 | Blob favicon; |
| 1150 | |
| 1151 | etag_check(ETAG_CONFIG, 0); |
| 1152 | blob_zero(&favicon); |
| 1153 | blob_init(&favicon, (char*)aLogo, sizeof(aLogo)); |
| 1154 | cgi_set_content_type("image/gif"); |
| 1155 | cgi_set_content(&favicon); |
| 1156 | } |
| 1157 | |
| 1158 | /* |
| 1159 | ** WEBPAGE: docsrch |
| 1160 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -1132,12 +1132,16 @@ | |
| 1132 | |
| 1133 | |
| 1134 | /* |
| 1135 | ** WEBPAGE: favicon.ico |
| 1136 | ** |
| 1137 | ** Return the configured favicon.ico image. If the TH1 style variables |
| 1138 | ** "favicon_data" and "favicon_mimetype" exist, they must be the base64 |
| 1139 | ** encoded data for the image to use and its associated MIME type, |
| 1140 | ** respectively; otherwise, the returned image is for the Fossil lizard |
| 1141 | ** icon. Since this page does not make use of the style header, these |
| 1142 | ** TH1 variables should generally be set in the "th1-setup" script. |
| 1143 | ** |
| 1144 | ** The intended use case here is to supply a favicon for the "fossil ui" |
| 1145 | ** command. For a permanent website, the recommended process is for |
| 1146 | ** the admin to set up a project-specific favicon and reference that |
| 1147 | ** icon in the HTML header using a line like: |
| @@ -1145,15 +1149,28 @@ | |
| 1149 | ** <link rel="icon" href="URL-FOR-YOUR-ICON" type="MIMETYPE"/> |
| 1150 | ** |
| 1151 | */ |
| 1152 | void favicon_page(void){ |
| 1153 | Blob favicon; |
| 1154 | const char *zMime = 0; |
| 1155 | const char *zData = Th_Fetch("favicon_data", 0); |
| 1156 | |
| 1157 | if( zData ){ |
| 1158 | int nData = 0; |
| 1159 | zData = decode64(zData, &nData); |
| 1160 | blob_zero(&favicon); |
| 1161 | blob_append(&favicon, zData, nData); |
| 1162 | fossil_free((char*)zData); |
| 1163 | zMime = Th_Fetch("favicon_mimetype", 0); |
| 1164 | if( zMime==0 ) zMime = "image/x-icon"; |
| 1165 | }else{ |
| 1166 | blob_zero(&favicon); |
| 1167 | blob_init(&favicon, (char*)aLogo, sizeof(aLogo)); |
| 1168 | } |
| 1169 | etag_check(ETAG_CONFIG, 0); |
| 1170 | if( zMime==0 ) zMime = "image/gif"; |
| 1171 | cgi_set_content_type(zMime); |
| 1172 | cgi_set_content(&favicon); |
| 1173 | } |
| 1174 | |
| 1175 | /* |
| 1176 | ** WEBPAGE: docsrch |
| 1177 |
+7
| --- www/customskin.md | ||
| +++ www/customskin.md | ||
| @@ -398,10 +398,17 @@ | ||
| 398 | 398 | * **log\_image\_url** - A URL for the logo image for this project, as |
| 399 | 399 | configured on the Admin/Logo page. |
| 400 | 400 | |
| 401 | 401 | * **background\_image\_url** - A URL for a background image for this |
| 402 | 402 | project, as configured on the Admin/Logo page. |
| 403 | + | |
| 404 | + * **favicon\_data** - The base64 encoded data for the image to return | |
| 405 | + from the "favicon.ico" page. | |
| 406 | + | |
| 407 | + * **favicon\_mimetype** - The MIME type associated with the image to | |
| 408 | + return from the "favicon.ico" page. This will not be used unless | |
| 409 | + custom image data has been specified. | |
| 403 | 410 | |
| 404 | 411 | All of the above are variables in the sense that either the header or the |
| 405 | 412 | footer is free to change or erase them. But they should probably be treated |
| 406 | 413 | as constants. New predefined values are likely to be added in future |
| 407 | 414 | releases of Fossil. |
| 408 | 415 |
| --- www/customskin.md | |
| +++ www/customskin.md | |
| @@ -398,10 +398,17 @@ | |
| 398 | * **log\_image\_url** - A URL for the logo image for this project, as |
| 399 | configured on the Admin/Logo page. |
| 400 | |
| 401 | * **background\_image\_url** - A URL for a background image for this |
| 402 | project, as configured on the Admin/Logo page. |
| 403 | |
| 404 | All of the above are variables in the sense that either the header or the |
| 405 | footer is free to change or erase them. But they should probably be treated |
| 406 | as constants. New predefined values are likely to be added in future |
| 407 | releases of Fossil. |
| 408 |
| --- www/customskin.md | |
| +++ www/customskin.md | |
| @@ -398,10 +398,17 @@ | |
| 398 | * **log\_image\_url** - A URL for the logo image for this project, as |
| 399 | configured on the Admin/Logo page. |
| 400 | |
| 401 | * **background\_image\_url** - A URL for a background image for this |
| 402 | project, as configured on the Admin/Logo page. |
| 403 | |
| 404 | * **favicon\_data** - The base64 encoded data for the image to return |
| 405 | from the "favicon.ico" page. |
| 406 | |
| 407 | * **favicon\_mimetype** - The MIME type associated with the image to |
| 408 | return from the "favicon.ico" page. This will not be used unless |
| 409 | custom image data has been specified. |
| 410 | |
| 411 | All of the above are variables in the sense that either the header or the |
| 412 | footer is free to change or erase them. But they should probably be treated |
| 413 | as constants. New predefined values are likely to be added in future |
| 414 | releases of Fossil. |
| 415 |