| 359 |
359 |
| 360 if(res->iscollection) { |
360 if(res->iscollection) { |
| 361 // default type |
361 // default type |
| 362 } else if(contenttype) { |
362 } else if(contenttype) { |
| 363 cxstring ctype = cx_str(contenttype); |
363 cxstring ctype = cx_str(contenttype); |
| 364 if(cx_strprefix(ctype, CX_STR("text/"))) { |
364 if(cx_strprefix(ctype, "text/")) { |
| 365 type = DAV_RESOURCE_VIEW_TEXT; |
365 type = DAV_RESOURCE_VIEW_TEXT; |
| 366 } else if(cx_strprefix(ctype, CX_STR("image/"))) { |
366 } else if(cx_strprefix(ctype, "image/")) { |
| 367 type = DAV_RESOURCE_VIEW_IMAGE; |
367 type = DAV_RESOURCE_VIEW_IMAGE; |
| 368 } else if(cx_strprefix(ctype, CX_STR("application/"))) { |
368 } else if(cx_strprefix(ctype, "application/")) { |
| 369 if(cx_strsuffix(ctype, CX_STR("json"))) { |
369 if(cx_strsuffix(ctype, "json")) { |
| 370 type = DAV_RESOURCE_VIEW_TEXT; |
370 type = DAV_RESOURCE_VIEW_TEXT; |
| 371 } else if(cx_strsuffix(ctype, CX_STR("/xml"))) { |
371 } else if(cx_strsuffix(ctype, "/xml")) { |
| 372 type = DAV_RESOURCE_VIEW_TEXT; |
372 type = DAV_RESOURCE_VIEW_TEXT; |
| 373 } else if(cx_strsuffix(ctype, CX_STR("+xml"))) { |
373 } else if(cx_strsuffix(ctype, "+xml")) { |
| 374 type = DAV_RESOURCE_VIEW_TEXT; |
374 type = DAV_RESOURCE_VIEW_TEXT; |
| 375 } else if(cx_strsuffix(ctype, CX_STR("/xml"))) { |
375 } else if(cx_strsuffix(ctype, "/xml")) { |
| 376 type = DAV_RESOURCE_VIEW_TEXT; |
376 type = DAV_RESOURCE_VIEW_TEXT; |
| 377 } |
377 } |
| 378 } |
378 } |
| 379 } else { |
379 } else { |
| 380 cxstring path = cx_str(res->path); |
380 cxstring path = cx_str(res->path); |
| 381 if(cx_strsuffix(path, CX_STR(".png"))) { |
381 if(cx_strsuffix(path, ".png")) { |
| 382 type = DAV_RESOURCE_VIEW_IMAGE; |
382 type = DAV_RESOURCE_VIEW_IMAGE; |
| 383 } else if(cx_strsuffix(path, CX_STR(".jpg"))) { |
383 } else if(cx_strsuffix(path, ".jpg")) { |
| 384 type = DAV_RESOURCE_VIEW_IMAGE; |
384 type = DAV_RESOURCE_VIEW_IMAGE; |
| 385 } else if(cx_strsuffix(path, CX_STR(".jpeg"))) { |
385 } else if(cx_strsuffix(path, ".jpeg")) { |
| 386 type = DAV_RESOURCE_VIEW_IMAGE; |
386 type = DAV_RESOURCE_VIEW_IMAGE; |
| 387 } else if(cx_strsuffix(path, CX_STR(".tif"))) { |
387 } else if(cx_strsuffix(path, ".tif")) { |
| 388 type = DAV_RESOURCE_VIEW_IMAGE; |
388 type = DAV_RESOURCE_VIEW_IMAGE; |
| 389 } else if(cx_strsuffix(path, CX_STR(".tiff"))) { |
389 } else if(cx_strsuffix(path, ".tiff")) { |
| 390 type = DAV_RESOURCE_VIEW_IMAGE; |
390 type = DAV_RESOURCE_VIEW_IMAGE; |
| 391 } else if(cx_strsuffix(path, CX_STR(".webp"))) { |
391 } else if(cx_strsuffix(path, ".webp")) { |
| 392 type = DAV_RESOURCE_VIEW_IMAGE; |
392 type = DAV_RESOURCE_VIEW_IMAGE; |
| 393 } else if(cx_strsuffix(path, CX_STR(".bmp"))) { |
393 } else if(cx_strsuffix(path, ".bmp")) { |
| 394 type = DAV_RESOURCE_VIEW_IMAGE; |
394 type = DAV_RESOURCE_VIEW_IMAGE; |
| 395 } else if(cx_strsuffix(path, CX_STR(".gif"))) { |
395 } else if(cx_strsuffix(path, ".gif")) { |
| 396 type = DAV_RESOURCE_VIEW_IMAGE; |
396 type = DAV_RESOURCE_VIEW_IMAGE; |
| 397 } else if(cx_strsuffix(path, CX_STR(".txt"))) { |
397 } else if(cx_strsuffix(path, ".txt")) { |
| 398 type = DAV_RESOURCE_VIEW_TEXT; |
398 type = DAV_RESOURCE_VIEW_TEXT; |
| 399 } else if(cx_strsuffix(path, CX_STR(".md"))) { |
399 } else if(cx_strsuffix(path, ".md")) { |
| 400 type = DAV_RESOURCE_VIEW_TEXT; |
400 type = DAV_RESOURCE_VIEW_TEXT; |
| 401 } else if(cx_strsuffix(path, CX_STR(".xml"))) { |
401 } else if(cx_strsuffix(path, ".xml")) { |
| 402 type = DAV_RESOURCE_VIEW_TEXT; |
402 type = DAV_RESOURCE_VIEW_TEXT; |
| 403 } |
403 } |
| 404 } |
404 } |
| 405 |
405 |
| 406 resourceviewer_new(browser, res->path, type); |
406 resourceviewer_new(browser, res->path, type); |