Example #1
0
        public async Task <IActionResult> Content(ContentSettingsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _blogConfig.ContentSettings.DisharmonyWords          = model.DisharmonyWords;
            _blogConfig.ContentSettings.EnableComments           = model.EnableComments;
            _blogConfig.ContentSettings.RequireCommentReview     = model.RequireCommentReview;
            _blogConfig.ContentSettings.EnableWordFilter         = model.EnableWordFilter;
            _blogConfig.ContentSettings.WordFilterMode           = Enum.Parse <WordFilterMode>(model.WordFilterMode);
            _blogConfig.ContentSettings.UseFriendlyNotFoundImage = model.UseFriendlyNotFoundImage;
            _blogConfig.ContentSettings.PostListPageSize         = model.PostListPageSize;
            _blogConfig.ContentSettings.HotTagAmount             = model.HotTagAmount;
            _blogConfig.ContentSettings.EnableGravatar           = model.EnableGravatar;
            _blogConfig.ContentSettings.ShowCalloutSection       = model.ShowCalloutSection;
            _blogConfig.ContentSettings.CalloutSectionHtmlPitch  = model.CalloutSectionHtmlPitch;
            _blogConfig.ContentSettings.ShowPostFooter           = model.ShowPostFooter;
            _blogConfig.ContentSettings.PostFooterHtmlPitch      = model.PostFooterHtmlPitch;
            _blogConfig.ContentSettings.DefaultLangCode          = model.DefaultLangCode;

            await _blogConfig.SaveAsync(_blogConfig.ContentSettings);

            await _blogAudit.AddAuditEntry(EventType.Settings, AuditEventId.SettingsSavedContent, "Content Settings updated.");

            return(Ok());
        }
        public async Task <IActionResult> ContentSettings(ContentSettingsViewModel model)
        {
            if (ModelState.IsValid)
            {
                _blogConfig.ContentSettings.DisharmonyWords          = model.DisharmonyWords;
                _blogConfig.ContentSettings.EnableComments           = model.EnableComments;
                _blogConfig.ContentSettings.RequireCommentReview     = model.RequireCommentReview;
                _blogConfig.ContentSettings.EnableWordFilter         = model.EnableWordFilter;
                _blogConfig.ContentSettings.UseFriendlyNotFoundImage = model.UseFriendlyNotFoundImage;
                _blogConfig.ContentSettings.PostListPageSize         = model.PostListPageSize;
                _blogConfig.ContentSettings.HotTagAmount             = model.HotTagAmount;
                _blogConfig.ContentSettings.EnableGravatar           = model.EnableGravatar;
                _blogConfig.ContentSettings.EnableImageLazyLoad      = model.EnableImageLazyLoad;
                _blogConfig.ContentSettings.ShowCalloutSection       = model.ShowCalloutSection;
                _blogConfig.ContentSettings.CalloutSectionHtmlPitch  = model.CalloutSectionHtmlPitch;
                _blogConfig.ContentSettings.ShowPostFooter           = model.ShowPostFooter;
                _blogConfig.ContentSettings.PostFooterHtmlPitch      = model.PostFooterHtmlPitch;
                var response = await _blogConfig.SaveConfigurationAsync(_blogConfig.ContentSettings);

                _blogConfig.RequireRefresh();

                Logger.LogInformation($"User '{User.Identity.Name}' updated ContentSettings");
                await _moongladeAudit.AddAuditEntry(EventType.Settings, Auditing.EventId.SettingsSavedContent, "Content Settings updated.");

                return(Json(response));
            }
            return(Json(new FailedResponse((int)ResponseFailureCode.InvalidModelState, "Invalid ModelState")));
        }
Example #3
0
        public async Task <IActionResult> Index(ContentSettingsViewModel model)
        {
            ViewData["Title"] = sr["Content Settings"];

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var projectSettings = await projectService.GetCurrentProjectSettings();

            projectSettings.ChannelCategoriesCsv = model.ChannelCategoriesCsv;
            //projectSettings.ChannelRating = model.ChannelRating;
            //projectSettings.ChannelTimeToLive = model.ChannelTimeToLive;
            projectSettings.CommentNotificationEmail = model.CommentNotificationEmail;
            projectSettings.DaysToComment            = model.DaysToComment;
            projectSettings.Description = model.Description;
            projectSettings.IncludePubDateInPostUrls = model.IncludePubDateInPostUrls;
            projectSettings.LanguageCode             = model.LanguageCode;
            projectSettings.ManagingEditorEmail      = model.ManagingEditorEmail;
            projectSettings.ModerateComments         = model.ModerateComments;
            projectSettings.PostsPerPage             = model.PostsPerPage;
            projectSettings.PubDateFormat            = model.PubDateFormat;
            //projectSettings.RemoteFeedProcessorUseAgentFragment = model.RemoteFeedProcessorUseAgentFragment;
            projectSettings.RemoteFeedUrl            = model.RemoteFeedUrl;
            projectSettings.ShowTitle                = model.ShowTitle;
            projectSettings.Title                    = model.Title;
            projectSettings.UseMetaDescriptionInFeed = model.UseMetaDescriptionInFeed;
            projectSettings.WebmasterEmail           = model.WebmasterEmail;
            bool needToClearMenuCache = false;

            if (projectSettings.BlogMenuLinksToNewestPost != model.BlogMenuLinksToNewestPost)
            {
                needToClearMenuCache = true;
            }
            if (projectSettings.DefaultPageSlug != model.DefaultPageSlug)
            {
                needToClearMenuCache = true;
            }
            if (projectSettings.BlogPagePosition != model.BlogPagePosition)
            {
                needToClearMenuCache = true;
            }
            projectSettings.BlogMenuLinksToNewestPost = model.BlogMenuLinksToNewestPost;
            projectSettings.DefaultPageSlug           = model.DefaultPageSlug;
            projectSettings.BlogPagePosition          = model.BlogPagePosition;

            await projectService.Update(projectSettings);

            if (needToClearMenuCache)
            {
                projectService.ClearNavigationCache();
            }

            this.AlertSuccess(sr["Content Settings were successfully updated."], true);

            return(RedirectToAction("Index"));
        }
Example #4
0
        public IActionResult ContentSettings()
        {
            var vm = new ContentSettingsViewModel
            {
                DisharmonyWords          = _blogConfig.ContentSettings.DisharmonyWords,
                EnableComments           = _blogConfig.ContentSettings.EnableComments,
                EnableWordFilter         = _blogConfig.ContentSettings.EnableWordFilter,
                UseFriendlyNotFoundImage = _blogConfig.ContentSettings.UseFriendlyNotFoundImage,
                PostListPageSize         = _blogConfig.ContentSettings.PostListPageSize,
                HotTagAmount             = _blogConfig.ContentSettings.HotTagAmount
            };

            return(View(vm));
        }
Example #5
0
        public async Task <IActionResult> ContentSettings(ContentSettingsViewModel model)
        {
            if (ModelState.IsValid)
            {
                _blogConfig.ContentSettings.DisharmonyWords          = model.DisharmonyWords;
                _blogConfig.ContentSettings.EnableComments           = model.EnableComments;
                _blogConfig.ContentSettings.EnableWordFilter         = model.EnableWordFilter;
                _blogConfig.ContentSettings.UseFriendlyNotFoundImage = model.UseFriendlyNotFoundImage;
                _blogConfig.ContentSettings.PostListPageSize         = model.PostListPageSize;
                _blogConfig.ContentSettings.HotTagAmount             = model.HotTagAmount;
                var response = await _blogConfig.SaveConfigurationAsync(_blogConfig.ContentSettings);

                _blogConfig.RequireRefresh();
                return(Json(response));
            }
            return(Json(new FailedResponse((int)ResponseFailureCode.InvalidModelState, "Invalid ModelState")));
        }
Example #6
0
     public void OnGet()
     {
         ViewModel = new()
         {
             DisharmonyWords        = _blogConfig.ContentSettings.DisharmonyWords,
             EnableComments         = _blogConfig.ContentSettings.EnableComments,
             RequireCommentReview   = _blogConfig.ContentSettings.RequireCommentReview,
             EnableWordFilter       = _blogConfig.ContentSettings.EnableWordFilter,
             WordFilterMode         = _blogConfig.ContentSettings.WordFilterMode.ToString(),
             PostListPageSize       = _blogConfig.ContentSettings.PostListPageSize,
             HotTagAmount           = _blogConfig.ContentSettings.HotTagAmount,
             EnableGravatar         = _blogConfig.ContentSettings.EnableGravatar,
             ShowCalloutSection     = _blogConfig.ContentSettings.ShowCalloutSection,
             CalloutSectionHtmlCode = _blogConfig.ContentSettings.CalloutSectionHtmlPitch,
             ShowPostFooter         = _blogConfig.ContentSettings.ShowPostFooter,
             PostFooterHtmlCode     = _blogConfig.ContentSettings.PostFooterHtmlPitch
         };
     }
 }
Example #7
0
        public IActionResult ContentSettings()
        {
            var vm = new ContentSettingsViewModel
            {
                DisharmonyWords          = _blogConfig.ContentSettings.DisharmonyWords,
                EnableComments           = _blogConfig.ContentSettings.EnableComments,
                RequireCommentReview     = _blogConfig.ContentSettings.RequireCommentReview,
                EnableWordFilter         = _blogConfig.ContentSettings.EnableWordFilter,
                UseFriendlyNotFoundImage = _blogConfig.ContentSettings.UseFriendlyNotFoundImage,
                PostListPageSize         = _blogConfig.ContentSettings.PostListPageSize,
                HotTagAmount             = _blogConfig.ContentSettings.HotTagAmount,
                EnableGravatar           = _blogConfig.ContentSettings.EnableGravatar,
                EnableImageLazyLoad      = _blogConfig.ContentSettings.EnableImageLazyLoad,
                ShowCalloutSection       = _blogConfig.ContentSettings.ShowCalloutSection,
                CalloutSectionHtmlPitch  = _blogConfig.ContentSettings.CalloutSectionHtmlPitch
            };

            return(View(vm));
        }
Example #8
0
        public IActionResult Content()
        {
            var vm = new ContentSettingsViewModel
            {
                DisharmonyWords          = _blogConfig.ContentSettings.DisharmonyWords,
                EnableComments           = _blogConfig.ContentSettings.EnableComments,
                RequireCommentReview     = _blogConfig.ContentSettings.RequireCommentReview,
                EnableWordFilter         = _blogConfig.ContentSettings.EnableWordFilter,
                WordFilterMode           = _blogConfig.ContentSettings.WordFilterMode.ToString(),
                UseFriendlyNotFoundImage = _blogConfig.ContentSettings.UseFriendlyNotFoundImage,
                PostListPageSize         = _blogConfig.ContentSettings.PostListPageSize,
                HotTagAmount             = _blogConfig.ContentSettings.HotTagAmount,
                EnableGravatar           = _blogConfig.ContentSettings.EnableGravatar,
                ShowCalloutSection       = _blogConfig.ContentSettings.ShowCalloutSection,
                CalloutSectionHtmlPitch  = _blogConfig.ContentSettings.CalloutSectionHtmlPitch,
                ShowPostFooter           = _blogConfig.ContentSettings.ShowPostFooter,
                PostFooterHtmlPitch      = _blogConfig.ContentSettings.PostFooterHtmlPitch,
                DefaultLangCode          = _blogConfig.ContentSettings.DefaultLangCode
            };

            return(View(vm));
        }
Example #9
0
        public async Task <IActionResult> Index()
        {
            ViewData["Title"] = sr["Content Settings"];

            var projectSettings = await projectService.GetCurrentProjectSettings();

            var model = new ContentSettingsViewModel();

            model.ChannelCategoriesCsv = projectSettings.ChannelCategoriesCsv;
            //model.ChannelRating = projectSettings.ChannelRating;
            //model.ChannelTimeToLive = projectSettings.ChannelTimeToLive;
            model.CommentNotificationEmail = projectSettings.CommentNotificationEmail;
            model.DaysToComment            = projectSettings.DaysToComment;
            model.Description = projectSettings.Description;
            model.IncludePubDateInPostUrls = projectSettings.IncludePubDateInPostUrls;
            model.LanguageCode             = projectSettings.LanguageCode;
            model.ManagingEditorEmail      = projectSettings.ManagingEditorEmail;
            model.ModerateComments         = projectSettings.ModerateComments;
            model.PostsPerPage             = projectSettings.PostsPerPage;
            model.PubDateFormat            = projectSettings.PubDateFormat;
            //model.RemoteFeedProcessorUseAgentFragment = projectSettings.RemoteFeedProcessorUseAgentFragment;
            model.RemoteFeedUrl             = projectSettings.RemoteFeedUrl;
            model.ShowTitle                 = projectSettings.ShowTitle;
            model.Title                     = projectSettings.Title;
            model.UseMetaDescriptionInFeed  = projectSettings.UseMetaDescriptionInFeed;
            model.WebmasterEmail            = projectSettings.WebmasterEmail;
            model.PostsPerPage              = projectSettings.PostsPerPage;
            model.BlogMenuLinksToNewestPost = projectSettings.BlogMenuLinksToNewestPost;
            model.DefaultPageSlug           = projectSettings.DefaultPageSlug;
            model.BlogPagePosition          = projectSettings.BlogPagePosition;

            bool canManageUsers = false;

            try
            {
                canManageUsers = await authorizationService.AuthorizeAsync(User, "UserManagementPolicy");
            }
            catch (InvalidOperationException) { } // thrown if policy doesn't exist


            if (canManageUsers)
            {
                var contentEditors = await userQueries.GetUsersForClaim(
                    new Guid(projectSettings.Id),
                    ProjectConstants.ContentEditorClaimType,
                    projectSettings.Id
                    );

                if (contentEditors != null)
                {
                    model.Editors.AddRange(contentEditors);
                }

                var blogEditors = await userQueries.GetUsersForClaim(
                    new Guid(projectSettings.Id),
                    ProjectConstants.BlogEditorClaimType,
                    projectSettings.Id
                    );

                if (blogEditors != null)
                {
                    model.Editors.AddRange(blogEditors);
                }

                var pageEditors = await userQueries.GetUsersForClaim(
                    new Guid(projectSettings.Id),
                    ProjectConstants.PageEditorClaimType,
                    projectSettings.Id
                    );

                if (pageEditors != null)
                {
                    model.Editors.AddRange(pageEditors);
                }
            }


            return(View(model));
        }
        public async Task <IActionResult> Index()
        {
            ViewData["Title"] = sr["Content Settings"];

            var projectSettings = await projectService.GetCurrentProjectSettings();

            var model = new ContentSettingsViewModel();

            model.ChannelCategoriesCsv = projectSettings.ChannelCategoriesCsv;
            //model.ChannelRating = projectSettings.ChannelRating;
            //model.ChannelTimeToLive = projectSettings.ChannelTimeToLive;
            model.CommentNotificationEmail = projectSettings.CommentNotificationEmail;
            model.DaysToComment            = projectSettings.DaysToComment;
            model.Description = projectSettings.Description;
            model.IncludePubDateInPostUrls = projectSettings.IncludePubDateInPostUrls;
            model.LanguageCode             = projectSettings.LanguageCode;
            model.ManagingEditorEmail      = projectSettings.ManagingEditorEmail;
            model.ModerateComments         = projectSettings.ModerateComments;
            model.PostsPerPage             = projectSettings.PostsPerPage;
            model.PubDateFormat            = projectSettings.PubDateFormat;
            //model.RemoteFeedProcessorUseAgentFragment = projectSettings.RemoteFeedProcessorUseAgentFragment;
            model.RemoteFeedUrl = projectSettings.RemoteFeedUrl;
            model.ShowTitle     = projectSettings.ShowTitle;
            model.Title         = projectSettings.Title; //aka Blog Page Title
            //model.UseMetaDescriptionInFeed = projectSettings.UseMetaDescriptionInFeed;
            model.WebmasterEmail      = projectSettings.WebmasterEmail;
            model.Publisher           = projectSettings.Publisher;
            model.PublisherLogoUrl    = projectSettings.PublisherLogoUrl;
            model.PublisherLogoHeight = projectSettings.PublisherLogoHeight;
            model.PublisherLogoWidth  = projectSettings.PublisherLogoWidth;
            model.PublisherEntityType = projectSettings.PublisherEntityType;
            model.DisqusShortName     = projectSettings.DisqusShortName;
            model.PostsPerPage        = projectSettings.PostsPerPage;

            model.BlogMenuLinksToNewestPost      = projectSettings.BlogMenuLinksToNewestPost;
            model.DefaultPageSlug                = projectSettings.DefaultPageSlug;
            model.ShowRecentPostsOnDefaultPage   = projectSettings.ShowRecentPostsOnDefaultPage;
            model.ShowFeaturedPostsOnDefaultPage = projectSettings.ShowFeaturedPostsOnDefaultPage;

            model.AddBlogToPagesTree             = projectSettings.AddBlogToPagesTree;
            model.BlogPagePosition               = projectSettings.BlogPagePosition;
            model.BlogPageText                   = projectSettings.BlogPageText;
            model.BlogPageNavComponentVisibility = projectSettings.BlogPageNavComponentVisibility;
            model.LocalMediaVirtualPath          = projectSettings.LocalMediaVirtualPath;
            model.CdnUrl = projectSettings.CdnUrl;

            model.FacebookAppId      = projectSettings.FacebookAppId;
            model.SiteName           = projectSettings.SiteName;
            model.TwitterCreator     = projectSettings.TwitterCreator;
            model.TwitterPublisher   = projectSettings.TwitterPublisher;
            model.DefaultContentType = projectSettings.DefaultContentType;

            model.TeasersDisabled        = _teasersDisabled;
            model.TeaserMode             = projectSettings.TeaserMode;
            model.TeaserTruncationMode   = projectSettings.TeaserTruncationMode;
            model.TeaserTruncationLength = projectSettings.TeaserTruncationLength;

            model.DefaultFeedItems = projectSettings.DefaultFeedItems;
            model.MaxFeedItems     = projectSettings.MaxFeedItems;
            model.AboutContent     = projectSettings.AboutContent;
            model.AboutHeading     = projectSettings.AboutHeading;
            model.ShowAboutBox     = projectSettings.ShowAboutBox;
            model.ShowRelatedPosts = projectSettings.ShowRelatedPosts;

            bool canManageUsers = false;

            try
            {
                var result = await authorizationService.AuthorizeAsync(User, "UserManagementPolicy");

                canManageUsers = result.Succeeded;
            }
            catch (InvalidOperationException) { } // thrown if policy doesn't exist


            if (canManageUsers)
            {
                var contentEditors = await userQueries.GetUsersForClaim(
                    new Guid(projectSettings.Id),
                    ProjectConstants.ContentEditorClaimType,
                    projectSettings.Id
                    );

                if (contentEditors != null)
                {
                    model.Editors.AddRange(contentEditors);
                }

                var blogEditors = await userQueries.GetUsersForClaim(
                    new Guid(projectSettings.Id),
                    ProjectConstants.BlogEditorClaimType,
                    projectSettings.Id
                    );

                if (blogEditors != null)
                {
                    model.Editors.AddRange(blogEditors);
                }

                var pageEditors = await userQueries.GetUsersForClaim(
                    new Guid(projectSettings.Id),
                    ProjectConstants.PageEditorClaimType,
                    projectSettings.Id
                    );

                if (pageEditors != null)
                {
                    model.Editors.AddRange(pageEditors);
                }
            }


            return(View(model));
        }
        public async Task <IActionResult> Index(ContentSettingsViewModel model)
        {
            ViewData["Title"] = sr["Content Settings"];

            if (!ModelState.IsValid)
            {
                model.TeasersDisabled = _teasersDisabled;
                return(View(model));
            }

            var projectSettings = await projectService.GetCurrentProjectSettings();

            projectSettings.ChannelCategoriesCsv = model.ChannelCategoriesCsv;
            //projectSettings.ChannelRating = model.ChannelRating;
            //projectSettings.ChannelTimeToLive = model.ChannelTimeToLive;
            projectSettings.CommentNotificationEmail = model.CommentNotificationEmail;
            projectSettings.DaysToComment            = model.DaysToComment;
            projectSettings.Description = model.Description;
            projectSettings.IncludePubDateInPostUrls = model.IncludePubDateInPostUrls;
            projectSettings.LanguageCode             = model.LanguageCode;
            projectSettings.ManagingEditorEmail      = model.ManagingEditorEmail;
            projectSettings.ModerateComments         = model.ModerateComments;
            projectSettings.PostsPerPage             = model.PostsPerPage;
            projectSettings.PubDateFormat            = model.PubDateFormat;
            //projectSettings.RemoteFeedProcessorUseAgentFragment = model.RemoteFeedProcessorUseAgentFragment;
            projectSettings.RemoteFeedUrl = model.RemoteFeedUrl;
            projectSettings.ShowTitle     = model.ShowTitle;
            projectSettings.Title         = model.Title;
            //projectSettings.UseMetaDescriptionInFeed = model.UseMetaDescriptionInFeed;
            projectSettings.WebmasterEmail                 = model.WebmasterEmail;
            projectSettings.Publisher                      = model.Publisher;
            projectSettings.PublisherLogoUrl               = model.PublisherLogoUrl;
            projectSettings.PublisherLogoWidth             = model.PublisherLogoWidth;
            projectSettings.PublisherLogoHeight            = model.PublisherLogoHeight;
            projectSettings.PublisherEntityType            = model.PublisherEntityType;
            projectSettings.DisqusShortName                = model.DisqusShortName;
            projectSettings.ShowRecentPostsOnDefaultPage   = model.ShowRecentPostsOnDefaultPage;
            projectSettings.ShowFeaturedPostsOnDefaultPage = model.ShowFeaturedPostsOnDefaultPage;

            bool needToClearMenuCache = false;

            if (model.BlogMenuLinksToNewestPost != projectSettings.BlogMenuLinksToNewestPost)
            {
                needToClearMenuCache = true;
            }
            if (model.DefaultPageSlug != projectSettings.DefaultPageSlug)
            {
                needToClearMenuCache = true;
            }
            if (model.AddBlogToPagesTree != projectSettings.AddBlogToPagesTree)
            {
                needToClearMenuCache = true;
            }
            if (model.BlogPagePosition != projectSettings.BlogPagePosition)
            {
                needToClearMenuCache = true;
            }
            if (model.BlogPageText != projectSettings.BlogPageText)
            {
                needToClearMenuCache = true;
            }
            if (model.BlogPageNavComponentVisibility != projectSettings.BlogPageNavComponentVisibility)
            {
                needToClearMenuCache = true;
            }

            projectSettings.BlogMenuLinksToNewestPost = model.BlogMenuLinksToNewestPost;
            projectSettings.DefaultPageSlug           = model.DefaultPageSlug;
            projectSettings.BlogPagePosition          = model.BlogPagePosition;
            projectSettings.AddBlogToPagesTree        = model.AddBlogToPagesTree;
            projectSettings.BlogPageText = model.BlogPageText;
            projectSettings.BlogPageNavComponentVisibility = model.BlogPageNavComponentVisibility;
            projectSettings.LocalMediaVirtualPath          = model.LocalMediaVirtualPath;
            projectSettings.CdnUrl = model.CdnUrl;

            projectSettings.FacebookAppId      = model.FacebookAppId;
            projectSettings.SiteName           = model.SiteName;
            projectSettings.TwitterPublisher   = model.TwitterPublisher;
            projectSettings.TwitterCreator     = model.TwitterCreator;
            projectSettings.DefaultContentType = model.DefaultContentType;

            projectSettings.TeaserMode             = model.TeaserMode;
            projectSettings.TeaserTruncationLength = model.TeaserTruncationLength;
            projectSettings.TeaserTruncationMode   = model.TeaserTruncationMode;

            projectSettings.DefaultFeedItems = model.DefaultFeedItems;
            projectSettings.MaxFeedItems     = model.MaxFeedItems;
            projectSettings.AboutContent     = model.AboutContent;
            projectSettings.AboutHeading     = model.AboutHeading;
            projectSettings.ShowAboutBox     = model.ShowAboutBox;
            projectSettings.ShowRelatedPosts = model.ShowRelatedPosts;

            await projectService.Update(projectSettings);

            if (needToClearMenuCache)
            {
                //projectService.ClearNavigationCache();
                await _navigationTreeBuilderService.ClearTreeCache();
            }

            this.AlertSuccess(sr["Content Settings were successfully updated."], true);

            return(RedirectToAction("Index"));
        }