Fossil SCM

Permit the 'favicon.ico' page to be customized via TH1.

mistachkin 2020-06-27 17:15 trunk
Commit ff735265175830b0073804b395b2f90e6f0869a5d4cbccde7c606a052eee116b
2 files changed +22 -5 +7
+22 -5
--- src/doc.c
+++ src/doc.c
@@ -1132,12 +1132,16 @@
11321132
11331133
11341134
/*
11351135
** WEBPAGE: favicon.ico
11361136
**
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.
11391143
**
11401144
** The intended use case here is to supply a favicon for the "fossil ui"
11411145
** command. For a permanent website, the recommended process is for
11421146
** the admin to set up a project-specific favicon and reference that
11431147
** icon in the HTML header using a line like:
@@ -1145,15 +1149,28 @@
11451149
** <link rel="icon" href="URL-FOR-YOUR-ICON" type="MIMETYPE"/>
11461150
**
11471151
*/
11481152
void favicon_page(void){
11491153
Blob favicon;
1154
+ const char *zMime = 0;
1155
+ const char *zData = Th_Fetch("favicon_data", 0);
11501156
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
+ }
11511169
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);
11551172
cgi_set_content(&favicon);
11561173
}
11571174
11581175
/*
11591176
** WEBPAGE: docsrch
11601177
--- 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
--- www/customskin.md
+++ www/customskin.md
@@ -398,10 +398,17 @@
398398
* **log\_image\_url** - A URL for the logo image for this project, as
399399
configured on the Admin/Logo page.
400400
401401
* **background\_image\_url** - A URL for a background image for this
402402
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.
403410
404411
All of the above are variables in the sense that either the header or the
405412
footer is free to change or erase them. But they should probably be treated
406413
as constants. New predefined values are likely to be added in future
407414
releases of Fossil.
408415
--- 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

Keyboard Shortcuts

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