예제 #1
0
        public void Initialize()
        {
            Guid dataTypeKey = new Guid("ec17fffe-3a33-4a08-a61a-3a6b7008e20f");

            CreateExampleBlock("exampleBlock", dataTypeKey);

            var specialCategoryId = new Guid("AAC6EE6A-EA54-4E90-A33B-049E39786BF5");

            _categoryRepository.Add(new ContentBlockCategory
            {
                Id   = specialCategoryId,
                Name = "Specials",
                Icon = "/App_Plugins/Perplex.ContentBlocks/assets/icons.svg#icon-cat-special"
            });

            // Block
            var block = new ContentBlockDefinition
            {
                Name        = "Example Block",
                Id          = new Guid("11111111-1111-1111-1111-111111111111"),
                DataTypeKey = dataTypeKey,
                // PreviewImage will usually be a path to some image,
                // for this demo we use a base64-encoded PNG of 3x2 pixels
                PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzzDwPCfAQqYGJAAACokAc/b6i7NAAAAAElFTkSuQmCC",
                Description  = "Example Block",

                Layouts = new IContentBlockLayout[]
                {
                    new ContentBlockLayout
                    {
                        Id           = new Guid("22222222-2222-2222-2222-222222222222"),
                        Name         = "Red",
                        Description  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae interdum dolor, sit amet luctus odio.",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzzDwPCfAQqYGJAAACokAc/b6i7NAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleBlock/Red.cshtml"
                    },
                    new ContentBlockLayout
                    {
                        Id           = new Guid("33333333-3333-3333-3333-333333333333"),
                        Name         = "Green",
                        Description  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae interdum dolor, sit amet luctus odio. Nam laoreet at odio eu faucibus. Vivamus non rhoncus erat, sit amet efficitur ipsum.",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYyy+JPafAQqYGJAAADcdAl5UlCmyAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleBlock/Green.cshtml"
                    },
                    new ContentBlockLayout
                    {
                        Id           = new Guid("44444444-4444-4444-4444-444444444444"),
                        Name         = "Blue",
                        Description  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae interdum dolor, sit amet luctus odio. Nam laoreet at odio eu faucibus. Vivamus non rhoncus erat, sit amet efficitur ipsum. Pellentesque tempus tellus eu posuere varius. Nulla elementum lacus lacus. Curabitur elementum faucibus velit sed mollis.",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzRJXfKfAQqYGJAAADOAAkAWXApqAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleBlock/Blue.cshtml",
                    },
                },

                CategoryIds = new[]
                {
                    Perplex.ContentBlocks.Constants.Categories.Content,
                    specialCategoryId,
                }
            };

            // Header
            var header = new ContentBlockDefinition
            {
                Name         = "Example Header",
                Id           = new Guid("55555555-5555-5555-5555-555555555555"),
                DataTypeKey  = dataTypeKey,
                PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZY/zz0v8/AxQwMSABAEvFAzckGfK1AAAAAElFTkSuQmCC",
                Description  = "Example Block",

                Layouts = new IContentBlockLayout[]
                {
                    new ContentBlockLayout
                    {
                        Id           = new Guid("66666666-6666-6666-6666-666666666666"),
                        Name         = "Yellow",
                        Description  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae interdum dolor, sit amet luctus odio.",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZY/zz0v8/AxQwMSABAEvFAzckGfK1AAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleHeader/Yellow.cshtml"
                    },
                    new ContentBlockLayout
                    {
                        Id           = new Guid("77777777-7777-7777-7777-777777777777"),
                        Name         = "Magenta",
                        Description  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae interdum dolor, sit amet luctus odio. Nam laoreet at odio eu faucibus. Vivamus non rhoncus erat, sit amet efficitur ipsum.",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZY/zP8P8/AxQwMSABAEYIAwEl5g6iAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleHeader/Magenta.cshtml"
                    },
                },

                CategoryIds = new[]
                {
                    Perplex.ContentBlocks.Constants.Categories.Headers,
                }
            };

            _definitions.Add(block);
            _definitions.Add(header);

            var all = _definitions.GetAll().ToList();

            for (int i = 0; i < all.Count; i++)
            {
                var def = all[i];

                for (int j = 0; j < 8; j++)
                {
                    var newDef = new ContentBlockDefinition
                    {
                        CategoryIds = def.CategoryIds.ToList(),
                        DataTypeId  = def.DataTypeId,
                        DataTypeKey = def.DataTypeKey,
                        Description = def.Description,
                        Id          = new Guid($"{i}{j}{def.Id.ToString().Substring(2)}"),
                        Layouts     = def.Layouts.Select(l => new ContentBlockLayout
                        {
                            Description  = l.Description,
                            Id           = new Guid($"{i}{j}{l.Id.ToString().Substring(2)}"),
                            Name         = l.Name,
                            PreviewImage = l.PreviewImage,
                            ViewPath     = l.ViewPath,
                        }).ToList(),
                        Name         = def.Name + $" - copy #{j + 1}",
                        PreviewImage = def.PreviewImage,
                    };

                    _definitions.Add(newDef);
                }
            }
        }
예제 #2
0
        public void Initialize()
        {
            Guid dataTypeKey = new Guid("ec17fffe-3a33-4a08-a61a-3a6b7008e20f");

            CreateExampleBlock("exampleBlock", dataTypeKey);

            // Block
            var block = new ContentBlockDefinition
            {
                Name        = "Example Block",
                Id          = new Guid("11111111-1111-1111-1111-111111111111"),
                DataTypeKey = dataTypeKey,
                // PreviewImage will usually be a path to some image,
                // for this demo we use a base64-encoded PNG of 3x2 pixels
                PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzzDwPCfAQqYGJAAACokAc/b6i7NAAAAAElFTkSuQmCC",
                Description  = "Example Block",

                Layouts = new IContentBlockLayout[]
                {
                    new ContentBlockLayout
                    {
                        Id           = new Guid("22222222-2222-2222-2222-222222222222"),
                        Name         = "Red",
                        Description  = "",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzzDwPCfAQqYGJAAACokAc/b6i7NAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleBlock/Red.cshtml"
                    },
                    new ContentBlockLayout
                    {
                        Id           = new Guid("33333333-3333-3333-3333-333333333333"),
                        Name         = "Green",
                        Description  = "",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYyy+JPafAQqYGJAAADcdAl5UlCmyAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleBlock/Green.cshtml"
                    },
                    new ContentBlockLayout
                    {
                        Id           = new Guid("44444444-4444-4444-4444-444444444444"),
                        Name         = "Blue",
                        Description  = "",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzRJXfKfAQqYGJAAADOAAkAWXApqAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleBlock/Blue.cshtml",
                    },
                },

                CategoryIds = new[]
                {
                    Perplex.ContentBlocks.Constants.Categories.Content,
                }
            };

            // Header
            var header = new ContentBlockDefinition
            {
                Name         = "Example Header",
                Id           = new Guid("55555555-5555-5555-5555-555555555555"),
                DataTypeKey  = dataTypeKey,
                PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZY/zz0v8/AxQwMSABAEvFAzckGfK1AAAAAElFTkSuQmCC",
                Description  = "Example Block",

                Layouts = new IContentBlockLayout[]
                {
                    new ContentBlockLayout
                    {
                        Id           = new Guid("66666666-6666-6666-6666-666666666666"),
                        Name         = "Yellow",
                        Description  = "",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZY/zz0v8/AxQwMSABAEvFAzckGfK1AAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleHeader/Yellow.cshtml"
                    },
                    new ContentBlockLayout
                    {
                        Id           = new Guid("77777777-7777-7777-7777-777777777777"),
                        Name         = "Magenta",
                        Description  = "",
                        PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZY/zP8P8/AxQwMSABAEYIAwEl5g6iAAAAAElFTkSuQmCC",
                        ViewPath     = "~/Views/Partials/ExampleHeader/Magenta.cshtml"
                    },
                },

                CategoryIds = new[]
                {
                    Perplex.ContentBlocks.Constants.Categories.Headers,
                }
            };

            _definitions.Add(block);
            _definitions.Add(header);

            var all = _definitions.GetAll().ToList();

            for (int i = 0; i < all.Count; i++)
            {
                var def = all[i];

                for (int j = 0; j < 8; j++)
                {
                    var newDef = new ContentBlockDefinition
                    {
                        CategoryIds = def.CategoryIds.ToList(),
                        DataTypeId  = def.DataTypeId,
                        DataTypeKey = def.DataTypeKey,
                        Description = def.Description,
                        Id          = new Guid($"{i}{j}{def.Id.ToString().Substring(2)}"),
                        Layouts     = def.Layouts.Select(l => new ContentBlockLayout
                        {
                            Description  = l.Description,
                            Id           = new Guid($"{i}{j}{l.Id.ToString().Substring(2)}"),
                            Name         = l.Name,
                            PreviewImage = l.PreviewImage,
                            ViewPath     = l.ViewPath,
                        }).ToList(),
                        Name         = def.Name + $" - copy #{j + 1}",
                        PreviewImage = def.PreviewImage,
                    };

                    _definitions.Add(newDef);
                }
            }
        }
        public void Initialize()
        {
            var heroBlock = new ContentBlockDefinition
            {
                Name         = "Hero Content Block",                               //name of the block
                Id           = Guid.Parse("b1f44c8a-8f66-475e-bdd3-21b3a48c157e"), //unique id, create your own guid
                DataTypeKey  = Guid.Parse("b9f44c8a-8f66-475e-bdd3-21b3a48c157e"), //datatype key for nested content data type created for the block
                PreviewImage = "/assets/img/hero.png",                             // Image that shows in the UI as a preview of this block. Relative path from the root of your site to an image.
                Description  = "Hero Content Block",                               //Description of this Content Block
                CategoryIds  = new[]                                               //List of ids of the categories this Content Block should appear in. This references the id of a IContentBlockCategory
                {
                    Perplex.ContentBlocks.Constants.Categories.Headers,
                    Perplex.ContentBlocks.Constants.Categories.Content,
                    _demoContentBlockCategory.Id
                },

                Layouts = new IContentBlockLayout[] //List of all layouts of this Content Block
                {
                    new ContentBlockLayout
                    {
                        Id           = Guid.Parse("b2f44c8a-8f66-475e-bdd3-21b3a48c157e"),         //unique id, create your own guid
                        Name         = "Layout 1",                                                 //name for layout
                        Description  = "Centre Aligned Text",                                      //description
                        PreviewImage = "/assets/img/hero.png",                                     //preview image for backoffice
                        ViewPath     = "~/Views/Partials/PerplexContentBlocks/Hero/Layout1.cshtml" //view for website rendering
                    },
                    new ContentBlockLayout
                    {
                        Id           = Guid.Parse("b3f44c8a-8f66-475e-bdd3-21b3a48c157e"),
                        Name         = "Layout 2",
                        Description  = "",
                        PreviewImage = "/assets/img/layout2.png",
                        ViewPath     = "~/Views/Partials/PerplexContentBlocks/Hero/Layout2.cshtml"
                    },
                }
            };

            _definitions.Add(heroBlock);

            var podsBlock = new ContentBlockDefinition
            {
                Name         = "Pods Block",                                       //name of the block
                Id           = Guid.Parse("b4f44c8a-8f66-475e-bdd3-21b3a48c157e"), //unique id
                DataTypeKey  = Guid.Parse("d0bf8fe5-7cef-42e8-a8d6-a1af88569679"), //datatype key for nested content data type created for the block
                PreviewImage = "/assets/img/pods.png",                             // Image that shows in the UI as a preview of this block. Relative path from the root of your site to an image.
                Description  = "Pods Content Block",                               //Description of this Content Block
                CategoryIds  = new[]                                               //List of ids of the categories this Content Block should appear in. This references the id of a IContentBlockCategory. See Content Block Categories for more details on categories.
                {
                    Perplex.ContentBlocks.Constants.Categories.Content,
                    _demoContentBlockCategory.Id
                },

                Layouts = new IContentBlockLayout[] //List of all layouts of this Content Block
                {
                    new ContentBlockLayout
                    {
                        Id           = Guid.Parse("b5f44c8a-8f66-475e-bdd3-21b3a48c157e"),
                        Name         = "Pods",
                        Description  = "",
                        PreviewImage = "/assets/img/hero.png",
                        ViewPath     = "~/Views/Partials/PerplexContentBlocks/Pods/Pods.cshtml"
                    }
                }
            };

            _definitions.Add(podsBlock);

            var stepsBlock = new ContentBlockDefinition
            {
                Name         = "Configuration Steps Block",                        //name of the block
                Id           = Guid.Parse("b6f44c8a-8f66-475e-bdd3-21b3a48c157e"), //unique id
                DataTypeKey  = Guid.Parse("7d242d00-e42c-467f-a5d5-dd1d8b75e356"), //datatype key for nested content data type created for the block
                PreviewImage = "/assets/img/steps.png",                            // Image that shows in the UI as a preview of this block. Relative path from the root of your site to an image.
                Description  = "Configuration Steps Content Block",                //Description of this Content Block
                CategoryIds  = new[]                                               //List of ids of the categories this Content Block should appear in. This references the id of a IContentBlockCategory. See Content Block Categories for more details on categories.
                {
                    Perplex.ContentBlocks.Constants.Categories.Content,
                    _demoContentBlockCategory.Id
                },

                Layouts = new IContentBlockLayout[] //List of all layouts of this Content Block
                {
                    new ContentBlockLayout
                    {
                        Id           = Guid.Parse("b7f44c8a-8f66-475e-bdd3-21b3a48c157e"),
                        Name         = "Steps",
                        Description  = "",
                        PreviewImage = "/assets/img/hero.png",
                        ViewPath     = "~/Views/Partials/PerplexContentBlocks/Steps/Steps.cshtml"
                    }
                }
            };

            _definitions.Add(stepsBlock);
        }
        public void Initialize()
        {
            var block = new PerplexCallToAction();

            _definitions.Add(block);
        }