Fossil SCM
Add support for URLs of the form: artifact?ci=CHECKIN&filename=FILENAME.
Commit
6f9901dd4231a587a33ccb72b971a0c82d296b7d
Parent
9d6507d25d6ab49…
1 file changed
+37
-2
+37
-2
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -937,28 +937,63 @@ | ||
| 937 | 937 | @ <blockquote><pre> |
| 938 | 938 | hexdump(&content); |
| 939 | 939 | @ </pre></blockquote> |
| 940 | 940 | style_footer(); |
| 941 | 941 | } |
| 942 | + | |
| 943 | +/* | |
| 944 | +** Look for "ci" and "filename" query parameters. If found, try to | |
| 945 | +** use them to extract the record ID of an artifact for the file. | |
| 946 | +*/ | |
| 947 | +int artifact_from_ci_and_filename(void){ | |
| 948 | + const char *zFilename; | |
| 949 | + const char *zCI; | |
| 950 | + int cirid; | |
| 951 | + Blob content; | |
| 952 | + Manifest m; | |
| 953 | + int i; | |
| 954 | + | |
| 955 | + zCI = P("ci"); | |
| 956 | + if( zCI==0 ) return 0; | |
| 957 | + zFilename = P("filename"); | |
| 958 | + if( zFilename==0 ) return 0; | |
| 959 | + cirid = name_to_rid_www("ci"); | |
| 960 | + if( !content_get(cirid, &content) ) return 0; | |
| 961 | + if( !manifest_parse(&m, &content) ) return 0; | |
| 962 | + if( m.type!=CFTYPE_MANIFEST ) return 0; | |
| 963 | + for(i=0; i<m.nFile; i++){ | |
| 964 | + if( strcmp(zFilename, m.aFile[i].zName)==0 ){ | |
| 965 | + return db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", m.aFile[i].zUuid); | |
| 966 | + } | |
| 967 | + } | |
| 968 | + return 0; | |
| 969 | +} | |
| 970 | + | |
| 942 | 971 | |
| 943 | 972 | /* |
| 944 | 973 | ** WEBPAGE: artifact |
| 945 | 974 | ** URL: /artifact?name=ARTIFACTID |
| 975 | +** URL: /artifact?ci=CHECKIN&filename=PATH | |
| 946 | 976 | ** |
| 947 | 977 | ** Show the complete content of a file identified by ARTIFACTID |
| 948 | 978 | ** as preformatted text. |
| 949 | 979 | */ |
| 950 | 980 | void artifact_page(void){ |
| 951 | - int rid; | |
| 981 | + int rid = 0; | |
| 952 | 982 | Blob content; |
| 953 | 983 | const char *zMime; |
| 954 | 984 | Blob downloadName; |
| 955 | 985 | int renderAsWiki = 0; |
| 956 | 986 | int renderAsHtml = 0; |
| 957 | 987 | const char *zUuid; |
| 988 | + if( P("ci") && P("filename") ){ | |
| 989 | + rid = artifact_from_ci_and_filename(); | |
| 990 | + } | |
| 991 | + if( rid==0 ){ | |
| 992 | + rid = name_to_rid_www("name"); | |
| 993 | + } | |
| 958 | 994 | |
| 959 | - rid = name_to_rid_www("name"); | |
| 960 | 995 | login_check_credentials(); |
| 961 | 996 | if( !g.okRead ){ login_needed(); return; } |
| 962 | 997 | if( rid==0 ) fossil_redirect_home(); |
| 963 | 998 | if( g.okAdmin ){ |
| 964 | 999 | const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 965 | 1000 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -937,28 +937,63 @@ | |
| 937 | @ <blockquote><pre> |
| 938 | hexdump(&content); |
| 939 | @ </pre></blockquote> |
| 940 | style_footer(); |
| 941 | } |
| 942 | |
| 943 | /* |
| 944 | ** WEBPAGE: artifact |
| 945 | ** URL: /artifact?name=ARTIFACTID |
| 946 | ** |
| 947 | ** Show the complete content of a file identified by ARTIFACTID |
| 948 | ** as preformatted text. |
| 949 | */ |
| 950 | void artifact_page(void){ |
| 951 | int rid; |
| 952 | Blob content; |
| 953 | const char *zMime; |
| 954 | Blob downloadName; |
| 955 | int renderAsWiki = 0; |
| 956 | int renderAsHtml = 0; |
| 957 | const char *zUuid; |
| 958 | |
| 959 | rid = name_to_rid_www("name"); |
| 960 | login_check_credentials(); |
| 961 | if( !g.okRead ){ login_needed(); return; } |
| 962 | if( rid==0 ) fossil_redirect_home(); |
| 963 | if( g.okAdmin ){ |
| 964 | const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 965 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -937,28 +937,63 @@ | |
| 937 | @ <blockquote><pre> |
| 938 | hexdump(&content); |
| 939 | @ </pre></blockquote> |
| 940 | style_footer(); |
| 941 | } |
| 942 | |
| 943 | /* |
| 944 | ** Look for "ci" and "filename" query parameters. If found, try to |
| 945 | ** use them to extract the record ID of an artifact for the file. |
| 946 | */ |
| 947 | int artifact_from_ci_and_filename(void){ |
| 948 | const char *zFilename; |
| 949 | const char *zCI; |
| 950 | int cirid; |
| 951 | Blob content; |
| 952 | Manifest m; |
| 953 | int i; |
| 954 | |
| 955 | zCI = P("ci"); |
| 956 | if( zCI==0 ) return 0; |
| 957 | zFilename = P("filename"); |
| 958 | if( zFilename==0 ) return 0; |
| 959 | cirid = name_to_rid_www("ci"); |
| 960 | if( !content_get(cirid, &content) ) return 0; |
| 961 | if( !manifest_parse(&m, &content) ) return 0; |
| 962 | if( m.type!=CFTYPE_MANIFEST ) return 0; |
| 963 | for(i=0; i<m.nFile; i++){ |
| 964 | if( strcmp(zFilename, m.aFile[i].zName)==0 ){ |
| 965 | return db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", m.aFile[i].zUuid); |
| 966 | } |
| 967 | } |
| 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | |
| 972 | /* |
| 973 | ** WEBPAGE: artifact |
| 974 | ** URL: /artifact?name=ARTIFACTID |
| 975 | ** URL: /artifact?ci=CHECKIN&filename=PATH |
| 976 | ** |
| 977 | ** Show the complete content of a file identified by ARTIFACTID |
| 978 | ** as preformatted text. |
| 979 | */ |
| 980 | void artifact_page(void){ |
| 981 | int rid = 0; |
| 982 | Blob content; |
| 983 | const char *zMime; |
| 984 | Blob downloadName; |
| 985 | int renderAsWiki = 0; |
| 986 | int renderAsHtml = 0; |
| 987 | const char *zUuid; |
| 988 | if( P("ci") && P("filename") ){ |
| 989 | rid = artifact_from_ci_and_filename(); |
| 990 | } |
| 991 | if( rid==0 ){ |
| 992 | rid = name_to_rid_www("name"); |
| 993 | } |
| 994 | |
| 995 | login_check_credentials(); |
| 996 | if( !g.okRead ){ login_needed(); return; } |
| 997 | if( rid==0 ) fossil_redirect_home(); |
| 998 | if( g.okAdmin ){ |
| 999 | const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1000 |