Skip to content

Commit

Permalink
cleanup startup
Browse files Browse the repository at this point in the history
  • Loading branch information
joeaudette committed Sep 12, 2016
1 parent d278ff7 commit 621f02b
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 243 deletions.
7 changes: 5 additions & 2 deletions notes/to-do.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

## Miscellaneous

EF storage layer
caching of post/page data
recent posts viewcomponent for homepage

Image Resizing and optimizing for uploaded images via:
https://github.com/JimBobSquarePants/ImageProcessor
http://jamessouth.me/archive/imageprocessor-core/

ado sql storage


## example project stuff

gulp/grunt work for production ie fontawesome copy to folder
using cloudscribe Core with NoDb

using cloudscribe Core with EF

latest trend single page site but the blog would be a separate page

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Author: Joe Audette
// Created: 2016-08-07
// Last Modified: 2016-08-14
// Last Modified: 2016-09-12
//

using cloudscribe.Core.Models;
Expand Down Expand Up @@ -68,6 +68,7 @@ public async Task<IActionResult> Index()
model.PostsPerPage = projectSettings.PostsPerPage;
model.BlogMenuLinksToNewestPost = projectSettings.BlogMenuLinksToNewestPost;
model.DefaultPageSlug = projectSettings.DefaultPageSlug;
model.BlogPagePosition = projectSettings.BlogPagePosition;

bool canManageUsers = false;
try
Expand Down Expand Up @@ -155,8 +156,13 @@ public async Task<IActionResult> Index(ContentSettingsViewModel model)
{
needToClearMenuCache = true;
}
if (projectSettings.BlogPagePosition != model.BlogPagePosition)
{
needToClearMenuCache = true;
}
projectSettings.BlogMenuLinksToNewestPost = model.BlogMenuLinksToNewestPost;
projectSettings.DefaultPageSlug = model.DefaultPageSlug;
projectSettings.BlogPagePosition = model.BlogPagePosition;

await projectService.Update(projectSettings);
if(needToClearMenuCache)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
using cloudscribe.Core.SimpleContent.Integration.Controllers;
using cloudscribe.SimpleContent.Models;
using cloudscribe.SimpleContent.Web.TagHelpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.FileProviders;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;
using cloudscribe.Core.Models;
using Microsoft.AspNetCore.Http;

namespace Microsoft.Extensions.DependencyInjection
{
Expand Down Expand Up @@ -41,7 +46,29 @@ public static RazorViewEngineOptions AddEmbeddedViewsForCloudscribeCoreSimpleCon
return options;
}


public static AuthorizationOptions AddCloudscribeCoreSimpleContentIntegrationDefaultPolicies(this AuthorizationOptions options)
{
options.AddPolicy(
"BlogEditPolicy",
authBuilder =>
{
//authBuilder.RequireClaim("blogId");
authBuilder.RequireRole("Administrators");
}
);

options.AddPolicy(
"PageEditPolicy",
authBuilder =>
{
authBuilder.RequireRole("Administrators");
});

return options;
}




}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Author: Joe Audette
// Created: 2016-08-05
// Last Modified: 2016-08-15
// Last Modified: 2016-09-12
//

using cloudscribe.Core.Models;
Expand Down Expand Up @@ -34,6 +34,8 @@ public ContentSettingsViewModel()

public bool BlogMenuLinksToNewestPost { get; set; } = false;

public int BlogPagePosition { get; set; } = 2; // right after home page


//public string LocalMediaVirtualPath { get; set; } = "/media/images/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
</div>
</div>
<div class="form-group">
<label asp-for="Description" class="col-md-2 control-label">@sr["Blog Tagline"]</label>
<label asp-for="Description" class="col-md-2 control-label">@sr["Blog Menu Position"]</label>
<div class="col-md-10">
<input asp-for="Description" class="form-control" />
<span asp-validation-for="Description" class="text-danger"></span>
<input asp-for="BlogPagePosition" class="form-control" />
<span asp-validation-for="BlogPagePosition" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="PostsPerPage" class="col-md-2 control-label">@sr["Posts Per Page"]</label>
<div class="col-md-10">
<input asp-for="PostsPerPage" class="form-control" />
<span asp-validation-for="PostsPerPage" class="text-danger"></span>
</div>
</div>
<div class="form-group">
Expand Down
3 changes: 3 additions & 0 deletions src/cloudscribe.Core.SimpleContent.Integration/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
"dependencies": {
"cloudscribe.Core.Identity": "1.0.0-*",
"cloudscribe.Core.Models": "1.0.2-*",
"cloudscribe.Core.Web": "1.0.0-*",
"cloudscribe.SimpleContent.Models": "1.0.0-*",
"cloudscribe.SimpleContent.Web": "1.0.0-*",
"cloudscribe.Web.Common": "1.0.0-*",
"cloudscribe.Web.Navigation": "1.0.2-*",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.0-*",
"Microsoft.AspNetCore.Routing": "1.0.0-*",
"Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*",
"Microsoft.Extensions.Localization": "1.0.0-*",
"Microsoft.Extensions.Logging.Abstractions": "1.0.0",
"Microsoft.Extensions.Options": "1.0.0-*",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-*",
"NETStandard.Library": "1.6.0-*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public List<string> Categories
{
get
{
//if(categories.Count == 0)
var list = CategoriesCsv.Split(new char[] { ',' },
StringSplitOptions.RemoveEmptyEntries).Select(c => c.Trim().ToLower()).ToList();

Expand Down Expand Up @@ -111,7 +110,6 @@ public List<PageComment> PageComments
set { pageComments = value; }
}


public static PageEntity FromIPage(IPage page)
{
var p = new PageEntity();
Expand Down
62 changes: 0 additions & 62 deletions src/cloudscribe.SimpleContent.Storage.EFCore/PostQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public async Task<PagedPostResult> GetPosts(
.OrderByDescending(x => x.PubDate)
;


var posts = await query
.AsNoTracking()
.Skip(offset)
Expand All @@ -97,52 +96,6 @@ public async Task<PagedPostResult> GetPosts(
return result;
}

//private async Task<List<Comment>> GetCommentsForPageOfPosts(
// string blogId,
// string category,
// bool includeUnpublished,
// DateTime currentTime,
// int pageNumber,
// int pageSize,
// CancellationToken cancellationToken = default(CancellationToken)
// )
//{
// ThrowIfDisposed();
// cancellationToken.ThrowIfCancellationRequested();

// int offset = (pageSize * pageNumber) - pageSize;


// var result = new List<Comment>();

// var query = from c in dbContext.Comments
// join x in dbContext.Posts
// on c.ContentId equals x.Id
// orderby x.PubDate
// where (
// x.BlogId == blogId
// && (includeUnpublished || (x.IsPublished && x.PubDate <= currentTime))
// && (string.IsNullOrEmpty(category) || (EF.Property<string>(x, "CategoryCsv").Contains(category))) // will this work?
// )

// select c

// ;


// //List<Comment> posts = await query
// // .AsNoTracking()
// // .Skip(offset)
// // .Take(pageSize)
// // .ToListAsync<Post>(cancellationToken)
// // .ConfigureAwait(false);




// return result;
//}

public async Task<int> GetCount(
string blogId,
string category,
Expand Down Expand Up @@ -403,28 +356,13 @@ public async Task<Dictionary<string, int>> GetCategories(

var result = new Dictionary<string, int>();

//var query = dbContext.PostCategories
// .AsNoTracking()
// .Where(t => t.ProjectId == blogId)
// .Select(x => new
// {
// cat = x.Value,
// count = dbContext.PostCategories.Count<PostCategory>(u => u.ProjectId == x.ProjectId && u.Value == x.Value )
// })
// ;

var query = from x in dbContext.PostCategories
join y in dbContext.Posts
on x.PostEntityId equals y.Id
where (
(x.ProjectId.Equals(blogId))
&& (includeUnpublished || (y.IsPublished && y.PubDate <= DateTime.UtcNow))
)
//select new
//{
// cat = x.Value,
// count = dbContext.PostCategories.Count<PostCategory>(u => u.ProjectId == x.ProjectId && u.Value == x.Value )
//}
select x
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public async Task AjaxPost(PageEditViewModel model)
page.MetaDescription = model.MetaDescription;
page.Content = model.Content;
if (page.PageOrder != model.PageOrder) needToClearCache = true;
//post.Categories = categories.ToList();

}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Author: Joe Audette
// Created: 2016-05-27
// Last Modified: 2016-09-08
// Last Modified: 2016-09-12
//

using cloudscribe.SimpleContent.Models;
Expand Down Expand Up @@ -104,8 +104,14 @@ private async Task<TreeNode<NavigationNode>> BuildTreeInternal(NavigationTreeBui
var treeRoot = new TreeNode<NavigationNode>(rootNav);

var rootList = await pageService.GetRootPages().ConfigureAwait(false);
var rootListCount = rootList.Count();
var blogPosition = project.BlogPagePosition;
if (project.AddBlogToPagesTree)
{
if (blogPosition > rootListCount) blogPosition = rootListCount;
}

if(rootList.Count() <= 1)
if (rootListCount <= 1)
{ // if there are no pages we won't hit the loop below so go ahead and add the blog page
if (project.AddBlogToPagesTree)
{
Expand Down Expand Up @@ -138,7 +144,7 @@ private async Task<TreeNode<NavigationNode>> BuildTreeInternal(NavigationTreeBui
foreach (var page in rootList)
{
var node = new NavigationNode();
if (project.AddBlogToPagesTree && rootPosition == project.BlogPagePosition)
if (project.AddBlogToPagesTree && rootPosition == blogPosition)
{
node.Key = project.BlogPageText;
node.ParentKey = "RootNode";
Expand Down
Loading

0 comments on commit 621f02b

Please sign in to comment.