Skip to content

Commit 9b5fe73

Browse files
committed
added highlight for searched posts
1 parent 5f1f833 commit 9b5fe73

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

VinePlus.Web/Pages/Queries.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ public static IEnumerable<PostSummary> searchUserPosts(ComicvineContext context,
298298
)
299299
)
300300
.Skip(Util.ThreadPerPage * (page - 1))
301-
.Take(Util.ThreadPerPage);
301+
.Take(Util.ThreadPerPage)
302+
.ToList();
302303
}
303304

304305
public static IEnumerable<Parsers.Post> getUserPosts(ComicvineContext context, string user, int page=1) {

VinePlus.Web/Pages/Search/Posts/Results.cshtml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ public class Results(ComicvineContext context) : Pagination<PostSummary>
99
public void OnGet(bool searchPost, string query, string creator, int p) {
1010
string s_query = $"searchPost={searchPost}&query={query}" + (creator==null ? "" : "&creator=takenstew22");
1111
NavRecord = new(p, int.MaxValue, s_query);
12-
Entities = Queries.searchUserPosts(context, query, creator, p);
12+
Entities = Queries.searchUserPosts(context, query, creator, p)
13+
.Select(entity =>
14+
entity with { post_content = entity.post_content.Replace(query, $"<span class=\"search-highlight\">{query}</span>")}
15+
);
16+
1317
}
1418

1519
public override Func<string, int, string> PageDelegate() {

VinePlus.Web/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The first can be time consuming - especially on low internet speed, while the ba
8282
- [ ] "How to search" UI
8383
- [x] pagination for search
8484
- [x] add ability to search posts
85-
- [ ] highlight search term
85+
- [x] highlight search term
8686

8787
### Stats
8888
- [ ] add stats UI

VinePlus.Web/wwwroot/css/main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,4 +889,10 @@ figure[data-size="small"] {
889889
}
890890
.error-img > img {
891891
margin: auto;
892+
}
893+
.search-highlight {
894+
background-color: yellow;
895+
font-weight: bold;
896+
color: gray;
897+
padding: 0 0.2rem;
892898
}

0 commit comments

Comments
 (0)