there is now a shitty document viewer
This commit is contained in:
parent
6d44b579d2
commit
4f0ac6ef5b
5 changed files with 70 additions and 3 deletions
10
Pages/Documents/View.cshtml
Normal file
10
Pages/Documents/View.cshtml
Normal file
|
@ -0,0 +1,10 @@
|
|||
@page "{id:int}"
|
||||
@model Snootalogue.Pages.Documents.ViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = $"Viewing \"{Model.Document.Title}\"";
|
||||
ViewData["SlimNavbar"] = true;
|
||||
ViewData["NoMainPadding"] = true;
|
||||
}
|
||||
|
||||
<iframe id="document-viewer" src="/Content/@Model.Document.Filename"></iframe>
|
31
Pages/Documents/View.cshtml.cs
Normal file
31
Pages/Documents/View.cshtml.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Snootalogue.Data;
|
||||
using Snootalogue.Models;
|
||||
|
||||
namespace Snootalogue.Pages.Documents {
|
||||
public class ViewModel : PageModel {
|
||||
private readonly SnootalogueContext _context;
|
||||
public Document Document { get; set; }
|
||||
|
||||
public ViewModel(SnootalogueContext context) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id) {
|
||||
if (id == null) {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Document = await _context.Document.FirstOrDefaultAsync(d => d.ID == id);
|
||||
|
||||
if (Document == null) {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
<div class="document">
|
||||
<div class="document-column left" style="background-image:url('/img/placeholder.png');"></div>
|
||||
<div class="document-column centre">
|
||||
<div class="title"><a href="/Content/@item.Filename">@Html.DisplayFor(modelItem => item.Title)</a></div>
|
||||
<div class="title"><a asp-page="./Documents/View" asp-route-id="@item.ID">@Html.DisplayFor(modelItem => item.Title)</a></div>
|
||||
<div class="authors">By @Html.DisplayFor(modelItem => item.Authors)</div>
|
||||
<div class="category">Category: @Html.DisplayFor(modelItem => item.Category)</div>
|
||||
<div class="tags">@Html.DisplayFor(modelItem => item.Tags)</div>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<nav @{if (ViewData.ContainsKey("SlimNavbar")) {<text>class = "slim"</text>}}>
|
||||
<div id="nav-links"><a href="/">Snootalogue</a></div>
|
||||
<div id="nav-controls">
|
||||
<input id="nav-search" type="search" placeholder="Search...">
|
||||
|
@ -18,7 +18,7 @@
|
|||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<main @{if (ViewData.ContainsKey("NoMainPadding")) {<text>class = "no-padding"</text>}}>
|
||||
@RenderBody()
|
||||
</main>
|
||||
</body>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
body {
|
||||
font-family: sans-serif;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
|
@ -78,6 +82,11 @@ nav {
|
|||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
nav.slim {
|
||||
padding: 5px 15px;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
#nav-links {
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
@ -87,8 +96,19 @@ nav {
|
|||
#nav-links, #nav-search {
|
||||
margin: auto 0;
|
||||
}
|
||||
#nav-search {
|
||||
padding: 8px;
|
||||
border: thin #a66 solid;
|
||||
}
|
||||
nav.slim #nav-search {
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
main {
|
||||
flex-grow: 1;
|
||||
margin: 0;
|
||||
}
|
||||
main:not(.no-padding) {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
@ -156,6 +176,12 @@ main {
|
|||
width: min-content;
|
||||
}
|
||||
|
||||
#document-viewer {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media only screen and (min-width: 1000px) {
|
||||
.documents {
|
||||
max-width: 80%;
|
||||
|
|
Loading…
Reference in a new issue