Fossil SCM

Add 'download' parameter to the 'artifact' web page that allows a specific artifact to be downloaded by specifying the file name and check-in.

drh 2015-12-16 01:06 trunk merge
Commit d10e2cb6392ddf9689257f18952d75d33612172e
1 file changed +9 -3
+9 -3
--- src/info.c
+++ src/info.c
@@ -1808,10 +1808,11 @@
18081808
** ln - show line numbers
18091809
** ln=N - highlight line number N
18101810
** ln=M-N - highlight lines M through N inclusive
18111811
** ln=M-N+Y-Z - higllight lines M through N and Y through Z (inclusive)
18121812
** verbose - show more detail in the description
1813
+** download - redirect to the download (artifact page only)
18131814
**
18141815
** The /artifact page show the complete content of a file
18151816
** identified by SHA1HASH as preformatted text. The
18161817
** /whatis page shows only a description of the file.
18171818
*/
@@ -1837,10 +1838,18 @@
18371838
}
18381839
18391840
login_check_credentials();
18401841
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
18411842
if( rid==0 ) fossil_redirect_home();
1843
+ if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1844
+ blob_zero(&downloadName);
1845
+ objType = object_description(rid, objdescFlags, &downloadName);
1846
+ if( !descOnly && P("download")!=0 ){
1847
+ cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
1848
+ db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
1849
+ /*NOTREACHED*/
1850
+ }
18421851
if( g.perm.Admin ){
18431852
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
18441853
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
18451854
style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
18461855
g.zTop, zUuid);
@@ -1847,20 +1856,17 @@
18471856
}else{
18481857
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
18491858
g.zTop, zUuid);
18501859
}
18511860
}
1852
- if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
18531861
style_header("%s", descOnly ? "Artifact Description" : "Artifact Content");
18541862
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
18551863
if( g.perm.Setup ){
18561864
@ <h2>Artifact %s(zUuid) (%d(rid)):</h2>
18571865
}else{
18581866
@ <h2>Artifact %s(zUuid):</h2>
18591867
}
1860
- blob_zero(&downloadName);
1861
- objType = object_description(rid, objdescFlags, &downloadName);
18621868
if( g.perm.Admin ){
18631869
Stmt q;
18641870
db_prepare(&q,
18651871
"SELECT coalesce(user.login,rcvfrom.uid),"
18661872
" datetime(rcvfrom.mtime), rcvfrom.ipaddr"
18671873
--- src/info.c
+++ src/info.c
@@ -1808,10 +1808,11 @@
1808 ** ln - show line numbers
1809 ** ln=N - highlight line number N
1810 ** ln=M-N - highlight lines M through N inclusive
1811 ** ln=M-N+Y-Z - higllight lines M through N and Y through Z (inclusive)
1812 ** verbose - show more detail in the description
 
1813 **
1814 ** The /artifact page show the complete content of a file
1815 ** identified by SHA1HASH as preformatted text. The
1816 ** /whatis page shows only a description of the file.
1817 */
@@ -1837,10 +1838,18 @@
1837 }
1838
1839 login_check_credentials();
1840 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1841 if( rid==0 ) fossil_redirect_home();
 
 
 
 
 
 
 
 
1842 if( g.perm.Admin ){
1843 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1844 if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
1845 style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
1846 g.zTop, zUuid);
@@ -1847,20 +1856,17 @@
1847 }else{
1848 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1849 g.zTop, zUuid);
1850 }
1851 }
1852 if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1853 style_header("%s", descOnly ? "Artifact Description" : "Artifact Content");
1854 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
1855 if( g.perm.Setup ){
1856 @ <h2>Artifact %s(zUuid) (%d(rid)):</h2>
1857 }else{
1858 @ <h2>Artifact %s(zUuid):</h2>
1859 }
1860 blob_zero(&downloadName);
1861 objType = object_description(rid, objdescFlags, &downloadName);
1862 if( g.perm.Admin ){
1863 Stmt q;
1864 db_prepare(&q,
1865 "SELECT coalesce(user.login,rcvfrom.uid),"
1866 " datetime(rcvfrom.mtime), rcvfrom.ipaddr"
1867
--- src/info.c
+++ src/info.c
@@ -1808,10 +1808,11 @@
1808 ** ln - show line numbers
1809 ** ln=N - highlight line number N
1810 ** ln=M-N - highlight lines M through N inclusive
1811 ** ln=M-N+Y-Z - higllight lines M through N and Y through Z (inclusive)
1812 ** verbose - show more detail in the description
1813 ** download - redirect to the download (artifact page only)
1814 **
1815 ** The /artifact page show the complete content of a file
1816 ** identified by SHA1HASH as preformatted text. The
1817 ** /whatis page shows only a description of the file.
1818 */
@@ -1837,10 +1838,18 @@
1838 }
1839
1840 login_check_credentials();
1841 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1842 if( rid==0 ) fossil_redirect_home();
1843 if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1844 blob_zero(&downloadName);
1845 objType = object_description(rid, objdescFlags, &downloadName);
1846 if( !descOnly && P("download")!=0 ){
1847 cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
1848 db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
1849 /*NOTREACHED*/
1850 }
1851 if( g.perm.Admin ){
1852 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1853 if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
1854 style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
1855 g.zTop, zUuid);
@@ -1847,20 +1856,17 @@
1856 }else{
1857 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1858 g.zTop, zUuid);
1859 }
1860 }
 
1861 style_header("%s", descOnly ? "Artifact Description" : "Artifact Content");
1862 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
1863 if( g.perm.Setup ){
1864 @ <h2>Artifact %s(zUuid) (%d(rid)):</h2>
1865 }else{
1866 @ <h2>Artifact %s(zUuid):</h2>
1867 }
 
 
1868 if( g.perm.Admin ){
1869 Stmt q;
1870 db_prepare(&q,
1871 "SELECT coalesce(user.login,rcvfrom.uid),"
1872 " datetime(rcvfrom.mtime), rcvfrom.ipaddr"
1873

Keyboard Shortcuts

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