Fossil SCM
Improvements to the setup page, including a button to automatically add the <base> element to the header if it is missing.
Commit
bf27074c825143d7ce596555ad4cc9041199c117
Parent
31732d77ff6c661…
1 file changed
+35
-13
+35
-13
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -62,11 +62,11 @@ | ||
| 62 | 62 | |
| 63 | 63 | /* Make sure the header contains <base href="...">. Issue a warning |
| 64 | 64 | ** if it does not. */ |
| 65 | 65 | if( !cgi_header_contains("<base href=") ){ |
| 66 | 66 | @ <p class="generalError"><b>Configuration Error:</b> Please add |
| 67 | - @ <tt><base href="$baseurl/" /></tt> after <tt><head></tt> | |
| 67 | + @ <tt><base href="$baseurl/"></tt> after <tt><head></tt> | |
| 68 | 68 | @ in the <a href="setup_header">HTML header</a>!</p> |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | @ <table border="0" cellspacing="7"> |
| 72 | 72 | setup_menu_entry("Users", "setup_ulist", |
| @@ -878,13 +878,15 @@ | ||
| 878 | 878 | login_verify_csrf_secret(); |
| 879 | 879 | db_set(zVar, zQ, 0); |
| 880 | 880 | z = zQ; |
| 881 | 881 | } |
| 882 | 882 | if( rows>0 && cols>0 ){ |
| 883 | - @ <textarea name="%s(zQP)" rows="%d(rows)" cols="%d(cols)">%h(z)</textarea> | |
| 884 | - if (zLabel && *zLabel) | |
| 883 | + @ <textarea id="id%s(zQP)" name="%s(zQP)" rows="%d(rows)" | |
| 884 | + @ cols="%d(cols)">%h(z)</textarea> | |
| 885 | + if (zLabel && *zLabel){ | |
| 885 | 886 | @ <span class="textareaLabel">%s(zLabel)</span> |
| 887 | + } | |
| 886 | 888 | } |
| 887 | 889 | } |
| 888 | 890 | |
| 889 | 891 | |
| 890 | 892 | /* |
| @@ -1306,22 +1308,21 @@ | ||
| 1306 | 1308 | if( P("clear")!=0 ){ |
| 1307 | 1309 | db_multi_exec("DELETE FROM config WHERE name='css'"); |
| 1308 | 1310 | cgi_replace_parameter("css", zDefaultCSS); |
| 1309 | 1311 | db_end_transaction(0); |
| 1310 | 1312 | cgi_redirect("setup_editcss"); |
| 1311 | - }else{ | |
| 1312 | - textarea_attribute(0, 0, 0, "css", "css", zDefaultCSS); | |
| 1313 | 1313 | } |
| 1314 | 1314 | if( P("submit")!=0 ){ |
| 1315 | + textarea_attribute(0, 0, 0, "css", "css", zDefaultCSS); | |
| 1315 | 1316 | db_end_transaction(0); |
| 1316 | 1317 | cgi_redirect("setup_editcss"); |
| 1317 | 1318 | } |
| 1318 | 1319 | style_header("Edit CSS"); |
| 1319 | 1320 | @ <form action="%s(g.zTop)/setup_editcss" method="post"><div> |
| 1320 | 1321 | login_insert_csrf_secret(); |
| 1321 | 1322 | @ Edit the CSS below:<br /> |
| 1322 | - textarea_attribute("", 40, 80, "css", "css", zDefaultCSS); | |
| 1323 | + textarea_attribute("", 35, 80, "css", "css", zDefaultCSS); | |
| 1323 | 1324 | @ <br /> |
| 1324 | 1325 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 1325 | 1326 | @ <input type="submit" name="clear" value="Revert To Default" /> |
| 1326 | 1327 | @ </div></form> |
| 1327 | 1328 | @ <p><span class="note">Note:</span> Press your browser Reload button after |
| @@ -1348,20 +1349,43 @@ | ||
| 1348 | 1349 | } |
| 1349 | 1350 | db_begin_transaction(); |
| 1350 | 1351 | if( P("clear")!=0 ){ |
| 1351 | 1352 | db_multi_exec("DELETE FROM config WHERE name='header'"); |
| 1352 | 1353 | cgi_replace_parameter("header", zDefaultHeader); |
| 1353 | - }else{ | |
| 1354 | + }else if( P("submit")!=0 ){ | |
| 1354 | 1355 | textarea_attribute(0, 0, 0, "header", "header", zDefaultHeader); |
| 1356 | + }else if( P("fixbase")!=0 ){ | |
| 1357 | + const char *z = db_get("header", (char*)zDefaultHeader); | |
| 1358 | + char *zHead = strstr(z, "<head>"); | |
| 1359 | + if( strstr(z, "<base href=")==0 && zHead!=0 ){ | |
| 1360 | + char *zNew; | |
| 1361 | + char *zTail = &zHead[6]; | |
| 1362 | + while( fossil_isspace(zTail[0]) ) zTail++; | |
| 1363 | + zNew = mprintf("%.*s\n<base href=\"$baseurl/\" />\n%s", | |
| 1364 | + zHead+6-z, z, zTail); | |
| 1365 | + cgi_replace_parameter("header", zNew); | |
| 1366 | + db_set("header", zNew, 0); | |
| 1367 | + } | |
| 1355 | 1368 | } |
| 1369 | + | |
| 1356 | 1370 | style_header("Edit Page Header"); |
| 1357 | - @ <form action="%s(g.zTop)/setup_header" method="post"><div> | |
| 1371 | + @ <form action="%R/setup_header" method="post"><div> | |
| 1372 | + | |
| 1373 | + /* Make sure the header contains <base href="...">. Issue a warning | |
| 1374 | + ** if it does not. */ | |
| 1375 | + if( !cgi_header_contains("<base href=") ){ | |
| 1376 | + @ <p class="generalError">Please add | |
| 1377 | + @ <tt><base href="$baseurl/"></tt> after <tt><head></tt> | |
| 1378 | + @ in the header! | |
| 1379 | + @ <input type="submit" name="fixbase" value="Add <base> Now"></p> | |
| 1380 | + } | |
| 1381 | + | |
| 1358 | 1382 | login_insert_csrf_secret(); |
| 1359 | 1383 | @ <p>Edit HTML text with embedded TH1 (a TCL dialect) that will be used to |
| 1360 | 1384 | @ generate the beginning of every page through start of the main |
| 1361 | 1385 | @ menu.</p> |
| 1362 | - textarea_attribute("", 40, 80, "header", "header", zDefaultHeader); | |
| 1386 | + textarea_attribute("", 35, 80, "header", "header", zDefaultHeader); | |
| 1363 | 1387 | @ <br /> |
| 1364 | 1388 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 1365 | 1389 | @ <input type="submit" name="clear" value="Revert To Default" /> |
| 1366 | 1390 | @ </div></form> |
| 1367 | 1391 | @ <hr /> |
| @@ -1386,13 +1410,12 @@ | ||
| 1386 | 1410 | } |
| 1387 | 1411 | db_begin_transaction(); |
| 1388 | 1412 | if( P("clear")!=0 ){ |
| 1389 | 1413 | db_multi_exec("DELETE FROM config WHERE name='footer'"); |
| 1390 | 1414 | cgi_replace_parameter("footer", zDefaultFooter); |
| 1391 | - }else{ | |
| 1392 | - textarea_attribute(0, 0, 0, "footer", "footer", zDefaultFooter); | |
| 1393 | 1415 | } |
| 1416 | + | |
| 1394 | 1417 | style_header("Edit Page Footer"); |
| 1395 | 1418 | @ <form action="%s(g.zTop)/setup_footer" method="post"><div> |
| 1396 | 1419 | login_insert_csrf_secret(); |
| 1397 | 1420 | @ <p>Edit HTML text with embedded TH1 (a TCL dialect) that will be used to |
| 1398 | 1421 | @ generate the end of every page.</p> |
| @@ -1423,13 +1446,12 @@ | ||
| 1423 | 1446 | } |
| 1424 | 1447 | db_begin_transaction(); |
| 1425 | 1448 | if( P("clear")!=0 ){ |
| 1426 | 1449 | db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'"); |
| 1427 | 1450 | cgi_replace_parameter("adunit",""); |
| 1428 | - }else{ | |
| 1429 | - textarea_attribute(0, 0, 0, "adunit", "adunit", ""); | |
| 1430 | 1451 | } |
| 1452 | + | |
| 1431 | 1453 | style_header("Edit Ad Unit"); |
| 1432 | 1454 | @ <form action="%s(g.zTop)/setup_adunit" method="post"><div> |
| 1433 | 1455 | login_insert_csrf_secret(); |
| 1434 | 1456 | @ <p>Edit HTML text for an ad unit that will be inserted after the |
| 1435 | 1457 | @ menu bar and above the content of every page.</p> |
| 1436 | 1458 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -62,11 +62,11 @@ | |
| 62 | |
| 63 | /* Make sure the header contains <base href="...">. Issue a warning |
| 64 | ** if it does not. */ |
| 65 | if( !cgi_header_contains("<base href=") ){ |
| 66 | @ <p class="generalError"><b>Configuration Error:</b> Please add |
| 67 | @ <tt><base href="$baseurl/" /></tt> after <tt><head></tt> |
| 68 | @ in the <a href="setup_header">HTML header</a>!</p> |
| 69 | } |
| 70 | |
| 71 | @ <table border="0" cellspacing="7"> |
| 72 | setup_menu_entry("Users", "setup_ulist", |
| @@ -878,13 +878,15 @@ | |
| 878 | login_verify_csrf_secret(); |
| 879 | db_set(zVar, zQ, 0); |
| 880 | z = zQ; |
| 881 | } |
| 882 | if( rows>0 && cols>0 ){ |
| 883 | @ <textarea name="%s(zQP)" rows="%d(rows)" cols="%d(cols)">%h(z)</textarea> |
| 884 | if (zLabel && *zLabel) |
| 885 | @ <span class="textareaLabel">%s(zLabel)</span> |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | |
| 890 | /* |
| @@ -1306,22 +1308,21 @@ | |
| 1306 | if( P("clear")!=0 ){ |
| 1307 | db_multi_exec("DELETE FROM config WHERE name='css'"); |
| 1308 | cgi_replace_parameter("css", zDefaultCSS); |
| 1309 | db_end_transaction(0); |
| 1310 | cgi_redirect("setup_editcss"); |
| 1311 | }else{ |
| 1312 | textarea_attribute(0, 0, 0, "css", "css", zDefaultCSS); |
| 1313 | } |
| 1314 | if( P("submit")!=0 ){ |
| 1315 | db_end_transaction(0); |
| 1316 | cgi_redirect("setup_editcss"); |
| 1317 | } |
| 1318 | style_header("Edit CSS"); |
| 1319 | @ <form action="%s(g.zTop)/setup_editcss" method="post"><div> |
| 1320 | login_insert_csrf_secret(); |
| 1321 | @ Edit the CSS below:<br /> |
| 1322 | textarea_attribute("", 40, 80, "css", "css", zDefaultCSS); |
| 1323 | @ <br /> |
| 1324 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 1325 | @ <input type="submit" name="clear" value="Revert To Default" /> |
| 1326 | @ </div></form> |
| 1327 | @ <p><span class="note">Note:</span> Press your browser Reload button after |
| @@ -1348,20 +1349,43 @@ | |
| 1348 | } |
| 1349 | db_begin_transaction(); |
| 1350 | if( P("clear")!=0 ){ |
| 1351 | db_multi_exec("DELETE FROM config WHERE name='header'"); |
| 1352 | cgi_replace_parameter("header", zDefaultHeader); |
| 1353 | }else{ |
| 1354 | textarea_attribute(0, 0, 0, "header", "header", zDefaultHeader); |
| 1355 | } |
| 1356 | style_header("Edit Page Header"); |
| 1357 | @ <form action="%s(g.zTop)/setup_header" method="post"><div> |
| 1358 | login_insert_csrf_secret(); |
| 1359 | @ <p>Edit HTML text with embedded TH1 (a TCL dialect) that will be used to |
| 1360 | @ generate the beginning of every page through start of the main |
| 1361 | @ menu.</p> |
| 1362 | textarea_attribute("", 40, 80, "header", "header", zDefaultHeader); |
| 1363 | @ <br /> |
| 1364 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 1365 | @ <input type="submit" name="clear" value="Revert To Default" /> |
| 1366 | @ </div></form> |
| 1367 | @ <hr /> |
| @@ -1386,13 +1410,12 @@ | |
| 1386 | } |
| 1387 | db_begin_transaction(); |
| 1388 | if( P("clear")!=0 ){ |
| 1389 | db_multi_exec("DELETE FROM config WHERE name='footer'"); |
| 1390 | cgi_replace_parameter("footer", zDefaultFooter); |
| 1391 | }else{ |
| 1392 | textarea_attribute(0, 0, 0, "footer", "footer", zDefaultFooter); |
| 1393 | } |
| 1394 | style_header("Edit Page Footer"); |
| 1395 | @ <form action="%s(g.zTop)/setup_footer" method="post"><div> |
| 1396 | login_insert_csrf_secret(); |
| 1397 | @ <p>Edit HTML text with embedded TH1 (a TCL dialect) that will be used to |
| 1398 | @ generate the end of every page.</p> |
| @@ -1423,13 +1446,12 @@ | |
| 1423 | } |
| 1424 | db_begin_transaction(); |
| 1425 | if( P("clear")!=0 ){ |
| 1426 | db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'"); |
| 1427 | cgi_replace_parameter("adunit",""); |
| 1428 | }else{ |
| 1429 | textarea_attribute(0, 0, 0, "adunit", "adunit", ""); |
| 1430 | } |
| 1431 | style_header("Edit Ad Unit"); |
| 1432 | @ <form action="%s(g.zTop)/setup_adunit" method="post"><div> |
| 1433 | login_insert_csrf_secret(); |
| 1434 | @ <p>Edit HTML text for an ad unit that will be inserted after the |
| 1435 | @ menu bar and above the content of every page.</p> |
| 1436 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -62,11 +62,11 @@ | |
| 62 | |
| 63 | /* Make sure the header contains <base href="...">. Issue a warning |
| 64 | ** if it does not. */ |
| 65 | if( !cgi_header_contains("<base href=") ){ |
| 66 | @ <p class="generalError"><b>Configuration Error:</b> Please add |
| 67 | @ <tt><base href="$baseurl/"></tt> after <tt><head></tt> |
| 68 | @ in the <a href="setup_header">HTML header</a>!</p> |
| 69 | } |
| 70 | |
| 71 | @ <table border="0" cellspacing="7"> |
| 72 | setup_menu_entry("Users", "setup_ulist", |
| @@ -878,13 +878,15 @@ | |
| 878 | login_verify_csrf_secret(); |
| 879 | db_set(zVar, zQ, 0); |
| 880 | z = zQ; |
| 881 | } |
| 882 | if( rows>0 && cols>0 ){ |
| 883 | @ <textarea id="id%s(zQP)" name="%s(zQP)" rows="%d(rows)" |
| 884 | @ cols="%d(cols)">%h(z)</textarea> |
| 885 | if (zLabel && *zLabel){ |
| 886 | @ <span class="textareaLabel">%s(zLabel)</span> |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | |
| 892 | /* |
| @@ -1306,22 +1308,21 @@ | |
| 1308 | if( P("clear")!=0 ){ |
| 1309 | db_multi_exec("DELETE FROM config WHERE name='css'"); |
| 1310 | cgi_replace_parameter("css", zDefaultCSS); |
| 1311 | db_end_transaction(0); |
| 1312 | cgi_redirect("setup_editcss"); |
| 1313 | } |
| 1314 | if( P("submit")!=0 ){ |
| 1315 | textarea_attribute(0, 0, 0, "css", "css", zDefaultCSS); |
| 1316 | db_end_transaction(0); |
| 1317 | cgi_redirect("setup_editcss"); |
| 1318 | } |
| 1319 | style_header("Edit CSS"); |
| 1320 | @ <form action="%s(g.zTop)/setup_editcss" method="post"><div> |
| 1321 | login_insert_csrf_secret(); |
| 1322 | @ Edit the CSS below:<br /> |
| 1323 | textarea_attribute("", 35, 80, "css", "css", zDefaultCSS); |
| 1324 | @ <br /> |
| 1325 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 1326 | @ <input type="submit" name="clear" value="Revert To Default" /> |
| 1327 | @ </div></form> |
| 1328 | @ <p><span class="note">Note:</span> Press your browser Reload button after |
| @@ -1348,20 +1349,43 @@ | |
| 1349 | } |
| 1350 | db_begin_transaction(); |
| 1351 | if( P("clear")!=0 ){ |
| 1352 | db_multi_exec("DELETE FROM config WHERE name='header'"); |
| 1353 | cgi_replace_parameter("header", zDefaultHeader); |
| 1354 | }else if( P("submit")!=0 ){ |
| 1355 | textarea_attribute(0, 0, 0, "header", "header", zDefaultHeader); |
| 1356 | }else if( P("fixbase")!=0 ){ |
| 1357 | const char *z = db_get("header", (char*)zDefaultHeader); |
| 1358 | char *zHead = strstr(z, "<head>"); |
| 1359 | if( strstr(z, "<base href=")==0 && zHead!=0 ){ |
| 1360 | char *zNew; |
| 1361 | char *zTail = &zHead[6]; |
| 1362 | while( fossil_isspace(zTail[0]) ) zTail++; |
| 1363 | zNew = mprintf("%.*s\n<base href=\"$baseurl/\" />\n%s", |
| 1364 | zHead+6-z, z, zTail); |
| 1365 | cgi_replace_parameter("header", zNew); |
| 1366 | db_set("header", zNew, 0); |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | style_header("Edit Page Header"); |
| 1371 | @ <form action="%R/setup_header" method="post"><div> |
| 1372 | |
| 1373 | /* Make sure the header contains <base href="...">. Issue a warning |
| 1374 | ** if it does not. */ |
| 1375 | if( !cgi_header_contains("<base href=") ){ |
| 1376 | @ <p class="generalError">Please add |
| 1377 | @ <tt><base href="$baseurl/"></tt> after <tt><head></tt> |
| 1378 | @ in the header! |
| 1379 | @ <input type="submit" name="fixbase" value="Add <base> Now"></p> |
| 1380 | } |
| 1381 | |
| 1382 | login_insert_csrf_secret(); |
| 1383 | @ <p>Edit HTML text with embedded TH1 (a TCL dialect) that will be used to |
| 1384 | @ generate the beginning of every page through start of the main |
| 1385 | @ menu.</p> |
| 1386 | textarea_attribute("", 35, 80, "header", "header", zDefaultHeader); |
| 1387 | @ <br /> |
| 1388 | @ <input type="submit" name="submit" value="Apply Changes" /> |
| 1389 | @ <input type="submit" name="clear" value="Revert To Default" /> |
| 1390 | @ </div></form> |
| 1391 | @ <hr /> |
| @@ -1386,13 +1410,12 @@ | |
| 1410 | } |
| 1411 | db_begin_transaction(); |
| 1412 | if( P("clear")!=0 ){ |
| 1413 | db_multi_exec("DELETE FROM config WHERE name='footer'"); |
| 1414 | cgi_replace_parameter("footer", zDefaultFooter); |
| 1415 | } |
| 1416 | |
| 1417 | style_header("Edit Page Footer"); |
| 1418 | @ <form action="%s(g.zTop)/setup_footer" method="post"><div> |
| 1419 | login_insert_csrf_secret(); |
| 1420 | @ <p>Edit HTML text with embedded TH1 (a TCL dialect) that will be used to |
| 1421 | @ generate the end of every page.</p> |
| @@ -1423,13 +1446,12 @@ | |
| 1446 | } |
| 1447 | db_begin_transaction(); |
| 1448 | if( P("clear")!=0 ){ |
| 1449 | db_multi_exec("DELETE FROM config WHERE name GLOB 'adunit*'"); |
| 1450 | cgi_replace_parameter("adunit",""); |
| 1451 | } |
| 1452 | |
| 1453 | style_header("Edit Ad Unit"); |
| 1454 | @ <form action="%s(g.zTop)/setup_adunit" method="post"><div> |
| 1455 | login_insert_csrf_secret(); |
| 1456 | @ <p>Edit HTML text for an ad unit that will be inserted after the |
| 1457 | @ menu bar and above the content of every page.</p> |
| 1458 |