| | @@ -224,15 +224,14 @@ |
| 224 | 224 | } builtin; |
| 225 | 225 | |
| 226 | 226 | #if INTERFACE |
| 227 | 227 | /* Various delivery mechanisms. The 0 option is the default. |
| 228 | 228 | */ |
| 229 | | -#define JS_INLINE_BATCH 0 /* inline, batched together */ |
| 230 | | -#define JS_INLINE_IMM 1 /* inline, as soon as requested */ |
| 231 | | -#define JS_SEP_BATCH 2 /* Separate resources, batched */ |
| 232 | | -#define JS_SEP_IMM 3 /* Separate resources, as requested */ |
| 233 | | -#define JS_BUNDLED 4 /* Single separate resource */ |
| 229 | +#define JS_INLINE 0 /* inline, batched together at end of file */ |
| 230 | +#define JS_SEPARATE 1 /* Separate HTTP request for each JS file */ |
| 231 | +#define JS_BUNDLED 2 /* One HTTP request to load all JS files */ |
| 232 | + /* concatenated together into a bundle */ |
| 234 | 233 | #endif /* INTERFACE */ |
| 235 | 234 | |
| 236 | 235 | /* |
| 237 | 236 | ** The argument is a request to change the javascript delivery mode. |
| 238 | 237 | ** The argument is a string which is a command-line option or CGI |
| | @@ -241,27 +240,20 @@ |
| 241 | 240 | ** bSilent is true. |
| 242 | 241 | */ |
| 243 | 242 | void builtin_set_js_delivery_mode(const char *zMode, int bSilent){ |
| 244 | 243 | if( zMode==0 ) return; |
| 245 | 244 | if( strcmp(zMode, "inline")==0 ){ |
| 246 | | - builtin.eDelivery = JS_INLINE_BATCH; |
| 247 | | - }else |
| 248 | | - if( strcmp(zMode, "inline-imm")==0 ){ |
| 249 | | - builtin.eDelivery = JS_INLINE_IMM; |
| 250 | | - }else |
| 251 | | - if( strcmp(zMode, "sep")==0 ){ |
| 252 | | - builtin.eDelivery = JS_SEP_BATCH; |
| 253 | | - }else |
| 254 | | - if( strcmp(zMode, "sep-imm")==0 ){ |
| 255 | | - builtin.eDelivery = JS_SEP_IMM; |
| 245 | + builtin.eDelivery = JS_INLINE; |
| 246 | + }else |
| 247 | + if( strcmp(zMode, "separate")==0 ){ |
| 248 | + builtin.eDelivery = JS_SEPARATE; |
| 256 | 249 | }else |
| 257 | 250 | if( strcmp(zMode, "bundled")==0 ){ |
| 258 | 251 | builtin.eDelivery = JS_BUNDLED; |
| 259 | 252 | }else if( !bSilent ){ |
| 260 | 253 | fossil_fatal("unknown javascript delivery mode \"%s\" - should be" |
| 261 | | - " one of: inline inline-immediate separate" |
| 262 | | - " separate-immediate bundled", zMode); |
| 254 | + " one of: inline separate bundled", zMode); |
| 263 | 255 | } |
| 264 | 256 | } |
| 265 | 257 | |
| 266 | 258 | /* |
| 267 | 259 | ** The caller wants the Javascript file named by zFilename to be |
| | @@ -294,15 +286,10 @@ |
| 294 | 286 | } |
| 295 | 287 | if( builtin.nReq>=count(builtin.aReq) ){ |
| 296 | 288 | fossil_panic("too many javascript files requested"); |
| 297 | 289 | } |
| 298 | 290 | builtin.aReq[builtin.nReq++] = i; |
| 299 | | - if( builtin.eDelivery==JS_INLINE_IMM |
| 300 | | - || builtin.eDelivery==JS_SEP_IMM |
| 301 | | - ){ |
| 302 | | - builtin_fulfill_js_requests(); |
| 303 | | - } |
| 304 | 291 | } |
| 305 | 292 | |
| 306 | 293 | /* |
| 307 | 294 | ** Fulfill all pending requests for javascript files. |
| 308 | 295 | ** |
| | @@ -311,12 +298,11 @@ |
| 311 | 298 | ** might choose to deliver javascript as separate resources. |
| 312 | 299 | */ |
| 313 | 300 | void builtin_fulfill_js_requests(void){ |
| 314 | 301 | if( builtin.nSent>=builtin.nReq ) return; /* nothing to do */ |
| 315 | 302 | switch( builtin.eDelivery ){ |
| 316 | | - case JS_INLINE_BATCH: |
| 317 | | - case JS_INLINE_IMM: { |
| 303 | + case JS_INLINE: { |
| 318 | 304 | CX("<script nonce='%h'>\n",style_nonce()); |
| 319 | 305 | do{ |
| 320 | 306 | int i = builtin.aReq[builtin.nSent++]; |
| 321 | 307 | CX("/* %s */\n", aBuiltinFiles[i].zName); |
| 322 | 308 | cgi_append_content((const char*)aBuiltinFiles[i].pData, |
| | @@ -323,27 +309,32 @@ |
| 323 | 309 | aBuiltinFiles[i].nByte); |
| 324 | 310 | }while( builtin.nSent<builtin.nReq ); |
| 325 | 311 | CX("</script>\n"); |
| 326 | 312 | break; |
| 327 | 313 | } |
| 328 | | - case JS_SEP_BATCH: |
| 329 | | - case JS_SEP_IMM: { |
| 314 | + case JS_BUNDLED: { |
| 315 | + if( builtin.nSent+1<builtin.nReq ){ |
| 316 | + Blob aList; |
| 317 | + blob_init(&aList,0,0); |
| 318 | + while( builtin.nSent<builtin.nReq ){ |
| 319 | + blob_appendf(&aList, ",%d", builtin.aReq[builtin.nSent++]+1); |
| 320 | + } |
| 321 | + CX("<script src='%R/builtin?m=%s&id=%.8s'></script>\n", |
| 322 | + blob_str(&aList)+1, fossil_exe_id()); |
| 323 | + blob_reset(&aList); |
| 324 | + break; |
| 325 | + } |
| 326 | + /* If there is only one JS file, fall through into the |
| 327 | + ** JS_SEPARATE case below. */ |
| 328 | + /*FALLTHROUGH*/ |
| 329 | + } |
| 330 | + case JS_SEPARATE: { |
| 330 | 331 | /* Each JS file as a separate resource */ |
| 331 | 332 | while( builtin.nSent<builtin.nReq ){ |
| 332 | 333 | int i = builtin.aReq[builtin.nSent++]; |
| 333 | 334 | CX("<script src='%R/builtin?name=%t&id=%.8s'></script>\n", |
| 334 | 335 | aBuiltinFiles[i].zName, fossil_exe_id()); |
| 335 | 336 | } |
| 336 | 337 | break; |
| 337 | 338 | } |
| 338 | | - case JS_BUNDLED: { |
| 339 | | - Blob aList; |
| 340 | | - blob_init(&aList,0,0); |
| 341 | | - while( builtin.nSent<builtin.nReq ){ |
| 342 | | - blob_appendf(&aList, ",%d", builtin.aReq[builtin.nSent++]+1); |
| 343 | | - } |
| 344 | | - CX("<script src='%R/builtin?m=%s&id=%.8s'></script>\n", |
| 345 | | - blob_str(&aList)+1, fossil_exe_id()); |
| 346 | | - blob_reset(&aList); |
| 347 | | - } |
| 348 | 339 | } |
| 349 | 340 | } |
| 350 | 341 | |