//[SampleMetadataTag(Name = BuiltInTagNames.SampleHidden)]
        public void CanDeploEmptyContentEditorWebpart()
        {
            var cewp = new ContentEditorWebPartDefinition
            {
                Title     = "Empty Content Editor Webpart",
                Id        = "m2EmptyCEWP",
                ZoneIndex = 10,
                ZoneId    = "Main"
            };

            var webPartPage = new WebPartPageDefinition
            {
                Title              = "M2 CEWP provision",
                FileName           = "cewp-provision.aspx",
                PageLayoutTemplate = BuiltInWebPartPageTemplates.spstd1
            };

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web.AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list.AddWebPartPage(webPartPage, page =>
                    {
                        page.AddContentEditorWebPart(cewp);
                    });
                });
            });

            DeployModel(model);
        }
Example #2
0
 public void ContentEditorWebPartSetup(ContentEditorWebPartDefinition typedModel,
                                       string content, string contentLink)
 {
     var wpXml = WebpartXmlExtensions
                 .LoadWebpartXmlDocument(BuiltInWebPartTemplates.ContentEditorWebPart)
                 .SetOrUpdateContentEditorWebPartProperty("Content", content, true)
                 .SetOrUpdateContentEditorWebPartProperty("ContentLink", contentLink)
                 .ToString();
 }
        //[SampleMetadataTag(Name = BuiltInTagNames.SampleHidden)]
        public void CanDeploContentEditorWebpartWithUrlLink()
        {
            var htmlContent = new ModuleFileDefinition
            {
                FileName  = "m2-cewp-content.html",
                Content   = Encoding.UTF8.GetBytes("M2 is everything you need to deploy stuff to Sharepoint"),
                Overwrite = true,
            };

            var cewp = new ContentEditorWebPartDefinition
            {
                Title       = "Content Editor Webpart with URL link",
                Id          = "m2ContentLinkCEWP",
                ZoneIndex   = 20,
                ZoneId      = "Main",
                ContentLink = UrlUtility.CombineUrl(new string[] {
                    "~sitecollection",
                    BuiltInListDefinitions.StyleLibrary.GetListUrl(),
                    htmlContent.FileName
                })
            };

            var webPartPage = new WebPartPageDefinition
            {
                Title              = "M2 CEWP provision",
                FileName           = "cewp-provision.aspx",
                PageLayoutTemplate = BuiltInWebPartPageTemplates.spstd1
            };

            var model = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddHostList(BuiltInListDefinitions.StyleLibrary, list =>
                {
                    list.AddModuleFile(htmlContent);
                })
                .AddHostList(BuiltInListDefinitions.SitePages, list =>
                {
                    list.AddWebPartPage(webPartPage, page =>
                    {
                        page.AddContentEditorWebPart(cewp);
                    });
                });
            });

            DeployModel(model);
        }
 public static TModelNode AddContentEditorWebPart <TModelNode>(this TModelNode model, ContentEditorWebPartDefinition definition,
                                                               Action <ContentEditorWebPartModelNode> action)
     where TModelNode : ModelNode, IWebpartHostModelNode, new()
 {
     return(model.AddTypedDefinitionNode(definition, action));
 }
 public static TModelNode AddContentEditorWebPart <TModelNode>(this TModelNode model, ContentEditorWebPartDefinition definition)
     where TModelNode : ModelNode, IWebpartHostModelNode, new()
 {
     return(AddContentEditorWebPart(model, definition, null));
 }
 public static ModelNode AddContentEditorWebPart(this ModelNode model, ContentEditorWebPartDefinition definition, Action <ModelNode> action)
 {
     return(model.AddDefinitionNode(definition, action));
 }
 public static ModelNode AddContentEditorWebPart(this ModelNode model, ContentEditorWebPartDefinition definition)
 {
     return(AddContentEditorWebPart(model, definition, null));
 }