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")); }
public async Task Create(IPage page) { await EnsureProjectSettings().ConfigureAwait(false); if (string.IsNullOrEmpty(page.Slug)) { var rootList = await GetRootPages().ConfigureAwait(false); if (rootList.Count == 0) { // no pages yet, creating first one so use default slug page.Slug = _settings.DefaultPageSlug; } else { var slug = ContentUtils.CreateSlug(page.Title); var available = await SlugIsAvailable(slug); while (!available) { slug = slug + "-"; available = await SlugIsAvailable(slug); } if (available) { page.Slug = slug; } } } await _pageCommands.Create(_settings.Id, page).ConfigureAwait(false); await _eventHandlers.HandleCreated(_settings.Id, page).ConfigureAwait(false); }
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)); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { using (OpenFileDialog ofd = new OpenFileDialog()) { string directory; if (!dialogDirs.TryGetValue(GetType(), out directory)) { directory = InitialDirectory ?? ""; dialogDirs.Add(GetType(), directory); } ofd.InitialDirectory = directory; ofd.RestoreDirectory = true; ofd.Filter = Filter; // set file filter info here if (ofd.ShowDialog() == DialogResult.OK) { var fileName = ofd.FileName; dialogDirs[GetType()] = Path.GetDirectoryName(fileName); if (Path.IsPathRooted(fileName)) { fileName = ContentUtils.MakeRelativePath(Builder.FullInputDirectory + @"\", fileName); } return(fileName); } } return(value); }
public static bool OpenFileDialog(string caption, string filter, string dir, bool getRelativePath, out string fileName) { fileName = null; using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.InitialDirectory = Path.Combine(Builder.FullInputDirectory, dir); ofd.RestoreDirectory = true; ofd.Filter = filter; ofd.Title = caption; // set file filter info here if (ofd.ShowDialog() == DialogResult.OK) { fileName = ofd.FileName; if (Path.IsPathRooted(fileName) && getRelativePath) { fileName = ContentUtils.MakeRelativePath(Builder.FullInputDirectory + @"\", fileName); } return(true); } else { return(false); } } }
/// <summary> /// /// </summary> public void RemoveDescriptors(IEnumerable <string> nameList) { //Path.Conver int count = assets.RemoveAll(item => nameList.Contains(ContentUtils.BackslashesToSlashes(item.AssetPath))); Log.Message("{0} content items removed", count); }
public ActionResult NewContentPage(string schemaId, string editContentHeading) { // Create a new Content Page to be passed to the edit content action var page = GetDefaultContentPage(); // If a schema was passed in, we will want to assign that schema id to the newly created page // We will also want to copy over html from an existing page that uses that html. That way the user has a consistent editor. ApplySchema(page, schemaId); Context.ContentPages.Add(page); Context.SaveChanges(); // Update the page title / permalink with the new id we now have page.DisplayName = "Page " + page.ContentPageId; page.Title = "Page " + page.ContentPageId; page.HTMLContent = ContentUtils.ReplacePageParametersInHtmlContent(page.HTMLUnparsed, page); AddNewPageExtension(page); Context.SaveChanges(); CachedObjects.GetCacheContentPages(true); // Pass content Heading along if it exists object routeParameters = new { id = page.ContentPageId }; if (!String.IsNullOrEmpty(editContentHeading)) { routeParameters = new { id = page.ContentPageId, schema = schemaId, editContentHeading }; } return(RedirectToAction("EditContent", "Pages", routeParameters)); }
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 CategorySingleViewModel(string category, HttpServerUtilityBase server) { _server = server; category = ContentUtils.GetFormattedUrl(category); AllBlogsInCategory = Context.Blogs.Where(x => x.Category.CategoryNameFormatted == category && x.IsActive) .OrderByDescending(blog => blog.Date) .ToList(); BlogRoll = AllBlogsInCategory .Take(MaxBlogCount) .ToList(); TheCategory = Context.BlogCategories.FirstOrDefault(x => x.CategoryNameFormatted == category); var model = new BlogListModel(Context); MaxBlogCount = model.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad; SkipBlogs = MaxBlogCount; BlogTitle = model.GetBlogSettings().BlogTitle; BlogsByCat = AllBlogsInCategory .Take(MaxBlogCount) .ToList(); }
public JsonResult ModifyEvent(Event entity) { JsonResult result = new JsonResult(); if (!String.IsNullOrEmpty(entity.Title)) { Event editedEvent = Context.Events.FirstOrDefault(x => x.EventId == entity.EventId); if (editedEvent != null) { editedEvent.HtmlContent = entity.HtmlContent; editedEvent.FeaturedImageUrl = ContentUtils.ScrubInput(entity.FeaturedImageUrl); editedEvent.IsActive = entity.IsActive; editedEvent.IsFeatured = entity.IsFeatured; editedEvent.Title = ContentUtils.ScrubInput(entity.Title); editedEvent.PermaLink = ContentUtils.ScrubInput(entity.PermaLink); editedEvent.MainCategory = ContentUtils.ScrubInput(entity.MainCategory); editedEvent.EventCategoryId = entity.EventCategoryId; editedEvent.ShortDesc = entity.ShortDesc; editedEvent.StartDate = entity.StartDate; editedEvent.EndDate = entity.EndDate; Context.SaveChanges(); result.Data = new { id = entity.EventId }; } } return(result); }
public CategorySingleViewModel LoadBlogsByCategory(String category) { var catModel = new CategorySingleViewModel(); category = ContentUtils.GetFormattedUrl(category); catModel.AllBlogsInCategory = _context.Blogs.Where(x => x.Category.CategoryNameFormatted == category && x.IsActive) .OrderByDescending(blog => blog.Date) .ToList(); catModel.BlogRoll = catModel.AllBlogsInCategory .Take(catModel.MaxBlogCount) .ToList(); catModel.TheCategory = _context.BlogCategories.FirstOrDefault(x => x.CategoryNameFormatted == category); var model = new BlogListModel(_context); catModel.MaxBlogCount = model.GetBlogSettings().MaxBlogsOnHomepageBeforeLoad; catModel.SkipBlogs = catModel.MaxBlogCount; catModel.BlogTitle = model.GetBlogSettings().BlogTitle; catModel.BlogsByCat = catModel.AllBlogsInCategory .Take(catModel.MaxBlogCount) .ToList(); return(catModel); }
private void SortSpawnsetFilesButton_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; foreach (Image image in spawnsetSortingImages) { if (image == button.Content as Image) { image.Source = new BitmapImage(ContentUtils.MakeUri(System.IO.Path.Combine("Content", "Images", "Buttons", "SpawnsetSortActive.png"))); image.RenderTransform = new ScaleTransform { ScaleY = -(image.RenderTransform as ScaleTransform).ScaleY }; } else { image.Source = new BitmapImage(ContentUtils.MakeUri(System.IO.Path.Combine("Content", "Images", "Buttons", "SpawnsetSort.png"))); } } SpawnsetListSorting <SpawnsetListEntry> sorting = button.Tag as SpawnsetListSorting <SpawnsetListEntry>; SpawnsetListHandler.Instance.ActiveSpawnsetSorting = sorting; SpawnsetListHandler.Instance.ActiveSpawnsetSorting.Ascending = !SpawnsetListHandler.Instance.ActiveSpawnsetSorting.Ascending; SortSpawnsets(sorting); }
public LocalFile(string baseDir, string fullPath) { this.Handled = false; this.BaseDir = baseDir; this.FullPath = fullPath; this.KeyPath = ContentUtils.BackslashesToSlashes(ContentUtils.MakeRelativePath(baseDir + "/", fullPath)); }
public static void SetAutomapperMappings() { Mapper.CreateMap <PageDetails, ContentPage>() .ForAllMembers(p => p.Condition(c => !c.IsSourceValueNull)); Mapper.CreateMap <ContentPage, PageDetails>(); Mapper.CreateMap <ContentPageComplete, ContentPageExtension>() .ForAllMembers(p => p.Condition(c => !c.IsSourceValueNull)); Mapper.CreateMap <ContentPageExtension, ContentPageComplete>() .ForAllMembers(p => p.Condition(c => !c.IsSourceValueNull)); Mapper.CreateMap <Module, ContentModule>().ReverseMap(); Mapper.CreateMap <Settings, SiteSettings>(); Mapper.CreateMap <BlogController.EditBlogModel, Blog>() .ForMember(dest => dest.Category, opts => opts.Ignore()) .ForMember(dest => dest.Tags, opts => opts.Ignore()) .ForMember(dest => dest.Title, opts => opts.MapFrom(src => ContentUtils.ScrubInput(src.Title))) .ForMember(dest => dest.ImageUrl, opts => opts.MapFrom(src => ContentUtils.ScrubInput(src.ImageUrl))) .ForMember(dest => dest.PermaLink, opts => opts.MapFrom(src => ContentUtils.GetFormattedUrl(src.PermaLink))); }
private async Task <string> GetConfigInner(string tenant, string dataId, string group, long timeoutMs) { group = ParamUtils.Null2DefaultGroup(group); ParamUtils.CheckKeyParam(dataId, group); ConfigResponse cr = new ConfigResponse(); cr.SetDataId(dataId); cr.SetTenant(tenant); cr.SetGroup(group); // 优先使用本地配置 string content = await FileLocalConfigInfoProcessor.GetFailoverAsync(_worker.GetAgentName(), dataId, group, tenant); if (content != null) { _logger?.LogWarning( "[{0}] [get-config] get failover ok, dataId={1}, group={2}, tenant={3}, config={4}", _worker.GetAgentName(), dataId, group, tenant, ContentUtils.TruncateContent(content)); cr.SetContent(content); _configFilterChainManager.DoFilter(null, cr); content = cr.GetContent(); return(content); } try { List <string> ct = await _worker.GetServerConfig(dataId, group, tenant, timeoutMs, false); cr.SetContent(ct[0]); _configFilterChainManager.DoFilter(null, cr); content = cr.GetContent(); return(content); } catch (NacosException ioe) { if (NacosException.NO_RIGHT == ioe.ErrorCode) { throw; } _logger?.LogWarning( "[{0}] [get-config] get from server error, dataId={1}, group={2}, tenant={3}, msg={4}", _worker.GetAgentName(), dataId, group, tenant, ioe.ErrorMsg); } _logger?.LogWarning( "[{0}] [get-config] get snapshot ok, dataId={1}, group={2}, tenant={3}, config={4}", _worker.GetAgentName(), dataId, group, tenant, ContentUtils.TruncateContent(content)); content = await FileLocalConfigInfoProcessor.GetSnapshotAync(_worker.GetAgentName(), dataId, group, tenant); cr.SetContent(content); _configFilterChainManager.DoFilter(null, cr); content = cr.GetContent(); return(content); }
public JsonResult AddNewPageFromTemplate(string templatePath, string viewTemplate, string permalink, string title, int parent) { var result = new JsonResult() { Data = new { success = false, message = "There was an error processing you request." } }; // check to see if permalink exists if (Context.ContentPages.Any(x => x.Permalink == permalink)) { result.Data = new { success = false, message = "Permalink is already in use." }; return(result); } var success = 0; var urlLink = ""; var page = new ContentPage { Title = title, IsActive = false, CreateDate = DateTime.UtcNow, Permalink = permalink, DisplayName = permalink, ParentNavigationItemId = parent, Template = !String.IsNullOrEmpty(viewTemplate) ? viewTemplate.ToLower() : "blank", HTMLContent = ContentUtils.RenderPartialViewToString(templatePath, null, ControllerContext, ViewData, TempData), }; Context.ContentPages.Add(page); success = Context.SaveChanges(); var parentHref = NavigationUtils.GetNavItemUrl(parent); if (!String.IsNullOrEmpty(parentHref)) { urlLink = parentHref + page.Permalink; } if (success > 0) { urlLink = string.IsNullOrEmpty(urlLink) ? "/" + page.Permalink : urlLink; result.Data = new { id = page.ContentPageId, url = urlLink, success = true, message = "Page created, redirecting." }; } return(result); }
public async Task <bool> EditPost( string blogId, string postId, string userName, string password, PostStruct post, bool publish) { var existing = await blogService.GetPost( blogId, postId, userName, password ).ConfigureAwait(false); if (existing == null) { return(false); } var update = mapper.GetPostFromStruct(post); existing.Title = update.Title; existing.MetaDescription = update.MetaDescription; existing.Content = update.Content; // TODO: does OLW enable changing pubdate? //if (existing.PubDate != update.PubDate) //{ // await blogService.HandlePubDateAboutToChange(existing, update.PubDate).ConfigureAwait(false); // existing.PubDate = update.PubDate; //} if (!string.Equals(existing.Slug, update.Slug, StringComparison.OrdinalIgnoreCase)) { // slug changed make sure the new slug is available var requestedSlug = ContentUtils.CreateSlug(update.Slug); var available = await blogService.SlugIsAvailable(blogId, requestedSlug).ConfigureAwait(false); if (available) { existing.Slug = requestedSlug; } } existing.Categories = update.Categories; existing.IsPublished = publish; await blogService.Update( blogId, userName, password, existing, publish).ConfigureAwait(false); return(true); }
/// <summary> /// Get a list of blogs based on search term /// </summary> /// <param name="tags"></param> /// <returns></returns> public JsonResult LoadBlogsByTags(string tags = "", string category = "") { var result = new JsonResult(); List <Blog> blogs = model.GetMoreBlogsByTags(tags, category); string html = ContentUtils.RenderPartialViewToString("/Views/Shared/Partials/BlogArticleSinglePartial.cshtml", blogs, ControllerContext, ViewData, TempData); result.Data = new { html = html, skip = 0, buttonClass = "hide" }; return(result); }
/// <summary> /// /// </summary> /// <param name="take"></param> /// <param name="skip"></param> /// <param name="category"></param> /// <param name="id"></param> /// <returns></returns> public JsonResult LoadMoreRelatedBlogs(int take, int skip, string category, int id = 0) { var result = new JsonResult(); List <Blog> blogs = model.GetMoreRelatedBlogs(take, skip, category, id); string html = ContentUtils.RenderPartialViewToString("/Views/Shared/Partials/RelatedBlogSinglePartial.cshtml", blogs, ControllerContext, ViewData, TempData); result.Data = new { html, skip = skip + take, buttonClass = blogs.Count() < take ? "hide" : "" }; return(result); }
private SelectCategoryDescription([NotNull] string name, string description, string filter, string icon, double order) { Name = ContentUtils.Translate(name); Description = ContentUtils.Translate(description); Filter = filter ?? @"*"; Order = order; Icon = ContentUtils.GetIcon(icon ?? name + @".png", _type).Get(); Source = _source; }
private static void LoadContentFromUploadedModel(ContentModule entity, ContentModule editedContent) { editedContent.ModuleName = ContentUtils.ScrubInput(entity.ModuleName); editedContent.HTMLContent = entity.HTMLContent; editedContent.HTMLUnparsed = entity.HTMLUnparsed; editedContent.JSContent = entity.JSContent; editedContent.CSSContent = entity.CSSContent; editedContent.SchemaId = entity.SchemaId; editedContent.SchemaEntryValues = entity.SchemaEntryValues; }
public EditBlogViewModel(string blogId) { var utils = new BlogUtils(Context); BlogId = Int32.Parse(blogId); _memUser = Membership.GetUser(HttpContext.Current.User.Identity.Name); SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath() + "blog/"; ThisBlog = Context.Blogs.FirstOrDefault(x => x.BlogId == BlogId); if (ThisBlog == null) { throw new KeyNotFoundException(); } if (ThisBlog.Category == null) { ThisBlog.Category = utils.GetUncategorizedCategory(); } // Make sure we have a permalink set if (String.IsNullOrEmpty(ThisBlog.PermaLink)) { ThisBlog.PermaLink = ContentUtils.GetFormattedUrl(ThisBlog.Title); Context.SaveChanges(); } // Get the list of Authors for the drop down select BlogUsers = Context.BlogUsers.Where(x => x.IsActive).OrderBy(x => x.DisplayName).ToList(); Categories = Context.BlogCategories.Where(x => x.IsActive).ToList(); UsersSelectedCategories = new List <string>(); _thisUser = Context.Users.FirstOrDefault(x => x.Username == _memUser.UserName); // Get and parse tags for unqiue count var tagList = Context.Blogs.Select(x => x.Tags).ToList(); var tagStr = String.Join(",", tagList); var tags = tagStr.Split(',').Select(x => x.Trim()).ToList(); TagCounts = new List <TagMetric>(); TagCounts = Context.BlogTags.Select(t => new TagMetric() { Tag = t.BlogTagName, Count = t.Blogs.Count() }).ToList(); BookmarkTitle = ThisBlog.Title; // Get the admin modules that will be displayed to the user in each column getAdminModules(); }
/// <summary> /// If no title or category, could be just listing page. /// If no title, but category is set, probably a category listing page /// If title and category are set, individual blog. /// </summary> /// <param name="title"></param> /// <param name="category"></param> /// <param name="date"></param> /// <returns>View</returns> public ActionResult Index(string title, string category, string date) { // Blog Listing Homepage if (String.IsNullOrEmpty(title) && String.IsNullOrEmpty(category)) { var model = new BlogHomeViewModel(date); return(View("~/Views/Home/Blog.cshtml", model)); } // Category if (String.IsNullOrEmpty(title)) { // Category var cats = Context.BlogCategories.ToList().Select(x => ContentUtils.GetFormattedUrl(x.CategoryName)); if (cats.Contains(category)) { var model = new CategorySingleViewModel(category, Server); return(View("~/Views/Blog/CategoriesSingle.cshtml", model)); } // Not a blog category or tags page HttpContext.Response.StatusCode = 404; return(View("~/Views/Home/Error404.cshtml")); } // Tag if (category == "tags" && !string.IsNullOrEmpty(title)) { var model = new TagSingleViewModel(title); return(View("~/Views/Blog/TagSingle.cshtml", model)); } // Blog User if (category == "user" && !string.IsNullOrEmpty(title)) { var model = new BlogsByUserViewModel(title); return(View("~/Views/Blog/BlogsByUser.cshtml", model)); } // Category is set and we are trying to view an individual blog var blog = Context.Blogs.FirstOrDefault(x => x.PermaLink == title); if (blog != null) { var theModel = new BlogSingleHomeViewModel(title); return(View("~/Views/Home/BlogSingle.cshtml", theModel)); } // Not a blog category or a blog HttpContext.Response.StatusCode = 404; return(View("~/Views/Home/Error404.cshtml")); }
private async Task CheckLocalConfig(string agentName, CacheData cacheData) { string dataId = cacheData.DataId; string group = cacheData.Group; string tenant = cacheData.Tenant; var path = FileLocalConfigInfoProcessor.GetFailoverFile(agentName, dataId, group, tenant); if (!cacheData.IsUseLocalConfig && path.Exists) { string content = await FileLocalConfigInfoProcessor.GetFailoverAsync(agentName, dataId, group, tenant); string md5 = HashUtil.GetMd5(content); cacheData.SetUseLocalConfigInfo(true); cacheData.SetLocalConfigInfoVersion(path.LastWriteTimeUtc.ToTimestamp()); cacheData.SetContent(content); _logger?.LogWarning( "[{0}] [failover-change] failover file created. dataId={1}, group={2}, tenant={3}, md5={4}, content={5}", agentName, dataId, group, tenant, md5, ContentUtils.TruncateContent(content)); return; } // If use local config info, then it doesn't notify business listener and notify after getting from server. if (cacheData.IsUseLocalConfig && !path.Exists) { cacheData.SetUseLocalConfigInfo(false); _logger?.LogWarning( "[{0}] [failover-change] failover file deleted. dataId={1}, group={2}, tenant={3}", agentName, dataId, group, tenant); return; } // When it changed. if (cacheData.IsUseLocalConfig && path.Exists && cacheData.GetLocalConfigInfoVersion() != path.LastWriteTimeUtc.ToTimestamp()) { string content = await FileLocalConfigInfoProcessor.GetFailoverAsync(agentName, dataId, group, tenant); string md5 = HashUtil.GetMd5(content); cacheData.SetUseLocalConfigInfo(true); cacheData.SetLocalConfigInfoVersion(path.LastWriteTimeUtc.ToTimestamp()); cacheData.SetContent(content); _logger?.LogWarning( "[{0}] [failover-change] failover file created. dataId={1}, group={2}, tenant={3}, md5={4}, content={5}", agentName, dataId, group, tenant, md5, ContentUtils.TruncateContent(content)); } }
public JsonResult ModifyContent(ContentPageComplete page, bool isBasic) { var result = new JsonResult(); if (page.Details == null || String.IsNullOrEmpty(page.Details.Title)) { return(result); } if (String.IsNullOrEmpty(page.Details.Title)) { return(result); } var editedContent = Context.ContentPages.FirstOrDefault(x => x.ContentPageId == page.Details.ContentPageId); if (editedContent == null) { return(result); } var contentUtility = new ContentUtils(); if (contentUtility.CheckPermalink(page.Details.Permalink, page.Details.ContentPageId, page.Details.ParentNavigationItemId)) { // permalink exists already under this parent page id result.Data = new { permalinkExists = true }; return(result); } SaveDraftInDb(page, editedContent.PublishDate); BookmarkUtil.UpdateTitle("/admin/pages/editcontent/" + editedContent.ContentPageId + "/", page.Details.Title); SetContentPageData(editedContent, page.Details, false, isBasic, null); UpdatePageExtenstion(page); editedContent.IsActive = true; // Saving / Publishing content sets this to true. editedContent.NoIndex = page.Details.NoIndex; editedContent.NoFollow = page.Details.NoFollow; Context.SaveChanges(); CachedObjects.GetCacheContentPages(true); result.Data = new { publishDate = SystemTime.CurrentLocalTime.ToString("MM/dd/yyyy @ hh:mm") }; return(result); }
/// <summary> /// /// </summary> /// <param name="keyPath"></param> public static void OpenReport(string keyPath) { string reportPath = Path.Combine(Options.FullTempDirectory, ContentUtils.GetHashedFileName(keyPath, ".html")); if (File.Exists(reportPath)) { Misc.ShellExecute(reportPath); } else { throw new BuildException(string.Format("File {0} not found", reportPath)); } }
/// <summary> /// /// </summary> /// <param name="lastMonth"></param> /// <param name="count"></param> /// <param name="idList"></param> /// <param name="user"></param> /// <param name="date"></param> /// <returns></returns> public JsonResult LoadMoreArchives(string lastMonth, int count, List <string> idList, string user = "", string date = "") { var result = new JsonResult(); IEnumerable <string> archives = model.GetArchives(lastMonth, count, idList, user, date); string html = ContentUtils.RenderPartialViewToString("/Views/Shared/Partials/BlogArchiveSinglePartial.cshtml", archives, ControllerContext, ViewData, TempData); lastMonth = !archives.Any() ? "0" : ""; result.Data = new { html = html, lastMonth = lastMonth }; return(result); }
public void OutputPageLinks() { bool forcePageSearch = true; StringBuilder html = new StringBuilder(); Dictionary <int, CmsPage> allPages = CmsContext.HomePage.getLinearizedPages(); if (!forcePageSearch && !DoPageSearch) { html.Append("<p><a onclick=\"document.getElementById('spinnerImg').display='block'; return true;\" href=\"DeleteResourcePopup.aspx?DoPageSearch=true&FileUrl=" + FileUrl + "\">Search entire site (" + allPages.Keys.Count + " pages) for this link</a> (slow!)"); html.Append(" <img style=\"display: none\" id=\"spinnerImg\" src=\"" + CmsContext.ApplicationPath + "images/_system/ajax-loader_16x16.gif\">"); html.Append("</p>"); } else { int numPagesFound = 0; html.Append("<strong>This link has been found on the following pages:</strong>"); html.Append("<ul>"); foreach (CmsPage pageToSearch in allPages.Values) { foreach (CmsLanguage lang in CmsConfig.Languages) { string[] linksToFind = new string[] { FileUrl }; string phContent = pageToSearch.renderAllPlaceholdersToString(lang, CmsPage.RenderPlaceholderFilterAction.RunAllPageAndPlaceholderFilters); string[] linksInPage = ContentUtils.FindFileLinksInHtml(phContent, linksToFind); if (linksInPage.Length > 0) { numPagesFound++; html.Append("<li><a href=\"" + pageToSearch.getUrl(CmsUrlFormat.FullIncludingProtocolAndDomainName, lang) + "\" target=\"_blank\">" + pageToSearch.getTitle(lang) + "</a> (" + pageToSearch.getPath(lang) + ")</li>" + Environment.NewLine); } } // foreach language } // foreach page html.Append("</ul>"); if (numPagesFound == 0) { html.Append("<p><strong>" + allPages.Keys.Count + " pages have been searched, and this link has not been found</strong></p>"); } else { html.Append("<p><strong>" + allPages.Keys.Count + " pages have been searched, and this link has been found on " + numPagesFound + " pages</strong></p>"); } } Response.Write(html.ToString()); }
public async Task Create( IPage page, bool publish) { await EnsureProjectSettings().ConfigureAwait(false); if (publish) { page.PubDate = DateTime.UtcNow; } if (string.IsNullOrEmpty(page.Slug)) { var slug = ContentUtils.CreateSlug(page.Title); var available = await SlugIsAvailable(slug); if (available) { page.Slug = slug; } } var urlHelper = urlHelperFactory.GetUrlHelper(actionContextAccesor.ActionContext); var imageAbsoluteBaseUrl = urlHelper.Content("~" + settings.LocalMediaVirtualPath); if (context != null) { imageAbsoluteBaseUrl = context.Request.AppBaseUrl() + settings.LocalMediaVirtualPath; } //this is no longer needed, we once used bootstrapwysiwyg which passed images as base64 content // but we don't use that anymore. now we have ckeditor and filemanager integration //page.Content = await mediaProcessor.ConvertBase64EmbeddedImagesToFilesWithUrls( // settings.LocalMediaVirtualPath, // page.Content // ).ConfigureAwait(false); var nonPublishedDate = new DateTime(1, 1, 1); if (page.PubDate == nonPublishedDate) { page.PubDate = DateTime.UtcNow; } await pageCommands.Create(settings.Id, page).ConfigureAwait(false); await eventHandlers.HandleCreated(settings.Id, page).ConfigureAwait(false); }
public async Task Create( IPage page, bool publish) { await EnsureProjectSettings().ConfigureAwait(false); if (publish) { page.PubDate = DateTime.UtcNow; } if (string.IsNullOrEmpty(page.Slug)) { var slug = ContentUtils.CreateSlug(page.Title); var available = await PageSlugIsAvailable(slug); if (available) { page.Slug = slug; } } var urlHelper = urlHelperFactory.GetUrlHelper(actionContextAccesor.ActionContext); var imageAbsoluteBaseUrl = urlHelper.Content("~" + settings.LocalMediaVirtualPath); if (context != null) { imageAbsoluteBaseUrl = context.Request.AppBaseUrl() + settings.LocalMediaVirtualPath; } page.Content = await mediaProcessor.ConvertBase64EmbeddedImagesToFilesWithUrls( settings.LocalMediaVirtualPath, page.Content ).ConfigureAwait(false); var nonPublishedDate = new DateTime(1, 1, 1); if (page.PubDate == nonPublishedDate) { page.PubDate = DateTime.UtcNow; } await pageCommands.Create(settings.Id, page).ConfigureAwait(false); await eventHandlers.HandleCreated(settings.Id, page).ConfigureAwait(false); }
public JsonResult CheckPermalink(int id, string permalink, int parentId = 0) { var result = new JsonResult() { Data = new { success = true, message = "" } }; // if id == 0, this is not a content page, we are not verifying permalink, should be from event call, just return if (id < 1) { return result; } var contentUtility = new ContentUtils(); // check to see if permalink exists if (contentUtility.CheckPermalink(permalink, id, parentId)) { result.Data = new { success = false, message = "Permalink is already in use." }; } return result; }
public JsonResult AddNewPageFromTemplate(string templatePath, string viewTemplate, string permalink, string title, int parent) { var result = new JsonResult(); var contentUtility = new ContentUtils(); // check to see if permalink exists if (contentUtility.CheckPermalink(permalink, 0, parent)) { result.Data = new { success = false, message = "Permalink is already in use." }; return result; } var urlLink = ""; var page = new ContentPage { Title = title, IsActive = false, CreateDate = DateTime.UtcNow, Permalink = permalink, DisplayName = permalink, ParentNavigationItemId = parent, Template = !String.IsNullOrEmpty(viewTemplate) ? viewTemplate.ToLower() : "blank", HTMLUnparsed = ContentUtils.RenderPartialViewToString(templatePath, null, ControllerContext, ViewData, TempData), HTMLContent = ContentUtils.RenderPartialViewToString(templatePath, null, ControllerContext, ViewData, TempData) }; try { Context.ContentPages.Add(page); Context.SaveChanges(); page.HTMLContent = ContentUtils.ReplacePageParametersInHtmlContent(page.HTMLUnparsed, page); Context.SaveChanges(); } catch (Exception) { result.Data = new { success = false, message = "Page could not be created." }; return result; } CachedObjects.GetCacheContentPages(true); var parentHref = NavigationUtils.GetNavItemUrl(parent); if (!String.IsNullOrEmpty(parentHref)) { urlLink = parentHref + page.Permalink; } urlLink = string.IsNullOrEmpty(urlLink) ? "/" + page.Permalink : urlLink; result.Data = new { id = page.ContentPageId, url = urlLink, success = true, message = "Page created, redirecting." }; return result; }
public JsonResult ModifyContent(ContentPageComplete page, bool isBasic) { var result = new JsonResult(); if (page.Details == null || String.IsNullOrEmpty(page.Details.Title)) { return result; } if (String.IsNullOrEmpty(page.Details.Title)) return result; var editedContent = Context.ContentPages.FirstOrDefault(x => x.ContentPageId == page.Details.ContentPageId); if (editedContent == null) { return result; } var contentUtility = new ContentUtils(); if (contentUtility.CheckPermalink(page.Details.Permalink, page.Details.ContentPageId, page.Details.ParentNavigationItemId)) { // permalink exists already under this parent page id result.Data = new { permalinkExists = true }; return result; } SaveDraftInDb(page, editedContent.PublishDate); BookmarkUtil.UpdateTitle("/admin/pages/editcontent/" + editedContent.ContentPageId + "/", page.Details.Title); SetContentPageData(editedContent, page.Details, false, isBasic, null); UpdatePageExtenstion(page); editedContent.IsActive = true; // Saving / Publishing content sets this to true. editedContent.NoIndex = page.Details.NoIndex; editedContent.NoFollow = page.Details.NoFollow; Context.SaveChanges(); CachedObjects.GetCacheContentPages(true); result.Data = new { publishDate = SystemTime.CurrentLocalTime.ToString("MM/dd/yyyy @ hh:mm") }; return result; }