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.
Commit
b794218f01df12351f996777cd6e2d13473b31fe
Parent
49467d2a494aae8…
2 files changed
+14
-7
+2
-1
+14
-7
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -59,10 +59,11 @@ | ||
| 59 | 59 | /* |
| 60 | 60 | ** Destinations for output text. |
| 61 | 61 | */ |
| 62 | 62 | #define CGI_HEADER 0 |
| 63 | 63 | #define CGI_BODY 1 |
| 64 | +#define CGI_OFF 2 | |
| 64 | 65 | |
| 65 | 66 | /* |
| 66 | 67 | ** Flags for SSH HTTP clients |
| 67 | 68 | */ |
| 68 | 69 | #define CGI_SSH_CLIENT 0x0001 /* Client is SSH */ |
| @@ -94,10 +95,14 @@ | ||
| 94 | 95 | break; |
| 95 | 96 | } |
| 96 | 97 | case CGI_BODY: { |
| 97 | 98 | pContent = &cgiContent[1]; |
| 98 | 99 | break; |
| 100 | + } | |
| 101 | + case CGI_OFF: { | |
| 102 | + pContent = 0; | |
| 103 | + break; | |
| 99 | 104 | } |
| 100 | 105 | default: { |
| 101 | 106 | cgi_panic("bad destination"); |
| 102 | 107 | } |
| 103 | 108 | } |
| @@ -113,11 +118,11 @@ | ||
| 113 | 118 | |
| 114 | 119 | /* |
| 115 | 120 | ** Append reply content to what already exists. |
| 116 | 121 | */ |
| 117 | 122 | void cgi_append_content(const char *zData, int nAmt){ |
| 118 | - blob_append(pContent, zData, nAmt); | |
| 123 | + if( pContent ) blob_append(pContent, zData, nAmt); | |
| 119 | 124 | } |
| 120 | 125 | |
| 121 | 126 | /* |
| 122 | 127 | ** Reset the HTTP reply text to be an empty string. |
| 123 | 128 | */ |
| @@ -1159,22 +1164,24 @@ | ||
| 1159 | 1164 | /* |
| 1160 | 1165 | ** This routine works like "printf" except that it has the |
| 1161 | 1166 | ** extra formatting capabilities such as %h and %t. |
| 1162 | 1167 | */ |
| 1163 | 1168 | 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 | + } | |
| 1168 | 1175 | } |
| 1169 | 1176 | |
| 1170 | 1177 | /* |
| 1171 | 1178 | ** This routine works like "vprintf" except that it has the |
| 1172 | 1179 | ** extra formatting capabilities such as %h and %t. |
| 1173 | 1180 | */ |
| 1174 | 1181 | void cgi_vprintf(const char *zFormat, va_list ap){ |
| 1175 | - vxprintf(pContent,zFormat,ap); | |
| 1182 | + if( pContent ) vxprintf(pContent,zFormat,ap); | |
| 1176 | 1183 | } |
| 1177 | 1184 | |
| 1178 | 1185 | |
| 1179 | 1186 | /* |
| 1180 | 1187 | ** Send a reply indicating that the HTTP request was malformed |
| @@ -1210,11 +1217,11 @@ | ||
| 1210 | 1217 | cgi_printf( |
| 1211 | 1218 | "<html><body><h1>Internal Server Error</h1>\n" |
| 1212 | 1219 | "<plaintext>" |
| 1213 | 1220 | ); |
| 1214 | 1221 | va_start(ap, zFormat); |
| 1215 | - vxprintf(pContent,zFormat,ap); | |
| 1222 | + if( pContent ) vxprintf(pContent,zFormat,ap); | |
| 1216 | 1223 | va_end(ap); |
| 1217 | 1224 | cgi_reply(); |
| 1218 | 1225 | fossil_exit(1); |
| 1219 | 1226 | } |
| 1220 | 1227 | } |
| 1221 | 1228 |
| --- 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 @@ | ||
| 1132 | 1132 | Stmt q; |
| 1133 | 1133 | int cnt = 0; |
| 1134 | 1134 | int nWiki = 0; |
| 1135 | 1135 | int objType = 0; |
| 1136 | 1136 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1137 | - | |
| 1138 | 1137 | char *prevName = 0; |
| 1139 | 1138 | |
| 1139 | + if( P("nodesc")!=0 ) cgi_destination(CGI_OFF); | |
| 1140 | 1140 | db_prepare(&q, |
| 1141 | 1141 | "SELECT filename.name, datetime(event.mtime)," |
| 1142 | 1142 | " coalesce(event.ecomment,event.comment)," |
| 1143 | 1143 | " coalesce(event.euser,event.user)," |
| 1144 | 1144 | " b.uuid, mlink.mperm," |
| @@ -1330,10 +1330,11 @@ | ||
| 1330 | 1330 | blob_appendf(pDownloadName, "%.10s.txt", zUuid); |
| 1331 | 1331 | } |
| 1332 | 1332 | }else if( linkToView && g.perm.Hyperlink ){ |
| 1333 | 1333 | @ %z(href("%R/artifact/%s",zUuid))[view]</a> |
| 1334 | 1334 | } |
| 1335 | + if( P("nodesc")!=0 ) cgi_destination(CGI_BODY); | |
| 1335 | 1336 | return objType; |
| 1336 | 1337 | } |
| 1337 | 1338 | |
| 1338 | 1339 | |
| 1339 | 1340 | /* |
| 1340 | 1341 |
| --- 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 |