danielpalme / mvcblog Goto Github PK
View Code? Open in Web Editor NEWBlog engine based on ASP.NET Core 8 and Twitter Bootstrap 4
License: Apache License 2.0
Blog engine based on ASP.NET Core 8 and Twitter Bootstrap 4
License: Apache License 2.0
When deleting a BlogEntry the EF will cascade delete the TagBlogEntries table but the Tags table isn't affected resulting in a lot of tag-orphans.
This means that the Tags section (sidebar) is stil displaying the deleted Tags (effective after an hour or application restart).
I've fixed it by adding Tag deletion code in the HandleAsync of the DeleteBlogEntryCommandHandler but maybe I'm overlooking something.....
By the way, why the 3600 cacheduration on the sidebar?
Great project!
Do you have any plans to work on sitemap creation in the blog to make it more search engine friendly?
private async Task AddTagsAsync(BlogEntry entry, IEnumerable<string> tags)
{
var existingTags = await this.unitOfWork.Tags.ToListAsync();
if (entry.Tags == null)
{
entry.Tags = new Collection<BlogEntryTag>();
}
foreach (var tag in entry.Tags.Where(t => !tags.Contains(t.Tag.Name)).ToArray())
{
entry.Tags.Remove(tag);
}
foreach (var tag in tags.Where(t => !entry.Tags.Select(et => et.Tag.Name).Contains(t)).ToArray())
{
var existingTag = existingTags.SingleOrDefault(t => t.Name.Equals(tag, StringComparison.OrdinalIgnoreCase));
if (existingTag == null)
{
existingTag = new Tag() { Name = tag };
existingTags.Add(existingTag);
this.unitOfWork.Tags.Add(existingTag);
}
entry.Tags.Add(new BlogEntryTag()
{
BlogEntryId = entry.Id,
TagId = existingTag.Id
});
}
}
Why do you fetching all tags here?
var existingTags = await this.unitOfWork.Tags.ToListAsync();
Is there any way to make the search also search the content as well, and not just the post title, etc.? I'm trying to include a wider search functionality.
Hello, I'm having problems with T4MVC. If I Debug T4 template or Run custom tool, I get these errors that won't go away:
Error 41 A namespace cannot directly contain members such as fields or methods C:\Users\edr\Downloads\MVCBlog-master2\MVCBlog-master\src\MVCBlog.Website\T4MVC.cs 1 1 MVCBlog.Website
Error 42 Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration c:\Users\edr\Downloads\MVCBlog-master2\MVCBlog-master\src\MVCBlog.Website\T4MVC.tt 1 1 MVCBlog.Website
Error 43 Compiling transformation: Method must have a return type c:\Users\edr\Downloads\MVCBlog-master2\MVCBlog-master\src\MVCBlog.Website\T4MVC.tt 1 6 MVCBlog.Website
Error 44 Compiling transformation: Type expected c:\Users\edr\Downloads\MVCBlog-master2\MVCBlog-master\src\MVCBlog.Website\T4MVC.tt 1 12 MVCBlog.Website
Do you know anything about this?
I have implemented your spam protection to my asp.net core 3.1 project but it's not building the <input type="hidden" name="SpamProtectionTimeStamp" value="1592192250" />
as it does on your site.
I'm not sure how to provide a bug as nothing shows up on my contact for but I am mirroring what's going on in your MVCBlog.
Do you know of something else I could try and look at? perhaps I'm missing something?
I'm using both Spam files in a /Helpers directory in a single project so my _ViewImports.cshtml file looks like this: @addTagHelper MySite.Helpers.SpamProtectionTagHelper, MySite
foreach (var tag in tags.Where(t => !entry.Tags.Select(et => et.Tag.Name).Contains(t)).ToArray())
{
var existingTag = existingTags.SingleOrDefault(t => t.Name.Equals(tag, StringComparison.OrdinalIgnoreCase));
if (existingTag == null)
{
existingTag = new Tag() { Name = tag };
existingTags.Add(existingTag);
this.unitOfWork.Tags.Add(existingTag);
}
entry.Tags.Add(new BlogEntryTag()
{
BlogEntryId = entry.Id,
TagId = existingTag.Id
});
}
AddOrUpdateBlogEntryCommandHandler.cs line: 84
var existingTag = existingTags.SingleOrDefault(t => t.Name.Equals(tag, StringComparison.OrdinalIgnoreCase));
In this line SingleOrDefault will throw an exception if existingTag is null. So, it seems there is no meaning of cheking existingTag if null or not.
if (existingTag == null)
{
existingTag = new Tag() { Name = tag };
existingTags.Add(existingTag);
this.unitOfWork.Tags.Add(existingTag);
}
I'm just asking to learn and understand. Why didn't you use FirstOfDefault instead of SingleOrDefault? Thank you.
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'MVCBlog.Website'.
Source Error:
Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="MVCBlog.Website.MvcApplication" Language="C#" %>
Source File: /global.asax Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237
how can i fix ?
Hi,
When I download the zip file and try to run the solution, I get 334 errors (i.e. "The type or namespace name 'Elmah' could not be found (are you missing a using directive or an assembly reference?).
I'm using VS 2015 community and Windows 10 with anniversary update.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.