Fossil SCM

Included submenu buttons to switch between unified diff and side-by-side in wdiff.

vor0nwe 2018-10-24 21:03 vor0nwe-wiki-wysiwyg
Commit b6e7473f95676c6ca7a81060a3d3d8a975b62f6123577c272465845b217deb00
1 file changed +16 -3
+16 -3
--- src/wiki.c
+++ src/wiki.c
@@ -862,11 +862,11 @@
862862
** Function called to output extra text at the end of each line in
863863
** a wiki history listing.
864864
*/
865865
static void wiki_history_extra(int rid){
866866
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>
868868
}
869869
}
870870
871871
/*
872872
** WEBPAGE: whistory
@@ -895,20 +895,21 @@
895895
style_footer();
896896
}
897897
898898
/*
899899
** WEBPAGE: wdiff
900
-** URL: /whistory?name=PAGENAME&a=RID1&b=RID2
900
+** URL: /wdiff?name=PAGENAME&a=RID1&b=RID2&diff=DIFFTYPE
901901
**
902902
** Show the difference between two wiki pages.
903903
*/
904904
void wdiff_page(void){
905905
int rid1, rid2;
906906
const char *zPageName;
907907
Manifest *pW1, *pW2 = 0;
908908
Blob w1, w2, d;
909909
u64 diffFlags;
910
+ int diffType; /* 0: none, 1: unified, 2: side-by-side */
910911
911912
login_check_credentials();
912913
rid1 = atoi(PD("a","0"));
913914
if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; }
914915
if( rid1==0 ) fossil_redirect_home();
@@ -932,13 +933,25 @@
932933
if( rid2 && (pW2 = manifest_get(rid2, CFTYPE_WIKI, 0))!=0 ){
933934
blob_init(&w2, pW2->zWiki, -1);
934935
}
935936
blob_zero(&d);
936937
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
+ }
938947
text_diff(&w2, &w1, &d, 0, diffFlags | DIFF_HTML | DIFF_LINENO);
948
+ if( diffType==2){
949
+ @ <pre class="sbsdiff">
950
+ }else{
939951
@ <pre class="udiff">
952
+ }
940953
@ %s(blob_str(&d))
941954
@ <pre>
942955
manifest_destroy(pW1);
943956
manifest_destroy(pW2);
944957
style_footer();
945958
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button