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.
Commit
d10e2cb6392ddf9689257f18952d75d33612172e
Parent
2684124311a5a74…
1 file changed
+9
-3
+9
-3
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1808,10 +1808,11 @@ | ||
| 1808 | 1808 | ** ln - show line numbers |
| 1809 | 1809 | ** ln=N - highlight line number N |
| 1810 | 1810 | ** ln=M-N - highlight lines M through N inclusive |
| 1811 | 1811 | ** ln=M-N+Y-Z - higllight lines M through N and Y through Z (inclusive) |
| 1812 | 1812 | ** verbose - show more detail in the description |
| 1813 | +** download - redirect to the download (artifact page only) | |
| 1813 | 1814 | ** |
| 1814 | 1815 | ** The /artifact page show the complete content of a file |
| 1815 | 1816 | ** identified by SHA1HASH as preformatted text. The |
| 1816 | 1817 | ** /whatis page shows only a description of the file. |
| 1817 | 1818 | */ |
| @@ -1837,10 +1838,18 @@ | ||
| 1837 | 1838 | } |
| 1838 | 1839 | |
| 1839 | 1840 | login_check_credentials(); |
| 1840 | 1841 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 1841 | 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 | + } | |
| 1842 | 1851 | if( g.perm.Admin ){ |
| 1843 | 1852 | const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1844 | 1853 | if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ |
| 1845 | 1854 | style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun", |
| 1846 | 1855 | g.zTop, zUuid); |
| @@ -1847,20 +1856,17 @@ | ||
| 1847 | 1856 | }else{ |
| 1848 | 1857 | style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun", |
| 1849 | 1858 | g.zTop, zUuid); |
| 1850 | 1859 | } |
| 1851 | 1860 | } |
| 1852 | - if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; | |
| 1853 | 1861 | style_header("%s", descOnly ? "Artifact Description" : "Artifact Content"); |
| 1854 | 1862 | zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1855 | 1863 | if( g.perm.Setup ){ |
| 1856 | 1864 | @ <h2>Artifact %s(zUuid) (%d(rid)):</h2> |
| 1857 | 1865 | }else{ |
| 1858 | 1866 | @ <h2>Artifact %s(zUuid):</h2> |
| 1859 | 1867 | } |
| 1860 | - blob_zero(&downloadName); | |
| 1861 | - objType = object_description(rid, objdescFlags, &downloadName); | |
| 1862 | 1868 | if( g.perm.Admin ){ |
| 1863 | 1869 | Stmt q; |
| 1864 | 1870 | db_prepare(&q, |
| 1865 | 1871 | "SELECT coalesce(user.login,rcvfrom.uid)," |
| 1866 | 1872 | " datetime(rcvfrom.mtime), rcvfrom.ipaddr" |
| 1867 | 1873 |
| --- 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 |