summaryrefslogtreecommitdiff
path: root/Pages
diff options
context:
space:
mode:
Diffstat (limited to 'Pages')
-rw-r--r--Pages/Index.cshtml.cs32
-rw-r--r--Pages/Shared/_Layout.cshtml1
-rw-r--r--Pages/Shared/_Layout.cshtml.css12
3 files changed, 43 insertions, 2 deletions
diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs
index e03a330..07d24f0 100644
--- a/Pages/Index.cshtml.cs
+++ b/Pages/Index.cshtml.cs
@@ -4,12 +4,40 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
namespace HyperBooru.Pages;
public class IndexModel : PageModel {
- public IEnumerable<DbMedia> Media => db.Media;
+ public IEnumerable<DbMedia> Media { get; private set; }
private HyperBooruDbContext db;
public IndexModel(HyperBooruDbContext db) =>
this.db = db;
- public void OnGet() {}
+ public void OnGet([FromQuery(Name = "q")] string? query) {
+ IEnumerable<DbMedia> media;
+
+ if(query is null) {
+ media = db.UploadedFiles
+ .OrderByDescending(uf => uf.UploadTime)
+ .Select(uf => uf.Media)
+ .Distinct();
+ } else {
+ query = query.ToLower();
+
+ var matchingTags = db.TagDefinitions
+ .Where(td => td.Name.ToLower().Contains(query))
+ .Select(td => td.Guid);
+
+ media = db.Media
+ .Where(m =>
+ m.Tags
+ .Select(t => t.TagDefinition.Guid)
+ .Intersect(matchingTags)
+ .Any());
+ }
+
+ Media = media.OrderByDescending(m =>
+ m.UploadedFiles
+ .Select(uf => uf.UploadTime)
+ .Order()
+ .Last());
+ }
} \ No newline at end of file
diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml
index 4c80500..9d6d382 100644
--- a/Pages/Shared/_Layout.cshtml
+++ b/Pages/Shared/_Layout.cshtml
@@ -17,6 +17,7 @@
<div id="navbar">
<a href="/">Home</a>
<a href="/TagDefinitions">Tags</a>
+ <input type="text" placeholder="Search"/>
</div>
<div id="content" style="overflow-y:@(ViewBag.ContentScroll ? "auto" : "hidden");padding:@(ViewBag.ContentMargin ?? "0");">
@RenderBody()
diff --git a/Pages/Shared/_Layout.cshtml.css b/Pages/Shared/_Layout.cshtml.css
index 22e36db..5b2f26e 100644
--- a/Pages/Shared/_Layout.cshtml.css
+++ b/Pages/Shared/_Layout.cshtml.css
@@ -1,6 +1,7 @@
div#navbar {
background: var(--col-navbar-bg);
box-shadow: rgba(0, 0, 0, 0.5) 0px 10px 10px;
+ display: flex;
}
div#navbar > a {
@@ -19,6 +20,17 @@ div#navbar > a:active {
color: var(--col-navbar-bg);
}
+div#navbar > input {
+ align-self: center;
+ background: var(--col-bg);
+ border-radius: 0;
+ color: white;
+ height: 40px !important;
+ margin: 0 20px 0 auto;
+ font-size: 12pt;
+ min-width: 30%;
+}
+
#content {
flex: 1 1 calc(100vh - 119px);
} \ No newline at end of file