Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the /jtext webpage, intended for use by XHR. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
5f7fcbabf01abf6fd4b7bc146e709c9d |
| User & Date: | drh 2021-09-07 19:09:29.366 |
Context
|
2021-09-07
| ||
| 19:15 | On the /jtext page, terminate the JSON array early if there are insufficient lines of text in the file to complete the request. ... (check-in: 6f5dfd9d80 user: drh tags: trunk) | |
| 19:09 | Add the /jtext webpage, intended for use by XHR. ... (check-in: 5f7fcbabf0 user: drh tags: trunk) | |
| 18:45 | When HTML diffs are generated from a webpage, include sufficient information in class names ids, and data- elements to permit JS to redraw the separators to include context fill-in buttons. ... (check-in: c275a166b3 user: drh tags: trunk) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 |
@ Unknown artifact: "%h(zName)"
return;
}
g.isConst = 1;
deliver_artifact(rid, P("m"));
}
/*
** Generate a verbatim artifact as the result of an HTTP request.
** If zMime is not NULL, use it as the mimetype. If zMime is
** NULL, guess at the mimetype based on the filename
** associated with the artifact.
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1946 1947 1948 1949 1950 |
@ Unknown artifact: "%h(zName)"
return;
}
g.isConst = 1;
deliver_artifact(rid, P("m"));
}
/*
** WEBPAGE: jtext
** URL: /jtext/HASH?from=N&to=M
**
** Return lines of text from a file as a JSON array - one entry in the
** array for each line of text.
**
** This page is intended to be used in an XHR from javascript on a diff
** page, to return unseen context to fill in additional context when the
** user clicks on the appropriate button.
*/
void jtext_page(void){
int rid = 0;
const char *zName = PD("name", "");
int iFrom = atoi(PD("from","0"));
int iTo = atoi(PD("to","0"));
int ln;
const char *zSep;
Blob content;
Blob line;
Blob *pOut;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName);
if( rid==0 ){
cgi_set_status(404, "Not Found");
@ Unknown artifact: "%h(zName)"
return;
}
if( iFrom<1 || iTo<iFrom ){
cgi_set_status(500, "Bad Request");
@ Invalid line range
return;
}
content_get(rid, &content);
g.isConst = 1;
cgi_set_content_type("text/json");
ln = 0;
zSep = "[\n";
while( ln<iFrom ){
blob_line(&content, &line);
ln++;
}
pOut = cgi_output_blob();
while( ln<=iTo ){
blob_append(pOut, zSep, 2);
blob_trim(&line);
blob_append_json_literal(pOut, blob_buffer(&line), blob_size(&line));
zSep = ",\n";
blob_line(&content, &line);
ln++;
}
blob_appendf(pOut,"]\n");
blob_reset(&content);
}
/*
** Generate a verbatim artifact as the result of an HTTP request.
** If zMime is not NULL, use it as the mimetype. If zMime is
** NULL, guess at the mimetype based on the filename
** associated with the artifact.
*/
|
| ︙ | ︙ |