diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e4b5498..b0ec85e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -36,7 +36,11 @@ "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], - "problemMatcher": "$msCompile" + "problemMatcher": "$msCompile", + "group": { + "kind": "build", + "isDefault": true + } } ] } diff --git a/Models/Document.cs b/Models/Document.cs index c789041..722c491 100644 --- a/Models/Document.cs +++ b/Models/Document.cs @@ -8,13 +8,16 @@ namespace Snootalogue.Models { public int ID { get; set; } public string Filename { get; set; } public string Hash { get; set; } + [UIHint("FileSize")] public long Size { get; set; } public string Title { get; set; } + [UIHint("CommaSeparatedList")] public List Authors { get; set; } public string Category { get; set; } [Display(Name = "Release Date")] public DateTime DateAdded { get; set; } + [UIHint("CommaSeparatedList")] public List Tags { get; set; } public Boolean Read { get; set; } } diff --git a/Models/SeedData.cs b/Models/SeedData.cs index 52c7d96..00d9095 100644 --- a/Models/SeedData.cs +++ b/Models/SeedData.cs @@ -20,10 +20,11 @@ namespace Snootalogue.Models { new Document { Title = "The Peebler Chronicles", Filename = "peebler.pdf", - Size = 5 * 1024 * 1024, + Size = Convert.ToInt64(0.5 * 1024 * 1024), DateAdded = DateTime.UtcNow, Authors = new List() { "Pempos", "Artep" }, - Category = "News" + Category = "News", + Hash = "0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0" }, new Document { Title = "Smooched by a Wifeoid", @@ -32,15 +33,17 @@ namespace Snootalogue.Models { DateAdded = DateTime.UtcNow, Authors = new List() { "Lynne", "Petra" }, Category = "Romance", - Read = true + Read = true, + Hash = "0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0" }, new Document { Title = "What on Boo Earth? My Girlfriend can Walk on the Ceiling?!", Filename = "ceiling_gf.pdf", - Size = 22 * 1024 * 1024, + Size = Convert.ToInt64(22.5 * 1024 * 1024), DateAdded = DateTime.UtcNow, Authors = new List() { "Lynne" }, - Category = "Romance" + Category = "Romance", + Hash = "0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0" } ); diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml index 3057cad..0ef4627 100644 --- a/Pages/Index.cshtml +++ b/Pages/Index.cshtml @@ -1,58 +1,32 @@ @page @model Snootalogue.Pages.IndexModel +@{ + ViewData["Title"] = "Home"; +} -

Documents

+@*

Documents

*@ +
+ @foreach (var item in Model.Documents) { +
+
+
+
@Html.DisplayFor(modelItem => item.Title)
+
By @Html.DisplayFor(modelItem => item.Authors)
+
Category: @Html.DisplayFor(modelItem => item.Category)
+
@Html.DisplayFor(modelItem => item.Tags)
+ @{string hash = item.Hash.Substring(0, 8);} + +
+
+ @* TODO: replace these with font awesome or something *@ +
+ View + Details + Edit + Delete +
+
- - - - - @* *@ - - - - - - - - - @foreach (var item in Model.Documents) { - - - - - - - - - } - - - -
- @Html.DisplayNameFor(model => model.Documents[0].Title) - - @Html.DisplayNameFor(model => model.Documents[0].Authors) - - @Html.DisplayNameFor(model => model.Documents[0].Category) - - @Html.DisplayNameFor(model => model.Documents[0].Size) - - @Html.DisplayNameFor(model => model.Documents[0].Read) - - @Html.DisplayNameFor(model => model.Documents[0].DateAdded) -
- @Html.DisplayFor(modelItem => item.Title) - - @Html.DisplayFor(modelItem => item.Category) - - @Html.DisplayFor(modelItem => item.Size) - - @Html.DisplayFor(modelItem => item.Read) - - @Html.DisplayFor(modelItem => item.DateAdded) - - Details - Edit - Delete -
+
+ } +
diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml new file mode 100644 index 0000000..e967518 --- /dev/null +++ b/Pages/Shared/_Layout.cshtml @@ -0,0 +1,22 @@ + + + + + + + @ViewData["Title"] | Snootalogue + + + + + + +
+ @RenderBody() +
+ + + diff --git a/Pages/_ViewStart.cshtml b/Pages/_ViewStart.cshtml new file mode 100644 index 0000000..e1b65b4 --- /dev/null +++ b/Pages/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} diff --git a/Startup.cs b/Startup.cs index 473e237..08a164c 100644 --- a/Startup.cs +++ b/Startup.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Westwind.AspNetCore.LiveReload; using Snootalogue.Data; namespace Snootalogue { @@ -17,7 +18,8 @@ namespace Snootalogue { // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services.AddRazorPages(); + services.AddLiveReload(); + services.AddRazorPages().AddRazorRuntimeCompilation(); services.AddDbContext(options => options.UseSqlite(Configuration.GetConnectionString("SnootalogueContext")) ); @@ -25,10 +27,13 @@ namespace Snootalogue { // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + app.UseLiveReload(); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } + app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { diff --git a/Views/Shared/DisplayTemplates/CommaSeparatedList.cshtml b/Views/Shared/DisplayTemplates/CommaSeparatedList.cshtml new file mode 100644 index 0000000..b94c498 --- /dev/null +++ b/Views/Shared/DisplayTemplates/CommaSeparatedList.cshtml @@ -0,0 +1,14 @@ +@using System.Text; +@model List + +@{ + if (@Model == null || @Model.Count == 0) { + + } else { + var sb = new StringBuilder(); + foreach(var item in @Model) { + sb.AppendFormat("{0}, ", item); + } + @sb.ToString().Substring(0, sb.Length - 2) + } +} diff --git a/Views/Shared/DisplayTemplates/FileSize.cshtml b/Views/Shared/DisplayTemplates/FileSize.cshtml new file mode 100644 index 0000000..c909799 --- /dev/null +++ b/Views/Shared/DisplayTemplates/FileSize.cshtml @@ -0,0 +1,15 @@ +@model long + +@{ + string[] suffixes = {"", "K", "M", "G", "T", "P"}; + double x = @Model; + int i = 0; + while (x > 1024) { + x = x / 1024.0; + i++; + } + if (i == 0){ + @x bytes + } else { + @x @suffixes[i]iB + }} diff --git a/snootalogue.csproj b/snootalogue.csproj index 255ee78..c2cb0d3 100644 --- a/snootalogue.csproj +++ b/snootalogue.csproj @@ -5,6 +5,7 @@ + @@ -15,6 +16,7 @@ + diff --git a/wwwroot/css/style.css b/wwwroot/css/style.css new file mode 100644 index 0000000..65d33a2 --- /dev/null +++ b/wwwroot/css/style.css @@ -0,0 +1,104 @@ +body { + font-family: sans-serif; + margin: 0; +} + +h1, h2, h3, h4, h5, h6 { + font-weight: 200; +} + +a.simple { + text-decoration: none; +} + +.vertical-buttons { + display: flex; + flex-direction: column; +} +.vertical-buttons a.button { + flex: 1; + color: #a66; + background: white; + border: thin #a66 solid; + border-bottom: none; + padding: 5px; + text-align: center; + transition: 0.2s all; +} +.vertical-buttons a.button:hover { + background: #a66; + color: white; +} +.vertical-buttons a.button:first-child { + border-radius: 5px 5px 0 0; +} +.vertical-buttons a.button:last-child { + border-bottom: thin #a66 solid; + border-radius: 0 0 5px 5px; +} + +nav { + padding: 20px 15px; + background: #a00; + color: white; + display: flex; + justify-content: space-between; +} +#nav-links { + font-size: 1.4em; +} +#nav-links, #nav-search { + margin: auto 0; +} + +main { + padding: 20px; +} + +.documents { + display: flex; + flex-direction: column; +} +.document { + display: flex; + flex: 1; + flex-direction: row; + margin: 10px; +} + +.document-column { + width: 10%; +} +.document-column.left { + background-size: contain; + background-repeat: no-repeat; + background-position: center; +} +.document-column.centre { + width: 80%; +} +.document-column.right ul { + list-style: none; + padding: 0; +} +.document-column.centre div { + margin: 3px 0; +} +.document-column .title { + font-size: 1.2em; + text-align: center; +} +.document-column .authors { + text-align: center; +} +.document-column .tags { + font-size: 0.8em; +} +.document-column .tags .list-empty::before { + display: inline-block; + content: "No tags"; +} +.document-column .metadata { + font-size: 0.8em; + color: #888; +} diff --git a/wwwroot/img/placeholder.png b/wwwroot/img/placeholder.png new file mode 100644 index 0000000..44842e4 Binary files /dev/null and b/wwwroot/img/placeholder.png differ diff --git a/wwwroot/img/placeholder.xcf b/wwwroot/img/placeholder.xcf new file mode 100644 index 0000000..238f10f Binary files /dev/null and b/wwwroot/img/placeholder.xcf differ