summaryrefslogtreecommitdiff
path: root/Pages
diff options
context:
space:
mode:
Diffstat (limited to 'Pages')
-rw-r--r--Pages/Index.cshtml15
-rw-r--r--Pages/Index.cshtml.cs15
-rw-r--r--Pages/Index.cshtml.css7
-rw-r--r--Pages/Shared/_Layout.cshtml25
-rw-r--r--Pages/Shared/_Layout.cshtml.css18
-rw-r--r--Pages/ViewMedia.cshtml88
-rw-r--r--Pages/ViewMedia.cshtml.cs23
-rw-r--r--Pages/ViewMedia.cshtml.css52
-rw-r--r--Pages/_ViewStart.cshtml3
9 files changed, 246 insertions, 0 deletions
diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml
new file mode 100644
index 0000000..80e05d9
--- /dev/null
+++ b/Pages/Index.cshtml
@@ -0,0 +1,15 @@
+@page
+@model HyperBooru.Pages.IndexModel
+
+<link rel="stylesheet" type="text/css" href="@(nameof(HyperBooru)).styles.css"/>
+
+<form id="upload" action="/media" method="post" enctype="multipart/form-data">
+ <input type="file" id="myFile" name="filename"/>
+ <input type="submit" />
+</form>
+
+@foreach(var media in Model.Media) {
+ <a href="/ViewMedia?m=@(media.Guid)">
+ <img src="/media/thumb/@(media.Guid)?h=200" />
+ </a>
+} \ No newline at end of file
diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs
new file mode 100644
index 0000000..e03a330
--- /dev/null
+++ b/Pages/Index.cshtml.cs
@@ -0,0 +1,15 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
+namespace HyperBooru.Pages;
+
+public class IndexModel : PageModel {
+ public IEnumerable<DbMedia> Media => db.Media;
+
+ private HyperBooruDbContext db;
+
+ public IndexModel(HyperBooruDbContext db) =>
+ this.db = db;
+
+ public void OnGet() {}
+} \ No newline at end of file
diff --git a/Pages/Index.cshtml.css b/Pages/Index.cshtml.css
new file mode 100644
index 0000000..f573988
--- /dev/null
+++ b/Pages/Index.cshtml.css
@@ -0,0 +1,7 @@
+img {
+ max-height: 200px;
+}
+
+form#upload {
+ padding-bottom: 30px;
+} \ No newline at end of file
diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml
new file mode 100644
index 0000000..be445cc
--- /dev/null
+++ b/Pages/Shared/_Layout.cshtml
@@ -0,0 +1,25 @@
+@{
+ ViewBag.Title ??= "HyperBooru";
+ ViewBag.ContentScroll ??= true;
+ ViewBag.ContentMargin ??= "30px";
+}
+
+<!DOCTYPE html>
+
+<html>
+<head>
+ <meta name="viewport" content="width=device-width"/>
+ <link rel="stylesheet" type="text/css" href="/styles/global.css"/>
+ <link rel="stylesheet" type="text/css" href="@(nameof(HyperBooru)).styles.css"/>
+ <title>@ViewBag.Title</title>
+</head>
+ <body>
+ <div id="navbar">
+ <a href="/">Home</a>
+ <a href="/tags">Tags</a>
+ </div>
+ <div id="content" style="overflow:@(ViewBag.ContentScroll ? "auto" : "hidden");margin:@(ViewBag.ContentMargin ?? "0");">
+ @RenderBody()
+ </div>
+ </body>
+</html> \ No newline at end of file
diff --git a/Pages/Shared/_Layout.cshtml.css b/Pages/Shared/_Layout.cshtml.css
new file mode 100644
index 0000000..5b2ba65
--- /dev/null
+++ b/Pages/Shared/_Layout.cshtml.css
@@ -0,0 +1,18 @@
+div#navbar {
+ background: var(--col-navbar-bg);
+ box-shadow: rgba(0, 0, 0, 0.5) 0px 10px 10px;
+}
+
+div#navbar > a {
+ display: inline-block;
+ padding: 20px 20px 20px 20px;
+}
+
+div#navbar > a:hover {
+ background: rgba(255, 255, 255, 0.4);
+}
+
+div#navbar > a:active {
+ background: #fff;
+ color: var(--col-navbar-bg);
+} \ No newline at end of file
diff --git a/Pages/ViewMedia.cshtml b/Pages/ViewMedia.cshtml
new file mode 100644
index 0000000..967759b
--- /dev/null
+++ b/Pages/ViewMedia.cshtml
@@ -0,0 +1,88 @@
+@page
+@model HyperBooru.Pages.ViewMediaModel
+@{
+ ViewBag.ContentScroll = false;
+}
+
+<link rel="stylesheet" type="text/css" href="@(nameof(HyperBooru)).styles.css"/>
+
+<script>
+ async function deleteMedia() {
+ var mediaId = new URL(window.location.href).searchParams.get('m');
+ var resp = await fetch('/media/' + mediaId, { method: 'delete' });
+ if(resp.ok) {
+ window.location.href = '/';
+ } else {
+ alert('Failed to delete media object!');
+ }
+ }
+
+ function selectPane(tab) {
+ var tabs = Array.from(document.querySelectorAll('div#metadata-header > a'));
+
+ var panes = Array.from(document.querySelectorAll('div#metadata > div'))
+ .filter(x => x.id != 'metadata-header');
+ var pane = panes.filter(x => x.id == tab.dataset.pane)[0];
+
+ for(var t of tabs) {
+ if(t == tab)
+ t.classList.add('selected');
+ else
+ t.classList.remove('selected');
+ }
+
+ for(var p of panes) {
+ if(p == pane)
+ p.classList.add('selected');
+ else
+ p.classList.remove('selected');
+ }
+ }
+</script>
+
+<div id="content">
+ <img src="/media/@(Model.Media.Guid)"/>
+ <div id="metadata">
+ <div id="metadata-header">
+ <a href="javascript:;" onclick="selectPane(this);" data-pane="metadata-fileinfo">File Info</a>
+ <a href="javascript:;" onclick="selectPane(this);" data-pane="metadata-tags" class="selected">Tags</a>
+ </div>
+@* <form method="post">
+ <label for="shortDescription">Short Description</label>
+ <input type="text" name="shortDescription" placeholder="@Model.Media.ShortDescription"/>
+ <label for="longDescription">Long Description</label>
+ <input type="text" name="longDescription" placeholder="@Model.Media.LongDescription"/>
+ <input type="submit" value="Update"/>
+ </form>*@
+ <div id="metadata-fileinfo">
+ <p>Upload history</p>
+ <hr />
+ <table class="data-table">
+ <tr>
+ <th>Created On</th>
+ <th>Last Write</th>
+ <th>Uploaded On</th>
+ <th>Filename</th>
+ <th>Original Checksum</th>
+ </tr>
+ @foreach(var file in Model.Media.UploadedFiles) {
+ <tr>
+ <td>@(file.CreateTime?.ToString() ?? "N/A")</td>
+ <td>@(file.LastWriteTime?.ToString() ?? "N/A")</td>
+ <td>@file.UploadTime</td>
+ <td>@file.Filename</td>
+ <td>@file.OriginalChecksum</td>
+ </tr>
+ }
+ </table>
+ </div>
+ <div id="metadata-tags" class="selected">
+ <table class="data-table">
+ <tr>
+ <th>Tag Name</th>
+ </tr>
+ </table>
+ <button>Add Tag</button>
+ </div>
+ </div>
+</div> \ No newline at end of file
diff --git a/Pages/ViewMedia.cshtml.cs b/Pages/ViewMedia.cshtml.cs
new file mode 100644
index 0000000..fe8d150
--- /dev/null
+++ b/Pages/ViewMedia.cshtml.cs
@@ -0,0 +1,23 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
+namespace HyperBooru.Pages;
+
+public class ViewMediaModel : PageModel {
+ public DbMedia Media { get; private set; }
+
+ private HyperBooruDbContext db;
+
+ public ViewMediaModel(HyperBooruDbContext db) =>
+ this.db = db;
+
+ public IActionResult OnGet([FromQuery(Name = "m")] Guid mediaId) {
+ var media = db.Media.First(m => m.Guid == mediaId);
+ if(media is null)
+ return NotFound();
+
+ Media = media;
+
+ return Page();
+ }
+} \ No newline at end of file
diff --git a/Pages/ViewMedia.cshtml.css b/Pages/ViewMedia.cshtml.css
new file mode 100644
index 0000000..ff8a1cd
--- /dev/null
+++ b/Pages/ViewMedia.cshtml.css
@@ -0,0 +1,52 @@
+div#content {
+ display: flex;
+ align-items: start;
+ height: 100%;
+}
+
+div#content > img {
+ max-width: 60%;
+ height: 100%;
+ object-fit: contain;
+}
+
+div#metadata {
+ margin-left: 15px;
+ width: 100%;
+}
+
+div#metadata > div {
+ display: none;
+}
+
+div#metadata > div.selected {
+ display: inherit !important;
+}
+
+div#metadata-header {
+ display: inherit !important;
+ border-bottom: 1px solid white;
+}
+
+div#metadata-header > a {
+ display: inline-block;
+ padding: 10px 10px 9px 10px;
+}
+
+div#metadata-header > a.selected {
+ border-bottom: 4px solid white;
+ padding-bottom: 5px;
+}
+
+div#metadata-header > a:hover {
+ background: rgba(255, 255, 255, 0.4);
+}
+
+div#metadata-fileinfo > table th {
+ font-size: 8pt;
+}
+
+div#metadata-fileinfo > table td {
+ font-family: 'Lucida Console';
+ font-size: 8pt;
+} \ No newline at end of file
diff --git a/Pages/_ViewStart.cshtml b/Pages/_ViewStart.cshtml
new file mode 100644
index 0000000..1af6e49
--- /dev/null
+++ b/Pages/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+} \ No newline at end of file