Fossil SCM
Included submenu buttons to switch between unified diff and side-by-side in wdiff.
Commit
b6e7473f95676c6ca7a81060a3d3d8a975b62f6123577c272465845b217deb00
Parent
0c19d2426381002…
1 file changed
+16
-3
+16
-3
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -862,11 +862,11 @@ | ||
| 862 | 862 | ** Function called to output extra text at the end of each line in |
| 863 | 863 | ** a wiki history listing. |
| 864 | 864 | */ |
| 865 | 865 | static void wiki_history_extra(int rid){ |
| 866 | 866 | if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d", rid) ){ |
| 867 | - @ %z(href("%R/wdiff?name=%t&a=%d",zWikiPageName,rid))[diff]</a> | |
| 867 | + @ %z(href("%R/wdiff?name=%t&a=%d",zWikiPageName,rid))[diff]</a> | |
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | /* |
| 872 | 872 | ** WEBPAGE: whistory |
| @@ -895,20 +895,21 @@ | ||
| 895 | 895 | style_footer(); |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | /* |
| 899 | 899 | ** WEBPAGE: wdiff |
| 900 | -** URL: /whistory?name=PAGENAME&a=RID1&b=RID2 | |
| 900 | +** URL: /wdiff?name=PAGENAME&a=RID1&b=RID2&diff=DIFFTYPE | |
| 901 | 901 | ** |
| 902 | 902 | ** Show the difference between two wiki pages. |
| 903 | 903 | */ |
| 904 | 904 | void wdiff_page(void){ |
| 905 | 905 | int rid1, rid2; |
| 906 | 906 | const char *zPageName; |
| 907 | 907 | Manifest *pW1, *pW2 = 0; |
| 908 | 908 | Blob w1, w2, d; |
| 909 | 909 | u64 diffFlags; |
| 910 | + int diffType; /* 0: none, 1: unified, 2: side-by-side */ | |
| 910 | 911 | |
| 911 | 912 | login_check_credentials(); |
| 912 | 913 | rid1 = atoi(PD("a","0")); |
| 913 | 914 | if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; } |
| 914 | 915 | if( rid1==0 ) fossil_redirect_home(); |
| @@ -932,13 +933,25 @@ | ||
| 932 | 933 | if( rid2 && (pW2 = manifest_get(rid2, CFTYPE_WIKI, 0))!=0 ){ |
| 933 | 934 | blob_init(&w2, pW2->zWiki, -1); |
| 934 | 935 | } |
| 935 | 936 | blob_zero(&d); |
| 936 | 937 | diffFlags = construct_diff_flags(1); |
| 937 | - if( P("sbs")!=0 ) diffFlags |= DIFF_SIDEBYSIDE; | |
| 938 | + diffType = atoi( PD("diff", "2") ); | |
| 939 | + if( diffType==2 ){ | |
| 940 | + diffFlags |= DIFF_SIDEBYSIDE; | |
| 941 | + style_submenu_element("Unified Diff", "%R/wdiff?name=%T&a=%d&b=%d&diff=1", | |
| 942 | + zPageName, rid1, rid2); | |
| 943 | + }else{ | |
| 944 | + style_submenu_element("Side-by-side Diff", "%R/wdiff?name=%T&a=%d&b=%d&diff=2", | |
| 945 | + zPageName, rid1, rid2); | |
| 946 | + } | |
| 938 | 947 | text_diff(&w2, &w1, &d, 0, diffFlags | DIFF_HTML | DIFF_LINENO); |
| 948 | + if( diffType==2){ | |
| 949 | + @ <pre class="sbsdiff"> | |
| 950 | + }else{ | |
| 939 | 951 | @ <pre class="udiff"> |
| 952 | + } | |
| 940 | 953 | @ %s(blob_str(&d)) |
| 941 | 954 | @ <pre> |
| 942 | 955 | manifest_destroy(pW1); |
| 943 | 956 | manifest_destroy(pW2); |
| 944 | 957 | style_footer(); |
| 945 | 958 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -862,11 +862,11 @@ | |
| 862 | ** Function called to output extra text at the end of each line in |
| 863 | ** a wiki history listing. |
| 864 | */ |
| 865 | static void wiki_history_extra(int rid){ |
| 866 | if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d", rid) ){ |
| 867 | @ %z(href("%R/wdiff?name=%t&a=%d",zWikiPageName,rid))[diff]</a> |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | /* |
| 872 | ** WEBPAGE: whistory |
| @@ -895,20 +895,21 @@ | |
| 895 | style_footer(); |
| 896 | } |
| 897 | |
| 898 | /* |
| 899 | ** WEBPAGE: wdiff |
| 900 | ** URL: /whistory?name=PAGENAME&a=RID1&b=RID2 |
| 901 | ** |
| 902 | ** Show the difference between two wiki pages. |
| 903 | */ |
| 904 | void wdiff_page(void){ |
| 905 | int rid1, rid2; |
| 906 | const char *zPageName; |
| 907 | Manifest *pW1, *pW2 = 0; |
| 908 | Blob w1, w2, d; |
| 909 | u64 diffFlags; |
| 910 | |
| 911 | login_check_credentials(); |
| 912 | rid1 = atoi(PD("a","0")); |
| 913 | if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; } |
| 914 | if( rid1==0 ) fossil_redirect_home(); |
| @@ -932,13 +933,25 @@ | |
| 932 | if( rid2 && (pW2 = manifest_get(rid2, CFTYPE_WIKI, 0))!=0 ){ |
| 933 | blob_init(&w2, pW2->zWiki, -1); |
| 934 | } |
| 935 | blob_zero(&d); |
| 936 | diffFlags = construct_diff_flags(1); |
| 937 | if( P("sbs")!=0 ) diffFlags |= DIFF_SIDEBYSIDE; |
| 938 | text_diff(&w2, &w1, &d, 0, diffFlags | DIFF_HTML | DIFF_LINENO); |
| 939 | @ <pre class="udiff"> |
| 940 | @ %s(blob_str(&d)) |
| 941 | @ <pre> |
| 942 | manifest_destroy(pW1); |
| 943 | manifest_destroy(pW2); |
| 944 | style_footer(); |
| 945 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -862,11 +862,11 @@ | |
| 862 | ** Function called to output extra text at the end of each line in |
| 863 | ** a wiki history listing. |
| 864 | */ |
| 865 | static void wiki_history_extra(int rid){ |
| 866 | if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d", rid) ){ |
| 867 | @ %z(href("%R/wdiff?name=%t&a=%d",zWikiPageName,rid))[diff]</a> |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | /* |
| 872 | ** WEBPAGE: whistory |
| @@ -895,20 +895,21 @@ | |
| 895 | style_footer(); |
| 896 | } |
| 897 | |
| 898 | /* |
| 899 | ** WEBPAGE: wdiff |
| 900 | ** URL: /wdiff?name=PAGENAME&a=RID1&b=RID2&diff=DIFFTYPE |
| 901 | ** |
| 902 | ** Show the difference between two wiki pages. |
| 903 | */ |
| 904 | void wdiff_page(void){ |
| 905 | int rid1, rid2; |
| 906 | const char *zPageName; |
| 907 | Manifest *pW1, *pW2 = 0; |
| 908 | Blob w1, w2, d; |
| 909 | u64 diffFlags; |
| 910 | int diffType; /* 0: none, 1: unified, 2: side-by-side */ |
| 911 | |
| 912 | login_check_credentials(); |
| 913 | rid1 = atoi(PD("a","0")); |
| 914 | if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; } |
| 915 | if( rid1==0 ) fossil_redirect_home(); |
| @@ -932,13 +933,25 @@ | |
| 933 | if( rid2 && (pW2 = manifest_get(rid2, CFTYPE_WIKI, 0))!=0 ){ |
| 934 | blob_init(&w2, pW2->zWiki, -1); |
| 935 | } |
| 936 | blob_zero(&d); |
| 937 | diffFlags = construct_diff_flags(1); |
| 938 | diffType = atoi( PD("diff", "2") ); |
| 939 | if( diffType==2 ){ |
| 940 | diffFlags |= DIFF_SIDEBYSIDE; |
| 941 | style_submenu_element("Unified Diff", "%R/wdiff?name=%T&a=%d&b=%d&diff=1", |
| 942 | zPageName, rid1, rid2); |
| 943 | }else{ |
| 944 | style_submenu_element("Side-by-side Diff", "%R/wdiff?name=%T&a=%d&b=%d&diff=2", |
| 945 | zPageName, rid1, rid2); |
| 946 | } |
| 947 | text_diff(&w2, &w1, &d, 0, diffFlags | DIFF_HTML | DIFF_LINENO); |
| 948 | if( diffType==2){ |
| 949 | @ <pre class="sbsdiff"> |
| 950 | }else{ |
| 951 | @ <pre class="udiff"> |
| 952 | } |
| 953 | @ %s(blob_str(&d)) |
| 954 | @ <pre> |
| 955 | manifest_destroy(pW1); |
| 956 | manifest_destroy(pW2); |
| 957 | style_footer(); |
| 958 |