Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Further enhancements to the new /file webpage. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
3cca4c254f885b0d2cd2af0127562d85 |
| User & Date: | drh 2016-11-29 14:32:24.056 |
Context
|
2016-11-29
| ||
| 16:57 | Make the "Line Numbers" submenu element on the /artifact and /file pages a check-box. ... (check-in: 4946efef65 user: drh tags: trunk) | |
| 14:32 | Further enhancements to the new /file webpage. ... (check-in: 3cca4c254f user: drh tags: trunk) | |
|
2016-11-28
| ||
| 16:44 | New /file page that works like /artifact except takes a filename as an argument instead of a SHA1 hash of an artifact, and resolves to the most recent version of any file with that name. ... (check-in: d95f712f2c user: drh tags: trunk) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
1563 1564 1565 1566 1567 1568 1569 |
void rawartifact_page(void){
int rid = 0;
char *zUuid;
const char *zMime;
Blob content;
if( P("ci") && P("filename") ){
| | | 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 |
void rawartifact_page(void){
int rid = 0;
char *zUuid;
const char *zMime;
Blob content;
if( P("ci") && P("filename") ){
rid = artifact_from_ci_and_filename(0);
}
if( rid==0 ){
rid = name_to_rid_www("name");
}
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( rid==0 ) fossil_redirect_home();
|
| ︙ | ︙ | |||
1697 1698 1699 1700 1701 1702 1703 | content_get(rid, &content); @ <blockquote><pre> hexdump(&content); @ </pre></blockquote> style_footer(); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | > > > > > | 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 |
content_get(rid, &content);
@ <blockquote><pre>
hexdump(&content);
@ </pre></blockquote>
style_footer();
}
/*
** Look for "ci" and "filename" query parameters. If found, try to
** use them to extract the record ID of an artifact for the file.
**
** Also look for "fn" as an alias for "filename". If either "filename"
** or "fn" is present but "ci" is missing, use "tip" as a default value
** for "ci".
*/
int artifact_from_ci_and_filename(HQuery *pUrl){
const char *zFilename;
const char *zCI;
int cirid;
Manifest *pManifest;
ManifestFile *pFile;
zFilename = P("filename");
if( zFilename==0 ){
zFilename = P("fn");
if( zFilename==0 ) return 0;
}
zCI = P("ci");
cirid = name_to_typed_rid(zCI ? zCI : "tip", "ci");
if( cirid<=0 ) return 0;
pManifest = manifest_get(cirid, CFTYPE_MANIFEST, 0);
if( pManifest==0 ) return 0;
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
if( fossil_strcmp(zFilename, pFile->zName)==0 ){
int rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", pFile->zUuid);
manifest_destroy(pManifest);
if( pUrl ){
url_add_parameter(pUrl, "fn", zFilename);
if( zCI ) url_add_parameter(pUrl, "ci", zCI);
}
return rid;
}
}
manifest_destroy(pManifest);
return 0;
}
/*
** The "z" argument is a string that contains the text of a source code
** file. This routine appends that text to the HTTP reply with line numbering.
**
|
| ︙ | ︙ | |||
1860 1861 1862 1863 1864 1865 1866 | ** /file/NAME ** ** Additional query parameters: ** ** ln - show line numbers ** ln=N - highlight line number N ** ln=M-N - highlight lines M through N inclusive | | | 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 | ** /file/NAME ** ** Additional query parameters: ** ** ln - show line numbers ** ln=N - highlight line number N ** ln=M-N - highlight lines M through N inclusive ** ln=M-N,Y-Z - highlight lines M through N and Y through Z (inclusive) ** verbose - show more detail in the description ** download - redirect to the download (artifact page only) ** name=SHA1HASH - Provide the SHA1HASH as a query parameter ** filename=NAME - Show information for content file NAME ** fn=NAME - "fn" is shorthand for "filename" ** ci=VERSION - The specific check-in to use for "filename=". ** |
| ︙ | ︙ | |||
1887 1888 1889 1890 1891 1892 1893 1894 |
int objType;
int asText;
const char *zUuid;
u32 objdescFlags = 0;
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
int isFile = fossil_strcmp(g.zPath,"file")==0;
const char *zLn = P("ln");
| > > > | > | > | > > > > > > | > > > > > | > > > > > > | > | | 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 |
int objType;
int asText;
const char *zUuid;
u32 objdescFlags = 0;
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
int isFile = fossil_strcmp(g.zPath,"file")==0;
const char *zLn = P("ln");
const char *zName = P("name");
HQuery url;
url_initialize(&url, g.zPath);
rid = artifact_from_ci_and_filename(&url);
if( rid==0 ){
url_add_parameter(&url, "name", zName);
if( isFile ){
if( zName==0 ) zName = "";
rid = db_int(0,
"SELECT fid FROM filename, mlink, event"
" WHERE name=%Q"
" AND mlink.fnid=filename.fnid"
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC LIMIT 1",
zName
);
if( rid==0 ){
style_header("No such file");
@ File '%h(zName)' does not exist in this repository.
style_footer();
return;
}
}else{
rid = name_to_rid_www("name");
}
}
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( rid==0 ){
style_header("No such artifact");
@ Artifact '%h(zName)' does not exist in this repository.
style_footer();
return;
}
if( descOnly || P("verbose")!=0 ){
url_add_parameter(&url, "verbose", "1");
objdescFlags |= OBJDESC_DETAIL;
}
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( isFile ){
@ <h2>Latest version of file '%h(zName)':</h2>
style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
}else if( g.perm.Setup ){
@ <h2>Artifact %s(zUuid) (%d(rid)):</h2>
}else{
@ <h2>Artifact %s(zUuid):</h2>
}
blob_zero(&downloadName);
objType = object_description(rid, objdescFlags, &downloadName);
if( !descOnly && P("download")!=0 ){
cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
/*NOTREACHED*/
}
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun", "%s/shun?accept=%s&sub=1#accshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
}
}
style_header("%s", isFile ? "File Content" :
descOnly ? "Artifact Description" : "Artifact Content");
if( g.perm.Admin ){
Stmt q;
db_prepare(&q,
"SELECT coalesce(user.login,rcvfrom.uid),"
" datetime(rcvfrom.mtime,toLocal()), rcvfrom.ipaddr"
" FROM blob, rcvfrom LEFT JOIN user ON user.uid=rcvfrom.uid"
" WHERE blob.rid=%d"
|
| ︙ | ︙ | |||
1957 1958 1959 1960 1961 1962 1963 |
style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s", zUuid);
}
asText = P("txt")!=0;
zMime = mimetype_from_name(blob_str(&downloadName));
if( zMime ){
if( fossil_strcmp(zMime, "text/html")==0 ){
if( asText ){
| | | | | > | < > > > > > | | | | 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 |
style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s", zUuid);
}
asText = P("txt")!=0;
zMime = mimetype_from_name(blob_str(&downloadName));
if( zMime ){
if( fossil_strcmp(zMime, "text/html")==0 ){
if( asText ){
style_submenu_element("Html", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsHtml = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0
|| fossil_strcmp(zMime, "text/x-markdown")==0 ){
if( asText ){
style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsWiki = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
if( zLn==0 ){
style_submenu_element("Line Numbers", "%s",
url_render(&url, "ln", "", 0, 0));
}else{
style_submenu_element("Line Numbers", "%s",
url_render(&url, "ln", 0, 0, 0));
}
@ <hr />
content_get(rid, &content);
if( renderAsWiki ){
wiki_render_by_mimetype(&content, zMime);
}else if( renderAsHtml ){
@ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)"
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
@ sandbox="allow-same-origin"
@ onload="this.height=this.contentDocument.documentElement.scrollHeight;">
@ </iframe>
}else{
style_submenu_element("Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
blob_to_utf8_no_bom(&content, 0);
zMime = mimetype_from_content(&content);
@ <blockquote>
if( zMime==0 ){
|
| ︙ | ︙ |