Fixes: U4-4892 Inconsistent (lack of) instructions regarding file extensions in the UI

This commit is contained in:
Niels Hartvig
2014-06-08 19:18:37 +02:00
parent bff415a4c6
commit 32cfdbe968
4 changed files with 28 additions and 6 deletions

View File

@@ -43,7 +43,11 @@ namespace umbraco
{
var pipesIndex = Alias.IndexOf("|||", System.StringComparison.Ordinal);
var template = Alias.Substring(0, pipesIndex).Trim();
var fileName = Alias.Substring(pipesIndex + 3, Alias.Length - pipesIndex - 3) + ".cshtml";
var fileName = Alias.Substring(pipesIndex + 3, Alias.Length - pipesIndex - 3);
if (!fileName.ToLowerInvariant().EndsWith(".cshtml"))
{
fileName += ".cshtml";
}
var fullFilePath = IOHelper.MapPath(BasePath + fileName);

View File

@@ -27,6 +27,13 @@ namespace umbraco
return true;
}
// remove file extension
if (fileName.ToLowerInvariant().EndsWith(fileType.ToLowerInvariant()))
{
fileName = fileName.Substring(0,
fileName.ToLowerInvariant().LastIndexOf(fileType.ToLowerInvariant(), System.StringComparison.Ordinal) - 1);
}
var found = ApplicationContext.Current.Services.FileService.GetScriptByName(relPath + fileName + "." + fileType);
if (found != null)
{

View File

@@ -24,8 +24,10 @@ namespace umbraco
{
var template = Alias.Substring(0, Alias.IndexOf("|||"));
var fileName = Alias.Substring(Alias.IndexOf("|||") + 3, Alias.Length - Alias.IndexOf("|||") - 3).Replace(" ", "");
if (!fileName.ToLowerInvariant().EndsWith(".xslt"))
fileName += ".xslt";
var xsltTemplateSource = IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/" + template);
var xsltNewFilename = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName + ".xslt");
var xsltNewFilename = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);
if (!System.IO.File.Exists(xsltNewFilename))
{
@@ -58,16 +60,19 @@ namespace umbraco
// Create macro?
if (ParentID == 1)
{
var name = Alias.Substring(Alias.IndexOf("|||") + 3, Alias.Length - Alias.IndexOf("|||") - 3)
.SplitPascalCasing().ToFirstUpperInvariant();
var name = Alias.Substring(Alias.IndexOf("|||") + 3, Alias.Length - Alias.IndexOf("|||") - 3);
if (name.ToLowerInvariant().EndsWith(".xslt"))
name = name.Substring(0, name.Length - 5);
name = name.SplitPascalCasing().ToFirstUpperInvariant();
cms.businesslogic.macro.Macro m =
cms.businesslogic.macro.Macro.MakeNew(name);
m.Xslt = fileName + ".xslt";
m.Xslt = fileName;
m.Save();
}
}
_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/xslt/editXslt.aspx?file={0}.xslt", fileName);
_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/xslt/editXslt.aspx?file={0}", fileName);
return true;
}

View File

@@ -175,6 +175,12 @@ namespace umbraco.cms.businesslogic.web
public static StyleSheet MakeNew(BusinessLogic.User user, string Text, string FileName, string Content)
{
// validate if node ends with css, if it does we'll remove it as we append it later
if (Text.ToLowerInvariant().EndsWith(".css"))
{
Text = Text.Substring(0, Text.Length - 4);
}
// Create the umbraco node
var newNode = CMSNode.MakeNew(-1, ModuleObjectType, user.Id, 1, Text, Guid.NewGuid());