Ejemplo n.º 1
0
        public ActionResult RatesPOST(ContentOptions options, IEnumerable <int> itemIds, string returnUrl)
        {
            if (!Services.Authorizer.Authorize(OShopPermissions.ManageShopSettings, T("Not allowed to manage VAT rates")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (itemIds != null)
            {
                var checkedContentItems = _contentManager.GetMany <ContentItem>(itemIds, VersionOptions.Latest, QueryHints.Empty);
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var item in checkedContentItems)
                    {
                        _contentManager.Remove(item);
                    }
                    Services.Notifier.Information(T("VAT rates successfully removed."));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(this.RedirectLocal(returnUrl, () => RedirectToAction("Rates")));
        }
Ejemplo n.º 2
0
        public Task <IActionResult> Admin(ContentOptions options, PagerParameters pagerParameters)
        {
            options.AdminTemplates = true;

            // Used to provide a different url such that the Admin Templates menu entry doesn't collide with the Templates ones
            return(Index(options, pagerParameters));
        }
        public async Task <ActionResult> IndexBulkActionPOST(ContentOptions options, IEnumerable <int> itemIds)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan))
            {
                return(Forbid());
            }

            if (itemIds?.Count() > 0)
            {
                var checkedItems = await _session.Query <DeploymentPlan, DeploymentPlanIndex>().Where(x => x.DocumentId.IsIn(itemIds)).ListAsync();

                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.Delete:
                    foreach (var item in checkedItems)
                    {
                        _session.Delete(item);
                    }
                    await _notifier.SuccessAsync(H["Deployment plans successfully deleted."]);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 4
0
 public ContentQueryParser(IMemoryCache cache, IJsonSerializer jsonSerializer, ITextIndex textIndex, IOptions <ContentOptions> options)
 {
     this.jsonSerializer = jsonSerializer;
     this.textIndex      = textIndex;
     this.cache          = cache;
     this.options        = options.Value;
 }
        public ActionResult ListFilterPost(ContentOptions options)
        {
            var routeValues = ControllerContext.RouteData.Values;

            if (options != null)
            {
                routeValues["Options.OrderBy"] = options.OrderBy;
                if ((OrderPart.States.Union(new[] { "any", "active" })).Any(
                        ctd => string.Equals(ctd, options.SelectedFilter, StringComparison.OrdinalIgnoreCase)))
                {
                    routeValues["Options.SelectedFilter"] = options.SelectedFilter;
                }
                else
                {
                    routeValues.Remove("Options.SelectedFilter");
                }
                if (String.IsNullOrWhiteSpace(options.Search))
                {
                    routeValues.Remove("Options.Search");
                }
                else
                {
                    routeValues["Options.Search"] = options.Search;
                }
            }

            return(RedirectToAction("List", routeValues));
        }
        public ActionResult ListPost(ContentOptions options, IEnumerable <int> itemIds, string returnUrl)
        {
            if (itemIds != null)
            {
                var checkedOrders = _contentManager.GetMany <OrderPart>(itemIds, VersionOptions.Latest,
                                                                        QueryHints.Empty);
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var order in checkedOrders)
                    {
                        if (!_orchardServices.Authorizer.Authorize(OrderPermissions.ManageOrders, order,
                                                                   T("Couldn't archive selected orders.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }

                        order.Status = OrderPart.Archived;
                    }
                    _orchardServices.Notifier.Information(T("Orders successfully archived."));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            return(this.RedirectLocal(returnUrl, () => RedirectToAction("List")));
        }
        public async Task <ActionResult> IndexPost(ContentOptions options, IEnumerable <string> itemIds)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTenantFeatureProfiles))
            {
                return(Forbid());
            }

            if (itemIds?.Count() > 0)
            {
                var featureProfilesDocument = await _featureProfilesManager.LoadFeatureProfilesDocumentAsync();

                var checkItems = featureProfilesDocument.FeatureProfiles.Where(x => itemIds.Contains(x.Key));
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var item in checkItems)
                    {
                        await _featureProfilesManager.RemoveFeatureProfileAsync(item.Key);
                    }
                    await _notifier.SuccessAsync(H["Feature profiles successfully removed."]);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageQueries))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var queries = await _queryManager.ListQueriesAsync();

            queries = queries.OrderBy(x => x.Name);

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                queries = queries.Where(q => q.Name.IndexOf(options.Search, StringComparison.OrdinalIgnoreCase) >= 0);
            }

            var results = queries
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ToList();

            // Maintain previous route data when generating page links
            var routeData = new RouteData();

            routeData.Values.Add("Options.Search", options.Search);

            var pagerShape = (await New.Pager(pager)).TotalItemCount(queries.Count()).RouteData(routeData);

            var model = new QueriesIndexViewModel
            {
                Queries          = new List <QueryEntry>(),
                Options          = options,
                Pager            = pagerShape,
                QuerySourceNames = _querySources.Select(x => x.Name).ToList()
            };

            foreach (var query in results)
            {
                model.Queries.Add(new QueryEntry
                {
                    Query = query,
                    Shape = await _displayManager.BuildDisplayAsync(query, _updateModelAccessor.ModelUpdater, "SummaryAdmin")
                });
            }

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View(model));
        }
Ejemplo n.º 9
0
        public ActionResult ListPOST(ContentOptions options, IEnumerable <int> itemIds, string returnUrl)
        {
            if (itemIds != null)
            {
                var checkedContentItems = _contentManager.GetMany <ContentItem>(itemIds, VersionOptions.Latest, QueryHints.Empty);
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.PublishNow:
                    foreach (var item in checkedContentItems)
                    {
                        if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }

                        _contentManager.Publish(item);
                    }
                    Services.Notifier.Success(T("Content successfully published."));
                    break;

                case ContentsBulkAction.Unpublish:
                    foreach (var item in checkedContentItems)
                    {
                        if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }

                        _contentManager.Unpublish(item);
                    }
                    Services.Notifier.Success(T("Content successfully unpublished."));
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var item in checkedContentItems)
                    {
                        if (!Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }

                        _contentManager.Remove(item);
                    }
                    Services.Notifier.Success(T("Content successfully removed."));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(this.RedirectLocal(returnUrl, () => RedirectToAction("List")));
        }
 public ContentPartHandlerResolver(
     IServiceProvider serviceProvider,
     IOptions <ContentOptions> contentDisplayOptions
     )
 {
     _serviceProvider = serviceProvider;
     _contentOptions  = contentDisplayOptions.Value;
 }
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan))
            {
                return(Forbid());
            }

            if (!await _authorizationService.AuthorizeAsync(User, Permissions.Export))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var deploymentPlans = _session.Query <DeploymentPlan, DeploymentPlanIndex>();

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                deploymentPlans = deploymentPlans.Where(x => x.Name.Contains(options.Search));
            }

            var count = await deploymentPlans.CountAsync();

            var results = await deploymentPlans
                          .OrderBy(p => p.Name)
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ListAsync();

            // Maintain previous route data when generating page links
            var routeData = new RouteData();

            routeData.Values.Add("Options.Search", options.Search);

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count).RouteData(routeData);

            var model = new DeploymentPlanIndexViewModel
            {
                DeploymentPlans = results.Select(x => new DeploymentPlanEntry {
                    DeploymentPlan = x
                }).ToList(),
                Options = options,
                Pager   = pagerShape
            };

            model.Options.DeploymentPlansBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Delete)
                }
            };

            return(View(model));
        }
Ejemplo n.º 12
0
 public static ContentOptions UseCulture(this ContentOptions options, params string[] resources)
 {
     options.DefaultCulture = "en";
     foreach (var resource in resources)
     {
         options.CultureResources.Add(resource);
     }
     return(options);
 }
Ejemplo n.º 13
0
 public ContentTypeDocumentProcessor(
     IOptions <OpenApiOptions> openApiOptions,
     IOptions <ContentOptions> contentOptions,
     IHttpContextAccessor httpContentAccessor
     )
 {
     _openApiOptions      = openApiOptions.Value;
     _httpContextAccessor = httpContentAccessor;
     _contentOptions      = contentOptions.Value;
 }
        public ISendEmailCommand AddContent(Action <IContentOption> option)
        {
            if (ContentOptions == null)
            {
                ContentOptions = new List <ContentOption>();
            }

            ContentOptions.Add(OptionProcessor.Process <IContentOption, ContentOption>(option));
            return(this);
        }
Ejemplo n.º 15
0
        public ContentQueryParser(IMemoryCache cache, IJsonSerializer jsonSerializer, IOptions <ContentOptions> options)
            : base(cache)
        {
            Guard.NotNull(jsonSerializer, nameof(jsonSerializer));
            Guard.NotNull(options, nameof(options));

            this.jsonSerializer = jsonSerializer;

            this.options = options.Value;
        }
Ejemplo n.º 16
0
        public SecurityController(
            IOptions <ContentOptions> contentOptions,
            UserManager <ApplicationUser> userManager,
            RoleManager <IdentityRole> roleManager)
        {
            _contentOptions = contentOptions.Value;

            _userManager = userManager;
            _roleManager = roleManager;
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageIndexes))
            {
                return(Forbid());
            }

            var indexes = (await _luceneIndexSettingsService.GetSettingsAsync()).Select(i => new IndexViewModel {
                Name = i.IndexName
            });

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager   = new Pager(pagerParameters, siteSettings.PageSize);
            var count   = indexes.Count();
            var results = indexes;

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                results = results.Where(q => q.Name.IndexOf(options.Search, StringComparison.OrdinalIgnoreCase) >= 0);
            }

            results = results
                      .Skip(pager.GetStartIndex())
                      .Take(pager.PageSize).ToList();

            // Maintain previous route data when generating page links
            var routeData  = new RouteData();
            var pagerShape = (await New.Pager(pager)).TotalItemCount(count).RouteData(routeData);

            var model = new AdminIndexViewModel
            {
                Indexes = results,
                Options = options,
                Pager   = pagerShape
            };

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Reset"], Value = nameof(ContentsBulkAction.Reset)
                },
                new SelectListItem()
                {
                    Text = S["Rebuild"], Value = nameof(ContentsBulkAction.Rebuild)
                },
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View(model));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!options.AdminTemplates && !await _authorizationService.AuthorizeAsync(User, Permissions.ManageTemplates))
            {
                return(Forbid());
            }

            if (options.AdminTemplates && !await _authorizationService.AuthorizeAsync(User, AdminTemplatesPermissions.ManageAdminTemplates))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager             = new Pager(pagerParameters, siteSettings.PageSize);
            var templatesDocument = options.AdminTemplates
                ? await _adminTemplatesManager.GetTemplatesDocumentAsync()
                : await _templatesManager.GetTemplatesDocumentAsync()
            ;

            var templates = templatesDocument.Templates.ToList();

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                templates = templates.Where(x => x.Key.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList();
            }

            var count = templates.Count;

            templates = templates.OrderBy(x => x.Key)
                        .Skip(pager.GetStartIndex())
                        .Take(pager.PageSize).ToList();

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count);

            var model = new TemplateIndexViewModel
            {
                Templates = templates.Select(x => new TemplateEntry {
                    Name = x.Key, Template = x.Value
                }).ToList(),
                Options = options,
                Pager   = pagerShape
            };

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View("Index", model));
        }
Ejemplo n.º 19
0
        public ActionResult RatesFilterPOST(ContentOptions options)
        {
            var routeValues = ControllerContext.RouteData.Values;

            if (options != null)
            {
                routeValues["Options.OrderBy"] = options.OrderBy; //todo: don't hard-code the key
            }

            return(RedirectToAction("Rates", routeValues));
        }
Ejemplo n.º 20
0
        public ContentQueryParser(IMemoryCache cache, IJsonSerializer jsonSerializer, ITextIndex textIndex, IOptions <ContentOptions> options)
        {
            Guard.NotNull(jsonSerializer, nameof(jsonSerializer));
            Guard.NotNull(textIndex, nameof(textIndex));
            Guard.NotNull(cache, nameof(cache));
            Guard.NotNull(options, nameof(options));

            this.jsonSerializer = jsonSerializer;
            this.textIndex      = textIndex;
            this.cache          = cache;
            this.options        = options.Value;
        }
Ejemplo n.º 21
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var config         = new HttpConfiguration();
            var contentOptions = new ContentOptions(AppSettings.Root).UseWeb();

            if (AppSettings.CultureResources.Length > 0)
            {
                contentOptions.UseCulture(AppSettings.CultureResources);
            }
            config.UseStatic(contentOptions);
            appBuilder.UseWebApi(config);
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> List(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageSitemaps))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var sitemaps = (await _sitemapManager.GetSitemapsAsync())
                           .OfType <Sitemap>();

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                sitemaps = sitemaps.Where(x => x.Name.Contains(options.Search, StringComparison.OrdinalIgnoreCase));
            }

            var count = sitemaps.Count();

            var results = sitemaps
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ToList();

            // Maintain previous route data when generating page links
            var routeData = new RouteData();

            routeData.Values.Add("Options.Search", options.Search);

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count).RouteData(routeData);

            var model = new ListSitemapViewModel
            {
                Sitemaps = results.Select(sm => new SitemapListEntry {
                    SitemapId = sm.SitemapId, Name = sm.Name, Enabled = sm.Enabled
                }).ToList(),
                Options = options,
                Pager   = pagerShape
            };

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View(model));
        }
Ejemplo n.º 23
0
        public ActionResult ListPOST(ContentOptions options, IEnumerable <int> itemIds, int?targetContainerId, string returnUrl)
        {
            if (itemIds != null)
            {
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.PublishNow:
                    if (!BulkPublishNow(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.Unpublish:
                    if (!BulkUnpublish(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.Remove:
                    if (!BulkRemove(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.RemoveFromList:
                    if (!BulkRemoveFromList(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.MoveToList:
                    if (!BulkMoveToList(itemIds, targetContainerId))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(this.RedirectLocal(returnUrl, () => RedirectToAction("List")));
        }
Ejemplo n.º 24
0
 public static ContentOptions UseMedia(this ContentOptions options)
 {
     options.DefaultMediaType = "application/octet-stream";
     options.SetMediaType(".ico", "image/vnd.microsoft.icon");
     options.SetMediaType(".png", "image/png");
     options.SetMediaType(".jpg", "image/jpeg");
     options.SetMediaType(".svg", "image/svg+xml");
     options.SetMediaType(".txt", "text/plain");
     options.SetMediaType(".gif", "image/gif");
     options.SetMediaType(".pdf", "application/pdf");
     options.SetMediaType(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
     options.SetMediaType(".mp3", "audio/mpeg");
     return(options);
 }
Ejemplo n.º 25
0
 public ContentQueryService(
     IAppProvider appProvider,
     IContentEnricher contentEnricher,
     IContentRepository contentRepository,
     IContentLoader contentLoader,
     IOptions <ContentOptions> options,
     ContentQueryParser queryParser)
 {
     this.appProvider       = appProvider;
     this.contentEnricher   = contentEnricher;
     this.contentRepository = contentRepository;
     this.contentLoader     = contentLoader;
     this.options           = options.Value;
     this.queryParser       = queryParser;
 }
Ejemplo n.º 26
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManagePlacements))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var shapeTypes = await _placementsManager.ListShapePlacementsAsync();

            var shapeList = shapeTypes.Select(entry => new ShapePlacementViewModel
            {
                ShapeType = entry.Key
            }).ToList();

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                shapeList = shapeList.Where(x => x.ShapeType.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList();
            }

            var count = shapeList.Count();

            shapeList = shapeList.OrderBy(x => x.ShapeType)
                        .Skip(pager.GetStartIndex())
                        .Take(pager.PageSize).ToList();

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count);

            var model = new ListShapePlacementsViewModel
            {
                ShapePlacements = shapeList,
                Pager           = pagerShape,
                Options         = options,
            };

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View("Index", model));
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRemoteClients))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var remoteClients = (await _remoteClientService.GetRemoteClientListAsync()).RemoteClients;

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                remoteClients = remoteClients.Where(x => x.ClientName.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList();
            }

            var count = remoteClients.Count();

            var startIndex = pager.GetStartIndex();
            var pageSize   = pager.PageSize;

            // Maintain previous route data when generating page links
            var routeData = new RouteData();

            routeData.Values.Add("Options.Search", options.Search);

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count).RouteData(routeData);

            var model = new RemoteClientIndexViewModel
            {
                RemoteClients = remoteClients,
                Pager         = pagerShape,
                Options       = options
            };

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View(model));
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Creates a new instance of <see cref="MediaTypeContentValidator"/>.
 /// </summary>
 /// <param name="options">Content options.</param>
 /// <param name="contents">Settings for content.</param>
 public MediaTypeContentValidator(
     ContentOptions options,
     IEnumerable <Models.Content> contents)
 {
     foreach (var content in contents)
     {
         if (string.IsNullOrEmpty(content.Schema))
         {
             _validators.Add(content.MediaType, null);
         }
         else
         {
             var validator = options.CreateContentValidator(content.MediaType, content.Schema);
             _validators.Add(content.MediaType, validator);
         }
     }
 }
Ejemplo n.º 29
0
 public static ContentOptions UseWeb(this ContentOptions options)
 {
     options.DefaultUrl = "index.html";
     options.SetMediaType(".html", "text/html");
     options.SetMediaType(".js", "application/javascript");
     options.SetMediaType(".css", "text/css");
     options.SetMediaType(".ico", "image/vnd.microsoft.icon");
     options.SetMediaType(".png", "image/png");
     options.SetMediaType(".jpg", "image/jpeg");
     options.SetMediaType(".eot", "application/vnd.ms-fontobject");
     options.SetMediaType(".svg", "image/svg+xml");
     options.SetMediaType(".ttf", "application/font-ttf");
     options.SetMediaType(".woff", "application/font-woff");
     options.SetMediaType(".woff2", "application/font-woff");
     options.SetMediaType(".appcache", "text/cache-manifest");
     return(options);
 }
Ejemplo n.º 30
0
        public async Task <ActionResult> ListPost(ContentOptions options, IEnumerable <string> itemIds)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTemplates))
            {
                return(Forbid());
            }

            if (itemIds?.Count() > 0)
            {
                var templatesDocument = options.AdminTemplates
                        ? await _adminTemplatesManager.LoadTemplatesDocumentAsync()
                        : await _templatesManager.LoadTemplatesDocumentAsync();

                var checkedContentItems = templatesDocument.Templates.Where(x => itemIds.Contains(x.Key));

                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var item in checkedContentItems)
                    {
                        await(options.AdminTemplates
                                    ? _adminTemplatesManager.RemoveTemplateAsync(item.Key)
                                    : _templatesManager.RemoveTemplateAsync(item.Key));
                    }
                    await _notifier.SuccessAsync(H["Templates successfully removed."]);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            if (options.AdminTemplates)
            {
                return(RedirectToAction(nameof(Admin)));
            }
            else
            {
                return(RedirectToAction(nameof(Index)));
            }
        }