Skip to content

Commit

Permalink
Merge pull request #446 from poppastring/category-mapper-updates
Browse files Browse the repository at this point in the history
Ensure everything works for Unique URLS.

Fixes the invalid URLs from category page and the RSS feed.
#442
  • Loading branch information
poppastring authored Aug 14, 2020
2 parents aabc55a + 802f6cd commit f1faa04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions source/DasBlog.Web.Repositories/BlogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public BlogManager( ILogger<BlogManager> logger, IDasBlogSettings dasBlogSetting
/// <param name="dt">if non-null then the post must be dated on that date</param>
public Entry GetBlogPost(string posttitle, DateTime? dt)
{
posttitle = posttitle.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement,string.Empty)
.Replace(".aspx", string.Empty);

if (dt == null)
{
posttitle = posttitle.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, string.Empty)
.Replace(".aspx", string.Empty);

return dataService.GetEntry(posttitle);
}
else
{
var entries = dataService.GetEntriesForDay(dt.Value, null, null, 1, 10, null);

return entries.FirstOrDefault(e => dasBlogSettings.GeneratePostUrl(e)
.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, string.Empty) == posttitle);
.EndsWith(posttitle, StringComparison.OrdinalIgnoreCase));
}
}

Expand Down
5 changes: 3 additions & 2 deletions source/DasBlog.Web.UI/Mappers/ProfilePost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public ProfilePost(IDasBlogSettings dasBlogSettings)

CreateMap<Entry, CategoryPostItem>()
.ForMember(dest => dest.BlogTitle, opt => opt.MapFrom(src => src.Title))
.ForMember(dest => dest.BlogId, opt => opt.MapFrom(src => src.EntryId));

.ForMember(dest => dest.BlogId, opt => opt.MapFrom(src => _dasBlogSettings.GeneratePostUrl(src)))
.ForMember(dest => dest.Category, opt => opt.MapFrom(src => src.GetSplitCategories().FirstOrDefault()))
.ForMember(dest => dest.Date, opt => opt.MapFrom(src => src.CreatedLocalTime));

CreateMap<Tag, TagViewModel>()
.ForMember(dest => dest.Allowed, opt => opt.MapFrom(src => src.Allowed))
Expand Down

0 comments on commit f1faa04

Please sign in to comment.