Fossil SCM
Break out configuration options for tarballs and ZIPs onto a new configuration page. Honor the short-project-name when constructing filesname for tarballs and ZIPs.
Commit
50dba704e1febdbfa15a550e31af6c327ea47fd49a47f762dd85bd7fb97f386a
Parent
57caee0317900b8…
2 files changed
+42
-22
+8
-4
+42
-22
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -118,10 +118,12 @@ | ||
| 118 | 118 | setup_menu_entry("Settings", "setup_settings", |
| 119 | 119 | "Web interface to the \"fossil settings\" command"); |
| 120 | 120 | } |
| 121 | 121 | setup_menu_entry("Timeline", "setup_timeline", |
| 122 | 122 | "Timeline display preferences"); |
| 123 | + setup_menu_entry("Tarballs and ZIPs", "setup_download", | |
| 124 | + "Preferences for auto-generated tarballs and ZIP files"); | |
| 123 | 125 | if( setup_user ){ |
| 124 | 126 | setup_menu_entry("Login-Group", "setup_login_group", |
| 125 | 127 | "Manage single sign-on between this repository and others" |
| 126 | 128 | " on the same server"); |
| 127 | 129 | setup_menu_entry("Tickets", "tktsetup", |
| @@ -1340,28 +1342,10 @@ | ||
| 1340 | 1342 | @ Omit the trailing "/". |
| 1341 | 1343 | @ If this repo will not be set up as a persistent server and will not |
| 1342 | 1344 | @ be sending email alerts, then leave this entry blank. |
| 1343 | 1345 | @ Suggested value: "%h(g.zBaseURL)" |
| 1344 | 1346 | @ (Property: "email-url")</p> |
| 1345 | - @ <hr> | |
| 1346 | - entry_attribute("Tarball and ZIP-archive Prefix", 20, "short-project-name", | |
| 1347 | - "spn", "", 0); | |
| 1348 | - @ <p>This is used as a prefix on the names of generated tarballs and | |
| 1349 | - @ ZIP archive. For best results, keep this prefix brief and avoid special | |
| 1350 | - @ characters such as "/" and "\". | |
| 1351 | - @ If no tarball prefix is specified, then the full Project Name above is used. | |
| 1352 | - @ (Property: "short-project-name") | |
| 1353 | - @ </p> | |
| 1354 | - @ <hr> | |
| 1355 | - entry_attribute("Download Tag", 20, "download-tag", "dlt", "trunk", 0); | |
| 1356 | - @ <p>The <a href='%R/download'>/download</a> page is designed to provide | |
| 1357 | - @ a convenient place for newbies | |
| 1358 | - @ to download a ZIP archive or a tarball of the project. By default, | |
| 1359 | - @ the latest trunk check-in is downloaded. Change this tag to something | |
| 1360 | - @ else (ex: release) to alter the behavior of the /download page. | |
| 1361 | - @ (Property: "download-tag") | |
| 1362 | - @ </p> | |
| 1363 | 1347 | @ <hr> |
| 1364 | 1348 | entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0); |
| 1365 | 1349 | @ <p>Enter the pathname of the page to display when the "Home" menu |
| 1366 | 1350 | @ option is selected and when no pathname is |
| 1367 | 1351 | @ specified in the URL. For example, if you visit the url:</p> |
| @@ -1440,28 +1424,64 @@ | ||
| 1440 | 1424 | @ (Property: sitemap-extra) |
| 1441 | 1425 | @ <p> |
| 1442 | 1426 | textarea_attribute("Custom Sitemap Entries", 8, 80, |
| 1443 | 1427 | "sitemap-extra", "smextra", "", 0); |
| 1444 | 1428 | @ <hr> |
| 1445 | - @ <p>Configuration for the <a href="%R/download">/download</a> page. | |
| 1446 | - @ The value is a TCL list divided into groups of four: | |
| 1429 | + @ <p><input type="submit" name="submit" value="Apply Changes"></p> | |
| 1430 | + @ </div></form> | |
| 1431 | + db_end_transaction(0); | |
| 1432 | + style_finish_page(); | |
| 1433 | +} | |
| 1434 | + | |
| 1435 | +/* | |
| 1436 | +** WEBPAGE: setup_download | |
| 1437 | +** | |
| 1438 | +** The "Admin/Download" page. Requires Setup privilege. | |
| 1439 | +*/ | |
| 1440 | +void setup_download(void){ | |
| 1441 | + login_check_credentials(); | |
| 1442 | + if( !g.perm.Setup ){ | |
| 1443 | + login_needed(0); | |
| 1444 | + return; | |
| 1445 | + } | |
| 1446 | + | |
| 1447 | + style_set_current_feature("setup"); | |
| 1448 | + style_header("Tarball and ZIP Downloads"); | |
| 1449 | + db_begin_transaction(); | |
| 1450 | + @ <form action="%R/setup_download" method="post"><div> | |
| 1451 | + login_insert_csrf_secret(); | |
| 1452 | + @ <input type="submit" name="submit" value="Apply Changes"></p> | |
| 1453 | + @ <hr> | |
| 1454 | + entry_attribute("Tarball and ZIP Name Prefix", 20, "short-project-name", | |
| 1455 | + "spn", "", 0); | |
| 1456 | + @ <p>This is used as a prefix for the names of generated tarballs and | |
| 1457 | + @ ZIP archive. Keep this prefix brief and use only lower-case ASCII | |
| 1458 | + @ characters, digits, "_", "-" in the name. If this setting is blank, | |
| 1459 | + @ then the full <a href='%R/help/project-name'>project-name</a> setting | |
| 1460 | + @ is used instead. | |
| 1461 | + @ (Property: "short-project-name") | |
| 1462 | + @ </p> | |
| 1463 | + @ <hr> | |
| 1464 | + @ <p><b>Configuration for the <a href="%R/download">/download</a> page.</b> | |
| 1465 | + @ <p>The value is a TCL list divided into groups of four tokens: | |
| 1447 | 1466 | @ <ol> |
| 1448 | 1467 | @ <li> Maximum number of matches (COUNT). |
| 1449 | 1468 | @ <li> Tag to match using glob (TAG). |
| 1450 | 1469 | @ <li> Maximum age of check-ins to match (MAX_AGE). |
| 1451 | 1470 | @ <li> Comment to apply to matches (COMMENT). |
| 1452 | 1471 | @ </ol> |
| 1453 | - @ The /download display is the union of all groups of four. | |
| 1472 | + @ Each 4-tuple will match zero or more check-ins. The /download page | |
| 1473 | + @ displays the union of matches from all 4-tuples. | |
| 1454 | 1474 | @ See the <a href="%R/help/suggested-downloads">suggested-downloads</a> |
| 1455 | 1475 | @ setting documentation for further detail. |
| 1456 | 1476 | @ <p> |
| 1457 | 1477 | @ The /download page is omitted from the <a href="%R/sitemap">/sitemap</a> |
| 1458 | 1478 | @ if the first token is "0" or "off" or "no". The default value |
| 1459 | 1479 | @ for this setting is "off". |
| 1460 | 1480 | @ (Property: <a href="%R/help/suggested-downloads">suggested-downloads</a>) |
| 1461 | 1481 | @ <p> |
| 1462 | - textarea_attribute("Suggested Downloads", 4, 80, | |
| 1482 | + textarea_attribute("", 4, 80, | |
| 1463 | 1483 | "suggested-downloads", "sgtrlst", "off", 0); |
| 1464 | 1484 | @ <hr> |
| 1465 | 1485 | @ <p><input type="submit" name="submit" value="Apply Changes"></p> |
| 1466 | 1486 | @ </div></form> |
| 1467 | 1487 | db_end_transaction(0); |
| 1468 | 1488 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -118,10 +118,12 @@ | |
| 118 | setup_menu_entry("Settings", "setup_settings", |
| 119 | "Web interface to the \"fossil settings\" command"); |
| 120 | } |
| 121 | setup_menu_entry("Timeline", "setup_timeline", |
| 122 | "Timeline display preferences"); |
| 123 | if( setup_user ){ |
| 124 | setup_menu_entry("Login-Group", "setup_login_group", |
| 125 | "Manage single sign-on between this repository and others" |
| 126 | " on the same server"); |
| 127 | setup_menu_entry("Tickets", "tktsetup", |
| @@ -1340,28 +1342,10 @@ | |
| 1340 | @ Omit the trailing "/". |
| 1341 | @ If this repo will not be set up as a persistent server and will not |
| 1342 | @ be sending email alerts, then leave this entry blank. |
| 1343 | @ Suggested value: "%h(g.zBaseURL)" |
| 1344 | @ (Property: "email-url")</p> |
| 1345 | @ <hr> |
| 1346 | entry_attribute("Tarball and ZIP-archive Prefix", 20, "short-project-name", |
| 1347 | "spn", "", 0); |
| 1348 | @ <p>This is used as a prefix on the names of generated tarballs and |
| 1349 | @ ZIP archive. For best results, keep this prefix brief and avoid special |
| 1350 | @ characters such as "/" and "\". |
| 1351 | @ If no tarball prefix is specified, then the full Project Name above is used. |
| 1352 | @ (Property: "short-project-name") |
| 1353 | @ </p> |
| 1354 | @ <hr> |
| 1355 | entry_attribute("Download Tag", 20, "download-tag", "dlt", "trunk", 0); |
| 1356 | @ <p>The <a href='%R/download'>/download</a> page is designed to provide |
| 1357 | @ a convenient place for newbies |
| 1358 | @ to download a ZIP archive or a tarball of the project. By default, |
| 1359 | @ the latest trunk check-in is downloaded. Change this tag to something |
| 1360 | @ else (ex: release) to alter the behavior of the /download page. |
| 1361 | @ (Property: "download-tag") |
| 1362 | @ </p> |
| 1363 | @ <hr> |
| 1364 | entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0); |
| 1365 | @ <p>Enter the pathname of the page to display when the "Home" menu |
| 1366 | @ option is selected and when no pathname is |
| 1367 | @ specified in the URL. For example, if you visit the url:</p> |
| @@ -1440,28 +1424,64 @@ | |
| 1440 | @ (Property: sitemap-extra) |
| 1441 | @ <p> |
| 1442 | textarea_attribute("Custom Sitemap Entries", 8, 80, |
| 1443 | "sitemap-extra", "smextra", "", 0); |
| 1444 | @ <hr> |
| 1445 | @ <p>Configuration for the <a href="%R/download">/download</a> page. |
| 1446 | @ The value is a TCL list divided into groups of four: |
| 1447 | @ <ol> |
| 1448 | @ <li> Maximum number of matches (COUNT). |
| 1449 | @ <li> Tag to match using glob (TAG). |
| 1450 | @ <li> Maximum age of check-ins to match (MAX_AGE). |
| 1451 | @ <li> Comment to apply to matches (COMMENT). |
| 1452 | @ </ol> |
| 1453 | @ The /download display is the union of all groups of four. |
| 1454 | @ See the <a href="%R/help/suggested-downloads">suggested-downloads</a> |
| 1455 | @ setting documentation for further detail. |
| 1456 | @ <p> |
| 1457 | @ The /download page is omitted from the <a href="%R/sitemap">/sitemap</a> |
| 1458 | @ if the first token is "0" or "off" or "no". The default value |
| 1459 | @ for this setting is "off". |
| 1460 | @ (Property: <a href="%R/help/suggested-downloads">suggested-downloads</a>) |
| 1461 | @ <p> |
| 1462 | textarea_attribute("Suggested Downloads", 4, 80, |
| 1463 | "suggested-downloads", "sgtrlst", "off", 0); |
| 1464 | @ <hr> |
| 1465 | @ <p><input type="submit" name="submit" value="Apply Changes"></p> |
| 1466 | @ </div></form> |
| 1467 | db_end_transaction(0); |
| 1468 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -118,10 +118,12 @@ | |
| 118 | setup_menu_entry("Settings", "setup_settings", |
| 119 | "Web interface to the \"fossil settings\" command"); |
| 120 | } |
| 121 | setup_menu_entry("Timeline", "setup_timeline", |
| 122 | "Timeline display preferences"); |
| 123 | setup_menu_entry("Tarballs and ZIPs", "setup_download", |
| 124 | "Preferences for auto-generated tarballs and ZIP files"); |
| 125 | if( setup_user ){ |
| 126 | setup_menu_entry("Login-Group", "setup_login_group", |
| 127 | "Manage single sign-on between this repository and others" |
| 128 | " on the same server"); |
| 129 | setup_menu_entry("Tickets", "tktsetup", |
| @@ -1340,28 +1342,10 @@ | |
| 1342 | @ Omit the trailing "/". |
| 1343 | @ If this repo will not be set up as a persistent server and will not |
| 1344 | @ be sending email alerts, then leave this entry blank. |
| 1345 | @ Suggested value: "%h(g.zBaseURL)" |
| 1346 | @ (Property: "email-url")</p> |
| 1347 | @ <hr> |
| 1348 | entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0); |
| 1349 | @ <p>Enter the pathname of the page to display when the "Home" menu |
| 1350 | @ option is selected and when no pathname is |
| 1351 | @ specified in the URL. For example, if you visit the url:</p> |
| @@ -1440,28 +1424,64 @@ | |
| 1424 | @ (Property: sitemap-extra) |
| 1425 | @ <p> |
| 1426 | textarea_attribute("Custom Sitemap Entries", 8, 80, |
| 1427 | "sitemap-extra", "smextra", "", 0); |
| 1428 | @ <hr> |
| 1429 | @ <p><input type="submit" name="submit" value="Apply Changes"></p> |
| 1430 | @ </div></form> |
| 1431 | db_end_transaction(0); |
| 1432 | style_finish_page(); |
| 1433 | } |
| 1434 | |
| 1435 | /* |
| 1436 | ** WEBPAGE: setup_download |
| 1437 | ** |
| 1438 | ** The "Admin/Download" page. Requires Setup privilege. |
| 1439 | */ |
| 1440 | void setup_download(void){ |
| 1441 | login_check_credentials(); |
| 1442 | if( !g.perm.Setup ){ |
| 1443 | login_needed(0); |
| 1444 | return; |
| 1445 | } |
| 1446 | |
| 1447 | style_set_current_feature("setup"); |
| 1448 | style_header("Tarball and ZIP Downloads"); |
| 1449 | db_begin_transaction(); |
| 1450 | @ <form action="%R/setup_download" method="post"><div> |
| 1451 | login_insert_csrf_secret(); |
| 1452 | @ <input type="submit" name="submit" value="Apply Changes"></p> |
| 1453 | @ <hr> |
| 1454 | entry_attribute("Tarball and ZIP Name Prefix", 20, "short-project-name", |
| 1455 | "spn", "", 0); |
| 1456 | @ <p>This is used as a prefix for the names of generated tarballs and |
| 1457 | @ ZIP archive. Keep this prefix brief and use only lower-case ASCII |
| 1458 | @ characters, digits, "_", "-" in the name. If this setting is blank, |
| 1459 | @ then the full <a href='%R/help/project-name'>project-name</a> setting |
| 1460 | @ is used instead. |
| 1461 | @ (Property: "short-project-name") |
| 1462 | @ </p> |
| 1463 | @ <hr> |
| 1464 | @ <p><b>Configuration for the <a href="%R/download">/download</a> page.</b> |
| 1465 | @ <p>The value is a TCL list divided into groups of four tokens: |
| 1466 | @ <ol> |
| 1467 | @ <li> Maximum number of matches (COUNT). |
| 1468 | @ <li> Tag to match using glob (TAG). |
| 1469 | @ <li> Maximum age of check-ins to match (MAX_AGE). |
| 1470 | @ <li> Comment to apply to matches (COMMENT). |
| 1471 | @ </ol> |
| 1472 | @ Each 4-tuple will match zero or more check-ins. The /download page |
| 1473 | @ displays the union of matches from all 4-tuples. |
| 1474 | @ See the <a href="%R/help/suggested-downloads">suggested-downloads</a> |
| 1475 | @ setting documentation for further detail. |
| 1476 | @ <p> |
| 1477 | @ The /download page is omitted from the <a href="%R/sitemap">/sitemap</a> |
| 1478 | @ if the first token is "0" or "off" or "no". The default value |
| 1479 | @ for this setting is "off". |
| 1480 | @ (Property: <a href="%R/help/suggested-downloads">suggested-downloads</a>) |
| 1481 | @ <p> |
| 1482 | textarea_attribute("", 4, 80, |
| 1483 | "suggested-downloads", "sgtrlst", "off", 0); |
| 1484 | @ <hr> |
| 1485 | @ <p><input type="submit" name="submit" value="Apply Changes"></p> |
| 1486 | @ </div></form> |
| 1487 | db_end_transaction(0); |
| 1488 |
+8
-4
| --- src/tar.c | ||
| +++ src/tar.c | ||
| @@ -67,25 +67,29 @@ | ||
| 67 | 67 | ** |
| 68 | 68 | ** The value returned is obtained from mprintf() or fossil_strdup() and should |
| 69 | 69 | ** be released by the caller using fossil_free(). |
| 70 | 70 | */ |
| 71 | 71 | char *archive_base_name(int rid){ |
| 72 | + char *zPrefix; | |
| 72 | 73 | char *zName; |
| 74 | + zPrefix = db_get("short-project-name",0); | |
| 75 | + if( zPrefix==0 || zPrefix[0]==0 ){ | |
| 76 | + zPrefix = db_get("project-name","unnamed"); | |
| 77 | + } | |
| 73 | 78 | zName = db_text(0, |
| 74 | - "SELECT coalesce(config.value,'unnamed')||" | |
| 79 | + "SELECT %Q||" | |
| 75 | 80 | " strftime('-%%Y%%m%%d%%H%%M%%S-',event.mtime)||" |
| 76 | 81 | " substr(blob.uuid,1,10)" |
| 77 | 82 | " FROM blob, event LEFT JOIN config" |
| 78 | 83 | " WHERE blob.rid=%d" |
| 79 | 84 | " AND event.objid=%d" |
| 80 | 85 | " AND config.name='project-name'", |
| 81 | - rid, rid); | |
| 86 | + zPrefix, rid, rid); | |
| 87 | + fossil_free(zPrefix); | |
| 82 | 88 | sanitize_name(zName); |
| 83 | 89 | return zName; |
| 84 | 90 | } |
| 85 | - | |
| 86 | - | |
| 87 | 91 | |
| 88 | 92 | /* |
| 89 | 93 | ** field lengths of 'ustar' name and prefix fields. |
| 90 | 94 | */ |
| 91 | 95 | #define USTAR_NAME_LEN 100 |
| 92 | 96 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -67,25 +67,29 @@ | |
| 67 | ** |
| 68 | ** The value returned is obtained from mprintf() or fossil_strdup() and should |
| 69 | ** be released by the caller using fossil_free(). |
| 70 | */ |
| 71 | char *archive_base_name(int rid){ |
| 72 | char *zName; |
| 73 | zName = db_text(0, |
| 74 | "SELECT coalesce(config.value,'unnamed')||" |
| 75 | " strftime('-%%Y%%m%%d%%H%%M%%S-',event.mtime)||" |
| 76 | " substr(blob.uuid,1,10)" |
| 77 | " FROM blob, event LEFT JOIN config" |
| 78 | " WHERE blob.rid=%d" |
| 79 | " AND event.objid=%d" |
| 80 | " AND config.name='project-name'", |
| 81 | rid, rid); |
| 82 | sanitize_name(zName); |
| 83 | return zName; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | |
| 88 | /* |
| 89 | ** field lengths of 'ustar' name and prefix fields. |
| 90 | */ |
| 91 | #define USTAR_NAME_LEN 100 |
| 92 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -67,25 +67,29 @@ | |
| 67 | ** |
| 68 | ** The value returned is obtained from mprintf() or fossil_strdup() and should |
| 69 | ** be released by the caller using fossil_free(). |
| 70 | */ |
| 71 | char *archive_base_name(int rid){ |
| 72 | char *zPrefix; |
| 73 | char *zName; |
| 74 | zPrefix = db_get("short-project-name",0); |
| 75 | if( zPrefix==0 || zPrefix[0]==0 ){ |
| 76 | zPrefix = db_get("project-name","unnamed"); |
| 77 | } |
| 78 | zName = db_text(0, |
| 79 | "SELECT %Q||" |
| 80 | " strftime('-%%Y%%m%%d%%H%%M%%S-',event.mtime)||" |
| 81 | " substr(blob.uuid,1,10)" |
| 82 | " FROM blob, event LEFT JOIN config" |
| 83 | " WHERE blob.rid=%d" |
| 84 | " AND event.objid=%d" |
| 85 | " AND config.name='project-name'", |
| 86 | zPrefix, rid, rid); |
| 87 | fossil_free(zPrefix); |
| 88 | sanitize_name(zName); |
| 89 | return zName; |
| 90 | } |
| 91 | |
| 92 | /* |
| 93 | ** field lengths of 'ustar' name and prefix fields. |
| 94 | */ |
| 95 | #define USTAR_NAME_LEN 100 |
| 96 |