public static webModels.Page ToWebModel(this coreModels.Page page) { var retVal = new webModels.Page(); retVal.Name = page.PageName; if (ContentTypeUtility.IsImageContentType(page.ContentType)) { if (page.ByteContent != null) { retVal.ByteContent = page.ByteContent; } } else if (ContentTypeUtility.IsTextContentType(page.ContentType)) { if (page.ByteContent != null) { retVal.Content = Encoding.UTF8.GetString(page.ByteContent); } } else // treat as a binary file for now { if (page.ByteContent != null) { retVal.ByteContent = page.ByteContent; } } retVal.Language = page.Language; retVal.ModifiedDate = page.Updated.RemoveMilliseconds(); retVal.Id = page.Id; retVal.ContentType = page.ContentType; return(retVal); }
public static IEnumerable <webModels.Page> GetShortPageInfoFromString(string[] pageNameAndLanguages) { var retVal = new List <webModels.Page>(); foreach (var pageNameAndLanguage in pageNameAndLanguages) { var addedItem = new webModels.Page(); addedItem.Name = pageNameAndLanguage.Split('^')[1]; addedItem.Language = pageNameAndLanguage.Split('^')[0]; retVal.Add(addedItem); } return(retVal); }
public static IEnumerable<webModels.Page> GetShortPageInfoFromString(string[] pageNameAndLanguages) { var retVal = new List<webModels.Page>(); foreach (var pageNameAndLanguage in pageNameAndLanguages) { var addedItem = new webModels.Page(); addedItem.Name = pageNameAndLanguage.Split('^')[1]; addedItem.Language = pageNameAndLanguage.Split('^')[0]; retVal.Add(addedItem); } return retVal; }
public static webModels.Page ToPageWebModel(this BlobInfo item) { var retVal = new webModels.Page(); retVal.Name = item.FileName; //Get language from file name file format name.lang.extension var fileNameParts = item.FileName.Split('.'); if(fileNameParts.Count() == 3) { retVal.Language = fileNameParts[1]; retVal.Name = fileNameParts[0] + "." + fileNameParts[2]; } retVal.ContentType = item.ContentType; retVal.ModifiedDate = item.ModifiedDate ?? default(DateTime); return retVal; }
public static webModels.Page ToPageWebModel(this BlobInfo item) { var retVal = new webModels.Page(); retVal.Name = item.FileName; //Get language from file name file format name.lang.extension var fileNameParts = item.FileName.Split('.'); if (fileNameParts.Count() == 3) { retVal.Language = fileNameParts[1]; retVal.Name = fileNameParts[0] + "." + fileNameParts[2]; } retVal.ContentType = item.ContentType; retVal.ModifiedDate = item.ModifiedDate ?? default(DateTime); return(retVal); }
public static coreModels.Page ToCoreModel(this webModels.Page page) { var retVal = new coreModels.Page(); if (page.ByteContent != null) { retVal.ByteContent = page.ByteContent; } else if (!string.IsNullOrEmpty(page.Content)) { retVal.ByteContent = Encoding.UTF8.GetBytes(page.Content); } retVal.PageName = page.Name; retVal.Language = page.Language; retVal.ContentType = page.ContentType; return(retVal); }
public static webModels.Page ToWebModel(this coreModels.Page page) { var retVal = new webModels.Page(); retVal.Name = page.PageName; if (ContentTypeUtility.IsImageContentType(page.ContentType)) { if (page.ByteContent != null) { //retVal.Content = ContentTypeUtility.ConvertImageToBase64String(item.ByteContent, item.ContentType); retVal.ByteContent = page.ByteContent; } //else //{ // retVal.Content = retVal.AssetUrl = item.AssetUrl; //} } else if (ContentTypeUtility.IsTextContentType(page.ContentType)) { if (page.ByteContent != null) { retVal.Content = Encoding.UTF8.GetString(page.ByteContent); } } else // treat as a binary file for now { if (page.ByteContent != null) { retVal.ByteContent = page.ByteContent; } } retVal.Language = page.Language; retVal.ModifiedDate = page.Updated.RemoveMilliseconds(); retVal.Id = page.Id; retVal.ContentType = page.ContentType; return retVal; }
public static webModels.Page ToWebModel(this coreModels.Page page) { var retVal = new webModels.Page(); retVal.Name = page.PageName; if (ContentTypeUtility.IsImageContentType(page.ContentType)) { if (page.ByteContent != null) { //retVal.Content = ContentTypeUtility.ConvertImageToBase64String(item.ByteContent, item.ContentType); retVal.ByteContent = page.ByteContent; } //else //{ // retVal.Content = retVal.AssetUrl = item.AssetUrl; //} } else if (ContentTypeUtility.IsTextContentType(page.ContentType)) { if (page.ByteContent != null) { retVal.Content = Encoding.UTF8.GetString(page.ByteContent); } } else // treat as a binary file for now { if (page.ByteContent != null) { retVal.ByteContent = page.ByteContent; } } retVal.Language = page.Language; retVal.ModifiedDate = page.Updated; retVal.Id = page.Id; retVal.ContentType = page.ContentType; return(retVal); }
public IHttpActionResult SaveItem(string storeId, Page page) { if (!string.IsNullOrEmpty(page.FileUrl)) { using(var webClient = new WebClient()) { var byteContent = webClient.DownloadData(page.FileUrl); page.ByteContent = byteContent; } } _pagesService.SavePage(storeId, page.ToCoreModel()); return Ok(); }
private Page GetDefaultBlog(string blogName) { var name = string.Format("blogs/{0}/default.md", blogName); var retVal = new Page { Id = name, Name = name, Language = "en-US", Content = "<p>Default blog content</p>", ContentType = "text/html" }; return retVal; }
private Page GetDefaultBlog(string blogName) { var retVal = new Page { Id = string.Format("blogs/{0}/default.md", blogName), Name = string.Format("blogs/{0}/default.md", blogName), Content = string.Format("---title: {0} --- ", blogName), ContentType = "text/html" }; return retVal; }
public IHttpActionResult SaveItem(string storeId, Page page) { CheckCurrentUserHasPermissionForObjects(ContentPredefinedPermissions.Update, new ContentScopeObject { StoreId = storeId }); var data = page.ByteContent; if (!string.IsNullOrEmpty(page.FileUrl)) { using (var webClient = new WebClient()) { data = webClient.DownloadData(page.FileUrl); } } else if (data == null) { data = Encoding.UTF8.GetBytes(page.Content); } if (!string.IsNullOrEmpty(page.Language)) { //add language to file name for new page var pageFileNameParts = page.Id.Split('.'); if (pageFileNameParts.Length == 2) { page.Id = pageFileNameParts[0] + "." + page.Language + "." + pageFileNameParts[1]; } } using (var stream = _contentStorageProvider.OpenWrite("/Pages/" + storeId + "/" + page.Id)) using (var memStream = new MemoryStream(data)) { memStream.CopyTo(stream); } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult SaveItem(string storeId, Page page) { base.CheckCurrentUserHasPermissionForObjects(ContentPredefinedPermissions.Update, new ContentScopeObject { StoreId = storeId }); if (!string.IsNullOrEmpty(page.FileUrl)) { using (var webClient = new WebClient()) { var byteContent = webClient.DownloadData(page.FileUrl); page.ByteContent = byteContent; } } _pagesService.SavePage(storeId, page.ToCoreModel()); return StatusCode(HttpStatusCode.NoContent); }