Fossil: Check-in [b695e97d7a]

Fossil SCM

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improvements to the /wdiff page.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:b695e97d7abf9f40a63580f04759b9ab9393fd50f484e3a57f5503dc5266d6d2
User & Date: drh 2018-12-12 01:23:43
References
2018-12-15
08:34
Move a variable declaration introduced by [b695e97d7a] to the beginning of the scope, for strict ANSI C-89 conformance, as specified in the Coding Style document [/doc/trunk/www/style.wiki]. (Required by some old MSVC compilers, to build executables with dynamic linking to msvcrt.dll.) Closed-Leaf check-in: 550b95e5ee user: florian tags: ansi-c89-compatibility
Context
2018-12-12
01:42
On the /info page for wiki, give a link to the next version of that wiki page in chronological order. check-in: 423c6a938e user: drh tags: trunk
01:23
Improvements to the /wdiff page. check-in: b695e97d7a user: drh tags: trunk
2018-12-11
21:31
Change timeline hyperlinks to wiki pages to point to the specific version of the wiki page that the timeline entry refers to, not to the latest version of that page. check-in: 606421edc5 user: drh tags: trunk
Changes

Changes to src/wiki.c.

384
385
386
387
388
389
390
391
392



393
394
395
396
397
398
399
...
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
...
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
      zBody = pWiki->zWiki;
      zMimetype = pWiki->zMimetype;
    }
  }
  zMimetype = wiki_filter_mimetypes(zMimetype);
  if( !g.isHome ){
    if( rid ){
      style_submenu_element("Diff", "%R/wdiff?name=%T&a=%d", zPageName, rid);
      zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);



      style_submenu_element("Details", "%R/info/%s", zUuid);
    }
    if( (rid && g.anon.WrWiki) || (!rid && g.anon.NewWiki) ){
      if( db_get_boolean("wysiwyg-wiki", 0) ){
        style_submenu_element("Edit", "%s/wikiedit?name=%T&wysiwyg=1",
             g.zTop, zPageName);
      }else{
................................................................................

/*
** Function called to output extra text at the end of each line in
** a wiki history listing.
*/
static void wiki_history_extra(int rid){
  if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d", rid) ){
    @ &nbsp;op: %z(href("%R/wdiff?name=%t&a=%d",zWikiPageName,rid))diff</a>\
  }
}

/*
** WEBPAGE: whistory
** URL: /whistory?name=PAGENAME
**
................................................................................
  www_print_timeline(&q, tmFlags, 0, 0, 0, wiki_history_extra);
  db_finalize(&q);
  style_footer();
}

/*
** WEBPAGE: wdiff
** URL: /whistory?name=PAGENAME&a=RID1&b=RID2

**
** Show the difference between two wiki pages.








*/
void wdiff_page(void){
  int rid1, rid2;

  const char *zPageName;
  Manifest *pW1, *pW2 = 0;

  Blob w1, w2, d;
  u64 diffFlags;

  login_check_credentials();
  rid1 = atoi(PD("a","0"));
  if( !g.perm.Hyperlink ){ login_needed(g.anon.Hyperlink); return; }

  if( rid1==0 ) fossil_redirect_home();
  rid2 = atoi(PD("b","0"));
  zPageName = PD("name","");
  style_header("Changes To %s", zPageName);

  if( rid2==0 ){
    rid2 = db_int(0,
      "SELECT objid FROM event JOIN tagxref ON objid=rid AND tagxref.tagid="
                        "(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
      " WHERE event.mtime<(SELECT mtime FROM event WHERE objid=%d)"
      " ORDER BY event.mtime DESC LIMIT 1",
      zPageName, rid1
    );
  }
  pW1 = manifest_get(rid1, CFTYPE_WIKI, 0);
  if( pW1==0 ) fossil_redirect_home();
  blob_init(&w1, pW1->zWiki, -1);
  blob_zero(&w2);





  if( rid2 && (pW2 = manifest_get(rid2, CFTYPE_WIKI, 0))!=0 ){
    blob_init(&w2, pW2->zWiki, -1);












  }

  blob_zero(&d);
  diffFlags = construct_diff_flags(1);
  text_diff(&w2, &w1, &d, 0, diffFlags | DIFF_HTML | DIFF_LINENO);
  @ <pre class="udiff">
  @ %s(blob_str(&d))
  @ <pre>
  manifest_destroy(pW1);







<

>
>
>







 







|







 







|
>

<
>
>
>
>
>
>
>
>


<
>
|

>




<
|
>
|
|
|
|
|
|
<
<
<
<
<
<
<
<



|
>
>
>
>
>
|

>
>
>
>
>
>
>
>
>
>
>
>

>







384
385
386
387
388
389
390

391
392
393
394
395
396
397
398
399
400
401
...
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
...
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
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
      zBody = pWiki->zWiki;
      zMimetype = pWiki->zMimetype;
    }
  }
  zMimetype = wiki_filter_mimetypes(zMimetype);
  if( !g.isHome ){
    if( rid ){

      zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
      if( pWiki && pWiki->nParent ){
        style_submenu_element("Diff", "%R/wdiff?id=%s", zUuid);
      }
      style_submenu_element("Details", "%R/info/%s", zUuid);
    }
    if( (rid && g.anon.WrWiki) || (!rid && g.anon.NewWiki) ){
      if( db_get_boolean("wysiwyg-wiki", 0) ){
        style_submenu_element("Edit", "%s/wikiedit?name=%T&wysiwyg=1",
             g.zTop, zPageName);
      }else{
................................................................................

/*
** Function called to output extra text at the end of each line in
** a wiki history listing.
*/
static void wiki_history_extra(int rid){
  if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d", rid) ){
    @ &nbsp;op: %z(href("%R/wdiff?rid=%d",rid))diff</a>\
  }
}

/*
** WEBPAGE: whistory
** URL: /whistory?name=PAGENAME
**
................................................................................
  www_print_timeline(&q, tmFlags, 0, 0, 0, wiki_history_extra);
  db_finalize(&q);
  style_footer();
}

/*
** WEBPAGE: wdiff
**
** Show the changes to a wiki page.
**

** Query parameters:
**
**      id=HASH           Hash prefix for the child version to be diffed.
**      rid=INTEGER       RecordID for the child version
**      pid=HASH          Hash prefix for the parent.
**
** The "id" query parameter is required.  "pid" is optional.  If "pid"
** is omitted, then the diff is against the first parent of the child.
*/
void wdiff_page(void){

  const char *zId;
  const char *zPid;
  Manifest *pW1, *pW2 = 0;
  int rid1, rid2;
  Blob w1, w2, d;
  u64 diffFlags;

  login_check_credentials();

  if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; }
  zId = P("id");
  if( zId==0 ){
    rid1 = atoi(PD("rid","0"));
  }else{
    rid1 = name_to_typed_rid(zId, "w");
  }
  zId = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid1);








  pW1 = manifest_get(rid1, CFTYPE_WIKI, 0);
  if( pW1==0 ) fossil_redirect_home();
  blob_init(&w1, pW1->zWiki, -1);
  zPid = P("pid");
  if( zPid==0 && pW1->nParent ){
    zPid = pW1->azParent[0];
  }
  if( zPid ){
    rid2 = name_to_typed_rid(zPid, "w");
    pW2 = manifest_get(rid2, CFTYPE_WIKI, 0);
    blob_init(&w2, pW2->zWiki, -1);
    char *zDate;
    @ <h2>Changes to \
    @ "%z(href("%R/whistory?name=%s",pW1->zWikiTitle))%h(pW1->zWikiTitle)</a>" \
    zDate = db_text(0, "SELECT datetime(%.16g)",pW2->rDate);
    @ between %z(href("%R/info/%s",zPid))%z(zDate)</a> \
    zDate = db_text(0, "SELECT datetime(%.16g)",pW1->rDate);
    @ and %z(href("%R/info/%s",zId))%z(zDate)</a></h2>
  }else{
    blob_zero(&w2);
    @ <h2>Initial version of \
    @ "%z(href("%R/whistory?name=%s",pW1->zWikiTitle))%h(pW1->zWikiTitle)</a>"\
    @ </h2>
  }
  style_header("Changes To %s", pW1->zWikiTitle);
  blob_zero(&d);
  diffFlags = construct_diff_flags(1);
  text_diff(&w2, &w1, &d, 0, diffFlags | DIFF_HTML | DIFF_LINENO);
  @ <pre class="udiff">
  @ %s(blob_str(&d))
  @ <pre>
  manifest_destroy(pW1);