public override IEnumerable <TemplateViewModel> TypePartEditorUpdate( ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.Name == "SeoPart") { var model = new SeoPartSettings(); updateModel.TryUpdateModel(model, "SeoPartSettings", null, null); builder.WithSetting("SeoPartSettings.RobotsNoIndex", model.RobotsNoIndex.ToString()); builder.WithSetting("SeoPartSettings.RobotsNoFollow", model.RobotsNoFollow.ToString()); builder.WithSetting("SeoPartSettings.RobotsNoSnippet", model.RobotsNoSnippet.ToString()); builder.WithSetting("SeoPartSettings.RobotsNoOdp", model.RobotsNoOdp.ToString()); builder.WithSetting("SeoPartSettings.RobotsNoArchive", model.RobotsNoArchive.ToString()); builder.WithSetting("SeoPartSettings.RobotsUnavailableAfter", model.RobotsUnavailableAfter.ToString()); builder.WithSetting("SeoPartSettings.RobotsNoImageIndex", model.RobotsNoImageIndex.ToString()); builder.WithSetting("SeoPartSettings.GoogleNoSiteLinkSearchBox", model.GoogleNoSiteLinkSearchBox.ToString()); builder.WithSetting("SeoPartSettings.GoogleNoTranslate", model.GoogleNoTranslate.ToString()); if (model.CanonicalUrl != null) { builder.WithSetting("SeoPartSettings.CanonicalUrl", model.CanonicalUrl.ToString()); } else { builder.WithSetting("SeoPartSettings.CanonicalUrl", ""); } builder.WithSetting("SeoPartSettings.JsonLd", model.JsonLd != null ? model.JsonLd.ToString() : ""); builder.WithSetting("SeoPartSettings.ShowAggregatedMicrodata", model.ShowAggregatedMicrodata.ToString()); yield return(DefinitionTemplate(model)); } yield break; }
// POST protected override DriverResult Editor(SeoPart part, IUpdateModel updater, dynamic shapeHelper) { if (!_authorizer.Authorize(DynamicPermissions.CreateDynamicPermission(SeoPermissions.EditSeoPart, part.ContentItem.TypeDefinition))) { return(null); } SeoPartEditViewModel model = new SeoPartEditViewModel(part); SeoPartSettings settings = part.Settings.GetModel <SeoPartSettings>(); model.DefaultRobots = settings.DefaultRobotsMeta; model.DefaultDescription = _seoService.GenerateDefaultDescription(part); model.DefaultKeywords = _seoService.GenerateDefaultKeywords(part); model.DefaultCanonicalUrl = _seoService.GenerateCanonicalUrl(part); if (updater != null && updater.TryUpdateModel(model, Prefix, null, null)) { part.Description = model.OverrideDescription ? model.Description : String.Empty; part.OverrideKeywords = model.OverrideKeywords; part.Keywords = model.Keywords; part.OverrideRobots = model.OverrideRobots; part.Robots = model.OverrideRobots ? model.Robots : model.DefaultRobots; part.CanonicalUrl = model.CanonicalUrl; } return(ContentShape("Parts_SeoPart_Edit", () => { return shapeHelper.EditorTemplate( TemplateName: TemplateName, Model: model, Prefix: Prefix); })); }
private string scriptEval(SeoPartSettings settings, SeoPart part) { var tokensDictionary = new Dictionary <string, object> { { "Content", part.ContentItem } }; return(_tokenizer.Replace(settings.JsonLd, tokensDictionary));; }
public string GetRobots(SeoPart part) { SeoRobotsMeta robots; if (part.OverrideRobots) { robots = part.Robots; } else { SeoPartSettings settings = part.Settings.GetModel <SeoPartSettings>(); robots = settings.DefaultRobotsMeta; } return(robots != SeoRobotsMeta.All ? robots.ToString().ToLower() : String.Empty); }
public string GenerateDefaultKeywords(SeoPart part) { SeoPartSettings settings = part.Settings.GetModel <SeoPartSettings>(); if (!String.IsNullOrWhiteSpace(settings.DefaultKeywordsPattern)) { return(_tokenizer.Replace( settings.DefaultKeywordsPattern, BuildTokenContext(part.ContentItem), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode })); } else { return(String.Empty); } }
public string GetCanonicalUrl(SeoPart part) { SeoPartSettings settings = part.Settings.GetModel <SeoPartSettings>(); return(part.CanonicalUrl ?? (settings.AddCanonicalLink ? GenerateCanonicalUrl(part) : String.Empty)); }