diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 54818e4477..79fad32639 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -845,6 +845,7 @@ To manage your website, simply open the Umbraco back office and start adding con Script view saved without any errors! Script view not saved An error occurred saving the file. + An error occurred saving the file. Uses CSS syntax ex: h1, .redHeader, .blueTex diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 3548526c83..4da1607c4b 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -846,6 +846,7 @@ To manage your website, simply open the Umbraco back office and start adding con Script view saved without any errors! Script view not saved An error occurred saving the file. + An error occurred saving the file. Uses CSS syntax ex: h1, .redHeader, .blueTex diff --git a/src/Umbraco.Web/WebServices/SaveFileController.cs b/src/Umbraco.Web/WebServices/SaveFileController.cs index bdae3e0804..cae33983da 100644 --- a/src/Umbraco.Web/WebServices/SaveFileController.cs +++ b/src/Umbraco.Web/WebServices/SaveFileController.cs @@ -187,7 +187,7 @@ namespace Umbraco.Web.WebServices [HttpPost] public JsonResult SaveScript(string filename, string oldName, string contents) { - filename = filename.TrimStart(System.IO.Path.DirectorySeparatorChar); + filename = filename.TrimStart('/', '\\'); var svce = (FileService) Services.FileService; var script = svce.GetScriptByName(oldName); @@ -220,6 +220,42 @@ namespace Umbraco.Web.WebServices }); } + [HttpPost] + public JsonResult SaveStylesheet(string filename, string oldName, string contents) + { + filename = filename.TrimStart('/', '\\'); + + var svce = (FileService) Services.FileService; + var stylesheet = svce.GetStylesheetByName(oldName); + if (stylesheet == null) + stylesheet = new Stylesheet(filename); + else + stylesheet.Path = filename; + stylesheet.Content = contents; + + try + { + if (svce.ValidateStylesheet(stylesheet) == false) + return Failed(ui.Text("speechBubbles", "cssErrorText"), ui.Text("speechBubbles", "cssErrorHeader"), + new FileSecurityException("File '" + filename + "' is not a valid stylesheet file.")); + + svce.SaveStylesheet(stylesheet); + } + catch (Exception e) + { + return Failed(ui.Text("speechBubbles", "cssErrorText"), ui.Text("speechBubbles", "cssErrorHeader"), e); + } + + return Success(ui.Text("speechBubbles", "cssSavedText"), ui.Text("speechBubbles", "cssSavedHeader"), + new + { + path = DeepLink.GetTreePathFromFilePath(stylesheet.Path), + name = stylesheet.Path, + url = stylesheet.VirtualPath, + contents = stylesheet.Content + }); + } + /// /// Returns a successful message ///