From f9768f3c33b98f38a12c4bb500c27a2c8d4fffec Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 7 Nov 2019 01:32:15 +0000 Subject: [PATCH] Add administrative area. --- .../Areas/Admin/Controllers/HomeController.cs | 48 ++++++ .../Areas/Admin/Views/Home/Index.cshtml | 37 +++++ .../Areas/Admin/Views/Shared/_Layout.cshtml | 137 ++++++++++++++++++ .../Admin}/Views/Shared/_LoginPartial.cshtml | 0 .../DiscImageChef.Server.csproj | 13 ++ DiscImageChef.Server/Startup.cs | 4 +- .../Views/Shared/_Layout.cshtml | 1 - 7 files changed, 237 insertions(+), 3 deletions(-) create mode 100644 DiscImageChef.Server/Areas/Admin/Controllers/HomeController.cs create mode 100644 DiscImageChef.Server/Areas/Admin/Views/Home/Index.cshtml create mode 100644 DiscImageChef.Server/Areas/Admin/Views/Shared/_Layout.cshtml rename DiscImageChef.Server/{ => Areas/Admin}/Views/Shared/_LoginPartial.cshtml (100%) diff --git a/DiscImageChef.Server/Areas/Admin/Controllers/HomeController.cs b/DiscImageChef.Server/Areas/Admin/Controllers/HomeController.cs new file mode 100644 index 00000000..d3a39679 --- /dev/null +++ b/DiscImageChef.Server/Areas/Admin/Controllers/HomeController.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : HomeController.cs +// Author(s) : Natalia Portillo +// +// Component : DiscImageChef Server. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides documentation data for razor views. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; + +namespace DiscImageChef.Server.Areas.Admin.Controllers +{ + [Area("Admin"), Authorize] + public class HomeController : Controller + { + readonly IWebHostEnvironment _environment; + + public HomeController(IWebHostEnvironment environment) => _environment = environment; + + public ActionResult Index() => View(); + } +} \ No newline at end of file diff --git a/DiscImageChef.Server/Areas/Admin/Views/Home/Index.cshtml b/DiscImageChef.Server/Areas/Admin/Views/Home/Index.cshtml new file mode 100644 index 00000000..e2bce4c1 --- /dev/null +++ b/DiscImageChef.Server/Areas/Admin/Views/Home/Index.cshtml @@ -0,0 +1,37 @@ +@{ + Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "DiscImageChef"; +} +@{ + // /*************************************************************************** + // The Disc Image Chef + // ---------------------------------------------------------------------------- + // + // Filename : Index.cshtml + // Author(s) : Natalia Portillo + // + // Component : DiscImageChef Server. + // + // --[ Description ] ---------------------------------------------------------- + // + // Renders readme. + // + // --[ License ] -------------------------------------------------------------- + // + // This library is free software; you can redistribute it and/or modify + // it under the terms of the GNU Lesser General Public License as + // published by the Free Software Foundation; either version 2.1 of the + // License, or (at your option) any later version. + // + // This library is distributed in the hope that it will be useful, but + // WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + // Lesser General Public License for more details. + // + // You should have received a copy of the GNU Lesser General Public + // License along with this library; if not, see . + // + // ---------------------------------------------------------------------------- + // Copyright © 2011-2019 Natalia Portillo + // ****************************************************************************/ +} \ No newline at end of file diff --git a/DiscImageChef.Server/Areas/Admin/Views/Shared/_Layout.cshtml b/DiscImageChef.Server/Areas/Admin/Views/Shared/_Layout.cshtml new file mode 100644 index 00000000..30e1cda7 --- /dev/null +++ b/DiscImageChef.Server/Areas/Admin/Views/Shared/_Layout.cshtml @@ -0,0 +1,137 @@ +@using Microsoft.AspNetCore.Identity +@inject SignInManager SignInManager +@inject UserManager UserManager +@{ + // /*************************************************************************** + // The Disc Image Chef + // ---------------------------------------------------------------------------- + // + // Filename : _Layout.cshtml + // Author(s) : Natalia Portillo + // + // Component : DiscImageChef Server. + // + // --[ Description ] ---------------------------------------------------------- + // + // Contains layout. + // + // --[ License ] -------------------------------------------------------------- + // + // This library is free software; you can redistribute it and/or modify + // it under the terms of the GNU Lesser General Public License as + // published by the Free Software Foundation; either version 2.1 of the + // License, or (at your option) any later version. + // + // This library is distributed in the hope that it will be useful, but + // WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + // Lesser General Public License for more details. + // + // You should have received a copy of the GNU Lesser General Public + // License along with this library; if not, see . + // + // ---------------------------------------------------------------------------- + // Copyright © 2011-2019 Natalia Portillo + // ****************************************************************************/ +} + + + + + @switch (DateTime.UtcNow.DayOfYear) + { + // 24th January, Macintosh launch + case 24: + + + break; + // 23rd July, Amiga launch + case 204: + + + break; + default: + + + break; + } + + @ViewBag.Title + + + + + +
+ Welcome to + + + DiscImageChef + + Server Administrative Area + @if (SignInManager.IsSignedIn(User)) + { + + } + else + { +
+ Login +
+ } +
+@RenderBody() +
+ © 2021-2019 + + Claunia.com + +
+ @switch (DateTime.UtcNow.DayOfYear) + { + // 24th January, Macintosh launch + case 24: + @Html.Raw("Fonts are © 2014 Robin Casady") + ; + break; + // 23rd July, Amiga launch + case 204: + @Html.Raw("Fonts are © 2013 TrueSchool Ascii") + ; + break; + default: + @Html.Raw("Fonts are © 2015 - 2016 VileR") + ; + break; + } +
+ CSS © 2018-2019 + + Bootstrap + and + + Claunia.com + +
+@RenderSection("Scripts", false) + + + + + \ No newline at end of file diff --git a/DiscImageChef.Server/Views/Shared/_LoginPartial.cshtml b/DiscImageChef.Server/Areas/Admin/Views/Shared/_LoginPartial.cshtml similarity index 100% rename from DiscImageChef.Server/Views/Shared/_LoginPartial.cshtml rename to DiscImageChef.Server/Areas/Admin/Views/Shared/_LoginPartial.cshtml diff --git a/DiscImageChef.Server/DiscImageChef.Server.csproj b/DiscImageChef.Server/DiscImageChef.Server.csproj index c7f2bb90..63017579 100644 --- a/DiscImageChef.Server/DiscImageChef.Server.csproj +++ b/DiscImageChef.Server/DiscImageChef.Server.csproj @@ -86,6 +86,19 @@ <_ContentIncludedByDefault Remove="wwwroot\js\site.js" /> <_ContentIncludedByDefault Remove="wwwroot\css\js\colors\dos.js" /> <_ContentIncludedByDefault Remove="wwwroot\css\js\colors\mac.js" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Shared\Error.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Shared\_CookieConsentPartial.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Shared\_Layout.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Shared\_LoginPartial.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Shared\_ValidationScriptsPartial.cshtml" /> + + + + + + + + diff --git a/DiscImageChef.Server/Startup.cs b/DiscImageChef.Server/Startup.cs index 0e65aa6e..80490da9 100644 --- a/DiscImageChef.Server/Startup.cs +++ b/DiscImageChef.Server/Startup.cs @@ -57,14 +57,14 @@ namespace DiscImageChef.Server app.UseRouting(); - app.UseAuthorization(); - app.UseAuthentication(); + app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); + endpoints.MapAreaControllerRoute("Admin", "Admin", "Admin/{controller=Home}/{action=Index}/{id?}"); }); } } diff --git a/DiscImageChef.Server/Views/Shared/_Layout.cshtml b/DiscImageChef.Server/Views/Shared/_Layout.cshtml index bff931bc..b02c9a4d 100644 --- a/DiscImageChef.Server/Views/Shared/_Layout.cshtml +++ b/DiscImageChef.Server/Views/Shared/_Layout.cshtml @@ -67,7 +67,6 @@ - @RenderBody()