Converted all resources over to use a newer structure for generating URLs, created unit tests for those, fixed the js build so that the name is still "umbraco" not "umbraco 7" since that causes problems with css and other file references.
This commit is contained in:
@@ -48,15 +48,26 @@ namespace Umbraco.Web.Editors
|
||||
//now we need to build up the variables
|
||||
var d = new Dictionary<string, object>
|
||||
{
|
||||
{"umbracoPath", GlobalSettings.Path},
|
||||
{"legacyTreeJs", Url.Action("LegacyTreeJs", "BackOffice")},
|
||||
{"contentApiBaseUrl", Url.GetUmbracoApiService<ContentController>("PostSave").TrimEnd("PostSave")},
|
||||
{"mediaApiBaseUrl", Url.GetUmbracoApiService<MediaController>("GetRootMedia").TrimEnd("GetRootMedia")},
|
||||
{"sectionApiBaseUrl", Url.GetUmbracoApiService<SectionController>("GetSections").TrimEnd("GetSections")},
|
||||
{"treeApplicationApiBaseUrl", Url.GetUmbracoApiService<ApplicationTreeController>("GetApplicationTrees").TrimEnd("GetApplicationTrees")},
|
||||
{"contentTypeApiBaseUrl", Url.GetUmbracoApiService<ContentTypeController>("GetAllowedChildren").TrimEnd("GetAllowedChildren")},
|
||||
{"mediaTypeApiBaseUrl", Url.GetUmbracoApiService<MediaTypeApiController>("GetAllowedChildren").TrimEnd("GetAllowedChildren")},
|
||||
{"authenticationApiBaseUrl", Url.GetUmbracoApiService<AuthenticationController>("PostLogin").TrimEnd("PostLogin")}
|
||||
{
|
||||
"umbracoUrls", new Dictionary<string, object>
|
||||
{
|
||||
{"legacyTreeJs", Url.Action("LegacyTreeJs", "BackOffice")},
|
||||
//API URLs
|
||||
{"contentApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<ContentController>("PostSave")},
|
||||
{"mediaApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<MediaController>("GetRootMedia")},
|
||||
{"sectionApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<SectionController>("GetSections")},
|
||||
{"treeApplicationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<ApplicationTreeController>("GetApplicationTrees")},
|
||||
{"contentTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<ContentTypeController>("GetAllowedChildren")},
|
||||
{"mediaTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<MediaTypeApiController>("GetAllowedChildren")},
|
||||
{"authenticationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<AuthenticationController>("PostLogin")}
|
||||
}
|
||||
},
|
||||
{
|
||||
"umbracoSettings", new Dictionary<string, object>
|
||||
{
|
||||
{"umbracoPath", GlobalSettings.Path}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return JavaScript(ServerVariablesParser.Parse(d));
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
using Umbraco.Web.Mvc;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.UI;
|
||||
using Umbraco.Web.WebApi;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
@@ -16,7 +22,7 @@ namespace Umbraco.Web.Editors
|
||||
/// </summary>
|
||||
public LegacyController()
|
||||
: this(UmbracoContext.Current)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,15 +34,30 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// This will perform the delete operation for legacy items which include any item that
|
||||
///// has functionality included in the ui.xml structure.
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public HttpResponseMessage DeleteLegacyItem(string nodeId, string nodeType)
|
||||
//{
|
||||
|
||||
//}
|
||||
/// <summary>
|
||||
/// This will perform the delete operation for legacy items which include any item that
|
||||
/// has functionality included in the ui.xml structure.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public HttpResponseMessage DeleteLegacyItem(string nodeId, string nodeType, string nodeText)
|
||||
{
|
||||
//In order to process this request we MUST have an HttpContext available
|
||||
var httpContextAttempt = TryGetHttpContext();
|
||||
if (httpContextAttempt.Success)
|
||||
{
|
||||
int id;
|
||||
if (int.TryParse(nodeId, out id))
|
||||
{
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, UmbracoUser, nodeType, id, nodeText);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
//We must have an integer id for this to work
|
||||
throw new HttpResponseException(HttpStatusCode.PreconditionFailed);
|
||||
}
|
||||
//We must have an HttpContext available for this to work.
|
||||
throw new HttpResponseException(HttpStatusCode.PreconditionFailed);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,19 @@ namespace Umbraco.Web
|
||||
return url.GetUmbracoApiService(actionName, typeof (T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the Base Url (not including the action) for a Web Api service
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="actionName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUmbracoApiServiceBaseUrl<T>(this UrlHelper url, string actionName)
|
||||
where T : UmbracoApiController
|
||||
{
|
||||
return url.GetUmbracoApiService<T>(actionName).TrimEnd(actionName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the Url for a Web Api service
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -21,6 +22,24 @@ namespace Umbraco.Web.WebApi
|
||||
Umbraco = new UmbracoHelper(umbracoContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to retreive the current HttpContext if one exists.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected Attempt<HttpContextBase> TryGetHttpContext()
|
||||
{
|
||||
object context;
|
||||
if (Request.Properties.TryGetValue("MS_HttpContext", out context))
|
||||
{
|
||||
var httpContext = context as HttpContext;
|
||||
if (httpContext != null)
|
||||
{
|
||||
return new Attempt<HttpContextBase>(true, new HttpContextWrapper(httpContext));
|
||||
}
|
||||
}
|
||||
return Attempt<HttpContextBase>.False;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current ApplicationContext
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user