1
2
3
4
5
6
7
|
/*
** Copyright (c) 2007 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/*TODO
** o Should /file behave differently for non-existent local files?
** o Look at adding an "extras" option (non-added, non-ignored files).
** o Look at sifting out "one line" differences from those with "diff blocks".
** Perhaps reset the query and re-run, displaying only non-diff entries the
** first time? Or perhaps buffer the output (probably bad idea).
** o If I keep the extra <hr/> I've added after a diff-block, is there a way
** to avoid the double <hr/> if the last entry has a diff-block?
** o Find a place to add links to /local.
** o Remove //TODO TESTING HACK TODO
** ?? In hexdump_page(), should content (and downloadName?) be reset/freed?
** ?? In the test fossil (\x\$Test\Fossil) there are (at time of writing) two
** commits under the same artifact... is this normal?
*/
/*
** Copyright (c) 2007 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
|
︙ | | | ︙ | |
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
|TIMELINE_NOSCROLL
|TIMELINE_XMERGE
|TIMELINE_CHPICK,
0, 0, 0, rid, rid2, 0);
db_finalize(&q);
}
/*
** Append the difference between artifacts to the output
*/
static void append_diff(
const char *zFrom, /* Diff from this artifact */
const char *zTo, /* ... to this artifact */
u64 diffFlags, /* Diff formatting flags */
ReCompiled *pRe /* Only show change matching this regex */
){
int fromid;
int toid;
Blob from, to, out;
if( zFrom ){
fromid = uuid_to_rid(zFrom, 0);
content_get(fromid, &from);
}else{
blob_zero(&from);
}
if( zTo ){
toid = uuid_to_rid(zTo, 0);
content_get(toid, &to);
}else{
blob_zero(&to);
}
blob_zero(&out);
if( diffFlags & DIFF_SIDEBYSIDE ){
text_diff(&from, &to, &out, pRe, diffFlags | DIFF_HTML | DIFF_NOTTOOBIG);
@ %s(blob_str(&out))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
|TIMELINE_NOSCROLL
|TIMELINE_XMERGE
|TIMELINE_CHPICK,
0, 0, 0, rid, rid2, 0);
db_finalize(&q);
}
/*
** Read the content of file zName (prepended with the checkout directory)
** and put it into the uninitialized blob. The blob is zeroed if the file
** does not exist (if the file cannot be read, blob_read_from_file() aborts
** the program).
*/
static void content_from_file(
const char *zName, /* Filename (relative to checkout) of file to be read */
Blob *pBlob /* Pointer to blob to receive contents */
){
const char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
blob_zero(pBlob);
if( file_size(zFullPath, ExtFILE)>=0 ){
blob_read_from_file(pBlob, zFullPath, ExtFILE);
}
}
/*
** Append the difference between artifacts to the output
** If zLocal is not NULL, instead compare against the local
** copy of the file it names in the repository.
*/
static void append_diff(
const char *zFrom, /* Diff from this artifact */
const char *zTo, /* ... to this artifact */
const char *zLocal, /* ... OR to this local file */
u64 diffFlags, /* Diff formatting flags */
ReCompiled *pRe /* Only show change matching this regex */
){
int fromid;
int toid;
Blob from, to, out;
if( zFrom ){
fromid = uuid_to_rid(zFrom, 0);
content_get(fromid, &from);
}else{
blob_zero(&from);
}
if( zTo ){
toid = uuid_to_rid(zTo, 0);
content_get(toid, &to);
}else if( zLocal ){ /* Read the file on disk */
content_from_file(zLocal, &to);
}else{
blob_zero(&to);
}
blob_zero(&out);
if( diffFlags & DIFF_SIDEBYSIDE ){
text_diff(&from, &to, &out, pRe, diffFlags | DIFF_HTML | DIFF_NOTTOOBIG);
@ %s(blob_str(&out))
|
︙ | | | ︙ | |
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
}else{
@ %h(zName) became a regular file.
}
}else{
@ Changes to %h(zName).
}
if( diffFlags ){
append_diff(zOld, zNew, diffFlags, pRe);
}
}else{
if( zOld && zNew ){
if( fossil_strcmp(zOld, zNew)!=0 ){
@ Modified %z(href("%R/finfo?name=%T&m=%!S",zName,zNew))%h(zName)</a>
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>
@ to %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
|
|
|
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
|
}else{
@ %h(zName) became a regular file.
}
}else{
@ Changes to %h(zName).
}
if( diffFlags ){
append_diff(zOld, zNew, NULL, diffFlags, pRe);
}
}else{
if( zOld && zNew ){
if( fossil_strcmp(zOld, zNew)!=0 ){
@ Modified %z(href("%R/finfo?name=%T&m=%!S",zName,zNew))%h(zName)</a>
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>
@ to %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
|
︙ | | | ︙ | |
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
@ Deleted %z(href("%R/finfo?name=%T&m=%!S",zName,zOld))%h(zName)</a>
@ version %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>.
}else{
@ Added %z(href("%R/finfo?name=%T&m=%!S",zName,zNew))%h(zName)</a>
@ version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
}
if( diffFlags ){
append_diff(zOld, zNew, diffFlags, pRe);
}else if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
@
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
}
}
@ </p>
}
/*
** Generate javascript to enhance HTML diffs.
*/
void append_diff_javascript(int sideBySide){
if( !sideBySide ) return;
style_load_one_js_file("sbsdiff.js");
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
@ Deleted %z(href("%R/finfo?name=%T&m=%!S",zName,zOld))%h(zName)</a>
@ version %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>.
}else{
@ Added %z(href("%R/finfo?name=%T&m=%!S",zName,zNew))%h(zName)</a>
@ version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
}
if( diffFlags ){
append_diff(zOld, zNew, NULL, diffFlags, pRe);
}else if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
@
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
}
}
@ </p>
}
/*
** Append notice of executable or symlink being gained or lost.
*/
static void append_status(
const char *zAction, /* Whether status was gained or lost */
const char *zStatus, /* The status that was gained/lost */
const char *zName, /* Name of file */
const char *zOld /* Existing artifact */
){
if( !g.perm.Hyperlink ){
@ %h(zName) %h(zAction) %h(zStatus) status.
}else{
@ %z(href("%R/finfo?name=%T&m=%!S",zName,zOld))%h(zName)</a>
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>
@ %h(zAction) %h(zStatus) status.
}
}
/*
** Append web-page output that shows changes between a file at last check-in
** and its current state on disk (i.e. any uncommitted changes). The status
** ("changed", "missing" etc.) is a blend of that from append_file_change_line()
** and diff_against_disk() (in "diffcmd.c").
**
** The file-differences (if being shown) use append_diff() as before, but
** there is an additional parameter (zLocal) which, if non-NULL, causes it
** to compare the checked-in version against the named file on disk.
*/
static void append_local_file_change_line(
const char *zName, /* Name of the file that has changed */
const char *zOld, /* blob.uuid before change. NULL for added files */
int isDeleted, /* Has the file-on-disk been removed from Fossil? */
int isChnged, /* Has the file changed in some way (see vfile.c) */
int isNew, /* Has the file been ADDed (but not yet committed? */
int isLink, /* Is the file a symbolic link? */
u64 diffFlags, /* Flags for text_diff(). Zero to omit diffs */
ReCompiled *pRe /* Only show diffs that match this regex, if not NULL */
){
char *zFullName = mprintf("%s%s", g.zLocalRoot, zName);
int isFilePresent = !file_access(zFullName, F_OK);
int showDiff = 0;
//TODO TESTING HACK TODO
if( strncmp(zName,"aa",2)==0 ){
isChnged = atoi(zName+2);
}
//TODO TESTING HACK TODO
@ <p>
if( !g.perm.Hyperlink ){
if( isDeleted ){
if( isFilePresent ){
@ Deleted %h(zName) (still present as a local file).
showDiff = 1;
}else{
@ Deleted %h(zName).
}
}else if( isNew ){
if( isFilePresent ){
@ Added %h(zName) but not committed.
}else{
@ Missing %h(zName) (was added to checkout).
}
}else switch( isChnged ){
/*TODO
** These "special cases" have not been properly tested (by creating
** entries in a in a repository to trigger them), but they do display
** as expected when "forced" to appear.
*/
case 3:
@ Added %h(zName) due to a merge.
break;
case 5:
@ Added %h(zName) due to an integration merge.
break;
case 6: append_status( "gained", "executable", zName, zOld); break;
case 7: append_status( "gained", "symlink", zName, zOld); break;
case 8: append_status( "lost", "executable", zName, zOld); break;
case 9: append_status( "lost", "symlink", zName, zOld); break;
default: /* Normal edit */
@ Local changes of %h(zName).
showDiff = 1;
}
if( showDiff && diffFlags ){
append_diff(zOld, NULL, zName, diffFlags, pRe);
@ <hr/>
}
}else{
if( isDeleted ){
if( isFilePresent ){ /* DELETEd but still on disk */
@ Deleted %z(href("%R/finfo?name=%T&m=%!S",zName,zOld))%h(zName)</a>
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a> (still present
@ as %z(href("%R/file/%T?ci=ckout&annot=removed from checkout",zName))
@ [local file]</a>).
showDiff = 1;
}else{ /* DELETEd and deleted from disk */
@ Deleted %z(href("%R/finfo?name=%T&m=%!S",zName,zOld))%h(zName)</a>
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>.
}
}else if( isNew ){
if( isFilePresent ){ /* ADDed and present on disk */
@ Added %z(href("%R/file/%T?ci=ckout",zName))%h(zName)</a>
@ but not committed.
}else{ /* ADDed but not present on disk */
@ Missing %h(zName) (was added to checkout).
}
}else switch( isChnged ){
/*TODO Not fully tested... see see no-hyperlink version above */
case 3: /* Added by a merge */
@ Added
@ %z(href("%R/file/%T?ci=ckout&annot=added by merge",zName))%h(zName)
@ </a> to %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a> due to merge.
break;
case 5: /* Added by an integration merge */
@ Added
@ %z(href("%R/file/%T?ci=ckout&annot=added by integration merge",zName))
@ %h(zName)</a> to
@ %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a> due to integrate merge.
break;
case 6: append_status( "gained", "executable", zName, zOld); break;
case 7: append_status( "gained", "symlink", zName, zOld); break;
case 8: append_status( "lost", "executable", zName, zOld); break;
case 9: append_status( "lost", "symlink", zName, zOld); break;
default: /* Normal edit */
@ Local changes of
@ %z(href("%R/finfo?name=%T&m=%!S",zName,zOld))%h(zName)</a>
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a> to
@ %z(href("%R/file/%T?ci=ckout&annot=edited locally",zName))
@ [local file]</a>
showDiff = 1;
}
if( showDiff ){
if( diffFlags ){
append_diff(zOld, NULL, zName, diffFlags, pRe);
/*TODO
** Not related to the local-mode, but if two or more files have been
** changed in a commit/"local changes", it is sometimes easy to miss
** the switch from one to the other. The following (IMHO) makes things
** clearer, but can mean there's a double rule at the bottom of the
** page. If kept, a similar <hr/> should probably be added to
** append_file_change_line() (but would need to check how things look
** when called from /vinfo).
*/
@ <hr/>
}else if( isChnged ){
@
@ %z(href("%R/localdiff?name=%T",zName))[diff]</a>
}
}
}
@ </p>
fossil_free(zFullName);
}
/*
** Generate javascript to enhance HTML diffs.
*/
void append_diff_javascript(int sideBySide){
if( !sideBySide ) return;
style_load_one_js_file("sbsdiff.js");
|
︙ | | | ︙ | |
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
|
db_finalize(&q);
style_footer();
}
/*
** WEBPAGE: vinfo
** WEBPAGE: ci
** URL: /ci/ARTIFACTID
** OR: /ci?name=ARTIFACTID
**
** Display information about a particular check-in. The exact
** same information is shown on the /info page if the name query
** parameter to /info describes a check-in.
**
** The ARTIFACTID can be a unique prefix for the HASH of the check-in,
** or a tag or branch name that identifies the check-in.
*/
void ci_page(void){
Stmt q1, q2, q3;
int rid;
int isLeaf;
int diffType; /* 0: no diff, 1: unified, 2: side-by-side */
u64 diffFlags; /* Flag parameter for text_diff() */
const char *zName; /* Name of the check-in to be displayed */
const char *zUuid; /* UUID of zName */
const char *zParent; /* UUID of the parent check-in (if any) */
const char *zRe; /* regex parameter */
ReCompiled *pRe = 0; /* regex */
const char *zW; /* URL param for ignoring whitespace */
const char *zPage = "vinfo"; /* Page that shows diffs */
const char *zPageHide = "ci"; /* Page that hides diffs */
const char *zBrName; /* Branch name */
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
zName = P("name");
rid = name_to_rid_www("name");
if( rid==0 ){
style_header("Check-in Information Error");
@ No such object: %h(g.argv[2])
style_footer();
return;
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
|
db_finalize(&q);
style_footer();
}
/*
** WEBPAGE: vinfo
** WEBPAGE: ci
** WEBPAGE: local
** URL: /ci/ARTIFACTID
** OR: /ci?name=ARTIFACTID
**
** Display information about a particular check-in. The exact
** same information is shown on the /info page if the name query
** parameter to /info describes a check-in.
**
** The ARTIFACTID can be a unique prefix for the HASH of the check-in,
** or a tag or branch name that identifies the check-in.
**
** Use of /local (or the use of "ckout" for ARTIFACTID) will show the
** same header details as /ci/tip, but then displays any (uncommitted)
** edits made to files in the checkout directory.
*/
void ci_page(void){
Stmt q1, q2, q3;
int rid;
int isLeaf;
int diffType; /* 0: no diff, 1: unified, 2: side-by-side */
u64 diffFlags; /* Flag parameter for text_diff() */
const char *zName; /* Name of the check-in to be displayed */
const char *zUuid; /* UUID of zName */
const char *zParent; /* UUID of the parent check-in (if any) */
const char *zRe; /* regex parameter */
ReCompiled *pRe = 0; /* regex */
const char *zW; /* URL param for ignoring whitespace */
const char *zPage = "vinfo"; /* Page that shows diffs */
const char *zPageHide = "ci"; /* Page that hides diffs */
const char *zBrName; /* Branch name */
int bLocalMode; /* TRUE for /local; FALSE otherwise */
int vid; /* Virtual file system? */
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
zName = P("name");
/* Local mode is selected by either "/local" or with a "name" of "ckout".
** First, check we have access to the checkout (and report to the user if we
** don't), then refresh the "vfile" table (recording which files in the
** checkout have changed etc.). We then change the "name" parameter to "tip"
** so that the "header" section displays info about the check-in that the
** checkout came from.
*/
bLocalMode = (g.zPath[0]=='l') || (fossil_strcmp(zName,"ckout")==0);
if( bLocalMode ){
vid = g.localOpen ? db_lget_int("checkout", 0) : 0;
if( vid==0 ){
/*TODO Is this the right response? */
style_header("No Local Checkout");
@ No access to local checkout.
style_footer();
return;
}
vfile_check_signature(vid, CKSIG_ENOTFILE);
zName = "tip";
cgi_replace_parameter("name","tip"); /* Needed to get rid below */
}
rid = name_to_rid_www("name");
if( rid==0 ){
style_header("Check-in Information Error");
@ No such object: %h(g.argv[2])
style_footer();
return;
}
|
︙ | | | ︙ | |
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
|
const char *zDate;
const char *zOrigDate;
int okWiki = 0;
Blob wiki_read_links = BLOB_INITIALIZER;
Blob wiki_add_links = BLOB_INITIALIZER;
Th_Store("current_checkin", zName);
style_header("Check-in [%S]", zUuid);
login_anonymous_available();
zEUser = db_text(0,
"SELECT value FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_USER, rid);
zEComment = db_text(0,
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
|
>
>
>
|
>
|
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
|
const char *zDate;
const char *zOrigDate;
int okWiki = 0;
Blob wiki_read_links = BLOB_INITIALIZER;
Blob wiki_add_links = BLOB_INITIALIZER;
Th_Store("current_checkin", zName);
if( bLocalMode ){
style_header("Local Changes from Check-in [%S]", zUuid);
}else{
style_header("Check-in [%S]", zUuid);
}
login_anonymous_available();
zEUser = db_text(0,
"SELECT value FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_USER, rid);
zEComment = db_text(0,
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
|
︙ | | | ︙ | |
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
|
db_finalize(&q1);
if( !PB("nowiki") ){
wiki_render_associated("checkin", zUuid, 0);
}
render_backlink_graph(zUuid, "<div class=\"section\">References</div>\n");
@ <div class="section">Context</div>
render_checkin_context(rid, 0, 0);
@ <div class="section">Changes</div>
@ <div class="sectionmenu">
diffFlags = construct_diff_flags(diffType);
zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
if( diffType!=0 ){
@ %z(chref("button","%R/%s/%T?diff=0",zPageHide,zName))\
@ Hide Diffs</a>
}
if( diffType!=1 ){
@ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
@ Unified Diffs</a>
|
>
>
>
|
>
>
>
>
>
>
>
>
|
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
|
db_finalize(&q1);
if( !PB("nowiki") ){
wiki_render_associated("checkin", zUuid, 0);
}
render_backlink_graph(zUuid, "<div class=\"section\">References</div>\n");
@ <div class="section">Context</div>
render_checkin_context(rid, 0, 0);
if( bLocalMode ){
@ <div class="section">Uncommitted Changes</div>
}else{
@ <div class="section">Changes</div>
}
@ <div class="sectionmenu">
diffFlags = construct_diff_flags(diffType);
zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
/* In local mode, having displayed the header info for "tip", switch zName
** to be "ckout" so the style-altering links (unified or side-by-side etc.)
** will correctly re-select local-mode.
*/
if( bLocalMode ){
zName = "ckout";
}
if( diffType!=0 ){
@ %z(chref("button","%R/%s/%T?diff=0",zPageHide,zName))\
@ Hide Diffs</a>
}
if( diffType!=1 ){
@ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
@ Unified Diffs</a>
|
︙ | | | ︙ | |
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
|
@ %z(chref("button","%R/%s/%T?diff=%d",zPage,zName,diffType))
@ Show Whitespace Changes</a>
}else{
@ %z(chref("button","%R/%s/%T?diff=%d&w",zPage,zName,diffType))
@ Ignore Whitespace</a>
}
}
if( zParent ){
@ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid))
@ Patch</a>
}
if( g.perm.Admin ){
@ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table</a>
}
@</div>
if( pRe ){
@ <p><b>Only differences that match regular expression "%h(zRe)"
@ are shown.</b></p>
}
db_prepare(&q3,
"SELECT name,"
" mperm,"
" (SELECT uuid FROM blob WHERE rid=mlink.pid),"
" (SELECT uuid FROM blob WHERE rid=mlink.fid),"
" (SELECT name FROM filename WHERE filename.fnid=mlink.pfnid)"
" FROM mlink JOIN filename ON filename.fnid=mlink.fnid"
" WHERE mlink.mid=%d AND NOT mlink.isaux"
" AND (mlink.fid>0"
" OR mlink.fnid NOT IN (SELECT pfnid FROM mlink WHERE mid=%d))"
" ORDER BY name /*sort*/",
rid, rid
);
while( db_step(&q3)==SQLITE_ROW ){
const char *zName = db_column_text(&q3,0);
int mperm = db_column_int(&q3, 1);
const char *zOld = db_column_text(&q3,2);
const char *zNew = db_column_text(&q3,3);
const char *zOldName = db_column_text(&q3, 4);
append_file_change_line(zName, zOld, zNew, zOldName, diffFlags,pRe,mperm);
}
db_finalize(&q3);
append_diff_javascript(diffType==2);
cookie_render();
style_footer();
}
/*
** WEBPAGE: winfo
** URL: /winfo?name=UUID
**
** Display information about a wiki page.
*/
|
>
>
>
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
|
@ %z(chref("button","%R/%s/%T?diff=%d",zPage,zName,diffType))
@ Show Whitespace Changes</a>
}else{
@ %z(chref("button","%R/%s/%T?diff=%d&w",zPage,zName,diffType))
@ Ignore Whitespace</a>
}
}
if( bLocalMode ){
@ %z(chref("button","%R/localpatch")) Patch</a>
}else{
if( zParent ){
@ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid))
@ Patch</a>
}
}
if( g.perm.Admin ){
@ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table</a>
}
@</div>
if( pRe ){
@ <p><b>Only differences that match regular expression "%h(zRe)"
@ are shown.</b></p>
}
if( bLocalMode ){
/* Following SQL taken from diff_against_disk() in diffcmd.c */
db_begin_transaction();
db_prepare(&q3,
"SELECT pathname, deleted, chnged , rid==0, rid, islink"
" FROM vfile"
" WHERE vid=%d"
" AND (deleted OR chnged OR rid==0)"
" ORDER BY pathname /*scan*/",
vid
);
/* TODO Have the option of showing "extras" (non-ignored files in the
** checkout directory that have not been ADDed). If done, they should
** be ahead of any potential "diff-blocks" so they don't get lost
** (which is the inspiration for...)
** TODO Consider making this two-pass, where the first pass skips anything
** that would show a diff-block (and the second pass only shows such
** entries). This would group all "one-line" entries at the top so
** they are less likely to be missed.
** TODO Possibly (at some stage) have an option to commit?
*/
while( db_step(&q3)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q3,0);
int isDeleted = db_column_int(&q3, 1);
int isChnged = db_column_int(&q3,2);
int isNew = db_column_int(&q3,3);
int srcid = db_column_int(&q3, 4);
int isLink = db_column_int(&q3, 5);
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", srcid);
append_local_file_change_line(zPathname, zUuid,
isDeleted, isChnged, isNew, isLink, diffFlags,pRe);
free(zUuid);
}
db_finalize(&q3);
db_end_transaction(1); /* ROLLBACK */
}else{ /* Normal, non-local-mode: show diffs against parent */
db_prepare(&q3,
"SELECT name,"
" mperm,"
" (SELECT uuid FROM blob WHERE rid=mlink.pid),"
" (SELECT uuid FROM blob WHERE rid=mlink.fid),"
" (SELECT name FROM filename WHERE filename.fnid=mlink.pfnid)"
" FROM mlink JOIN filename ON filename.fnid=mlink.fnid"
" WHERE mlink.mid=%d AND NOT mlink.isaux"
" AND (mlink.fid>0"
" OR mlink.fnid NOT IN (SELECT pfnid FROM mlink WHERE mid=%d))"
" ORDER BY name /*sort*/",
rid, rid
);
while( db_step(&q3)==SQLITE_ROW ){
const char *zName = db_column_text(&q3,0);
int mperm = db_column_int(&q3, 1);
const char *zOld = db_column_text(&q3,2);
const char *zNew = db_column_text(&q3,3);
const char *zOldName = db_column_text(&q3, 4);
append_file_change_line(zName, zOld, zNew, zOldName, diffFlags,pRe,mperm);
}
db_finalize(&q3);
}
append_diff_javascript(diffType==2);
cookie_render();
style_footer();
}
/*
** WEBPAGE: localpatch
** URL: /localpatch
**
** Shows a patch from the current checkout, incorporating any
** uncommitted local edits.
*/
void localpatch_page(void){
Stmt q3;
int vid;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
vid = g.localOpen ? db_lget_int("checkout", 0) : 0;
if( vid==0 ){
/*TODO Is this the right response? */
style_header("No Local Checkout");
@ No access to local checkout.
style_footer();
return;
}
vfile_check_signature(vid, CKSIG_ENOTFILE);
cgi_set_content_type("text/plain");
db_begin_transaction();
/*TODO
** This query is the same as in ci_page() for local-mode (as well as in
** diff_against_disk() in diffcmd.c, where it was originally taken from).
** Should they be "coalesced" in some way?
*/
db_prepare(&q3,
"SELECT pathname, deleted, chnged , rid==0, rid, islink"
" FROM vfile"
" WHERE vid=%d"
" AND (deleted OR chnged OR rid==0)"
" ORDER BY pathname /*scan*/",
vid
);
while( db_step(&q3)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q3,0);
int isDeleted = db_column_int(&q3, 1);
int isChnged = db_column_int(&q3,2);
int isNew = db_column_int(&q3,3);
int srcid = db_column_int(&q3, 4);
int isLink = db_column_int(&q3, 5);
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", srcid);
if( isChnged ){
Blob c1, c2; /* Content to diff */
Blob out; /* Diff output text */
int diffFlags = 4;
content_get(srcid, &c1);
content_from_file(zPathname, &c2);
blob_zero(&out);
text_diff(&c1, &c2, &out, 0, diffFlags);
blob_reset(&c1);
blob_reset(&c2);
if( blob_size(&out) ){
diff_print_index(zPathname, diffFlags);
diff_print_filenames(zPathname, zPathname, diffFlags);
fossil_print("%s\n", blob_str(&out));
}
/* Release memory resources */
blob_reset(&out);
}
free(zUuid);
}
db_finalize(&q3);
db_end_transaction(1); /* ROLLBACK */
}
/*
** WEBPAGE: winfo
** URL: /winfo?name=UUID
**
** Display information about a wiki page.
*/
|
︙ | | | ︙ | |
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
|
}
if( diffType!=2 ){
style_submenu_element("Side-by-Side Diff",
"%R/vdiff?%s&diff=2%s%T%s",
zQuery,
zGlob ? "&glob=" : "", zGlob ? zGlob : "", zW);
}
if( diffType!=1 ) {
style_submenu_element("Unified Diff",
"%R/vdiff?%s&diff=1%s%T%s",
zQuery,
zGlob ? "&glob=" : "", zGlob ? zGlob : "", zW);
}
if( zBranch==0 ){
style_submenu_element("Invert",
|
|
|
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
|
}
if( diffType!=2 ){
style_submenu_element("Side-by-Side Diff",
"%R/vdiff?%s&diff=2%s%T%s",
zQuery,
zGlob ? "&glob=" : "", zGlob ? zGlob : "", zW);
}
if( diffType!=1 ){
style_submenu_element("Unified Diff",
"%R/vdiff?%s&diff=1%s%T%s",
zQuery,
zGlob ? "&glob=" : "", zGlob ? zGlob : "", zW);
}
if( zBranch==0 ){
style_submenu_element("Invert",
|
︙ | | | ︙ | |
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
|
if( cnt==1 ){
@ %z(href("%R/whatis/%!S",zUuid))[more...]</a>
}
cnt++;
continue;
}
if( !sameFilename ){
if( prevName && showDetail ) {
@ </ul>
}
if( mPerm==PERM_LNK ){
@ <li>Symbolic link
objType |= OBJTYPE_SYMLINK;
}else if( mPerm==PERM_EXE ){
@ <li>Executable file
|
|
|
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
|
if( cnt==1 ){
@ %z(href("%R/whatis/%!S",zUuid))[more...]</a>
}
cnt++;
continue;
}
if( !sameFilename ){
if( prevName && showDetail ){
@ </ul>
}
if( mPerm==PERM_LNK ){
@ <li>Symbolic link
objType |= OBJTYPE_SYMLINK;
}else if( mPerm==PERM_EXE ){
@ <li>Executable file
|
︙ | | | ︙ | |
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
|
}else if( zType[0]=='t' ){
@ Ticket change
objType |= OBJTYPE_TICKET;
}else if( zType[0]=='c' ){
@ Manifest of check-in
objType |= OBJTYPE_CHECKIN;
}else if( zType[0]=='e' ){
if( eventTagId != 0) {
@ Instance of technote
objType |= OBJTYPE_EVENT;
hyperlink_to_event_tagid(db_column_int(&q, 5));
}else{
@ Attachment to technote
}
}else if( zType[0]=='f' ){
|
|
|
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
|
}else if( zType[0]=='t' ){
@ Ticket change
objType |= OBJTYPE_TICKET;
}else if( zType[0]=='c' ){
@ Manifest of check-in
objType |= OBJTYPE_CHECKIN;
}else if( zType[0]=='e' ){
if( eventTagId != 0){
@ Instance of technote
objType |= OBJTYPE_EVENT;
hyperlink_to_event_tagid(db_column_int(&q, 5));
}else{
@ Attachment to technote
}
}else if( zType[0]=='f' ){
|
︙ | | | ︙ | |
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
|
if( cnt>0 ){
@ Also attachment "%h(zFilename)" to
}else{
@ Attachment "%h(zFilename)" to
}
objType |= OBJTYPE_ATTACHMENT;
if( fossil_is_uuid(zTarget) ){
if ( db_exists("SELECT 1 FROM tag WHERE tagname='tkt-%q'",
zTarget)
){
if( g.perm.Hyperlink && g.anon.RdTkt ){
@ ticket [%z(href("%R/tktview?name=%!S",zTarget))%S(zTarget)</a>]
}else{
@ ticket [%S(zTarget)]
}
|
|
|
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
|
if( cnt>0 ){
@ Also attachment "%h(zFilename)" to
}else{
@ Attachment "%h(zFilename)" to
}
objType |= OBJTYPE_ATTACHMENT;
if( fossil_is_uuid(zTarget) ){
if( db_exists("SELECT 1 FROM tag WHERE tagname='tkt-%q'",
zTarget)
){
if( g.perm.Hyperlink && g.anon.RdTkt ){
@ ticket [%z(href("%R/tktview?name=%!S",zTarget))%S(zTarget)</a>]
}else{
@ ticket [%S(zTarget)]
}
|
︙ | | | ︙ | |
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
|
}
return objType;
}
/*
** WEBPAGE: fdiff
** URL: fdiff?v1=UUID&v2=UUID
**
** Two arguments, v1 and v2, identify the artifacts to be diffed.
** Show diff side by side unless sbs is 0. Generate plain text if
** "patch" is present, otherwise generate "pretty" HTML.
**
** Alternative URL: fdiff?from=filename1&to=filename2&ci=checkin
**
** If the "from" and "to" query parameters are both present, then they are
** the names of two files within the check-in "ci" that are diffed. If the
** "ci" parameter is omitted, then the most recent check-in ("tip") is
** used.
**
** Additional parameters:
**
** dc=N Show N lines of context around each diff
** patch Use the patch diff format
** regex=REGEX Only show differences that match REGEX
** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
|
>
>
>
>
>
>
|
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
|
}
return objType;
}
/*
** WEBPAGE: fdiff
** WEBPAGE: localdiff
** URL: fdiff?v1=UUID&v2=UUID
** URL: localdiff?name=filename
**
** Two arguments, v1 and v2, identify the artifacts to be diffed.
** Show diff side by side unless sbs is 0. Generate plain text if
** "patch" is present, otherwise generate "pretty" HTML.
**
** Alternative URL: fdiff?from=filename1&to=filename2&ci=checkin
**
** If the "from" and "to" query parameters are both present, then they are
** the names of two files within the check-in "ci" that are diffed. If the
** "ci" parameter is omitted, then the most recent check-in ("tip") is
** used.
**
** The /localdiff version will diff the given filename from the most recent
** check-in ("tip") against the current (edited) version in the checkout
** directory.
**
** Additional parameters:
**
** dc=N Show N lines of context around each diff
** patch Use the patch diff format
** regex=REGEX Only show differences that match REGEX
** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
|
︙ | | | ︙ | |
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
|
char *zV1;
char *zV2;
const char *zRe;
ReCompiled *pRe = 0;
u64 diffFlags;
u32 objdescFlags = 0;
int verbose = PB("verbose");
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
cookie_link_parameter("diff","diff","2");
diffType = atoi(PD("diff","2"));
cookie_render();
if( P("from") && P("to") ){
v1 = artifact_from_ci_and_filename("from");
v2 = artifact_from_ci_and_filename("to");
}else{
Stmt q;
v1 = name_to_rid_www("v1");
v2 = name_to_rid_www("v2");
|
>
>
>
>
>
>
|
|
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
|
char *zV1;
char *zV2;
const char *zRe;
ReCompiled *pRe = 0;
u64 diffFlags;
u32 objdescFlags = 0;
int verbose = PB("verbose");
int bLocalMode = g.zPath[0]=='l'; /* diff against checkout */
const char *zLocalName = NULL; /* Holds local filename */
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
cookie_link_parameter("diff","diff","2");
diffType = atoi(PD("diff","2"));
cookie_render();
if( bLocalMode ){
zLocalName = P("name");
v1 = artifact_from_ci_and_filename("name");
v2 = (zLocalName!=NULL)?-1:0; /* -1 prevents "not found" check below */
}else if( P("from") && P("to") ){
v1 = artifact_from_ci_and_filename("from");
v2 = artifact_from_ci_and_filename("to");
}else{
Stmt q;
v1 = name_to_rid_www("v1");
v2 = name_to_rid_www("v2");
|
︙ | | | ︙ | |
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
|
if( v1==0 || v2==0 ) fossil_redirect_home();
zRe = P("regex");
if( zRe ) re_compile(&pRe, zRe, 0);
if( verbose ) objdescFlags |= OBJDESC_DETAIL;
if( isPatch ){
Blob c1, c2, *pOut;
pOut = cgi_output_blob();
cgi_set_content_type("text/plain");
diffFlags = 4;
content_get(v1, &c1);
content_get(v2, &c2);
text_diff(&c1, &c2, pOut, pRe, diffFlags);
blob_reset(&c1);
blob_reset(&c2);
return;
}
zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
diffFlags = construct_diff_flags(diffType) | DIFF_HTML;
style_header("Diff");
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0);
if( diffType==2 ){
style_submenu_element("Unified Diff", "%R/fdiff?v1=%T&v2=%T&diff=1",
P("v1"), P("v2"));
}else{
style_submenu_element("Side-by-side Diff", "%R/fdiff?v1=%T&v2=%T&diff=2",
P("v1"), P("v2"));
}
style_submenu_checkbox("verbose", "Verbose", 0, 0);
style_submenu_element("Patch", "%R/fdiff?v1=%T&v2=%T&patch",
P("v1"), P("v2"));
if( P("smhdr")!=0 ){
@ <h2>Differences From Artifact
@ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
@ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
}else{
@ <h2>Differences From
@ Artifact %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a>:</h2>
object_description(v1, objdescFlags,0, 0);
@ <h2>To Artifact %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>:</h2>
object_description(v2, objdescFlags,0, 0);
}
if( pRe ){
@ <b>Only differences that match regular expression "%h(zRe)"
@ are shown.</b>
}
@ <hr />
append_diff(zV1, zV2, diffFlags, pRe);
append_diff_javascript(diffType);
style_footer();
}
/*
** WEBPAGE: raw
** URL: /raw/ARTIFACTID
|
>
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
|
|
|
|
|
|
>
>
>
>
|
|
>
>
>
>
>
|
>
>
>
>
>
|
|
>
|
|
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
|
if( v1==0 || v2==0 ) fossil_redirect_home();
zRe = P("regex");
if( zRe ) re_compile(&pRe, zRe, 0);
if( verbose ) objdescFlags |= OBJDESC_DETAIL;
if( isPatch ){
Blob c1, c2, *pOut;
pOut = cgi_output_blob();
cgi_set_content_type("text/plain");
diffFlags = 4;
content_get(v1, &c1);
if( bLocalMode ){
content_from_file(zLocalName, &c2);
}else{
content_get(v2, &c2);
}
text_diff(&c1, &c2, pOut, pRe, diffFlags);
blob_reset(&c1);
blob_reset(&c2);
return;
}
zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
diffFlags = construct_diff_flags(diffType) | DIFF_HTML;
style_header("Diff");
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0);
if( bLocalMode ){
if( diffType==2 ){
style_submenu_element("Unified Diff", "%R/localdiff?name=%T&diff=1",
zLocalName);
}else{
style_submenu_element("Side-by-side Diff", "%R/localdiff?name=%T&diff=2",
zLocalName);
}
}else{ /* Normal */
if( diffType==2 ){
style_submenu_element("Unified Diff", "%R/fdiff?v1=%T&v2=%T&diff=1",
P("v1"), P("v2"));
}else{
style_submenu_element("Side-by-side Diff", "%R/fdiff?v1=%T&v2=%T&diff=2",
P("v1"), P("v2"));
}
}
style_submenu_checkbox("verbose", "Verbose", 0, 0);
if( bLocalMode ){
style_submenu_element("Patch", "%R/localdiff?name=%T&patch", zLocalName);
}else{
style_submenu_element("Patch", "%R/fdiff?v1=%T&v2=%T&patch",
P("v1"), P("v2"));
}
if( P("smhdr")!=0 ){
@ <h2>Differences From Artifact
@ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
if( bLocalMode ){
@ %z(href("%R/local"))[Local Changes]</a> of
@ %z(href("%R/file/%T?ci=ckout",zLocalName))%h(zLocalName)</a>.
}else{
@ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
}
}else{
@ <h2>Differences From
@ Artifact %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a>:</h2>
object_description(v1, objdescFlags,0, 0);
if( bLocalMode ){
@ <h2>To %z(href("%R/local"))[Local Changes]</a>
@ of %z(href("%R/file/%T?ci=ckout",zLocalName))%h(zLocalName)</a>.</h2>
}else{
@ <h2>To Artifact %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>:</h2>
object_description(v2, objdescFlags,0, 0);
}
}
if( pRe ){
@ <b>Only differences that match regular expression "%h(zRe)"
@ are shown.</b>
}
@ <hr />
append_diff(zV1, zV2, zLocalName, diffFlags, pRe);
append_diff_javascript(diffType);
style_footer();
}
/*
** WEBPAGE: raw
** URL: /raw/ARTIFACTID
|
︙ | | | ︙ | |
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
|
@ %h(zLine)
}
}
/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
**
** Other parameters:
**
** verbose Show more detail when describing the object
*/
void hexdump_page(void){
int rid;
Blob content;
Blob downloadName;
char *zUuid;
u32 objdescFlags = 0;
rid = name_to_rid_www("name");
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( rid==0 ) fossil_redirect_home();
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun", "%s/shun?accept=%s&sub=1#delshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
}
}
style_header("Hex Artifact Content");
zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid);
@ <h2>Artifact
style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
if( g.perm.Setup ){
@ (%d(rid)):</h2>
}else{
@ :</h2>
}
blob_zero(&downloadName);
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
object_description(rid, objdescFlags, 0, &downloadName);
style_submenu_element("Download", "%R/raw/%s?at=%T",
zUuid, file_tail(blob_str(&downloadName)));
@ <hr />
content_get(rid, &content);
@ <blockquote><pre>
hexdump(&content);
@ </pre></blockquote>
style_footer();
}
/*
** Look for "ci" and "filename" query parameters. If found, try to
** use them to extract the record ID of an artifact for the file.
|
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
|
>
>
|
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
|
@ %h(zLine)
}
}
/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
** URL: /hexdump?local=FILENAME
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
**
** The second version does the same for FILENAME from the local checkout.
**
** Other parameters:
**
** verbose Show more detail when describing the object
*/
void hexdump_page(void){
int rid;
Blob content;
Blob downloadName;
char *zUuid;
u32 objdescFlags = 0;
const char *zLocalName = P("local");
int bLocalMode = zLocalName!=NULL;
rid = name_to_rid_www("name");
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( !bLocalMode ){
if( rid==0 ) fossil_redirect_home();
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun", "%s/shun?accept=%s&sub=1#delshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
}
}
}
style_header("Hex Artifact Content");
/* TODO
** Could the call to style_header() be moved so these two exclusion
** blocks could be merged? I don't think any of them make sense for
** a local file.
*/
if( !bLocalMode ){
zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid);
@ <h2>Artifact
style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
if( g.perm.Setup ){
@ (%d(rid)):</h2>
}else{
@ :</h2>
}
blob_zero(&downloadName);
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
object_description(rid, objdescFlags, 0, &downloadName);
style_submenu_element("Download", "%R/raw/%s?at=%T",
zUuid, file_tail(blob_str(&downloadName)));
}else{
@ <h2>File %z(href("%R/finfo?name=%T&m=tip",zLocalName))%h(zLocalName)</a>
@ from %z(href("%R/local"))[Local Changes]</a></h2>
}
@ <hr />
if( bLocalMode ){
content_from_file(zLocalName, &content);
}else{
content_get(rid, &content);
}
@ <blockquote><pre>
hexdump(&content);
/* TODO: Should content (and downloadName?) be reset/freed? */
@ </pre></blockquote>
style_footer();
}
/*
** Look for "ci" and "filename" query parameters. If found, try to
** use them to extract the record ID of an artifact for the file.
|
︙ | | | ︙ | |
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
|
** parameter is also present, then name= must refer to a file name.
** If ci= is omitted, then the hash interpretation is preferred but
** if name= cannot be understood as a hash, a default "tip" value is
** used for ci=.
**
** For /file, name= can only be interpreted as a filename. As before,
** a default value of "tip" is used for ci= if ci= is omitted.
*/
void artifact_page(void){
int rid = 0;
Blob content;
const char *zMime;
Blob downloadName;
int renderAsWiki = 0;
|
>
>
>
|
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
|
** parameter is also present, then name= must refer to a file name.
** If ci= is omitted, then the hash interpretation is preferred but
** if name= cannot be understood as a hash, a default "tip" value is
** used for ci=.
**
** For /file, name= can only be interpreted as a filename. As before,
** a default value of "tip" is used for ci= if ci= is omitted.
**
** If ci=ckout then display the content of the file NAME in the local
** checkout directory.
*/
void artifact_page(void){
int rid = 0;
Blob content;
const char *zMime;
Blob downloadName;
int renderAsWiki = 0;
|
︙ | | | ︙ | |
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
|
const char *zName = P("name");
const char *zCI = P("ci");
HQuery url;
char *zCIUuid = 0;
int isSymbolicCI = 0; /* ci= exists and is a symbolic name, not a hash */
int isBranchCI = 0; /* ci= refers to a branch name */
char *zHeader = 0;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
/* Capture and normalize the name= and ci= query parameters */
if( zName==0 ){
zName = P("filename");
|
>
|
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
|
const char *zName = P("name");
const char *zCI = P("ci");
HQuery url;
char *zCIUuid = 0;
int isSymbolicCI = 0; /* ci= exists and is a symbolic name, not a hash */
int isBranchCI = 0; /* ci= refers to a branch name */
char *zHeader = 0;
int bLocalMode = 0; /* TRUE if trying to show file in local checkout */
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
/* Capture and normalize the name= and ci= query parameters */
if( zName==0 ){
zName = P("filename");
|
︙ | | | ︙ | |
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
|
if( zCI==0 && !isFile ){
/* If there is no ci= query parameter, then prefer to interpret
** name= as a hash for /artifact and /whatis. But for not for /file.
** For /file, a name= without a ci= while prefer to use the default
** "tip" value for ci=. */
rid = name_to_rid(zName);
}
if( rid==0 ){
rid = artifact_from_ci_and_filename(0);
}
if( rid==0 ){ /* Artifact not found */
if( isFile ){
/* For /file, also check to see if name= refers to a directory,
** and if so, do a listing for that directory */
|
>
>
>
|
|
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
|
if( zCI==0 && !isFile ){
/* If there is no ci= query parameter, then prefer to interpret
** name= as a hash for /artifact and /whatis. But for not for /file.
** For /file, a name= without a ci= while prefer to use the default
** "tip" value for ci=. */
rid = name_to_rid(zName);
}
if( fossil_strcmp(zCI,"ckout")==0 ){
bLocalMode = 1;
rid = -1; /* Dummy value to make it look found */
}else if( rid==0 ){
rid = artifact_from_ci_and_filename(0);
}
if( rid==0 ){ /* Artifact not found */
if( isFile ){
/* For /file, also check to see if name= refers to a directory,
** and if so, do a listing for that directory */
|
︙ | | | ︙ | |
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
|
url_add_parameter(&url, "verbose", "1");
objdescFlags |= OBJDESC_DETAIL;
}
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
asText = P("txt")!=0;
if( isFile ){
if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
zCI = "tip";
isSymbolicCI = 1; /* Mark default-to-"tip" as symbolic */
@ <h2>File %z(href("%R/finfo?name=%T&m=tip",zName))%h(zName)</a>
@ from the %z(href("%R/info/tip"))latest check-in</a></h2>
}else{
const char *zPath;
Blob path;
blob_zero(&path);
hyperlinked_path(zName, &path, zCI, "dir", "", LINKPATH_FINFO);
zPath = blob_str(&path);
@ <h2>File %s(zPath) \
if( isBranchCI ){
@ on branch %z(href("%R/timeline?r=%T",zCI))%h(zCI)</a></h2>
}else if( isSymbolicCI ){
@ as of check-in %z(href("%R/info/%!S",zCIUuid))%s(zCI)</a></h2>
}else{
@ as of check-in [%z(href("%R/info/%!S",zCIUuid))%S(zCIUuid)</a>]</h2>
}
blob_reset(&path);
}
style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
style_submenu_element("Annotate", "%R/annotate?filename=%T&checkin=%T",
zName, zCI);
style_submenu_element("Blame", "%R/blame?filename=%T&checkin=%T",
zName, zCI);
blob_init(&downloadName, zName, -1);
objType = OBJTYPE_CONTENT;
}else{
@ <h2>Artifact
style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
if( g.perm.Setup ){
@ (%d(rid)):</h2>
}else{
@ :</h2>
}
blob_zero(&downloadName);
if( asText ) objdescFlags &= ~OBJDESC_BASE;
objType = object_description(rid, objdescFlags,
(isFile?zName:0), &downloadName);
}
if( !descOnly && P("download")!=0 ){
cgi_redirectf("%R/raw/%s?at=%T",
db_text("x", "SELECT uuid FROM blob WHERE rid=%d", rid),
file_tail(blob_str(&downloadName)));
/*NOTREACHED*/
}
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun", "%s/shun?accept=%s&sub=1#accshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
}
}
if( isFile ){
if( isSymbolicCI ){
zHeader = mprintf("%s at %s", file_tail(zName), zCI);
}else if( zCI ){
zHeader = mprintf("%s at [%S]", file_tail(zName), zCIUuid);
}else{
zHeader = mprintf("%s", file_tail(zName));
}
}else if( descOnly ){
zHeader = mprintf("Artifact Description [%S]", zUuid);
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
|
|
|
|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
|
url_add_parameter(&url, "verbose", "1");
objdescFlags |= OBJDESC_DETAIL;
}
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
asText = P("txt")!=0;
if( isFile ){
if( bLocalMode ){
/*TODO
** Is this the best way of handling annotations to the description?
** If "annot=message" is part of the URL, the message is appended
** to the description of the file. Only used for "local" files to
** distinguish such files from part of the repository.
*/
const char *annot = P("annot");
@ <h2>File %z(href("%R/finfo?name=%T&m=tip",zName))%h(zName)</a>
@ from %z(href("%R/local"))[Local Changes]</a>
if( annot ){
@ (%h(annot))
}
@ </h2>
}else if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
zCI = "tip";
isSymbolicCI = 1; /* Mark default-to-"tip" as symbolic */
@ <h2>File %z(href("%R/finfo?name=%T&m=tip",zName))%h(zName)</a>
@ from the %z(href("%R/info/tip"))latest check-in</a></h2>
}else{
const char *zPath;
Blob path;
blob_zero(&path);
hyperlinked_path(zName, &path, zCI, "dir", "", LINKPATH_FINFO);
zPath = blob_str(&path);
@ <h2>File %s(zPath) \
if( isBranchCI ){
@ on branch %z(href("%R/timeline?r=%T",zCI))%h(zCI)</a></h2>
}else if( isSymbolicCI ){
@ as of check-in %z(href("%R/info/%!S",zCIUuid))%s(zCI)</a></h2>
}else{
@ as of check-in [%z(href("%R/info/%!S",zCIUuid))%S(zCIUuid)</a>]</h2>
}
blob_reset(&path);
}
if( !bLocalMode ){
style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
style_submenu_element("Annotate", "%R/annotate?filename=%T&checkin=%T",
zName, zCI);
style_submenu_element("Blame", "%R/blame?filename=%T&checkin=%T",
zName, zCI);
}
blob_init(&downloadName, zName, -1);
objType = OBJTYPE_CONTENT;
}else{
@ <h2>Artifact
style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
if( g.perm.Setup ){
@ (%d(rid)):</h2>
}else{
@ :</h2>
}
blob_zero(&downloadName);
if( asText ) objdescFlags &= ~OBJDESC_BASE;
objType = object_description(rid, objdescFlags,
(isFile?zName:0), &downloadName);
}
if( !bLocalMode ){
if( !descOnly && P("download")!=0 ){
cgi_redirectf("%R/raw/%s?at=%T",
db_text("x", "SELECT uuid FROM blob WHERE rid=%d", rid),
file_tail(blob_str(&downloadName)));
/*NOTREACHED*/
}
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun", "%s/shun?accept=%s&sub=1#accshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
}
}
}
if( isFile ){
if( isSymbolicCI ){
zHeader = mprintf("%s at %s", file_tail(zName), zCI);
}else if( bLocalMode ){
zHeader = mprintf("%s (local changes)", file_tail(zName));
}else if( zCI ){
zHeader = mprintf("%s at [%S]", file_tail(zName), zCIUuid);
}else{
zHeader = mprintf("%s", file_tail(zName));
}
}else if( descOnly ){
zHeader = mprintf("Artifact Description [%S]", zUuid);
|
︙ | | | ︙ | |
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
|
const char *zUser = db_column_text(&q,0);
const char *zDate = db_column_text(&q,1);
const char *zIp = db_column_text(&q,2);
@ <p>Received on %s(zDate) from %h(zUser) at %h(zIp).</p>
}
db_finalize(&q);
}
style_submenu_element("Download", "%R/raw/%s?at=%T", zUuid, file_tail(zName));
if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){
style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s", zUuid);
}
zMime = mimetype_from_name(blob_str(&downloadName));
if( zMime ){
if( fossil_strcmp(zMime, "text/html")==0 ){
if( asText ){
style_submenu_element("Html", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsHtml = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0
|| fossil_strcmp(zMime, "text/x-markdown")==0 ){
if( asText ){
style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsWiki = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}
if( fileedit_is_editable(zName) ){
style_submenu_element("Edit",
"%R/fileedit?filename=%T&checkin=%!S",
zName, zCI);
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
@ <hr />
content_get(rid, &content);
if( renderAsWiki ){
wiki_render_by_mimetype(&content, zMime);
}else if( renderAsHtml ){
@ <iframe src="%R/raw/%s(zUuid)"
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
@ sandbox="allow-same-origin" id="ifm1">
@ </iframe>
@ <script nonce="%h(style_nonce())">
@ document.getElementById("ifm1").addEventListener("load",
@ function(){
@ this.height=this.contentDocument.documentElement.scrollHeight + 75;
@ }
@ );
@ </script>
}else{
style_submenu_element("Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
if( zLn==0 || atoi(zLn)==0 ){
style_submenu_checkbox("ln", "Line Numbers", 0, 0);
}
blob_to_utf8_no_bom(&content, 0);
zMime = mimetype_from_content(&content);
@ <blockquote>
if( zMime==0 ){
|
>
|
>
|
|
>
>
>
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
|
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
|
const char *zUser = db_column_text(&q,0);
const char *zDate = db_column_text(&q,1);
const char *zIp = db_column_text(&q,2);
@ <p>Received on %s(zDate) from %h(zUser) at %h(zIp).</p>
}
db_finalize(&q);
}
if( !bLocalMode ){
style_submenu_element("Download", "%R/raw/%s?at=%T",
zUuid, file_tail(zName));
if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){
style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s",
zUuid);
}
}
zMime = mimetype_from_name(blob_str(&downloadName));
if( zMime ){
if( fossil_strcmp(zMime, "text/html")==0 ){
if( asText ){
style_submenu_element("Html", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsHtml = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0
|| fossil_strcmp(zMime, "text/x-markdown")==0 ){
if( asText ){
style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsWiki = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}
if( !bLocalMode ){ /* This way madness lies... */
if( fileedit_is_editable(zName) ){
style_submenu_element("Edit",
"%R/fileedit?filename=%T&checkin=%!S",
zName, zCI);
}
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
@ <hr />
if( bLocalMode ){
/*TODO
** Should we handle non-existent local files differently? Currently,
** they are shown the same as if the file was present but empty. This
** should never happen through "normal" operation, but someone might
** craft a link to one. Perhaps have content_from_file() perform an
** existence-check (rather than relying on blob_read_from_file() which
** it calls returning an empty blob)?
*/
content_from_file(zName, &content);
}else{
content_get(rid, &content);
}
if( renderAsWiki ){
wiki_render_by_mimetype(&content, zMime);
}else if( renderAsHtml ){
@ <iframe src="%R/raw/%s(zUuid)"
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
@ sandbox="allow-same-origin" id="ifm1">
@ </iframe>
@ <script nonce="%h(style_nonce())">
@ document.getElementById("ifm1").addEventListener("load",
@ function(){
@ this.height=this.contentDocument.documentElement.scrollHeight + 75;
@ }
@ );
@ </script>
}else{
if( bLocalMode ){
style_submenu_element("Hex", "%R/hexdump?local=%s", zName);
}else{
style_submenu_element("Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
}
if( zLn==0 || atoi(zLn)==0 ){
style_submenu_checkbox("ln", "Line Numbers", 0, 0);
}
blob_to_utf8_no_bom(&content, 0);
zMime = mimetype_from_content(&content);
@ <blockquote>
if( zMime==0 ){
|
︙ | | | ︙ | |