Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the ci=LABEL parameter to the "dir" webpage in order to look at just files within a single check-in. Add a Download link on the artifact and hexdump viewers. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
923d644b89211895883a8442883afed8 |
| User & Date: | drh 2009-01-28 21:41:41.000 |
Context
|
2009-01-28
| ||
| 22:23 | A a "View" submenu option for the content viewer when the file is HTML. ... (check-in: d4fedbb4ad user: drh tags: trunk) | |
| 21:41 | Add the ci=LABEL parameter to the "dir" webpage in order to look at just files within a single check-in. Add a Download link on the artifact and hexdump viewers. ... (check-in: 923d644b89 user: drh tags: trunk) | |
|
2009-01-26
| ||
| 19:41 | Fix incorrect check-in numbers (referring to Figure 5) in the branching tutorial ... (check-in: 5e4b1632bc user: eric tags: trunk) | |
Changes
Changes to src/browse.c.
| ︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
/*
** WEBPAGE: dir
**
** Query parameters:
**
** name=PATH Directory to display. Required.
*/
void page_dir(void){
const char *zD = P("name");
int mxLen;
int nCol, nRow;
int cnt, i;
char *zPrefix;
Stmt q;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
style_header("File List");
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
pathelementFunc, 0, 0);
/* If the name= parameter is an empty string, make it a NULL pointer */
if( zD && strlen(zD)==0 ){ zD = 0; }
/* Compute the title of the page */
if( zD ){
Blob title;
blob_zero(&title);
blob_appendf(&title, "Files in directory ");
hyperlinked_path(zD, &title);
| > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < | | < | | | > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
/*
** WEBPAGE: dir
**
** Query parameters:
**
** name=PATH Directory to display. Required.
** ci=LABEL Show only files in this check-in. Optional.
*/
void page_dir(void){
const char *zD = P("name");
int mxLen;
int nCol, nRow;
int cnt, i;
char *zPrefix;
Stmt q;
const char *zCI = P("ci");
int rid = 0;
Blob content;
Manifest m;
const char *zSubdirLink;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
style_header("File List");
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
pathelementFunc, 0, 0);
/* If the name= parameter is an empty string, make it a NULL pointer */
if( zD && strlen(zD)==0 ){ zD = 0; }
/* If a specific check-in is requested, fetch and parse it. */
if( zCI && (rid = name_to_rid(zCI))!=0 && content_get(rid, &content) ){
if( !manifest_parse(&m, &content) || m.type!=CFTYPE_MANIFEST ){
zCI = 0;
}
}
/* Compute the title of the page */
if( zD ){
Blob title;
blob_zero(&title);
blob_appendf(&title, "Files in directory ");
hyperlinked_path(zD, &title);
@ <h2>%s(blob_str(&title))
blob_reset(&title);
zPrefix = mprintf("%h/", zD);
}else{
@ <h2>Files in the top-level directory
zPrefix = "";
}
if( zCI ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
char zShort[20];
memcpy(zShort, zUuid, 10);
zShort[10] = 0;
@ of check-in [<a href="vinfo?name=%T(zUuid)">%s(zShort)</a>]</h2>
zSubdirLink = mprintf("%s/dir?ci=%s&name=%T", g.zBaseURL, zUuid, zPrefix);
if( zD ){
style_submenu_element("Top", "Top", "%s/dir?ci=%s", g.zBaseURL, zUuid);
}
}else{
@ </h2>
zSubdirLink = mprintf("%s/dir?name=%T", g.zBaseURL, zPrefix);
}
/* Compute the temporary table "localfiles" containing the names
** of all files and subdirectories in the zD[] directory.
**
** Subdirectory names begin with "/". This causes them to sort
** first and it also gives us an easy way to distinguish files
** from directories in the loop that follows.
*/
db_multi_exec(
"CREATE TEMP TABLE localfiles(x UNIQUE NOT NULL, u);"
"CREATE TEMP TABLE allfiles(x UNIQUE NOT NULL, u);"
);
if( zCI ){
Stmt ins;
int i;
db_prepare(&ins, "INSERT INTO allfiles VALUES(:x, :u)");
for(i=0; i<m.nFile; i++){
db_bind_text(&ins, ":x", m.aFile[i].zName);
db_bind_text(&ins, ":u", m.aFile[i].zUuid);
db_step(&ins);
db_reset(&ins);
}
db_finalize(&ins);
}else{
db_multi_exec(
"INSERT INTO allfiles SELECT name, NULL FROM filename"
);
}
if( zD ){
db_multi_exec(
"INSERT OR IGNORE INTO localfiles "
" SELECT pathelement(x,%d), u FROM allfiles"
" WHERE x GLOB '%q/*'",
strlen(zD)+1, zD
);
}else{
db_multi_exec(
"INSERT OR IGNORE INTO localfiles "
" SELECT pathelement(x,0), u FROM allfiles"
);
}
/* Generate a multi-column table listing the contents of zD[]
** directory.
*/
mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles");
cnt = db_int(0, "SELECT count(*) FROM localfiles");
nCol = 4;
nRow = (cnt+nCol-1)/nCol;
db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x");
@ <table border="0" width="100%%"><tr><td valign="top" width="25%%">
i = 0;
while( db_step(&q)==SQLITE_ROW ){
const char *zFName;
if( i==nRow ){
@ </td><td valign="top" width="25%%">
i = 0;
}
i++;
zFName = db_column_text(&q, 0);
if( zFName[0]=='/' ){
zFName++;
@ <li><a href="%s(zSubdirLink)%T(zFName)">
@ %h(zFName)/</a></li>
}else if( zCI ){
const char *zUuid = db_column_text(&q, 1);
@ <li><a href="%s(g.zBaseURL)/artifact?name=%s(zUuid)">%h(zFName)</a>
}else{
@ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFName)">
@ %h(zFName)</a></li>
}
}
db_finalize(&q);
@ </td></tr></table>
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
if( cnt ){
@ </ul>
}
}
/*
** WEBPAGE: ci
** URL: /ci?name=RID|ARTIFACTID
**
** Return information about a baseline
*/
void ci_page(void){
Stmt q;
| > | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
if( cnt ){
@ </ul>
}
}
/*
** WEBPAGE: vinfo
** WEBPAGE: ci
** URL: /ci?name=RID|ARTIFACTID
**
** Return information about a baseline
*/
void ci_page(void){
Stmt q;
|
| ︙ | ︙ | |||
423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
@ | <a href="%s(g.zBaseURL)/timeline?t=%T(zTagName)">%h(zTagName)</a>
}
db_finalize(&q);
@ </td></tr>
@ <tr><th>Commands:</th>
@ <td>
@ <a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a>
@ | <a href="%s(g.zBaseURL)/zip/%s(zProjName)-%s(zShortUuid).zip?uuid=%s(zUuid)">
@ ZIP archive</a>
@ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a>
if( g.okWrite ){
@ | <a href="%s(g.zBaseURL)/ci_edit?r=%d(rid)">edit</a>
}
@ </td>
| > | 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
@ | <a href="%s(g.zBaseURL)/timeline?t=%T(zTagName)">%h(zTagName)</a>
}
db_finalize(&q);
@ </td></tr>
@ <tr><th>Commands:</th>
@ <td>
@ <a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a>
@ | <a href="%s(g.zBaseURL)/dir?ci=%s(zShortUuid)">files</a>
@ | <a href="%s(g.zBaseURL)/zip/%s(zProjName)-%s(zShortUuid).zip?uuid=%s(zUuid)">
@ ZIP archive</a>
@ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a>
if( g.okWrite ){
@ | <a href="%s(g.zBaseURL)/ci_edit?r=%d(rid)">edit</a>
}
@ </td>
|
| ︙ | ︙ | |||
734 735 736 737 738 739 740 | ** ** * It's uuid ** * date of check-in ** * Comment & user */ static void object_description( int rid, /* The artifact ID */ | | > | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 |
**
** * It's uuid
** * date of check-in
** * Comment & user
*/
static void object_description(
int rid, /* The artifact ID */
int linkToView, /* Add viewer link if true */
Blob *pDownloadName /* Fill with an appropriate download name */
){
Stmt q;
int cnt = 0;
int nWiki = 0;
db_prepare(&q,
"SELECT filename.name, datetime(event.mtime), substr(a.uuid,1,10),"
" coalesce(event.ecomment,event.comment),"
|
| ︙ | ︙ | |||
769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
@ File
}
@ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
@ uuid %s(zFuuid) part of check-in
hyperlink_to_uuid(zVers);
@ %w(zCom) by %h(zUser) on %s(zDate).
cnt++;
}
db_finalize(&q);
db_prepare(&q,
"SELECT substr(tagname, 6, 10000), datetime(event.mtime),"
" coalesce(event.euser, event.user), uuid"
" FROM tagxref, tag, event, blob"
" WHERE tagxref.rid=%d"
| > > > | 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
@ File
}
@ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
@ uuid %s(zFuuid) part of check-in
hyperlink_to_uuid(zVers);
@ %w(zCom) by %h(zUser) on %s(zDate).
cnt++;
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zName, -1);
}
}
db_finalize(&q);
db_prepare(&q,
"SELECT substr(tagname, 6, 10000), datetime(event.mtime),"
" coalesce(event.euser, event.user), uuid"
" FROM tagxref, tag, event, blob"
" WHERE tagxref.rid=%d"
|
| ︙ | ︙ | |||
796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
}else{
@ Wiki page
}
@ [<a href="%s(g.zBaseURL)/wiki?name=%t(zPagename)">%h(zPagename)</a>]
@ uuid %s(zUuid) by %h(zUser) on %s(zDate).
nWiki++;
cnt++;
}
db_finalize(&q);
if( nWiki==0 ){
db_prepare(&q,
"SELECT datetime(mtime), user, comment, uuid, type"
" FROM event, blob"
" WHERE event.objid=%d"
| > > > | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
}else{
@ Wiki page
}
@ [<a href="%s(g.zBaseURL)/wiki?name=%t(zPagename)">%h(zPagename)</a>]
@ uuid %s(zUuid) by %h(zUser) on %s(zDate).
nWiki++;
cnt++;
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zPagename, -1);
}
}
db_finalize(&q);
if( nWiki==0 ){
db_prepare(&q,
"SELECT datetime(mtime), user, comment, uuid, type"
" FROM event, blob"
" WHERE event.objid=%d"
|
| ︙ | ︙ | |||
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
}else if( zType[0]=='c' ){
@ Manifest of baseline
}else{
@ Control file referencing
}
hyperlink_to_uuid(zUuid);
@ %w(zCom) by %h(zUser) on %s(zDate).
cnt++;
}
db_finalize(&q);
}
if( cnt==0 ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
@ Control file %s(zUuid).
}else if( linkToView ){
@ <a href="%s(g.zBaseURL)/artifact/%d(rid)">[view]</a>
}
}
/*
** WEBPAGE: fdiff
| > > > > > > | 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
}else if( zType[0]=='c' ){
@ Manifest of baseline
}else{
@ Control file referencing
}
hyperlink_to_uuid(zUuid);
@ %w(zCom) by %h(zUser) on %s(zDate).
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zUuid, -1);
}
cnt++;
}
db_finalize(&q);
}
if( cnt==0 ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
@ Control file %s(zUuid).
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zUuid, -1);
}
}else if( linkToView ){
@ <a href="%s(g.zBaseURL)/artifact/%d(rid)">[view]</a>
}
}
/*
** WEBPAGE: fdiff
|
| ︙ | ︙ | |||
854 855 856 857 858 859 860 |
Blob c1, c2, diff;
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
style_header("Diff");
@ <h2>Differences From:</h2>
@ <blockquote>
| | | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
Blob c1, c2, diff;
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
style_header("Diff");
@ <h2>Differences From:</h2>
@ <blockquote>
object_description(v1, 1, 0);
@ </blockquote>
@ <h2>To:</h2>
@ <blockquote>
object_description(v2, 1, 0);
@ </blockquote>
@ <hr>
@ <blockquote><pre>
content_get(v1, &c1);
content_get(v2, &c2);
blob_zero(&diff);
text_diff(&c1, &c2, &diff, 4);
|
| ︙ | ︙ | |||
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 |
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
*/
void hexdump_page(void){
int rid;
Blob content;
rid = name_to_rid(PD("name","0"));
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
if( rid==0 ){ cgi_redirect("/home"); }
if( g.okAdmin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
style_header("Hex Artifact Content");
@ <h2>Hexadecimal Content Of:</h2>
@ <blockquote>
| > > | > > > > | > > | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 |
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
*/
void hexdump_page(void){
int rid;
Blob content;
Blob downloadName;
rid = name_to_rid(PD("name","0"));
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
if( rid==0 ){ cgi_redirect("/home"); }
if( g.okAdmin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
style_header("Hex Artifact Content");
@ <h2>Hexadecimal Content Of:</h2>
@ <blockquote>
blob_zero(&downloadName);
object_description(rid, 0, &downloadName);
style_submenu_element("Download", "Download",
"%s/raw/%T?name=%d", g.zBaseURL, blob_str(&downloadName), rid);
@ </blockquote>
@ <hr>
content_get(rid, &content);
@ <blockquote><pre>
hexdump(&content);
@ </pre></blockquote>
style_footer();
}
/*
** WEBPAGE: artifact
** URL: /artifact?name=ARTIFACTID
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
*/
void artifact_page(void){
int rid;
Blob content;
const char *zMime;
Blob downloadName;
rid = name_to_rid(PD("name","0"));
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
if( rid==0 ){ cgi_redirect("/home"); }
if( g.okAdmin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
style_header("Artifact Content");
@ <h2>Content Of:</h2>
@ <blockquote>
blob_zero(&downloadName);
object_description(rid, 0, &downloadName);
style_submenu_element("Download", "Download",
"%s/raw/%T?name=%d", g.zTop, blob_str(&downloadName), rid);
@ </blockquote>
@ <hr>
@ <blockquote>
content_get(rid, &content);
zMime = mimetype_from_content(&content);
if( zMime==0 ){
@ <pre>
|
| ︙ | ︙ |