Fossil SCM

Add the ability to set a background image as part of the server configuration. Process the CSS using TH1 so that $baseurl can be inserted into the CSS.

drh 2012-03-31 15:18 trunk
Commit 62398459fb904b129f94d0811f9bc70b9b3df20d
+15 -6
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
7878
{ "css", CONFIGSET_SKIN },
7979
{ "header", CONFIGSET_SKIN },
8080
{ "footer", CONFIGSET_SKIN },
8181
{ "logo-mimetype", CONFIGSET_SKIN },
8282
{ "logo-image", CONFIGSET_SKIN },
83
+ { "background-mimetype", CONFIGSET_SKIN },
84
+ { "background-image", CONFIGSET_SKIN },
85
+ { "index-page", CONFIGSET_SKIN },
86
+ { "timeline-block-markup", CONFIGSET_SKIN },
87
+ { "timeline-max-comment", CONFIGSET_SKIN },
88
+#ifdef FOSSIL_ENABLE_TCL
89
+ { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
90
+#endif
91
+
8392
{ "project-name", CONFIGSET_PROJ },
8493
{ "project-description", CONFIGSET_PROJ },
8594
{ "manifest", CONFIGSET_PROJ },
8695
{ "ignore-glob", CONFIGSET_PROJ },
8796
{ "crnl-glob", CONFIGSET_PROJ },
8897
{ "empty-dirs", CONFIGSET_PROJ },
8998
{ "allow-symlinks", CONFIGSET_PROJ },
90
- { "index-page", CONFIGSET_SKIN },
91
-#ifdef FOSSIL_ENABLE_TCL
92
- { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
93
-#endif
94
- { "timeline-block-markup", CONFIGSET_SKIN },
95
- { "timeline-max-comment", CONFIGSET_SKIN },
99
+
96100
{ "ticket-table", CONFIGSET_TKT },
97101
{ "ticket-common", CONFIGSET_TKT },
98102
{ "ticket-change", CONFIGSET_TKT },
99103
{ "ticket-newpage", CONFIGSET_TKT },
100104
{ "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
103107
{ "ticket-report-template", CONFIGSET_TKT },
104108
{ "ticket-key-template", CONFIGSET_TKT },
105109
{ "ticket-title-expr", CONFIGSET_TKT },
106110
{ "ticket-closed-expr", CONFIGSET_TKT },
107111
{ "@reportfmt", CONFIGSET_TKT },
112
+
108113
{ "@user", CONFIGSET_USER },
114
+
109115
{ "@concealed", CONFIGSET_ADDR },
116
+
110117
{ "@shun", CONFIGSET_SHUN },
118
+
111119
{ "xfer-common-script", CONFIGSET_XFER },
112120
{ "xfer-push-script", CONFIGSET_XFER },
121
+
113122
};
114123
static int iConfig = 0;
115124
116125
/*
117126
** Return name of first configuration property matching the given mask.
118127
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
78 { "css", CONFIGSET_SKIN },
79 { "header", CONFIGSET_SKIN },
80 { "footer", CONFIGSET_SKIN },
81 { "logo-mimetype", CONFIGSET_SKIN },
82 { "logo-image", CONFIGSET_SKIN },
 
 
 
 
 
 
 
 
 
83 { "project-name", CONFIGSET_PROJ },
84 { "project-description", CONFIGSET_PROJ },
85 { "manifest", CONFIGSET_PROJ },
86 { "ignore-glob", CONFIGSET_PROJ },
87 { "crnl-glob", CONFIGSET_PROJ },
88 { "empty-dirs", CONFIGSET_PROJ },
89 { "allow-symlinks", CONFIGSET_PROJ },
90 { "index-page", CONFIGSET_SKIN },
91 #ifdef FOSSIL_ENABLE_TCL
92 { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
93 #endif
94 { "timeline-block-markup", CONFIGSET_SKIN },
95 { "timeline-max-comment", CONFIGSET_SKIN },
96 { "ticket-table", CONFIGSET_TKT },
97 { "ticket-common", CONFIGSET_TKT },
98 { "ticket-change", CONFIGSET_TKT },
99 { "ticket-newpage", CONFIGSET_TKT },
100 { "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
103 { "ticket-report-template", CONFIGSET_TKT },
104 { "ticket-key-template", CONFIGSET_TKT },
105 { "ticket-title-expr", CONFIGSET_TKT },
106 { "ticket-closed-expr", CONFIGSET_TKT },
107 { "@reportfmt", CONFIGSET_TKT },
 
108 { "@user", CONFIGSET_USER },
 
109 { "@concealed", CONFIGSET_ADDR },
 
110 { "@shun", CONFIGSET_SHUN },
 
111 { "xfer-common-script", CONFIGSET_XFER },
112 { "xfer-push-script", CONFIGSET_XFER },
 
113 };
114 static int iConfig = 0;
115
116 /*
117 ** Return name of first configuration property matching the given mask.
118
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
78 { "css", CONFIGSET_SKIN },
79 { "header", CONFIGSET_SKIN },
80 { "footer", CONFIGSET_SKIN },
81 { "logo-mimetype", CONFIGSET_SKIN },
82 { "logo-image", CONFIGSET_SKIN },
83 { "background-mimetype", CONFIGSET_SKIN },
84 { "background-image", CONFIGSET_SKIN },
85 { "index-page", CONFIGSET_SKIN },
86 { "timeline-block-markup", CONFIGSET_SKIN },
87 { "timeline-max-comment", CONFIGSET_SKIN },
88 #ifdef FOSSIL_ENABLE_TCL
89 { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
90 #endif
91
92 { "project-name", CONFIGSET_PROJ },
93 { "project-description", CONFIGSET_PROJ },
94 { "manifest", CONFIGSET_PROJ },
95 { "ignore-glob", CONFIGSET_PROJ },
96 { "crnl-glob", CONFIGSET_PROJ },
97 { "empty-dirs", CONFIGSET_PROJ },
98 { "allow-symlinks", CONFIGSET_PROJ },
99
 
 
 
 
 
100 { "ticket-table", CONFIGSET_TKT },
101 { "ticket-common", CONFIGSET_TKT },
102 { "ticket-change", CONFIGSET_TKT },
103 { "ticket-newpage", CONFIGSET_TKT },
104 { "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
107 { "ticket-report-template", CONFIGSET_TKT },
108 { "ticket-key-template", CONFIGSET_TKT },
109 { "ticket-title-expr", CONFIGSET_TKT },
110 { "ticket-closed-expr", CONFIGSET_TKT },
111 { "@reportfmt", CONFIGSET_TKT },
112
113 { "@user", CONFIGSET_USER },
114
115 { "@concealed", CONFIGSET_ADDR },
116
117 { "@shun", CONFIGSET_SHUN },
118
119 { "xfer-common-script", CONFIGSET_XFER },
120 { "xfer-push-script", CONFIGSET_XFER },
121
122 };
123 static int iConfig = 0;
124
125 /*
126 ** Return name of first configuration property matching the given mask.
127
+33
--- src/doc.c
+++ src/doc.c
@@ -604,5 +604,38 @@
604604
}
605605
cgi_set_content_type(zMime);
606606
cgi_set_content(&logo);
607607
g.isConst = 1;
608608
}
609
+
610
+/*
611
+** The default background image: a 16x16 white GIF
612
+*/
613
+static const unsigned char aBackground[] = {
614
+ 71, 73, 70, 56, 57, 97, 16, 0, 16, 0,
615
+ 240, 0, 0, 255, 255, 255, 0, 0, 0, 33,
616
+ 254, 4, 119, 105, 115, 104, 0, 44, 0, 0,
617
+ 0, 0, 16, 0, 16, 0, 0, 2, 14, 132,
618
+ 143, 169, 203, 237, 15, 163, 156, 180, 218, 139,
619
+ 179, 62, 5, 0, 59,
620
+};
621
+
622
+
623
+/*
624
+** WEBPAGE: background
625
+**
626
+** Return the background image.
627
+*/
628
+void background_page(void){
629
+ Blob bgimg;
630
+ char *zMime;
631
+
632
+ zMime = db_get("background-mimetype", "image/gif");
633
+ blob_zero(&bgimg);
634
+ db_blob(&bgimg, "SELECT value FROM config WHERE name='background-image'");
635
+ if( blob_size(&bgimg)==0 ){
636
+ blob_init(&bgimg, (char*)aBackground, sizeof(aBackground));
637
+ }
638
+ cgi_set_content_type(zMime);
639
+ cgi_set_content(&bgimg);
640
+ g.isConst = 1;
641
+}
609642
--- src/doc.c
+++ src/doc.c
@@ -604,5 +604,38 @@
604 }
605 cgi_set_content_type(zMime);
606 cgi_set_content(&logo);
607 g.isConst = 1;
608 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
--- src/doc.c
+++ src/doc.c
@@ -604,5 +604,38 @@
604 }
605 cgi_set_content_type(zMime);
606 cgi_set_content(&logo);
607 g.isConst = 1;
608 }
609
610 /*
611 ** The default background image: a 16x16 white GIF
612 */
613 static const unsigned char aBackground[] = {
614 71, 73, 70, 56, 57, 97, 16, 0, 16, 0,
615 240, 0, 0, 255, 255, 255, 0, 0, 0, 33,
616 254, 4, 119, 105, 115, 104, 0, 44, 0, 0,
617 0, 0, 16, 0, 16, 0, 0, 2, 14, 132,
618 143, 169, 203, 237, 15, 163, 156, 180, 218, 139,
619 179, 62, 5, 0, 59,
620 };
621
622
623 /*
624 ** WEBPAGE: background
625 **
626 ** Return the background image.
627 */
628 void background_page(void){
629 Blob bgimg;
630 char *zMime;
631
632 zMime = db_get("background-mimetype", "image/gif");
633 blob_zero(&bgimg);
634 db_blob(&bgimg, "SELECT value FROM config WHERE name='background-image'");
635 if( blob_size(&bgimg)==0 ){
636 blob_init(&bgimg, (char*)aBackground, sizeof(aBackground));
637 }
638 cgi_set_content_type(zMime);
639 cgi_set_content(&bgimg);
640 g.isConst = 1;
641 }
642
+80 -26
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
8484
setup_menu_entry("Header", "setup_header",
8585
"Edit HTML text inserted at the top of every page");
8686
setup_menu_entry("Footer", "setup_footer",
8787
"Edit HTML text inserted at the bottom of every page");
8888
setup_menu_entry("Logo", "setup_logo",
89
- "Change the logo image for the server");
89
+ "Change the logo and background images for the server");
9090
setup_menu_entry("Shunned", "shun",
9191
"Show artifacts that are shunned by this repository");
9292
setup_menu_entry("Log", "rcvfromlist",
9393
"A record of received artifacts and their sources");
9494
setup_menu_entry("User-Log", "access_log",
@@ -1319,69 +1319,123 @@
13191319
13201320
/*
13211321
** WEBPAGE: setup_logo
13221322
*/
13231323
void setup_logo(void){
1324
- const char *zMime = db_get("logo-mimetype","image/gif");
1325
- const char *aImg = P("im");
1326
- int szImg = atoi(PD("im:bytes","0"));
1327
- if( szImg>0 ){
1328
- zMime = PD("im:mimetype","image/gif");
1324
+ const char *zLogoMime = db_get("logo-mimetype","image/gif");
1325
+ const char *aLogoImg = P("logoim");
1326
+ int szLogoImg = atoi(PD("logoim:bytes","0"));
1327
+ const char *zBgMime = db_get("background-mimetype","image/gif");
1328
+ const char *aBgImg = P("bgim");
1329
+ int szBgImg = atoi(PD("bgim:bytes","0"));
1330
+ if( szLogoImg>0 ){
1331
+ zLogoMime = PD("logoim:mimetype","image/gif");
1332
+ }
1333
+ if( szBgImg>0 ){
1334
+ zBgMime = PD("bgim:mimetype","image/gif");
13291335
}
13301336
login_check_credentials();
13311337
if( !g.perm.Setup ){
13321338
login_needed();
13331339
}
13341340
db_begin_transaction();
1335
- if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1341
+ if( P("setlogo")!=0 && zLogoMime && zLogoMime[0] && szLogoImg>0 ){
13361342
Blob img;
13371343
Stmt ins;
1338
- blob_init(&img, aImg, szImg);
1344
+ blob_init(&img, aLogoImg, szLogoImg);
13391345
db_prepare(&ins,
13401346
"REPLACE INTO config(name,value,mtime)"
13411347
" VALUES('logo-image',:bytes,now())"
13421348
);
13431349
db_bind_blob(&ins, ":bytes", &img);
13441350
db_step(&ins);
13451351
db_finalize(&ins);
13461352
db_multi_exec(
13471353
"REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1348
- zMime
1354
+ zLogoMime
1355
+ );
1356
+ db_end_transaction(0);
1357
+ cgi_redirect("setup_logo");
1358
+ }else if( P("clrlogo")!=0 ){
1359
+ db_multi_exec(
1360
+ "DELETE FROM config WHERE name IN "
1361
+ "('logo-image','logo-mimetype')"
1362
+ );
1363
+ db_end_transaction(0);
1364
+ cgi_redirect("setup_logo");
1365
+ }else if( P("setbg")!=0 && zBgMime && zBgMime[0] && szBgImg>0 ){
1366
+ Blob img;
1367
+ Stmt ins;
1368
+ blob_init(&img, aBgImg, szBgImg);
1369
+ db_prepare(&ins,
1370
+ "REPLACE INTO config(name,value,mtime)"
1371
+ " VALUES('background-image',:bytes,now())"
1372
+ );
1373
+ db_bind_blob(&ins, ":bytes", &img);
1374
+ db_step(&ins);
1375
+ db_finalize(&ins);
1376
+ db_multi_exec(
1377
+ "REPLACE INTO config(name,value,mtime)"
1378
+ " VALUES('background-mimetype',%Q,now())",
1379
+ zBgMime
13491380
);
13501381
db_end_transaction(0);
13511382
cgi_redirect("setup_logo");
1352
- }else if( P("clr")!=0 ){
1383
+ }else if( P("clrbg")!=0 ){
13531384
db_multi_exec(
1354
- "DELETE FROM config WHERE name GLOB 'logo-*'"
1385
+ "DELETE FROM config WHERE name IN "
1386
+ "('background-image','background-mimetype')"
13551387
);
13561388
db_end_transaction(0);
13571389
cgi_redirect("setup_logo");
13581390
}
1359
- style_header("Edit Project Logo");
1360
- @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1361
- @ like this:</p>
1362
- @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" /></p></blockquote>
1391
+ style_header("Edit Project Logo And Background");
1392
+ @ <p>The current project logo has a MIME-Type of <b>%h(zLogoMime)</b>
1393
+ @ and looks like this:</p>
1394
+ @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" border="1" />
1395
+ @ </p></blockquote>
13631396
@
1397
+ @ <form action="%s(g.zTop)/setup_logo" method="post"
1398
+ @ enctype="multipart/form-data"><div>
13641399
@ <p>The logo is accessible to all users at this URL:
13651400
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
13661401
@ The logo may or may not appear on each
13671402
@ page depending on the <a href="setup_editcss">CSS</a> and
1368
- @ <a href="setup_header">header setup</a>.</p>
1403
+ @ <a href="setup_header">header setup</a>.
1404
+ @ To change the logo image, use the following form:</p>
1405
+ login_insert_csrf_secret();
1406
+ @ Logo Image file:
1407
+ @ <input type="file" name="logoim" size="60" accept="image/*" />
1408
+ @ <p align="center">
1409
+ @ <input type="submit" name="setlogo" value="Change Logo" />
1410
+ @ <input type="submit" name="clrlogo" value="Revert To Default" /></p>
1411
+ @ </div></form>
1412
+ @ <hr />
1413
+ @
1414
+ @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b>
1415
+ @ and looks like this:</p>
1416
+ @ <blockquote><p><img src="%s(g.zTop)/background" alt="background" border=1 />
1417
+ @ </p></blockquote>
13691418
@
13701419
@ <form action="%s(g.zTop)/setup_logo" method="post"
13711420
@ enctype="multipart/form-data"><div>
1372
- @ <p>To set a new logo image, select a file to use as the logo using
1373
- @ the entry box below and then press the "Change Logo" button.</p>
1421
+ @ <p>The background image is accessible to all users at this URL:
1422
+ @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1423
+ @ The background image may or may not appear on each
1424
+ @ page depending on the <a href="setup_editcss">CSS</a> and
1425
+ @ <a href="setup_header">header setup</a>.
1426
+ @ To change the background image, use the following form:</p>
13741427
login_insert_csrf_secret();
1375
- @ Logo Image file:
1376
- @ <input type="file" name="im" size="60" accept="image/*" /><br />
1377
- @ <input type="submit" name="set" value="Change Logo" />
1378
- @ <input type="submit" name="clr" value="Revert To Default" />
1428
+ @ Background image file:
1429
+ @ <input type="file" name="bgim" size="60" accept="image/*" />
1430
+ @ <p align="center">
1431
+ @ <input type="submit" name="setbg" value="Change Background" />
1432
+ @ <input type="submit" name="clrbg" value="Revert To Default" /></p>
13791433
@ </div></form>
1434
+ @ <hr />
13801435
@
1381
- @ <p><span class="note">Note:</span> Your browser has probably cached the
1382
- @ logo image, so you will probably need to press the Reload button on your
1383
- @ browser after changing the logo to provoke your browser to reload the new
1384
- @ logo image. </p>
1436
+ @ <p><span class="note">Note:</span> Your browser has probably cached these
1437
+ @ images, so you may need to press the Reload button before changes will
1438
+ @ take effect. </p>
13851439
style_footer();
13861440
db_end_transaction(0);
13871441
}
13881442
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo image for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
93 "A record of received artifacts and their sources");
94 setup_menu_entry("User-Log", "access_log",
@@ -1319,69 +1319,123 @@
1319
1320 /*
1321 ** WEBPAGE: setup_logo
1322 */
1323 void setup_logo(void){
1324 const char *zMime = db_get("logo-mimetype","image/gif");
1325 const char *aImg = P("im");
1326 int szImg = atoi(PD("im:bytes","0"));
1327 if( szImg>0 ){
1328 zMime = PD("im:mimetype","image/gif");
 
 
 
 
 
 
1329 }
1330 login_check_credentials();
1331 if( !g.perm.Setup ){
1332 login_needed();
1333 }
1334 db_begin_transaction();
1335 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1336 Blob img;
1337 Stmt ins;
1338 blob_init(&img, aImg, szImg);
1339 db_prepare(&ins,
1340 "REPLACE INTO config(name,value,mtime)"
1341 " VALUES('logo-image',:bytes,now())"
1342 );
1343 db_bind_blob(&ins, ":bytes", &img);
1344 db_step(&ins);
1345 db_finalize(&ins);
1346 db_multi_exec(
1347 "REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1348 zMime
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1349 );
1350 db_end_transaction(0);
1351 cgi_redirect("setup_logo");
1352 }else if( P("clr")!=0 ){
1353 db_multi_exec(
1354 "DELETE FROM config WHERE name GLOB 'logo-*'"
 
1355 );
1356 db_end_transaction(0);
1357 cgi_redirect("setup_logo");
1358 }
1359 style_header("Edit Project Logo");
1360 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1361 @ like this:</p>
1362 @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" /></p></blockquote>
 
1363 @
 
 
1364 @ <p>The logo is accessible to all users at this URL:
1365 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1366 @ The logo may or may not appear on each
1367 @ page depending on the <a href="setup_editcss">CSS</a> and
1368 @ <a href="setup_header">header setup</a>.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1369 @
1370 @ <form action="%s(g.zTop)/setup_logo" method="post"
1371 @ enctype="multipart/form-data"><div>
1372 @ <p>To set a new logo image, select a file to use as the logo using
1373 @ the entry box below and then press the "Change Logo" button.</p>
 
 
 
 
1374 login_insert_csrf_secret();
1375 @ Logo Image file:
1376 @ <input type="file" name="im" size="60" accept="image/*" /><br />
1377 @ <input type="submit" name="set" value="Change Logo" />
1378 @ <input type="submit" name="clr" value="Revert To Default" />
 
1379 @ </div></form>
 
1380 @
1381 @ <p><span class="note">Note:</span> Your browser has probably cached the
1382 @ logo image, so you will probably need to press the Reload button on your
1383 @ browser after changing the logo to provoke your browser to reload the new
1384 @ logo image. </p>
1385 style_footer();
1386 db_end_transaction(0);
1387 }
1388
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo and background images for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
93 "A record of received artifacts and their sources");
94 setup_menu_entry("User-Log", "access_log",
@@ -1319,69 +1319,123 @@
1319
1320 /*
1321 ** WEBPAGE: setup_logo
1322 */
1323 void setup_logo(void){
1324 const char *zLogoMime = db_get("logo-mimetype","image/gif");
1325 const char *aLogoImg = P("logoim");
1326 int szLogoImg = atoi(PD("logoim:bytes","0"));
1327 const char *zBgMime = db_get("background-mimetype","image/gif");
1328 const char *aBgImg = P("bgim");
1329 int szBgImg = atoi(PD("bgim:bytes","0"));
1330 if( szLogoImg>0 ){
1331 zLogoMime = PD("logoim:mimetype","image/gif");
1332 }
1333 if( szBgImg>0 ){
1334 zBgMime = PD("bgim:mimetype","image/gif");
1335 }
1336 login_check_credentials();
1337 if( !g.perm.Setup ){
1338 login_needed();
1339 }
1340 db_begin_transaction();
1341 if( P("setlogo")!=0 && zLogoMime && zLogoMime[0] && szLogoImg>0 ){
1342 Blob img;
1343 Stmt ins;
1344 blob_init(&img, aLogoImg, szLogoImg);
1345 db_prepare(&ins,
1346 "REPLACE INTO config(name,value,mtime)"
1347 " VALUES('logo-image',:bytes,now())"
1348 );
1349 db_bind_blob(&ins, ":bytes", &img);
1350 db_step(&ins);
1351 db_finalize(&ins);
1352 db_multi_exec(
1353 "REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1354 zLogoMime
1355 );
1356 db_end_transaction(0);
1357 cgi_redirect("setup_logo");
1358 }else if( P("clrlogo")!=0 ){
1359 db_multi_exec(
1360 "DELETE FROM config WHERE name IN "
1361 "('logo-image','logo-mimetype')"
1362 );
1363 db_end_transaction(0);
1364 cgi_redirect("setup_logo");
1365 }else if( P("setbg")!=0 && zBgMime && zBgMime[0] && szBgImg>0 ){
1366 Blob img;
1367 Stmt ins;
1368 blob_init(&img, aBgImg, szBgImg);
1369 db_prepare(&ins,
1370 "REPLACE INTO config(name,value,mtime)"
1371 " VALUES('background-image',:bytes,now())"
1372 );
1373 db_bind_blob(&ins, ":bytes", &img);
1374 db_step(&ins);
1375 db_finalize(&ins);
1376 db_multi_exec(
1377 "REPLACE INTO config(name,value,mtime)"
1378 " VALUES('background-mimetype',%Q,now())",
1379 zBgMime
1380 );
1381 db_end_transaction(0);
1382 cgi_redirect("setup_logo");
1383 }else if( P("clrbg")!=0 ){
1384 db_multi_exec(
1385 "DELETE FROM config WHERE name IN "
1386 "('background-image','background-mimetype')"
1387 );
1388 db_end_transaction(0);
1389 cgi_redirect("setup_logo");
1390 }
1391 style_header("Edit Project Logo And Background");
1392 @ <p>The current project logo has a MIME-Type of <b>%h(zLogoMime)</b>
1393 @ and looks like this:</p>
1394 @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" border="1" />
1395 @ </p></blockquote>
1396 @
1397 @ <form action="%s(g.zTop)/setup_logo" method="post"
1398 @ enctype="multipart/form-data"><div>
1399 @ <p>The logo is accessible to all users at this URL:
1400 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1401 @ The logo may or may not appear on each
1402 @ page depending on the <a href="setup_editcss">CSS</a> and
1403 @ <a href="setup_header">header setup</a>.
1404 @ To change the logo image, use the following form:</p>
1405 login_insert_csrf_secret();
1406 @ Logo Image file:
1407 @ <input type="file" name="logoim" size="60" accept="image/*" />
1408 @ <p align="center">
1409 @ <input type="submit" name="setlogo" value="Change Logo" />
1410 @ <input type="submit" name="clrlogo" value="Revert To Default" /></p>
1411 @ </div></form>
1412 @ <hr />
1413 @
1414 @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b>
1415 @ and looks like this:</p>
1416 @ <blockquote><p><img src="%s(g.zTop)/background" alt="background" border=1 />
1417 @ </p></blockquote>
1418 @
1419 @ <form action="%s(g.zTop)/setup_logo" method="post"
1420 @ enctype="multipart/form-data"><div>
1421 @ <p>The background image is accessible to all users at this URL:
1422 @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1423 @ The background image may or may not appear on each
1424 @ page depending on the <a href="setup_editcss">CSS</a> and
1425 @ <a href="setup_header">header setup</a>.
1426 @ To change the background image, use the following form:</p>
1427 login_insert_csrf_secret();
1428 @ Background image file:
1429 @ <input type="file" name="bgim" size="60" accept="image/*" />
1430 @ <p align="center">
1431 @ <input type="submit" name="setbg" value="Change Background" />
1432 @ <input type="submit" name="clrbg" value="Revert To Default" /></p>
1433 @ </div></form>
1434 @ <hr />
1435 @
1436 @ <p><span class="note">Note:</span> Your browser has probably cached these
1437 @ images, so you may need to press the Reload button before changes will
1438 @ take effect. </p>
 
1439 style_footer();
1440 db_end_transaction(0);
1441 }
1442
+20 -13
--- src/style.c
+++ src/style.c
@@ -813,28 +813,35 @@
813813
814814
/*
815815
** WEBPAGE: style.css
816816
*/
817817
void page_style_css(void){
818
+ Blob css;
818819
const char *zCSS = 0;
819820
int i;
820821
821822
cgi_set_content_type("text/css");
822
- zCSS = db_get("css",(char*)zDefaultCSS);
823
- /* append user defined css */
824
- cgi_append_content(zCSS, -1);
823
+ blob_init(&css, db_get("css",(char*)zDefaultCSS), -1);
824
+
825825
/* add special missing definitions */
826
- for (i=1;cssDefaultList[i].elementClass;i++)
827
- if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
828
- cgi_append_content("/* ", -1);
829
- cgi_append_content(cssDefaultList[i].comment, -1);
830
- cgi_append_content(" */\n", -1);
831
- cgi_append_content(cssDefaultList[i].elementClass, -1);
832
- cgi_append_content(" {\n", -1);
833
- cgi_append_content(cssDefaultList[i].value, -1);
834
- cgi_append_content("}\n\n", -1);
835
- }
826
+ for(i=1; cssDefaultList[i].elementClass; i++){
827
+ if( strstr(blob_str(&css), cssDefaultList[i].elementClass)==0 ){
828
+ blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
829
+ cssDefaultList[i].comment,
830
+ cssDefaultList[i].elementClass,
831
+ cssDefaultList[i].value);
832
+ }
833
+ }
834
+
835
+ /* Process through TH1 in order to give an opportunity to substitute
836
+ ** variables such as $baseurl.
837
+ */
838
+ Th_Store("baseurl", g.zBaseURL);
839
+ Th_Store("home", g.zTop);
840
+ Th_Render(blob_str(&css));
841
+
842
+ /* Tell CGI that the content returned by this page is considered cacheable */
836843
g.isConst = 1;
837844
}
838845
839846
/*
840847
** WEBPAGE: test_env
841848
--- src/style.c
+++ src/style.c
@@ -813,28 +813,35 @@
813
814 /*
815 ** WEBPAGE: style.css
816 */
817 void page_style_css(void){
 
818 const char *zCSS = 0;
819 int i;
820
821 cgi_set_content_type("text/css");
822 zCSS = db_get("css",(char*)zDefaultCSS);
823 /* append user defined css */
824 cgi_append_content(zCSS, -1);
825 /* add special missing definitions */
826 for (i=1;cssDefaultList[i].elementClass;i++)
827 if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
828 cgi_append_content("/* ", -1);
829 cgi_append_content(cssDefaultList[i].comment, -1);
830 cgi_append_content(" */\n", -1);
831 cgi_append_content(cssDefaultList[i].elementClass, -1);
832 cgi_append_content(" {\n", -1);
833 cgi_append_content(cssDefaultList[i].value, -1);
834 cgi_append_content("}\n\n", -1);
835 }
 
 
 
 
 
 
 
836 g.isConst = 1;
837 }
838
839 /*
840 ** WEBPAGE: test_env
841
--- src/style.c
+++ src/style.c
@@ -813,28 +813,35 @@
813
814 /*
815 ** WEBPAGE: style.css
816 */
817 void page_style_css(void){
818 Blob css;
819 const char *zCSS = 0;
820 int i;
821
822 cgi_set_content_type("text/css");
823 blob_init(&css, db_get("css",(char*)zDefaultCSS), -1);
824
 
825 /* add special missing definitions */
826 for(i=1; cssDefaultList[i].elementClass; i++){
827 if( strstr(blob_str(&css), cssDefaultList[i].elementClass)==0 ){
828 blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
829 cssDefaultList[i].comment,
830 cssDefaultList[i].elementClass,
831 cssDefaultList[i].value);
832 }
833 }
834
835 /* Process through TH1 in order to give an opportunity to substitute
836 ** variables such as $baseurl.
837 */
838 Th_Store("baseurl", g.zBaseURL);
839 Th_Store("home", g.zTop);
840 Th_Render(blob_str(&css));
841
842 /* Tell CGI that the content returned by this page is considered cacheable */
843 g.isConst = 1;
844 }
845
846 /*
847 ** WEBPAGE: test_env
848

Keyboard Shortcuts

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