Skip to content

Commit

Permalink
Minor changes and fixes (#42)
Browse files Browse the repository at this point in the history
* update jquery cdn, and remove popper
* add ToPostSlug extension method, and re-add popper
  • Loading branch information
petervandenhout authored Aug 11, 2019
1 parent 83bcdfc commit 2ec7427
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion samples/Opw.PineBlog.Sample/DatabaseSeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CreateBlogPosts()
{
AuthorId = author.Id,
Title = title,
Slug = title.ToSlug(),
Slug = title.ToPostSlug(),
Description = WaffleEngine.Text(1, false),
Published = DateTime.UtcNow.AddDays(-i * 10)
};
Expand Down
4 changes: 2 additions & 2 deletions samples/Opw.PineBlog.Sample/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
<script src="~/js/bootstrap.js"></script>
</environment>
<environment exclude="Development">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
asp-fallback-src="~/js/jquery.min.js"
asp-fallback-test="window.jQuery"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
Expand Down
2 changes: 1 addition & 1 deletion src/Opw.PineBlog.Core/Posts/AddPostCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task<Result<Post>> Handle(AddPostCommand request, CancellationToken
{
AuthorId = author.Id,
Title = request.Title,
Slug = request.Title.ToSlug(),
Slug = request.Title.ToPostSlug(),
Description = request.Description,
Content = request.Content,
Categories = request.Categories,
Expand Down
2 changes: 1 addition & 1 deletion src/Opw.PineBlog.Core/Posts/UpdatePostCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public async Task<Result<Post>> Handle(UpdatePostCommand request, CancellationTo
return Result<Post>.Fail(new NotFoundException<Post>($"Could not find post, id: \"{request.Id}\""));

entity.Title = request.Title;
entity.Slug = request.Title.ToSlug();
entity.Slug = request.Title.ToPostSlug();
entity.Description = request.Description;
entity.Content = request.Content;
entity.Categories = request.Categories;
Expand Down
11 changes: 11 additions & 0 deletions src/Opw.PineBlog.Core/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

namespace Opw.PineBlog
{
public static class StringExtensions
{
public static string ToPostSlug(this string s)
{
return s.ToLower().ToSlug();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@model UpdatePostModel
@{
ViewData["Id"] = Model.Post.Id;
ViewData["Slug"] = Model.Post.Title.ToSlug();
ViewData["Slug"] = Model.Post.Title.ToPostSlug();
ViewData["FilePath"] = Model.Post.Id.ToShortGuid();
}
@section scripts {
Expand Down
2 changes: 1 addition & 1 deletion src/Opw/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class StringExtensions
public static string ToSlug(this string s)
{
string str = s.RemoveDiacritics();
// add add a space before every upercase char
// add a space before every uppercase char
str = Regex.Replace(str, @"(\B[A-Z]+?(?=[A-Z][^A-Z])|\B[A-Z]+?(?=[^A-Z]))", " $1");
str = str.ToLower();

Expand Down
2 changes: 1 addition & 1 deletion tests/Opw.PineBlog.Core.Tests/Posts/AddPostCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task Handler_Should_HaveSlug()

result.IsSuccess.Should().BeTrue();
result.Value.Title.Should().Be("title or slug");
result.Value.Slug.Should().MatchRegex(result.Value.Title.ToSlug());
result.Value.Slug.Should().MatchRegex(result.Value.Title.ToPostSlug());
}

private void SeedDatabase()
Expand Down

0 comments on commit 2ec7427

Please sign in to comment.