Fossil SCM

Experimental change to add a "nodesc" query parameter to pages like /artifact that suppresses the sometimes length description of what the artifact is used for.

drh 2014-04-22 13:57 UTC trunk
Commit b794218f01df12351f996777cd6e2d13473b31fe
2 files changed +14 -7 +2 -1
+14 -7
--- src/cgi.c
+++ src/cgi.c
@@ -59,10 +59,11 @@
5959
/*
6060
** Destinations for output text.
6161
*/
6262
#define CGI_HEADER 0
6363
#define CGI_BODY 1
64
+#define CGI_OFF 2
6465
6566
/*
6667
** Flags for SSH HTTP clients
6768
*/
6869
#define CGI_SSH_CLIENT 0x0001 /* Client is SSH */
@@ -94,10 +95,14 @@
9495
break;
9596
}
9697
case CGI_BODY: {
9798
pContent = &cgiContent[1];
9899
break;
100
+ }
101
+ case CGI_OFF: {
102
+ pContent = 0;
103
+ break;
99104
}
100105
default: {
101106
cgi_panic("bad destination");
102107
}
103108
}
@@ -113,11 +118,11 @@
113118
114119
/*
115120
** Append reply content to what already exists.
116121
*/
117122
void cgi_append_content(const char *zData, int nAmt){
118
- blob_append(pContent, zData, nAmt);
123
+ if( pContent ) blob_append(pContent, zData, nAmt);
119124
}
120125
121126
/*
122127
** Reset the HTTP reply text to be an empty string.
123128
*/
@@ -1159,22 +1164,24 @@
11591164
/*
11601165
** This routine works like "printf" except that it has the
11611166
** extra formatting capabilities such as %h and %t.
11621167
*/
11631168
void cgi_printf(const char *zFormat, ...){
1164
- va_list ap;
1165
- va_start(ap,zFormat);
1166
- vxprintf(pContent,zFormat,ap);
1167
- va_end(ap);
1169
+ if( pContent ){
1170
+ va_list ap;
1171
+ va_start(ap,zFormat);
1172
+ vxprintf(pContent,zFormat,ap);
1173
+ va_end(ap);
1174
+ }
11681175
}
11691176
11701177
/*
11711178
** This routine works like "vprintf" except that it has the
11721179
** extra formatting capabilities such as %h and %t.
11731180
*/
11741181
void cgi_vprintf(const char *zFormat, va_list ap){
1175
- vxprintf(pContent,zFormat,ap);
1182
+ if( pContent ) vxprintf(pContent,zFormat,ap);
11761183
}
11771184
11781185
11791186
/*
11801187
** Send a reply indicating that the HTTP request was malformed
@@ -1210,11 +1217,11 @@
12101217
cgi_printf(
12111218
"<html><body><h1>Internal Server Error</h1>\n"
12121219
"<plaintext>"
12131220
);
12141221
va_start(ap, zFormat);
1215
- vxprintf(pContent,zFormat,ap);
1222
+ if( pContent ) vxprintf(pContent,zFormat,ap);
12161223
va_end(ap);
12171224
cgi_reply();
12181225
fossil_exit(1);
12191226
}
12201227
}
12211228
--- src/cgi.c
+++ src/cgi.c
@@ -59,10 +59,11 @@
59 /*
60 ** Destinations for output text.
61 */
62 #define CGI_HEADER 0
63 #define CGI_BODY 1
 
64
65 /*
66 ** Flags for SSH HTTP clients
67 */
68 #define CGI_SSH_CLIENT 0x0001 /* Client is SSH */
@@ -94,10 +95,14 @@
94 break;
95 }
96 case CGI_BODY: {
97 pContent = &cgiContent[1];
98 break;
 
 
 
 
99 }
100 default: {
101 cgi_panic("bad destination");
102 }
103 }
@@ -113,11 +118,11 @@
113
114 /*
115 ** Append reply content to what already exists.
116 */
117 void cgi_append_content(const char *zData, int nAmt){
118 blob_append(pContent, zData, nAmt);
119 }
120
121 /*
122 ** Reset the HTTP reply text to be an empty string.
123 */
@@ -1159,22 +1164,24 @@
1159 /*
1160 ** This routine works like "printf" except that it has the
1161 ** extra formatting capabilities such as %h and %t.
1162 */
1163 void cgi_printf(const char *zFormat, ...){
1164 va_list ap;
1165 va_start(ap,zFormat);
1166 vxprintf(pContent,zFormat,ap);
1167 va_end(ap);
 
 
1168 }
1169
1170 /*
1171 ** This routine works like "vprintf" except that it has the
1172 ** extra formatting capabilities such as %h and %t.
1173 */
1174 void cgi_vprintf(const char *zFormat, va_list ap){
1175 vxprintf(pContent,zFormat,ap);
1176 }
1177
1178
1179 /*
1180 ** Send a reply indicating that the HTTP request was malformed
@@ -1210,11 +1217,11 @@
1210 cgi_printf(
1211 "<html><body><h1>Internal Server Error</h1>\n"
1212 "<plaintext>"
1213 );
1214 va_start(ap, zFormat);
1215 vxprintf(pContent,zFormat,ap);
1216 va_end(ap);
1217 cgi_reply();
1218 fossil_exit(1);
1219 }
1220 }
1221
--- src/cgi.c
+++ src/cgi.c
@@ -59,10 +59,11 @@
59 /*
60 ** Destinations for output text.
61 */
62 #define CGI_HEADER 0
63 #define CGI_BODY 1
64 #define CGI_OFF 2
65
66 /*
67 ** Flags for SSH HTTP clients
68 */
69 #define CGI_SSH_CLIENT 0x0001 /* Client is SSH */
@@ -94,10 +95,14 @@
95 break;
96 }
97 case CGI_BODY: {
98 pContent = &cgiContent[1];
99 break;
100 }
101 case CGI_OFF: {
102 pContent = 0;
103 break;
104 }
105 default: {
106 cgi_panic("bad destination");
107 }
108 }
@@ -113,11 +118,11 @@
118
119 /*
120 ** Append reply content to what already exists.
121 */
122 void cgi_append_content(const char *zData, int nAmt){
123 if( pContent ) blob_append(pContent, zData, nAmt);
124 }
125
126 /*
127 ** Reset the HTTP reply text to be an empty string.
128 */
@@ -1159,22 +1164,24 @@
1164 /*
1165 ** This routine works like "printf" except that it has the
1166 ** extra formatting capabilities such as %h and %t.
1167 */
1168 void cgi_printf(const char *zFormat, ...){
1169 if( pContent ){
1170 va_list ap;
1171 va_start(ap,zFormat);
1172 vxprintf(pContent,zFormat,ap);
1173 va_end(ap);
1174 }
1175 }
1176
1177 /*
1178 ** This routine works like "vprintf" except that it has the
1179 ** extra formatting capabilities such as %h and %t.
1180 */
1181 void cgi_vprintf(const char *zFormat, va_list ap){
1182 if( pContent ) vxprintf(pContent,zFormat,ap);
1183 }
1184
1185
1186 /*
1187 ** Send a reply indicating that the HTTP request was malformed
@@ -1210,11 +1217,11 @@
1217 cgi_printf(
1218 "<html><body><h1>Internal Server Error</h1>\n"
1219 "<plaintext>"
1220 );
1221 va_start(ap, zFormat);
1222 if( pContent ) vxprintf(pContent,zFormat,ap);
1223 va_end(ap);
1224 cgi_reply();
1225 fossil_exit(1);
1226 }
1227 }
1228
+2 -1
--- src/info.c
+++ src/info.c
@@ -1132,13 +1132,13 @@
11321132
Stmt q;
11331133
int cnt = 0;
11341134
int nWiki = 0;
11351135
int objType = 0;
11361136
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1137
-
11381137
char *prevName = 0;
11391138
1139
+ if( P("nodesc")!=0 ) cgi_destination(CGI_OFF);
11401140
db_prepare(&q,
11411141
"SELECT filename.name, datetime(event.mtime),"
11421142
" coalesce(event.ecomment,event.comment),"
11431143
" coalesce(event.euser,event.user),"
11441144
" b.uuid, mlink.mperm,"
@@ -1330,10 +1330,11 @@
13301330
blob_appendf(pDownloadName, "%.10s.txt", zUuid);
13311331
}
13321332
}else if( linkToView && g.perm.Hyperlink ){
13331333
@ %z(href("%R/artifact/%s",zUuid))[view]</a>
13341334
}
1335
+ if( P("nodesc")!=0 ) cgi_destination(CGI_BODY);
13351336
return objType;
13361337
}
13371338
13381339
13391340
/*
13401341
--- src/info.c
+++ src/info.c
@@ -1132,13 +1132,13 @@
1132 Stmt q;
1133 int cnt = 0;
1134 int nWiki = 0;
1135 int objType = 0;
1136 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1137
1138 char *prevName = 0;
1139
 
1140 db_prepare(&q,
1141 "SELECT filename.name, datetime(event.mtime),"
1142 " coalesce(event.ecomment,event.comment),"
1143 " coalesce(event.euser,event.user),"
1144 " b.uuid, mlink.mperm,"
@@ -1330,10 +1330,11 @@
1330 blob_appendf(pDownloadName, "%.10s.txt", zUuid);
1331 }
1332 }else if( linkToView && g.perm.Hyperlink ){
1333 @ %z(href("%R/artifact/%s",zUuid))[view]</a>
1334 }
 
1335 return objType;
1336 }
1337
1338
1339 /*
1340
--- src/info.c
+++ src/info.c
@@ -1132,13 +1132,13 @@
1132 Stmt q;
1133 int cnt = 0;
1134 int nWiki = 0;
1135 int objType = 0;
1136 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
 
1137 char *prevName = 0;
1138
1139 if( P("nodesc")!=0 ) cgi_destination(CGI_OFF);
1140 db_prepare(&q,
1141 "SELECT filename.name, datetime(event.mtime),"
1142 " coalesce(event.ecomment,event.comment),"
1143 " coalesce(event.euser,event.user),"
1144 " b.uuid, mlink.mperm,"
@@ -1330,10 +1330,11 @@
1330 blob_appendf(pDownloadName, "%.10s.txt", zUuid);
1331 }
1332 }else if( linkToView && g.perm.Hyperlink ){
1333 @ %z(href("%R/artifact/%s",zUuid))[view]</a>
1334 }
1335 if( P("nodesc")!=0 ) cgi_destination(CGI_BODY);
1336 return objType;
1337 }
1338
1339
1340 /*
1341

Keyboard Shortcuts

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