Fossil SCM

Add support for URLs of the form: artifact?ci=CHECKIN&filename=FILENAME.

drh 2010-05-02 19:21 trunk
Commit 6f9901dd4231a587a33ccb72b971a0c82d296b7d
1 file changed +37 -2
+37 -2
--- src/info.c
+++ src/info.c
@@ -937,28 +937,63 @@
937937
@ <blockquote><pre>
938938
hexdump(&content);
939939
@ </pre></blockquote>
940940
style_footer();
941941
}
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
+
942971
943972
/*
944973
** WEBPAGE: artifact
945974
** URL: /artifact?name=ARTIFACTID
975
+** URL: /artifact?ci=CHECKIN&filename=PATH
946976
**
947977
** Show the complete content of a file identified by ARTIFACTID
948978
** as preformatted text.
949979
*/
950980
void artifact_page(void){
951
- int rid;
981
+ int rid = 0;
952982
Blob content;
953983
const char *zMime;
954984
Blob downloadName;
955985
int renderAsWiki = 0;
956986
int renderAsHtml = 0;
957987
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
+ }
958994
959
- rid = name_to_rid_www("name");
960995
login_check_credentials();
961996
if( !g.okRead ){ login_needed(); return; }
962997
if( rid==0 ) fossil_redirect_home();
963998
if( g.okAdmin ){
964999
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
9651000
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button