Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Continuing UX improvements on the /file, /artifact, and /whatis pages. More needs to be done. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
1b5d0b0e18d6372afa5e848a053c79cc |
| User & Date: | drh 2020-05-11 18:12:01.281 |
Context
|
2020-05-11
| ||
| 19:24 | Further enhancements to the file browsing UX. ... (check-in: cd05cb20db user: drh tags: trunk) | |
| 18:12 | Continuing UX improvements on the /file, /artifact, and /whatis pages. More needs to be done. ... (check-in: 1b5d0b0e18 user: drh tags: trunk) | |
|
2020-05-10
| ||
| 15:29 | Fix a null-pointer reference and segfault in /file if the filename= query parameter is used with ci= and without name=. ... (check-in: 26011322cd user: drh tags: trunk) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
1659 1660 1661 1662 1663 1664 1665 |
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
cookie_link_parameter("diff","diff","2");
diffType = atoi(PD("diff","2"));
cookie_render();
if( P("from") && P("to") ){
| | | | 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 |
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
cookie_link_parameter("diff","diff","2");
diffType = atoi(PD("diff","2"));
cookie_render();
if( P("from") && P("to") ){
v1 = artifact_from_ci_and_filename("from");
v2 = artifact_from_ci_and_filename("to");
}else{
Stmt q;
v1 = name_to_rid_www("v1");
v2 = name_to_rid_www("v2");
/* If the two file versions being compared both have the same
** filename, then offer an "Annotate" link that constructs an
|
| ︙ | ︙ | |||
1761 1762 1763 1764 1765 1766 1767 |
** Return the uninterpreted content of an artifact. Used primarily
** to view artifacts that are images.
*/
void rawartifact_page(void){
int rid = 0;
char *zUuid;
| | | | 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 |
** Return the uninterpreted content of an artifact. Used primarily
** to view artifacts that are images.
*/
void rawartifact_page(void){
int rid = 0;
char *zUuid;
if( P("ci") ){
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();
|
| ︙ | ︙ | |||
1940 1941 1942 1943 1944 1945 1946 | 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. ** | | | | | | < < | < < | > > > > | | | < < < < < < | | | 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 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 |
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" and "name" as an aliases for "filename". If any
** "filename" or "fn" or "name" are present but "ci" is missing, then
** use "tip" as the default value for "ci".
**
** If zNameParam is not NULL, then use that parameter as the filename
** rather than "fn" or "filename" or "name". the zNameParam is used
** for the from= and to= query parameters of /fdiff.
*/
int artifact_from_ci_and_filename(const char *zNameParam){
const char *zFilename;
const char *zCI;
int cirid;
Manifest *pManifest;
ManifestFile *pFile;
int rid = 0;
if( zNameParam ){
zFilename = P(zNameParam);
}else{
zFilename = P("filename");
if( zFilename==0 ){
zFilename = P("fn");
}
if( zFilename==0 ){
zFilename = P("name");
}
}
if( zFilename==0 ) return 0;
zCI = PD("ci", "tip");
cirid = name_to_typed_rid(zCI, "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 ){
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", pFile->zUuid);
break;
}
}
manifest_destroy(pManifest);
return rid;
}
/*
** 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.
**
** zLn is the ?ln= parameter for the HTTP query. If there is an argument,
|
| ︙ | ︙ | |||
2094 2095 2096 2097 2098 2099 2100 | ** ** 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) | | | > < | > | | | > > > > > > > > > < > | > | > > | < < < < | | > > > > > > > > > | | > > > > > | < > > | < | < | | < | < < < < < | | | | | | | < < > > > > > | < < < < > | | > > > | > | > | | < | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < | > > | > | | > | < > > > | 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 |
**
** 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=NAME - filename or hash as a query parameter
** filename=NAME - alternative spelling for "name="
** fn=NAME - alternative spelling for "name="
** ci=VERSION - The specific check-in to use with "name=" to
** identify the file.
**
** The /artifact page show the complete content of a file
** identified by HASH. The /whatis page shows only a description
** of how the artifact is used. The /file page shows the most recent
** version of the file or directory called NAME, or a list of the
** top-level directory if NAME is omitted.
**
** The name= query parameter can refer to either the name of a file,
** or an artifact hash. If the ci= query parameter is also present,
** then name= must refer to a file name. If ci= is omitted, either
** interpretation may be used. When name= is a filename and ci=
** is omitted, a default value of "tip" is used for ci=.
**
** If name= is ambiguous in that it might be either a filename or
** a hash, then the hash interpretation is preferred for /artifact
** and /whatis and the filename interpretation is preferred for /file.
*/
void artifact_page(void){
int rid = 0;
Blob content;
const char *zMime;
Blob downloadName;
int renderAsWiki = 0;
int renderAsHtml = 0;
int objType;
int asText;
const char *zUuid = 0;
u32 objdescFlags = OBJDESC_BASE;
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");
const char *zCI = P("ci");
HQuery url;
char *zCIUuid = 0;
int isSymbolicCI = 0; /* ci= exists and is a symbolic name, not a hash */
int isBranchCI = 0; /* ci= refers to a branch name */
char *zHeader = 0;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
/* Capture and normalize the name= and ci= query parameters */
if( zName==0 ){
zName = P("filename");
if( zName==0 ){
zName = P("fn");
}
}
if( zCI && strlen(zCI)==0 ){ zCI = 0; }
if( zCI
&& name_to_uuid2(zCI, "ci", &zCIUuid)
&& sqlite3_strnicmp(zCIUuid, zCI, strlen(zCI))!=0
){
isSymbolicCI = 1;
isBranchCI = db_exists(
"SELECT 1 FROM tagxref, blob"
" WHERE blob.uuid=%Q AND tagxref.rid=blob.rid"
" AND tagxref.value=%Q AND tagxref.tagtype>0"
" AND tagxref.tagid=%d",
zCIUuid, zCI, TAG_BRANCH
);
}
/* The name= query parameter (or at least one of its alternative
** spellings) is required. Except for /file, show a top-level
** directory listing if name= is omitted.
*/
if( zName==0 ){
if( isFile ){
if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
page_tree();
return;
}
style_header("Missing name= query parameter");
@ The name= query parameter is missing
style_footer();
return;
}
url_initialize(&url, g.zPath);
url_add_parameter(&url, "name", zName);
url_add_parameter(&url, "ci", zCI);
if( zCI==0 && !isFile ){
/* If there is no ci= query parameter, then prefer to interpret
** name= as a hash for /artifact and /whatis. But for not for /file.
** For /file, a name= without a ci= while prefer to use the default
** "tip" value for ci=. */
rid = name_to_rid(zName);
}
if( rid==0 ){
rid = artifact_from_ci_and_filename(0);
}
if( rid==0 && zCI==0 && isFile ){
/* For /file, only try to interpret name= as a hash if it did not
** match any known filename. */
rid = name_to_rid(zName);
}
if( rid==0 && isFile ){
/* If no file called NAME exists, instead look for a directory
** with that name, and do a directory listing */
int nName = (int)strlen(zName);
if( nName && zName[nName-1]=='/' ) nName--;
if( db_exists(
"SELECT 1 FROM filename"
" WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';",
nName, zName, nName+1, nName, zName
) ){
if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
page_tree();
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 ){
if( zCI==0 ){
@ <h2>Latest version of file '%h(zName)':</h2>
}else{
const char *zPath;
Blob path;
blob_zero(&path);
hyperlinked_path(zName, &path, zCI, "dir", "");
zPath = blob_str(&path);
@ <h2>File %s(zPath) \
if( isBranchCI ){
@ on branch %z(href("%R/timeline?r=%T",zCI))%h(zCI)</a></h2>
}else if( isSymbolicCI ){
@ as of check-in %z(href("/info/%!S",zCIUuid))%s(zCI)</a></h2>
}else{
@ as of check-in [%z(href("/info/%!S",zCIUuid))%S(zCIUuid)</a>]</h2>
}
blob_reset(&path);
}
style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
}else{
@ <h2>Artifact
style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
if( g.perm.Setup ){
@ (%d(rid)):</h2>
|
| ︙ | ︙ |