Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using SeoToolkit.Umbraco.Common.Core.Interfaces;
using SeoToolkit.Umbraco.Common.Core.Models.ViewModels;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Models;

namespace SeoToolkit.Umbraco.MetaFields.Core.Common.DisplayProviders
{
[Weight(100)]
public class MetaFieldsContentDisplayProvider : ISeoDisplayProvider
{
public SeoDisplayViewModel Get(IContent content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public IActionResult Get(int nodeId, string culture)
Title = key.Title,
Description = key.Description,
GroupAlias = key.GroupAlias,
Suggestions = key.Suggestions.Select(it => it.ToViewModel()).ToArray(),
Value = humanReadableValue?.ToString(),
UserValue = userValue,
EditView = key.EditEditor.View,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Html;

namespace SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField
Expand All @@ -9,6 +10,7 @@ public interface ISeoField
string Alias { get; }
string Description { get; }
string GroupAlias { get; }
List<ISeoFieldSuggestion> Suggestions { get; }
Type FieldType { get; }
ISeoFieldEditor Editor { get; }
ISeoFieldEditEditor EditEditor { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField.ViewModels;

namespace SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField
{
public interface ISeoFieldSuggestion
{
string Alias { get; }

SeoSuggestionViewModel ToViewModel();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Html;
Expand All @@ -19,6 +20,7 @@ public class KeywordsField : ISeoField
public string Alias => SeoFieldAliasConstants.Keywords;
public string Description => "Keywords for the page";
public string GroupAlias => SeoFieldGroupConstants.MetaFieldsGroup;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>();
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new KeywordsFieldPropertyEditor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;
using System.Web;
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
Expand All @@ -16,6 +17,7 @@ public class OpenGraphDescriptionField : ISeoField
public string Alias => SeoFieldAliasConstants.OpenGraphDescription;
public string Description => "Description for Open Graph";
public string GroupAlias => SeoFieldGroupConstants.SocialMediaGroup;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>();
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using SeoToolkit.Umbraco.MetaFields.Core.Constants;
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
Expand All @@ -19,6 +20,7 @@ public class OpenGraphImageField : ISeoField
public string Alias => SeoFieldAliasConstants.OpenGraphImage;
public string Description => "Image for Open Graph";
public string GroupAlias => SeoFieldGroupConstants.SocialMediaGroup;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>();
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] { "Umbraco.MediaPicker", "Umbraco.MediaPicker3" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;
using System.Web;
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
Expand All @@ -16,6 +17,7 @@ public class OpenGraphTitleField : ISeoField
public string Alias => SeoFieldAliasConstants.OpenGraphTitle;
public string Description => "Title for open graph";
public string GroupAlias => SeoFieldGroupConstants.SocialMediaGroup;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>();
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] { "Umbraco.TextBox", "Umbraco.TextArea", "Umbraco.TinyMCE" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;
using System.Web;
using System.Collections.Generic;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldSuggestions;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
Expand All @@ -16,6 +18,10 @@ public class SeoDescriptionField : ISeoField
public string Alias => SeoFieldAliasConstants.MetaDescription;
public string Description => "Meta description for the page";
public string GroupAlias => SeoFieldGroupConstants.MetaFieldsGroup;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>
{
new SeoFieldMaxLengthSuggestion() { MaxLength = 160 }
};
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Html;
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;

Expand All @@ -10,6 +11,7 @@ public abstract class SeoField<T> : ISeoField
public abstract string Alias { get; }
public abstract string Description { get; }
public abstract string GroupAlias { get; }
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>();
public Type FieldType => typeof(T);
public abstract ISeoFieldEditor Editor { get; }
public abstract ISeoFieldEditEditor EditEditor { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;
using System.Web;
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
Expand All @@ -16,6 +17,7 @@ public class SeoSchemaField : ISeoField
public string Alias => SeoFieldAliasConstants.Schema;
public string Description => "The schemas are a set of 'types', each associated with a set of properties. The types are arranged in a hierarchy.";
public string GroupAlias => SeoFieldGroupConstants.Others;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>();
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] { "Umbraco.TextBox", "Umbraco.TextArea", "Umbraco.TinyMCE" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldEditors;
using System.Web;
using System.Collections.Generic;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldSuggestions;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField
{
Expand All @@ -16,6 +18,10 @@ public class SeoTitleField : ISeoField
public string Alias => SeoFieldAliasConstants.Title;
public string Description => "Title for the page";
public string GroupAlias => SeoFieldGroupConstants.MetaFieldsGroup;
public List<ISeoFieldSuggestion> Suggestions { get; } = new List<ISeoFieldSuggestion>
{
new SeoFieldMaxLengthSuggestion() { MaxLength = 60 }
};
public Type FieldType => typeof(string);

public ISeoFieldEditor Editor => new SeoFieldFieldsEditor(new[] { "Umbraco.TextBox", "Umbraco.TextArea", "Umbraco.TinyMCE" });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField.ViewModels
{
Expand All @@ -8,6 +9,7 @@ public class SeoSettingsFieldViewModel
public string Title { get; set; }
public string Description { get; set; }
public string GroupAlias { get; set; }
public SeoSuggestionViewModel[] Suggestions { get; set; }
public string Value { get; set; }
public object UserValue { get; set; }
public string EditView { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField.ViewModels
{
public class SeoSuggestionViewModel
{
public string Alias { get; set; }
public Dictionary<string, object> Config { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using SeoToolkit.Umbraco.MetaFields.Core.Interfaces.SeoField;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoField.ViewModels;
using System.Collections.Generic;

namespace SeoToolkit.Umbraco.MetaFields.Core.Models.SeoFieldSuggestions
{
public class SeoFieldMaxLengthSuggestion : ISeoFieldSuggestion
{
public string Alias => "maxLength";
public int MaxLength { get; set; }

public SeoSuggestionViewModel ToViewModel()
{
return new SeoSuggestionViewModel
{
Alias = Alias,
Config = new Dictionary<string, object>
{
{ "maxLength", MaxLength }
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageProjectUrl>https://github.com/patrickdemooij9/SeoToolkit.Umbraco</PackageProjectUrl>
<RepositoryUrl>https://github.com/patrickdemooij9/SeoToolkit.Umbraco</RepositoryUrl>
<PackageIconUrl>https://raw.githubusercontent.com/patrickdemooij9/SeoToolkit.Umbraco/main/package/SeoToolkitIcon.png</PackageIconUrl>
<Version>3.9.0</Version>
<Version>3.10.0-beta1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/patrickdemooij9/SeoToolkit.Umbraco</PackageProjectUrl>
<RepositoryUrl>https://github.com/patrickdemooij9/SeoToolkit.Umbraco</RepositoryUrl>
<PackageIconUrl>https://raw.githubusercontent.com/patrickdemooij9/SeoToolkit.Umbraco/main/package/SeoToolkitIcon.png</PackageIconUrl>
<Version>3.9.0</Version>
<Version>3.10.0-beta1</Version>
<StaticWebAssetBasePath>App_Plugins/SeoToolkit</StaticWebAssetBasePath>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
</umb-property-editor>
<small class="property-fallback-info" ng-if="field.value">Fallback value: <strong>{{vm.getValue(field)}}</strong></small>
<small class="property-fallback-info" ng-if="!field.value">No fallback value found!</small>
<div ng-if="field.suggestions.length > 0">
<div ng-repeat="suggestion in field.suggestions" class="field-suggestion">
<p ng-if="suggestion.alias === 'maxLength'" ng-class="{'valid': !field.getValue() || field.getValue().length < suggestion.config.maxLength }">
Best practice: Length of the text to be lower than {{ suggestion.config.maxLength }} characters.
</p>
</div>
</div>
</div>
</div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/SeoToolkit.Umbraco.MetaFields/wwwroot/MetaFields/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
color: #515054;
}

.field-suggestion {
font-size: 0.9em;
color: #f44336;
margin-top: 2px;
}

.field-suggestion > .valid {
color: #4caf50;
}

.seo-content .groups {
display: flex;
}

.seo-content .groups .properties{
width: 60%;
padding-right: 60px;
flex-shrink: 0;
}

/* Previewers */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MissingDescriptionCheck : ISiteCheck
public string Name => "Missing Description Check";
public string Alias => "MissingDescriptionCheck";
public string Description => "Checks if you are missing any descriptions";
public string ErrorMessage => "Your site has invalid descriptions!";
public string ErrorMessage => "Your site has missing meta descriptions!";
public IEnumerable<CheckPageCrawlResult> RunCheck(CrawledPageModel page, SiteAuditContext context)
{
if (page.Content == null) yield break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using SeoToolkit.Umbraco.Common.Core.Interfaces;
using SeoToolkit.Umbraco.Common.Core.Models.ViewModels;
using System;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Models;

namespace SeoToolkit.Umbraco.SiteAudit.Core.Collections
{
[Weight(200)]
public class SiteAuditDisplayProvider : ISeoDisplayProvider
{
public SeoDisplayViewModel Get(IContent content)
{
return new SeoDisplayViewModel()
{
Alias = "pageChecks",
Name = "Page checks",
View = "/App_Plugins/SeoToolkit/SiteAudit/Interface/SeoDisplays/pageChecks.html"
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using SeoToolkit.Umbraco.SiteAudit.Core.Notifications;
using SeoToolkit.Umbraco.SiteAudit.Core.Repositories;
using SeoToolkit.Umbraco.SiteAudit.Core.Services;
using SeoToolkit.Umbraco.Common.Core.Collections;

namespace SeoToolkit.Umbraco.SiteAudit.Core.Composers
{
Expand All @@ -45,6 +46,9 @@ public void Compose(IUmbracoBuilder builder)
.Append<BrokenImageCheck>()
.Append<MissingImageAltCheck>();

builder.WithCollectionBuilder<SeoDisplayCollectionBuilder>()
.Add<SiteAuditDisplayProvider>();

builder.AddNotificationHandler<SiteAuditUpdatedNotification, SiteAuditUpdateNotificationHandler>();

builder.Services.Configure<SiteAuditAppSettingsModel>(builder.Config.GetSection("SeoToolkit:SiteAudit"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.AspNetCore.Mvc;
using SeoToolkit.Umbraco.SiteAudit.Core.Interfaces;
using SeoToolkit.Umbraco.SiteAudit.Core.Models.Business;
using SeoToolkit.Umbraco.SiteAudit.Core.Models.PostModels;
using SeoToolkit.Umbraco.SiteAudit.Core.Models.ViewModels;
using SeoToolkit.Umbraco.SiteAudit.Core.Services;
using System;
using System.Linq;
using System.Threading.Tasks;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Extensions;

namespace SeoToolkit.Umbraco.SiteAudit.Core.Controllers
{
[PluginController("SeoToolkit")]
public class SiteAuditPageCheckController : UmbracoAuthorizedApiController
{
private readonly SiteAuditService _siteAuditService;
private readonly ISiteCheckService _siteCheckService;
private readonly IUmbracoContextFactory _umbracoContextFactory;

public SiteAuditPageCheckController(SiteAuditService siteAuditService, ISiteCheckService siteCheckService, IUmbracoContextFactory umbracoContextFactory)
{
_siteAuditService = siteAuditService;
_siteCheckService = siteCheckService;
_umbracoContextFactory = umbracoContextFactory;
}

[HttpGet]
public IActionResult GetPageChecks()
{
return new JsonResult(_siteCheckService.GetAll().Where(it => it.AllowedAsPageCheck).Select(it => new SiteAuditCheckViewModel { Id = it.Id, Name = it.Check.Name, Description = it.Check.Description }).ToArray());
}

[HttpPost]
public async Task<IActionResult> RunPageChecks(RunPageCheckPostModel postModel)
{
using var ctx = _umbracoContextFactory.EnsureUmbracoContext();
var model = new SiteAuditDto
{
Name = string.Empty,
CreatedDate = DateTime.UtcNow,
StartingUrl = new Uri(ctx.UmbracoContext.Content.GetById(postModel.ContentId).Url(mode: UrlMode.Absolute)),
SiteChecks = _siteCheckService.GetAll().Where(it => it.AllowedAsPageCheck).ToList(),
MaxPagesToCrawl = 1,
DelayBetweenRequests = 1000,
Persistent = false
};

var result = await _siteAuditService.StartSiteAudit(model);
return new JsonResult(new SiteAuditDetailViewModel(result));
}
}
}
Loading
Loading