Fossil SCM
Implement the new (internal-use) /rchvdwnld page. On /dir and /tree there is now just a single "Download" submenu item that redirects to this new /rchvdwnld page, allowing the user to select a tarball, ZIP, or SQLAR.
Commit
6b515d7b9c897e6a79687007a64b308f0120d4d12e258835cc335679c9e90b1d
Parent
bdbf5db22224e28…
2 files changed
+2
-12
+51
+2
-12
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -230,16 +230,11 @@ | ||
| 230 | 230 | zMatch = ""; |
| 231 | 231 | } |
| 232 | 232 | style_header("%s", zHeader); |
| 233 | 233 | fossil_free(zHeader); |
| 234 | 234 | if( rid && zD==0 && zMatch[0]==0 && g.perm.Zip ){ |
| 235 | - char *zBase = archive_base_name(rid); | |
| 236 | - style_submenu_element("Tarball","%R/tarball/%!S/%s.tar.gz", | |
| 237 | - zUuid, zBase); | |
| 238 | - style_submenu_element("ZIP","%R/zip/%!S/%s.zip", | |
| 239 | - zUuid, zBase); | |
| 240 | - fossil_free(zBase); | |
| 235 | + style_submenu_element("Download","%R/rchvdwnld/%!S",zUuid); | |
| 241 | 236 | } |
| 242 | 237 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 243 | 238 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 244 | 239 | pathelementFunc, 0, 0); |
| 245 | 240 | url_initialize(&sURI, "dir"); |
| @@ -823,16 +818,11 @@ | ||
| 823 | 818 | } |
| 824 | 819 | } |
| 825 | 820 | style_submenu_element("Flat-View", "%s", |
| 826 | 821 | url_render(&sURI, "type", "flat", 0, 0)); |
| 827 | 822 | if( rid && zD==0 && zRE==0 && !showDirOnly && g.perm.Zip ){ |
| 828 | - char *zBase = archive_base_name(rid); | |
| 829 | - style_submenu_element("Tarball","%R/tarball/%!S/%s.tar.gz", | |
| 830 | - zUuid, zBase); | |
| 831 | - style_submenu_element("ZIP","%R/zip/%!S/%s.zip", | |
| 832 | - zUuid, zBase); | |
| 833 | - fossil_free(zBase); | |
| 823 | + style_submenu_element("Download","%R/rchvdwnld/%!S", zUuid); | |
| 834 | 824 | } |
| 835 | 825 | |
| 836 | 826 | /* Compute the file hierarchy. |
| 837 | 827 | */ |
| 838 | 828 | if( zCI ){ |
| 839 | 829 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -230,16 +230,11 @@ | |
| 230 | zMatch = ""; |
| 231 | } |
| 232 | style_header("%s", zHeader); |
| 233 | fossil_free(zHeader); |
| 234 | if( rid && zD==0 && zMatch[0]==0 && g.perm.Zip ){ |
| 235 | char *zBase = archive_base_name(rid); |
| 236 | style_submenu_element("Tarball","%R/tarball/%!S/%s.tar.gz", |
| 237 | zUuid, zBase); |
| 238 | style_submenu_element("ZIP","%R/zip/%!S/%s.zip", |
| 239 | zUuid, zBase); |
| 240 | fossil_free(zBase); |
| 241 | } |
| 242 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 243 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 244 | pathelementFunc, 0, 0); |
| 245 | url_initialize(&sURI, "dir"); |
| @@ -823,16 +818,11 @@ | |
| 823 | } |
| 824 | } |
| 825 | style_submenu_element("Flat-View", "%s", |
| 826 | url_render(&sURI, "type", "flat", 0, 0)); |
| 827 | if( rid && zD==0 && zRE==0 && !showDirOnly && g.perm.Zip ){ |
| 828 | char *zBase = archive_base_name(rid); |
| 829 | style_submenu_element("Tarball","%R/tarball/%!S/%s.tar.gz", |
| 830 | zUuid, zBase); |
| 831 | style_submenu_element("ZIP","%R/zip/%!S/%s.zip", |
| 832 | zUuid, zBase); |
| 833 | fossil_free(zBase); |
| 834 | } |
| 835 | |
| 836 | /* Compute the file hierarchy. |
| 837 | */ |
| 838 | if( zCI ){ |
| 839 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -230,16 +230,11 @@ | |
| 230 | zMatch = ""; |
| 231 | } |
| 232 | style_header("%s", zHeader); |
| 233 | fossil_free(zHeader); |
| 234 | if( rid && zD==0 && zMatch[0]==0 && g.perm.Zip ){ |
| 235 | style_submenu_element("Download","%R/rchvdwnld/%!S",zUuid); |
| 236 | } |
| 237 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 238 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 239 | pathelementFunc, 0, 0); |
| 240 | url_initialize(&sURI, "dir"); |
| @@ -823,16 +818,11 @@ | |
| 818 | } |
| 819 | } |
| 820 | style_submenu_element("Flat-View", "%s", |
| 821 | url_render(&sURI, "type", "flat", 0, 0)); |
| 822 | if( rid && zD==0 && zRE==0 && !showDirOnly && g.perm.Zip ){ |
| 823 | style_submenu_element("Download","%R/rchvdwnld/%!S", zUuid); |
| 824 | } |
| 825 | |
| 826 | /* Compute the file hierarchy. |
| 827 | */ |
| 828 | if( zCI ){ |
| 829 |
+51
| --- src/tar.c | ||
| +++ src/tar.c | ||
| @@ -1117,5 +1117,56 @@ | ||
| 1117 | 1117 | www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, tarlist_extra); |
| 1118 | 1118 | db_finalize(&q); |
| 1119 | 1119 | } |
| 1120 | 1120 | style_finish_page(); |
| 1121 | 1121 | } |
| 1122 | + | |
| 1123 | +/* | |
| 1124 | +** WEBPAGE: rchvdwnld | |
| 1125 | +** | |
| 1126 | +** Short for "archive download". This page should have a single name= | |
| 1127 | +** query parameter that is a check-in hash. It present a menu of possible | |
| 1128 | +** download options for that check-in, including tarball, ZIP, or SQLAR. | |
| 1129 | +** | |
| 1130 | +** This is a utility page. The /dir and /tree pages sometimes have a | |
| 1131 | +** "Download" option in their submenu which redirects here. Those pages | |
| 1132 | +** used to have separate "Tarball" and "ZIP" submenu entries, but as | |
| 1133 | +** submenu entries appear in alphabetical order, that caused the two | |
| 1134 | +** submenu entries to be separated from one another, which is distracting. | |
| 1135 | +*/ | |
| 1136 | +void rchvdwnld_page(void){ | |
| 1137 | + const char *zUuid; | |
| 1138 | + char *zBase; | |
| 1139 | + int nUuid; | |
| 1140 | + int rid; | |
| 1141 | + login_check_credentials(); | |
| 1142 | + if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; } | |
| 1143 | + robot_restrict("zip"); | |
| 1144 | + | |
| 1145 | + zUuid = P("name"); | |
| 1146 | + if( zUuid==0 | |
| 1147 | + || (nUuid = (int)strlen(zUuid))<6 | |
| 1148 | + || !validate16(zUuid,-1) | |
| 1149 | + || (rid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid))==0 | |
| 1150 | + || !db_exists("SELECT 1 from event WHERE type='ci' AND objid=%d",rid) | |
| 1151 | + ){ | |
| 1152 | + fossil_redirect_home(); | |
| 1153 | + } | |
| 1154 | + zUuid = db_text(zUuid, "SELECT uuid FROM blob WHERE rid=%d", rid); | |
| 1155 | + style_header("Downloads For Check-in %!S", zUuid); | |
| 1156 | + zBase = archive_base_name(rid); | |
| 1157 | + @ <ul> | |
| 1158 | + @ <li><p> | |
| 1159 | + @ Tarball: %z(href("%R/tarball/%!S/%s.tar.gz",zUuid,zBase))\ | |
| 1160 | + @ %s(g.zBaseURL)%R/tarball/%!S(zUuid)/%s(zBase).tar.gz</a> | |
| 1161 | + @ | |
| 1162 | + @ <li><p> | |
| 1163 | + @ ZIP: %z(href("%R/zip/%!S/%s.zip",zUuid,zBase))\ | |
| 1164 | + @ %s(g.zBaseURL)%R/zip/%!S(zUuid)/%s(zBase).zip</a> | |
| 1165 | + @ | |
| 1166 | + @ <li><p> | |
| 1167 | + @ SQLAR: %z(href("%R/sqlar/%!S/%s.sqlar",zUuid,zBase))\ | |
| 1168 | + @ %s(g.zBaseURL)%R/sqlar/%!S(zUuid)/%s(zBase).sqlar</a> | |
| 1169 | + @ </ul> | |
| 1170 | + fossil_free(zBase); | |
| 1171 | + style_finish_page(); | |
| 1172 | +} | |
| 1122 | 1173 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -1117,5 +1117,56 @@ | |
| 1117 | www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, tarlist_extra); |
| 1118 | db_finalize(&q); |
| 1119 | } |
| 1120 | style_finish_page(); |
| 1121 | } |
| 1122 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -1117,5 +1117,56 @@ | |
| 1117 | www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, tarlist_extra); |
| 1118 | db_finalize(&q); |
| 1119 | } |
| 1120 | style_finish_page(); |
| 1121 | } |
| 1122 | |
| 1123 | /* |
| 1124 | ** WEBPAGE: rchvdwnld |
| 1125 | ** |
| 1126 | ** Short for "archive download". This page should have a single name= |
| 1127 | ** query parameter that is a check-in hash. It present a menu of possible |
| 1128 | ** download options for that check-in, including tarball, ZIP, or SQLAR. |
| 1129 | ** |
| 1130 | ** This is a utility page. The /dir and /tree pages sometimes have a |
| 1131 | ** "Download" option in their submenu which redirects here. Those pages |
| 1132 | ** used to have separate "Tarball" and "ZIP" submenu entries, but as |
| 1133 | ** submenu entries appear in alphabetical order, that caused the two |
| 1134 | ** submenu entries to be separated from one another, which is distracting. |
| 1135 | */ |
| 1136 | void rchvdwnld_page(void){ |
| 1137 | const char *zUuid; |
| 1138 | char *zBase; |
| 1139 | int nUuid; |
| 1140 | int rid; |
| 1141 | login_check_credentials(); |
| 1142 | if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; } |
| 1143 | robot_restrict("zip"); |
| 1144 | |
| 1145 | zUuid = P("name"); |
| 1146 | if( zUuid==0 |
| 1147 | || (nUuid = (int)strlen(zUuid))<6 |
| 1148 | || !validate16(zUuid,-1) |
| 1149 | || (rid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid))==0 |
| 1150 | || !db_exists("SELECT 1 from event WHERE type='ci' AND objid=%d",rid) |
| 1151 | ){ |
| 1152 | fossil_redirect_home(); |
| 1153 | } |
| 1154 | zUuid = db_text(zUuid, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1155 | style_header("Downloads For Check-in %!S", zUuid); |
| 1156 | zBase = archive_base_name(rid); |
| 1157 | @ <ul> |
| 1158 | @ <li><p> |
| 1159 | @ Tarball: %z(href("%R/tarball/%!S/%s.tar.gz",zUuid,zBase))\ |
| 1160 | @ %s(g.zBaseURL)%R/tarball/%!S(zUuid)/%s(zBase).tar.gz</a> |
| 1161 | @ |
| 1162 | @ <li><p> |
| 1163 | @ ZIP: %z(href("%R/zip/%!S/%s.zip",zUuid,zBase))\ |
| 1164 | @ %s(g.zBaseURL)%R/zip/%!S(zUuid)/%s(zBase).zip</a> |
| 1165 | @ |
| 1166 | @ <li><p> |
| 1167 | @ SQLAR: %z(href("%R/sqlar/%!S/%s.sqlar",zUuid,zBase))\ |
| 1168 | @ %s(g.zBaseURL)%R/sqlar/%!S(zUuid)/%s(zBase).sqlar</a> |
| 1169 | @ </ul> |
| 1170 | fossil_free(zBase); |
| 1171 | style_finish_page(); |
| 1172 | } |
| 1173 |