Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
0
 public IEnumerable <IContentBlockDefinition> GetAllDefinitions()
 => _definitionRepository.GetAll();