Skip to content

Commit

Permalink
Admin base
Browse files Browse the repository at this point in the history
  • Loading branch information
petervandenhout committed Jul 14, 2019
1 parent 993fe77 commit 4d760b3
Show file tree
Hide file tree
Showing 20 changed files with 311 additions and 264 deletions.
8 changes: 8 additions & 0 deletions samples/Opw.PineBlog.Sample/Areas/Admin/Pages/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@page
@model Opw.PineBlog.Sample.Areas.Admin.Pages.IndexModel
@{
}
<div class="container">
<h1>Admin</h1>
<p>Admin index page.</p>
</div>
16 changes: 16 additions & 0 deletions samples/Opw.PineBlog.Sample/Areas/Admin/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Opw.PineBlog.Sample.Areas.Admin.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
@{
Layout = "~/Pages/Shared/_AdminLayout.cshtml";
Layout = "~/Pages/Shared/_Layout.cshtml";
}
@section head {
<environment include="Development">
<link rel="stylesheet" href="~/themes/default/css/admin.css">
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="~/themes/default/css/admin.min.css" asp-append-version="true">
</environment>
}
@section scripts {
<environment include="Development">
<script src="~/themes/default/js/admin.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
<script src="~/themes/default/js/admin.min.js" asp-append-version="true"></script>
</environment>
}
<partial name="_Header" />
@RenderBody()
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="~/admin">Admin</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="~/admin/posts">Posts</a>
</li>
</ul>
</div>
</div>
</nav>
2 changes: 0 additions & 2 deletions samples/Opw.PineBlog.Sample/Opw.PineBlog.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</PropertyGroup>

<ItemGroup>
<Content Remove="Pages\Shared\_AdminLayout.cshtml" />
<Content Remove="Pages\Shared\_SiteLayout.cshtml" />
<Content Remove="wwwroot\images\avatar-female.png" />
<Content Remove="wwwroot\images\avatar-male.png" />
Expand All @@ -18,7 +17,6 @@
</ItemGroup>

<ItemGroup>
<None Include="Pages\Shared\_AdminLayout.cshtml" />
<None Include="Pages\Shared\_SiteLayout.cshtml" />
</ItemGroup>

Expand Down
20 changes: 0 additions & 20 deletions samples/Opw.PineBlog.Sample/Pages/Shared/_AdminLayout.cshtml

This file was deleted.

2 changes: 0 additions & 2 deletions samples/Opw.PineBlog.Sample/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
<body>
@RenderBody()

<partial name="~/Pages/Shared/_Footer.cshtml" />

<environment include="Development">
<script src="~/js/jquery.js"></script>
<script src="~/js/bootstrap.js"></script>
Expand Down
9 changes: 7 additions & 2 deletions samples/Opw.PineBlog.Sample/Pages/Shared/_SiteLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Layout = "~/Pages/Shared/_Layout.cshtml";
}
<partial name="_CookieConsentPartial" />
<partial name="~/Pages/Shared/_Header.cshtml" />

@RenderBody()
<div class="pineblog">
<partial name="~/Pages/Shared/_Header.cshtml" />

@RenderBody()

<partial name="_Footer.cshtml" />
</div>
5 changes: 0 additions & 5 deletions src/Opw.PineBlog.RazorPages/Areas/Admin/Pages/Index.cshtml

This file was deleted.

30 changes: 30 additions & 0 deletions src/Opw.PineBlog.RazorPages/Areas/Admin/Pages/Posts.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@page
@model PostsModel
@{
var posts = Model.Model;
}
<div class="container">
<h1>Posts</h1>

<table class="table">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Published</th>
<th scope="col">Created</th>
<th scope="col">Modified</th>
</tr>
</thead>
<tbody>
@foreach (var post in posts)
{
<tr>
<td>@post.Title</td>
<td>@post.Published</td>
<td>@post.Created</td>
<td>@post.Modified</td>
</tr>
}
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Opw.PineBlog.Entities;

namespace Opw.PineBlog.Areas.Admin.Pages
{
public class IndexModel : PageModelBase<IndexModel>
public class PostsModel : PageModelBase<PostsModel>
{
private readonly IMediator _mediator;

public IndexModel(IMediator mediator, ILogger<IndexModel> logger) : base(logger)
public IEnumerable<Post> Model { get; private set; }

public PostsModel(IMediator mediator, ILogger<PostsModel> logger) : base(logger)
{
_mediator = mediator;
}

public async Task<IActionResult> OnGetAsync(CancellationToken cancellationToken)
public async Task<IActionResult> OnGetAsync(CancellationToken cancellationToken, [FromQuery]int page = 1)
{
//var result = await _mediator.Send(new GetPagedPostListQuery { Page = page }, cancellationToken);
//var result = await _mediator.Send(new GetPagedPostsQuery { Page = page }, cancellationToken);

//Model = result.Value;
//Title = Model.Blog.Title;

return Page();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
<footer class="footer copy">
<div class="container d-lg-flex text-center text-lg-left">
<p>PineBlog &copy; @DateTime.Now.Year Of Pine Wood (@ViewData["ApplicationVersion"])</p>
<div class="ml-auto">
@if (User.Identity.IsAuthenticated)
{
<a href="~/admin">admin</a>
}
else
{
<a asp-area="Identity" asp-page="/Account/Login">login</a>
}
</div>
</div>
</footer>
@{
//TODO: Update this view from _Footer in sample project
}
<h1>TODO: Update this view from _Footer in sample project</h1>
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
@{
var showTitle = ViewData["ShowTitle"] != null && true;
var showSearch = ViewData["ShowSearch"] != null && true;
//TODO: Update this view from _Header in sample project
}
<header class="blog-header d-flex flex-column">
<div class="container d-flex">
<a href="~/" class="blog-logo my-auto d-flex">
@if (showTitle)
{
@*<span class="my-auto">@Model.Title</span>*@
}
</a>
<ul class="blog-social nav ml-auto my-auto">
@*@await Component.InvokeAsync("HtmlBlock", new { theme = "Standard", widget = "Social Buttons" })*@
</ul>
@if (showSearch)
{
<button class="blog-search-toggle btn-unstyled" type="button" data-toggle="modal" data-target="#blog-search">
<i class="fa fa-search"></i>
</button>
}
</div>
</header>
<h1>TODO: Update this view from _Header in sample project</h1>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>@ViewData["Title"]</title>
</head>
<body>
<h1>Add a custom layout page to your web project in the folder <code>./Areas/Admin/Pages/Shared/</code></h1>
<h1>Add a custom <code>_Layout.cshtml</code> or <code>_AdminLayout.cshtml</code> page to your web project in the folder <code>./Areas/Admin/Pages/Shared/</code></h1>
@RenderBody()
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@{
var showTitle = ViewData["ShowTitle"] != null && true;
var showSearch = ViewData["ShowSearch"] != null && true;
//TODO: Update this view from _Header in sample project
}
<h1>TODO: Update this view from _Header in sample project</h1>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"]</title>
</head>
<body>
<h1>Add a custom layout page to your web project in the folder <code>./Areas/Blog/Pages/Shared/</code></h1>
<body class="pineblog">
<h1>Add a custom <code>_Layout.cshtml</code> or <code>_AdminLayout.cshtml</code> page to your web project in the folder <code>./Areas/Blog/Pages/Shared/</code></h1>
@RenderBody()
</body>
</html>
9 changes: 9 additions & 0 deletions src/Opw.PineBlog.RazorPages/Opw.PineBlog.RazorPages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,14 @@
<EmbeddedResource Include="wwwroot\**\css\*" />
<EmbeddedResource Include="wwwroot\**\js\*" />
</ItemGroup>

<ItemGroup>
<Content Update="Areas\Admin\Pages\Shared\_Footer.cshtml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Areas\Admin\Pages\Shared\_Header.cshtml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

</Project>
Loading

0 comments on commit 4d760b3

Please sign in to comment.