Fossil

Check-in [fa947eeb]
Login

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

Overview
Comment:In documentation search results, change URLs of the form "/doc/BRANCH/path" so that BRANCH is the branch name specified by the "doc-branch" setting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fa947eebfdcd78286e6593896bf81c2521664d7a
User & Date: drh 2016-08-30 00:49:38
Context
2016-08-30
13:35
Add the /test-ftsdocs page, accessible only by administrators. Improved comments in the search logic. check-in: 375bc71e user: drh tags: trunk
00:49
In documentation search results, change URLs of the form "/doc/BRANCH/path" so that BRANCH is the branch name specified by the "doc-branch" setting. check-in: fa947eeb user: drh tags: trunk
2016-08-29
14:15
Fix the /uv page so that works on Solaris. check-in: 0cd96edc user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/search.c.

918
919
920
921
922
923
924

925
926
927
928
929
930
931
...
939
940
941
942
943
944
945

946
947
948
949









950

951
952
953
954
955
956
957
958
959
int search_run_and_output(
  const char *zPattern,       /* The query pattern */
  unsigned int srchFlags,     /* What to search over */
  int fDebug                  /* Extra debugging output */
){
  Stmt q;
  int nRow = 0;


  srchFlags = search_restrict(srchFlags);
  if( srchFlags==0 ) return 0;
  search_sql_setup(g.db);
  add_content_sql_commands(g.db);
  db_multi_exec(
    "CREATE TEMP TABLE x(label,url,score,id,date,snip);"
................................................................................
  db_prepare(&q, "SELECT url, snip, label, score, id"
                 "  FROM x"
                 " ORDER BY score DESC, date DESC;");
  while( db_step(&q)==SQLITE_ROW ){
    const char *zUrl = db_column_text(&q, 0);
    const char *zSnippet = db_column_text(&q, 1);
    const char *zLabel = db_column_text(&q, 2);

    if( nRow==0 ){
      @ <ol>
    }
    nRow++;









    @ <li><p><a href='%R%s(zUrl)'>%h(zLabel)</a>

    if( fDebug ){
      @ (%e(db_column_double(&q,3)), %s(db_column_text(&q,4)))
    }
    @ <br /><span class='snippet'>%z(cleanSnippet(zSnippet))</span></li>
  }
  db_finalize(&q);
  if( nRow ){
    @ </ol>
  }







>







 







>




>
>
>
>
>
>
>
>
>
|
>

|







918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
...
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
966
967
968
969
970
971
int search_run_and_output(
  const char *zPattern,       /* The query pattern */
  unsigned int srchFlags,     /* What to search over */
  int fDebug                  /* Extra debugging output */
){
  Stmt q;
  int nRow = 0;
  const char *zDocBr = 0;         /* The branch of documentation to search */

  srchFlags = search_restrict(srchFlags);
  if( srchFlags==0 ) return 0;
  search_sql_setup(g.db);
  add_content_sql_commands(g.db);
  db_multi_exec(
    "CREATE TEMP TABLE x(label,url,score,id,date,snip);"
................................................................................
  db_prepare(&q, "SELECT url, snip, label, score, id"
                 "  FROM x"
                 " ORDER BY score DESC, date DESC;");
  while( db_step(&q)==SQLITE_ROW ){
    const char *zUrl = db_column_text(&q, 0);
    const char *zSnippet = db_column_text(&q, 1);
    const char *zLabel = db_column_text(&q, 2);
    const char *zId = db_column_text(&q,4);
    if( nRow==0 ){
      @ <ol>
    }
    nRow++;
    if( strncmp(zUrl,"/doc/",5)==0 ){
      /* Change the BRANCH in URLs like "/doc/BRANCH/path" into the
      ** branch name specified by the doc-branch setting. */
      int i;
      if( zDocBr==0 ) zDocBr = db_get("doc-branch","trunk");
      for(i=5; zUrl[i]; i++) if( zUrl[i]=='/' ){ i++; break; }
      @ <li><p><a href='%R/doc/%T(zDocBr)/%T(zUrl+i)'>%h(zLabel)</a>
    }else{
      /* Non-"/doc/" URLs are delivered as is */
      @ <li><p><a href='%R%T(zUrl)'>%h(zLabel)</a>
    }
    if( fDebug ){
      @ (%e(db_column_double(&q,3)), %s(zId))
    }
    @ <br /><span class='snippet'>%z(cleanSnippet(zSnippet))</span></li>
  }
  db_finalize(&q);
  if( nRow ){
    @ </ol>
  }