Fossil

Check-in [49a990b6fd]
Login

Check-in [49a990b6fd]

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

Overview
Comment:Improvements to search dialog boxes. On the /search menu, allow restricting the search to a specific category of document. Add a search submenu item on the timeline page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | form-submenu
Files: files | file ages | folders
SHA1: 49a990b6fdba3faa875aea83b5c237604c52adf1
User & Date: drh 2015-02-05 15:48:06.096
Context
2015-02-05
15:49
Fix the link on the Search submenu element on the /timeline. ... (check-in: 5eed9680d5 user: drh tags: form-submenu)
15:48
Improvements to search dialog boxes. On the /search menu, allow restricting the search to a specific category of document. Add a search submenu item on the timeline page. ... (check-in: 49a990b6fd user: drh tags: form-submenu)
15:06
Avoid unnecessary database interaction in the search_restrict() function. ... (check-in: 76f9036b71 user: drh tags: form-submenu)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/doc.c.
783
784
785
786
787
788
789
790
791
792
** WEBPAGE: /docsrch
**
** Search for documents that match a user-supplied pattern.
*/
void doc_search_page(void){
  login_check_credentials();
  style_header("Document Search");
  search_screen(SRCH_DOC, "docsrch");
  style_footer();
}







|


783
784
785
786
787
788
789
790
791
792
** WEBPAGE: /docsrch
**
** Search for documents that match a user-supplied pattern.
*/
void doc_search_page(void){
  login_check_credentials();
  style_header("Document Search");
  search_screen(SRCH_DOC, 0);
  style_footer();
}
Changes to src/search.c.
880
881
882
883
884
885
886
887
888
889
890
891


892



893
894
895
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
}

/*
** Generate some HTML for doing search.  At a minimum include the
** Search-Text entry form.  If the "s" query parameter is present, also
** show search results.
**
** The srchFlags parameter is used to customize some of the text of the
** form and the results.  srchFlags should be either a single search
** category or all categories.  Any srchFlags with two or more bits set
** is treated like SRCH_ALL for display purposes.
**


** The entry box is shown disabled if srchFlags is 0.



*/
void search_screen(unsigned srchFlags, const char *zAction){
  const char *zType = 0;
  const char *zClass = 0;
  const char *zDisable1;
  const char *zDisable2;
  const char *zPattern;

  switch( srchFlags ){
    case SRCH_CKIN:  zType = " Check-ins";  zClass = "Ckin";  break;
    case SRCH_DOC:   zType = " Docs";       zClass = "Doc";   break;
    case SRCH_TKT:   zType = " Tickets";    zClass = "Tkt";   break;
    case SRCH_WIKI:  zType = " Wiki";       zClass = "Wiki";  break;
  }
  srchFlags = search_restrict(srchFlags);
  if( srchFlags==0 ){
    zDisable1 = " disabled";
    zDisable2 = " disabled";
    zPattern = "";
  }else{
    zDisable1 = " autofocus";
    zDisable2 = "";
    zPattern = PD("s","");
  }
  @ <form method='GET' action='%s(zAction)'>
  if( zClass ){
    @ <div class='searchForm searchForm%s(zClass)'>
  }else{
    @ <div class='searchForm'>
  }
  @ <input type="text" name="s" size="40" value="%h(zPattern)"%s(zDisable1)>
























  @ <input type="submit" value="Search%s(zType)"%s(zDisable2)>
  if( srchFlags==0 ){
    @ <p class="generalError">Search is disabled</p>
  }
  @ </div></form>
  while( fossil_isspace(zPattern[0]) ) zPattern++;
  if( zPattern[0] ){







|
|
|


>
>
|
>
>
>

|





>






<









|






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







880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
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
948
949
950
951
952
953
954
955
956
957
958
}

/*
** Generate some HTML for doing search.  At a minimum include the
** Search-Text entry form.  If the "s" query parameter is present, also
** show search results.
**
** The srchFlags parameter restricts the set of documents to be searched.
** srchFlags should normally be either a single search category or all
** categories.  Any srchFlags with two or more bits set
** is treated like SRCH_ALL for display purposes.
**
** This routine automatically restricts srchFlag according to user
** permissions and the server configuration.  The entry box is shown
** disabled if srchFlags is 0 after these restrictions are applied.
**
** If useYparam is true, then this routine also looks at the y= query
** parameter for further search restrictions.
*/
void search_screen(unsigned srchFlags, int useYparam){
  const char *zType = 0;
  const char *zClass = 0;
  const char *zDisable1;
  const char *zDisable2;
  const char *zPattern;
  srchFlags = search_restrict(srchFlags);
  switch( srchFlags ){
    case SRCH_CKIN:  zType = " Check-ins";  zClass = "Ckin";  break;
    case SRCH_DOC:   zType = " Docs";       zClass = "Doc";   break;
    case SRCH_TKT:   zType = " Tickets";    zClass = "Tkt";   break;
    case SRCH_WIKI:  zType = " Wiki";       zClass = "Wiki";  break;
  }

  if( srchFlags==0 ){
    zDisable1 = " disabled";
    zDisable2 = " disabled";
    zPattern = "";
  }else{
    zDisable1 = " autofocus";
    zDisable2 = "";
    zPattern = PD("s","");
  }
  @ <form method='GET' action='%R/%t(g.zPath)'>
  if( zClass ){
    @ <div class='searchForm searchForm%s(zClass)'>
  }else{
    @ <div class='searchForm'>
  }
  @ <input type="text" name="s" size="40" value="%h(zPattern)"%s(zDisable1)>
  if( useYparam && (srchFlags & (srchFlags-1))!=0 && useYparam ){
    static const struct { char *z; char *zNm; unsigned m; } aY[] = {
       { "all",  "All",        SRCH_ALL  },
       { "c",    "Check-ins",  SRCH_CKIN },
       { "d",    "Docs",       SRCH_DOC  },
       { "t",    "Tickets",    SRCH_TKT  },
       { "w",    "Wiki",       SRCH_WIKI },
    };
    const char *zY = PD("y","all");
    unsigned newFlags = srchFlags;
    int i;
    @ <select size='1' name='y'>
    for(i=0; i<ArraySize(aY); i++){
      if( (aY[i].m & srchFlags)==0 ) continue;
      cgi_printf("<option value='%s'", aY[i].z);
      if( fossil_strcmp(zY,aY[i].z)==0 ){
        newFlags &= aY[i].m;
        cgi_printf(" selected");
      }
      cgi_printf(">%s</option>\n", aY[i].zNm);
    }
    @ </select>
    srchFlags = newFlags;
  }
  @ <input type="submit" value="Search%s(zType)"%s(zDisable2)>
  if( srchFlags==0 ){
    @ <p class="generalError">Search is disabled</p>
  }
  @ </div></form>
  while( fossil_isspace(zPattern[0]) ) zPattern++;
  if( zPattern[0] ){
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
/*
** WEBPAGE: /search
**
** Search for check-in comments, documents, tickets, or wiki that
** match a user-supplied pattern.
*/
void search_page(void){
  unsigned srchFlags = SRCH_ALL;
  const char *zOnly = P("only");

  login_check_credentials();
  if( zOnly ){
    if( strchr(zOnly,'c') ) srchFlags &= SRCH_CKIN;
    if( strchr(zOnly,'d') ) srchFlags &= SRCH_DOC;
    if( strchr(zOnly,'t') ) srchFlags &= SRCH_TKT;
    if( strchr(zOnly,'w') ) srchFlags &= SRCH_WIKI;
  }
  style_header("Search");
  search_screen(srchFlags, "search");
  style_footer();
}


/*
** This is a helper function for search_stext().  Writing into pOut
** the search text obtained from pIn according to zMimetype.







<
<
<

<
<
<
<
<
<

|







971
972
973
974
975
976
977



978






979
980
981
982
983
984
985
986
987
/*
** WEBPAGE: /search
**
** Search for check-in comments, documents, tickets, or wiki that
** match a user-supplied pattern.
*/
void search_page(void){



  login_check_credentials();






  style_header("Search");
  search_screen(SRCH_ALL, 1);
  style_footer();
}


/*
** This is a helper function for search_stext().  Writing into pOut
** the search text obtained from pIn according to zMimetype.
Changes to src/timeline.c.
1563
1564
1565
1566
1567
1568
1569

1570
1571
1572
1573
1574
1575
1576
      if( zUses==0 ) timeline_y_submenu();
      style_submenu_entry("n","Lines",1);
    }
  }
  if( P("showsql") ){
    @ <blockquote>%h(blob_sql_text(&sql))</blockquote>
  }

  if( P("showid") ) tmFlags |= TIMELINE_SHOWRID;
  blob_zero(&sql);
  db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
  @ <h2>%b(&desc)</h2>
  blob_reset(&desc);
  www_print_timeline(&q, tmFlags, zThisUser, zThisTag, 0);
  db_finalize(&q);







>







1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
      if( zUses==0 ) timeline_y_submenu();
      style_submenu_entry("n","Lines",1);
    }
  }
  if( P("showsql") ){
    @ <blockquote>%h(blob_sql_text(&sql))</blockquote>
  }
  style_submenu_element("Search", 0, "/search?y=c");
  if( P("showid") ) tmFlags |= TIMELINE_SHOWRID;
  blob_zero(&sql);
  db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
  @ <h2>%b(&desc)</h2>
  blob_reset(&desc);
  www_print_timeline(&q, tmFlags, zThisUser, zThisTag, 0);
  db_finalize(&q);
Changes to src/tkt.c.
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
**
** Full-text search of all current tickets
*/
void tkt_srchpage(void){
  login_check_credentials();
  style_header("Ticket Search");
  ticket_standard_submenu(T_ALL_BUT(T_SRCH));
  search_screen(SRCH_TKT, "tktsrch");
  style_footer();
}







|


1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
**
** Full-text search of all current tickets
*/
void tkt_srchpage(void){
  login_check_credentials();
  style_header("Ticket Search");
  ticket_standard_submenu(T_ALL_BUT(T_SRCH));
  search_screen(SRCH_TKT, 0);
  style_footer();
}
Changes to src/wiki.c.
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
**
** Full-text search of all current wiki text
*/
void wiki_srchpage(void){
  login_check_credentials();
  style_header("Wiki Search");
  wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
  search_screen(SRCH_WIKI, "wikisrch");
  style_footer();
}

/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/







|







289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
**
** Full-text search of all current wiki text
*/
void wiki_srchpage(void){
  login_check_credentials();
  style_header("Wiki Search");
  wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
  search_screen(SRCH_WIKI, 0);
  style_footer();
}

/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/