Fossil SCM
add search to wiki
Commit
07bd8796dc91cc6cd631481f5b1712809becf1e6
Parent
c4c231069e4bde4…
1 file changed
+29
+29
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -151,10 +151,13 @@ | ||
| 151 | 151 | if( g.okNewWiki ){ |
| 152 | 152 | @ <li> Create a <a href="%s(g.zBaseURL)/wikinew">new wiki page</a>.</li> |
| 153 | 153 | } |
| 154 | 154 | @ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a> |
| 155 | 155 | @ available on this server.</li> |
| 156 | + @ <li> <form method="GET" action="%s(g.zBaseURL)/wfind"> | |
| 157 | + @ Search the wiki: <input type="text" name="title"/> <input type="submit" /> | |
| 158 | + @ </li> | |
| 156 | 159 | @ </ul> |
| 157 | 160 | style_footer(); |
| 158 | 161 | return; |
| 159 | 162 | } |
| 160 | 163 | if( check_name(zPageName) ) return; |
| @@ -614,10 +617,36 @@ | ||
| 614 | 617 | @ <ul> |
| 615 | 618 | db_prepare(&q, |
| 616 | 619 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 617 | 620 | " ORDER BY lower(tagname)" |
| 618 | 621 | ); |
| 622 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 623 | + const char *zName = db_column_text(&q, 0); | |
| 624 | + @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li> | |
| 625 | + } | |
| 626 | + db_finalize(&q); | |
| 627 | + @ </ul> | |
| 628 | + style_footer(); | |
| 629 | +} | |
| 630 | + | |
| 631 | +/* | |
| 632 | +** WEBPAGE: wfind | |
| 633 | +** | |
| 634 | +** URL: /wfind?title=TITLE | |
| 635 | +** List all wiki pages whose titles contain the search text | |
| 636 | +*/ | |
| 637 | +void wfind_page(void){ | |
| 638 | + Stmt q; | |
| 639 | + const char * zTitle; | |
| 640 | + login_check_credentials(); | |
| 641 | + if( !g.okRdWiki ){ login_needed(); return; } | |
| 642 | + zTitle = PD("title","*"); | |
| 643 | + style_header("Wiki Pages Found"); | |
| 644 | + @ <ul> | |
| 645 | + db_prepare(&q, | |
| 646 | + "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%' ORDER BY lower(tagname)" , | |
| 647 | + zTitle); | |
| 619 | 648 | while( db_step(&q)==SQLITE_ROW ){ |
| 620 | 649 | const char *zName = db_column_text(&q, 0); |
| 621 | 650 | @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li> |
| 622 | 651 | } |
| 623 | 652 | db_finalize(&q); |
| 624 | 653 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -151,10 +151,13 @@ | |
| 151 | if( g.okNewWiki ){ |
| 152 | @ <li> Create a <a href="%s(g.zBaseURL)/wikinew">new wiki page</a>.</li> |
| 153 | } |
| 154 | @ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a> |
| 155 | @ available on this server.</li> |
| 156 | @ </ul> |
| 157 | style_footer(); |
| 158 | return; |
| 159 | } |
| 160 | if( check_name(zPageName) ) return; |
| @@ -614,10 +617,36 @@ | |
| 614 | @ <ul> |
| 615 | db_prepare(&q, |
| 616 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 617 | " ORDER BY lower(tagname)" |
| 618 | ); |
| 619 | while( db_step(&q)==SQLITE_ROW ){ |
| 620 | const char *zName = db_column_text(&q, 0); |
| 621 | @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li> |
| 622 | } |
| 623 | db_finalize(&q); |
| 624 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -151,10 +151,13 @@ | |
| 151 | if( g.okNewWiki ){ |
| 152 | @ <li> Create a <a href="%s(g.zBaseURL)/wikinew">new wiki page</a>.</li> |
| 153 | } |
| 154 | @ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a> |
| 155 | @ available on this server.</li> |
| 156 | @ <li> <form method="GET" action="%s(g.zBaseURL)/wfind"> |
| 157 | @ Search the wiki: <input type="text" name="title"/> <input type="submit" /> |
| 158 | @ </li> |
| 159 | @ </ul> |
| 160 | style_footer(); |
| 161 | return; |
| 162 | } |
| 163 | if( check_name(zPageName) ) return; |
| @@ -614,10 +617,36 @@ | |
| 617 | @ <ul> |
| 618 | db_prepare(&q, |
| 619 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 620 | " ORDER BY lower(tagname)" |
| 621 | ); |
| 622 | while( db_step(&q)==SQLITE_ROW ){ |
| 623 | const char *zName = db_column_text(&q, 0); |
| 624 | @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li> |
| 625 | } |
| 626 | db_finalize(&q); |
| 627 | @ </ul> |
| 628 | style_footer(); |
| 629 | } |
| 630 | |
| 631 | /* |
| 632 | ** WEBPAGE: wfind |
| 633 | ** |
| 634 | ** URL: /wfind?title=TITLE |
| 635 | ** List all wiki pages whose titles contain the search text |
| 636 | */ |
| 637 | void wfind_page(void){ |
| 638 | Stmt q; |
| 639 | const char * zTitle; |
| 640 | login_check_credentials(); |
| 641 | if( !g.okRdWiki ){ login_needed(); return; } |
| 642 | zTitle = PD("title","*"); |
| 643 | style_header("Wiki Pages Found"); |
| 644 | @ <ul> |
| 645 | db_prepare(&q, |
| 646 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%' ORDER BY lower(tagname)" , |
| 647 | zTitle); |
| 648 | while( db_step(&q)==SQLITE_ROW ){ |
| 649 | const char *zName = db_column_text(&q, 0); |
| 650 | @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li> |
| 651 | } |
| 652 | db_finalize(&q); |
| 653 |