Example #1
0
        public ActionResult Index()
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByTitle("home")
            };

            if (model.ThePage != null)
            {
                ViewBag.IsPage      = true;
                ViewBag.PageId      = model.ThePage.ContentPageId;
                ViewBag.IsPublished = model.ThePage.IsActive;
                ViewBag.OGType      = model.ThePage.OGType ?? "website";
                ViewBag.MetaDesc    = model.ThePage.MetaDescription ?? "";
                ViewBag.Title       = model.ThePage.Title;
                ViewBag.OGTitle     = model.ThePage.Title ?? model.ThePage.OGTitle;
                ViewBag.OGImage     = model.ThePage.OGImage ?? "";
                model.TheTemplate   = ContentLoader.GetContentTemplate(model.ThePage.Template);
                // Set the page Canonical Tag and OGURl
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? GetCanonical(model.ThePage);
                ViewBag.Canonical = GetCanonical(model.ThePage);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent, Context);
                ViewBag.Index     = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow    = model.ThePage.NoFollow ? "nofollow" : "follow";

                return(View(model.TheTemplate.ViewLocation, model));
            }

            HttpContext.Response.StatusCode = 404;
            return(View("~/Views/Home/Error404.cshtml"));
        }
Example #2
0
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsById(id)
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            if (model.ThePage != null)
            {
                ViewBag.IsPublished = model.IsPublished;
                return(View(model.TheTemplate.ViewLocation, model));
            }

            model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsById(Convert.ToInt16(ConfigurationManager.AppSettings["404ContentPageId"]))
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage      = true;
            ViewBag.PageId      = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title       = model.ThePage.Title;
            ViewBag.Index       = "noindex";
            ViewBag.Follow      = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return(View(model.TheTemplate.ViewLocation, model));
        }
        public ActionResult ResetPasswordSuccess()
        {
            var model = new ContentViewViewModel("resetpasswordsuccess");

            if (model.ThePage != null)
            {
                return(View(model.TheTemplate.ViewLocation, model));
            }

            model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByTitle("404")
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage      = true;
            ViewBag.PageId      = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title       = model.ThePage.Title;
            ViewBag.Index       = "noindex";
            ViewBag.Follow      = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return(View(model.TheTemplate.ViewLocation, model));
        }
Example #4
0
        public ActionResult Index()
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByPermalink("home")
            };

            if (model.ThePage != null)
            {
                ViewBag.IsPage      = true;
                ViewBag.PageId      = model.ThePage.ContentPageId;
                ViewBag.IsPublished = model.ThePage.IsActive;
                ViewBag.OGType      = model.ThePage.OGType ?? "website";
                ViewBag.MetaDesc    = model.ThePage.MetaDescription ?? "";
                ViewBag.Title       = model.ThePage.Title;
                ViewBag.OGTitle     = model.ThePage.Title ?? model.ThePage.OGTitle;
                ViewBag.OGImage     = model.ThePage.OGImage ?? "";
                model.TheTemplate   = ContentLoader.GetContentTemplate(model.ThePage.Template);
                // Set the page Canonical Tag and OGURl
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? GetCanonical(model.ThePage);
                ViewBag.Canonical = GetCanonical(model.ThePage);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);
                ViewBag.Index     = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow    = model.ThePage.NoFollow ? "nofollow" : "follow";

                return(View(model.TheTemplate.ViewLocation, model));
            }

            model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsById(Convert.ToInt16(ConfigurationManager.AppSettings["404ContentPageId"]))
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage      = true;
            ViewBag.PageId      = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title       = model.ThePage.Title;
            ViewBag.Index       = "noindex";
            ViewBag.Follow      = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return(View(model.TheTemplate.ViewLocation, model));
        }
Example #5
0
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailById(id)
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent, Context);

            if (model.ThePage != null)
            {
                ViewBag.IsPublished = model.IsPublished;
                return(View(model.TheTemplate.ViewLocation, model));
            }

            HttpContext.Response.StatusCode = 404;
            return(View("~/Views/Home/Error404.cshtml"));
        }
Example #6
0
        private ContentViewViewModel GetSubDirectoryModel(string path)
        {
            var masterList = CachedObjects.GetMasterNavigationList();
            var pathPieces = path.Split('/');
            var permalink  = pathPieces.Last().ToLower();

            var currentPath       = "/" + pathPieces[0] + "/";
            var currentNavigation = masterList.FirstOrDefault(x => String.Equals(x.Href, currentPath, StringComparison.CurrentCultureIgnoreCase));

            foreach (var piece in pathPieces.Skip(1).Take(pathPieces.Count() - 2))
            {
                if (currentNavigation == null)
                {
                    break;
                }
                currentPath       = currentPath + piece + "/";
                currentNavigation = currentNavigation.Children.FirstOrDefault(x => String.Equals(x.Href, currentPath, StringComparison.CurrentCultureIgnoreCase));
            }

            if (currentNavigation == null)
            {
                return(null);
            }

            var thePage = CachedObjects.GetCacheContentPages().FirstOrDefault(x => x.Permalink == permalink && x.ParentNavigationItemId == currentNavigation.NavigationItemId);

            if (thePage != null)
            {
                var model = new ContentViewViewModel {
                    ThePage = ContentLoader.GetDetailById(thePage.ContentPageId)
                };
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent, Context);
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        public ActionResult Index()
        {
            ContentViewViewModel model = null;

            //Remove query string
            var thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path));

            // Check for content pages before returning a 404
            var title = GetPageTitle(thisUri);

            // If url has a subdirectory, try the master url list to see if it is a child page
            bool hasSubDirectory = title.Contains("/");

            if (hasSubDirectory)
            {
                model = GetSubDirectoryModel(title);
            }

            // If not a subdirectory try based on permalink / title
            if (model == null || model.ThePage == null)
            {
                model = new ContentViewViewModel {
                    ThePage = ContentLoader.GetDetailsByTitle(title)
                };
            }

            // If we found a hit, return the view, otherwise 404
            if (model.ThePage != null)
            {
                model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
                model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

                if (UserUtils.UserIsAdmin())
                {
                    var userName = UserUtils.CurrentMembershipUsername();
                    var user     = Context.Users.First(usr => usr.Username == userName);

                    var pageModel         = new EditContentViewModel();
                    var editContentHelper = new EditContentHelper(Context);
                    editContentHelper.LoadContentViewById(model.ThePage.ContentPageId, pageModel);

                    pageModel.BookmarkTitle = model.ThePage.Title;
                    pageModel.IsBookmarked  =
                        Context.Bookmarks.Any(
                            bookmark =>
                            bookmark.Title == title && bookmark.Url == Request.RawUrl &&
                            bookmark.UserId == user.UserId);


                    ViewBag.PageModel = pageModel;
                }

                ViewBag.IsPage      = true;
                ViewBag.PageId      = model.ThePage.ContentPageId;
                ViewBag.IsPublished = model.ThePage.IsActive;
                ViewBag.OGType      = model.ThePage.OGType ?? "website";
                ViewBag.MetaDesc    = model.ThePage.MetaDescription ?? "";
                ViewBag.Title       = model.ThePage.Title;
                ViewBag.OGTitle     = model.ThePage.Title ?? model.ThePage.OGTitle;
                ViewBag.OGImage     = model.ThePage.OGImage ?? "";

                // Set the page Canonical Tag and OGURl
                ViewBag.Canonical = GetCanonical(model.ThePage);
                ViewBag.OGUrl     = model.ThePage.OGUrl ?? ViewBag.Canonical;

                ViewBag.Index  = model.ThePage.NoIndex ? "noindex" : "index";
                ViewBag.Follow = model.ThePage.NoFollow ? "nofollow" : "follow";

                return(View(model.TheTemplate.ViewLocation, model));
            }

            model = new ContentViewViewModel {
                ThePage = ContentLoader.GetDetailsByTitle("404")
            };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData    = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage      = true;
            ViewBag.PageId      = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title       = model.ThePage.Title;
            ViewBag.Index       = "noindex";
            ViewBag.Follow      = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return(View(model.TheTemplate.ViewLocation, model));
        }