Fossil SCM
Enhance the s= query parameter (search) on /timeline so that it also searches the forum post content if the vfx query parameter is present.
Commit
ea688fa67fd020713363d1c9b1470628082654ffd5f2901a6be5615d84b89f5c
Parent
ee8d34f5aa9d948…
1 file changed
+32
-3
+32
-3
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -144,10 +144,28 @@ | ||
| 144 | 144 | db_bind_int(&q, "$rid", rid); |
| 145 | 145 | res = db_step(&q)==SQLITE_ROW; |
| 146 | 146 | db_reset(&q); |
| 147 | 147 | return res; |
| 148 | 148 | } |
| 149 | + | |
| 150 | +/* | |
| 151 | +** Return the text of the unformatted | |
| 152 | +** forum post given by the RID in the argument. | |
| 153 | +*/ | |
| 154 | +static void forum_post_content_function( | |
| 155 | + sqlite3_context *context, | |
| 156 | + int argc, | |
| 157 | + sqlite3_value **argv | |
| 158 | +){ | |
| 159 | + int rid = sqlite3_value_int(argv[0]); | |
| 160 | + Manifest *pPost = manifest_get(rid, CFTYPE_FORUM, 0); | |
| 161 | + if( pPost ){ | |
| 162 | + sqlite3_result_text(context, pPost->zWiki, -1, SQLITE_TRANSIENT); | |
| 163 | + manifest_destroy(pPost); | |
| 164 | + } | |
| 165 | +} | |
| 166 | + | |
| 149 | 167 | |
| 150 | 168 | /* |
| 151 | 169 | ** Output a timeline in the web format given a query. The query |
| 152 | 170 | ** should return these columns: |
| 153 | 171 | ** |
| @@ -2562,13 +2580,24 @@ | ||
| 2562 | 2580 | blob_append_sql(&cond, " AND (event.user=%Q OR event.euser=%Q)", |
| 2563 | 2581 | zUser, zUser); |
| 2564 | 2582 | zThisUser = zUser; |
| 2565 | 2583 | } |
| 2566 | 2584 | if( zSearch ){ |
| 2567 | - blob_append_sql(&cond, | |
| 2568 | - " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')", | |
| 2569 | - zSearch, zSearch); | |
| 2585 | + if( tmFlags & TIMELINE_FORUMTXT ){ | |
| 2586 | + sqlite3_create_function(g.db, "forum_post_content", 1, SQLITE_UTF8, | |
| 2587 | + 0, forum_post_content_function, 0, 0); | |
| 2588 | + blob_append_sql(&cond, | |
| 2589 | + " AND (event.comment LIKE '%%%q%%'" | |
| 2590 | + " OR event.brief LIKE '%%%q%%'" | |
| 2591 | + " OR (event.type=='f' AND" | |
| 2592 | + " forum_post_content(event.objid) LIKE '%%%q%%'))", | |
| 2593 | + zSearch, zSearch, zSearch); | |
| 2594 | + }else{ | |
| 2595 | + blob_append_sql(&cond, | |
| 2596 | + " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')", | |
| 2597 | + zSearch, zSearch); | |
| 2598 | + } | |
| 2570 | 2599 | } |
| 2571 | 2600 | rBefore = symbolic_name_to_mtime(zBefore, &zBefore); |
| 2572 | 2601 | rAfter = symbolic_name_to_mtime(zAfter, &zAfter); |
| 2573 | 2602 | rCirca = symbolic_name_to_mtime(zCirca, &zCirca); |
| 2574 | 2603 | blob_append_sql(&sql, "%s", blob_sql_text(&cond)); |
| 2575 | 2604 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -144,10 +144,28 @@ | |
| 144 | db_bind_int(&q, "$rid", rid); |
| 145 | res = db_step(&q)==SQLITE_ROW; |
| 146 | db_reset(&q); |
| 147 | return res; |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | ** Output a timeline in the web format given a query. The query |
| 152 | ** should return these columns: |
| 153 | ** |
| @@ -2562,13 +2580,24 @@ | |
| 2562 | blob_append_sql(&cond, " AND (event.user=%Q OR event.euser=%Q)", |
| 2563 | zUser, zUser); |
| 2564 | zThisUser = zUser; |
| 2565 | } |
| 2566 | if( zSearch ){ |
| 2567 | blob_append_sql(&cond, |
| 2568 | " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')", |
| 2569 | zSearch, zSearch); |
| 2570 | } |
| 2571 | rBefore = symbolic_name_to_mtime(zBefore, &zBefore); |
| 2572 | rAfter = symbolic_name_to_mtime(zAfter, &zAfter); |
| 2573 | rCirca = symbolic_name_to_mtime(zCirca, &zCirca); |
| 2574 | blob_append_sql(&sql, "%s", blob_sql_text(&cond)); |
| 2575 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -144,10 +144,28 @@ | |
| 144 | db_bind_int(&q, "$rid", rid); |
| 145 | res = db_step(&q)==SQLITE_ROW; |
| 146 | db_reset(&q); |
| 147 | return res; |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | ** Return the text of the unformatted |
| 152 | ** forum post given by the RID in the argument. |
| 153 | */ |
| 154 | static void forum_post_content_function( |
| 155 | sqlite3_context *context, |
| 156 | int argc, |
| 157 | sqlite3_value **argv |
| 158 | ){ |
| 159 | int rid = sqlite3_value_int(argv[0]); |
| 160 | Manifest *pPost = manifest_get(rid, CFTYPE_FORUM, 0); |
| 161 | if( pPost ){ |
| 162 | sqlite3_result_text(context, pPost->zWiki, -1, SQLITE_TRANSIENT); |
| 163 | manifest_destroy(pPost); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | |
| 168 | /* |
| 169 | ** Output a timeline in the web format given a query. The query |
| 170 | ** should return these columns: |
| 171 | ** |
| @@ -2562,13 +2580,24 @@ | |
| 2580 | blob_append_sql(&cond, " AND (event.user=%Q OR event.euser=%Q)", |
| 2581 | zUser, zUser); |
| 2582 | zThisUser = zUser; |
| 2583 | } |
| 2584 | if( zSearch ){ |
| 2585 | if( tmFlags & TIMELINE_FORUMTXT ){ |
| 2586 | sqlite3_create_function(g.db, "forum_post_content", 1, SQLITE_UTF8, |
| 2587 | 0, forum_post_content_function, 0, 0); |
| 2588 | blob_append_sql(&cond, |
| 2589 | " AND (event.comment LIKE '%%%q%%'" |
| 2590 | " OR event.brief LIKE '%%%q%%'" |
| 2591 | " OR (event.type=='f' AND" |
| 2592 | " forum_post_content(event.objid) LIKE '%%%q%%'))", |
| 2593 | zSearch, zSearch, zSearch); |
| 2594 | }else{ |
| 2595 | blob_append_sql(&cond, |
| 2596 | " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')", |
| 2597 | zSearch, zSearch); |
| 2598 | } |
| 2599 | } |
| 2600 | rBefore = symbolic_name_to_mtime(zBefore, &zBefore); |
| 2601 | rAfter = symbolic_name_to_mtime(zAfter, &zAfter); |
| 2602 | rCirca = symbolic_name_to_mtime(zCirca, &zCirca); |
| 2603 | blob_append_sql(&sql, "%s", blob_sql_text(&cond)); |
| 2604 |