Updating XmlRpc functionality to clear up the confusion with Live Writer (WLW) and categories (since there is not category support)

- updated IXmlRpcHandler to also have a vvoid SetCapabilities(XElement element) so handlers can specify what capabilities they support
- updated the WLW manifest to have a thiner capability set (e.g. no category support) so handlers can light up what they support
- updated the XmlRpcHandlers to add what capabilities they support. there'a room for imporoving (adding/removing) specified capabilities here so the WLW only shows features for what's supported
- added WLW support for tags so a tags input can be used in place of the categories input in the WLW UI

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-17 15:36:57 -08:00
parent 5b8bbfb3cf
commit bb3e63b9d9
17 changed files with 331 additions and 111 deletions
@@ -147,6 +147,7 @@
<Compile Include="Widgets\RuleEngine\UrlRuleProviderTest.cs" />
<Compile Include="Widgets\Services\WidgetsServiceTest.cs" />
<Compile Include="Widgets\WidgetsTests.cs" />
<Compile Include="XmlRpc\Controllers\LiveWriterControllerTests.cs" />
<Compile Include="XmlRpc\Controllers\HomeControllerTests.cs" />
<Compile Include="XmlRpc\Services\XmlRpcReaderTests.cs" />
<Compile Include="XmlRpc\Services\XmlRpcWriterTests.cs" />
@@ -37,6 +37,8 @@ namespace Orchard.Tests.Modules.XmlRpc.Controllers {
}
public class StubHandler : IXmlRpcHandler {
public void SetCapabilities(XElement element) {}
public void Process(XmlRpcContext context) {
ProcessCalls++;
context.Response = new XRpcMethodResponse();
@@ -0,0 +1,60 @@
using System;
using System.Web.Mvc;
using System.Xml.Linq;
using Autofac;
using NUnit.Framework;
using Orchard.Core.XmlRpc;
using Orchard.Core.XmlRpc.Controllers;
using Orchard.Core.XmlRpc.Models;
using Orchard.Core.XmlRpc.Services;
namespace Orchard.Tests.Modules.XmlRpc.Controllers {
[TestFixture]
public class LiveWriterControllerTests {
[Test]
public void HandlersShouldSetCapabilitiesForManifest() {
var thing = new StubHandler();
var thingToo = new StubTooHandler();
var builder = new ContainerBuilder();
builder.RegisterType<LiveWriterController>();
builder.RegisterType<XmlRpcReader>().As<IMapper<XElement, XRpcMethodCall>>();
builder.RegisterType<XmlRpcWriter>().As<IMapper<XRpcMethodResponse, XElement>>();
builder.RegisterInstance(thing).As<IXmlRpcHandler>();
builder.RegisterInstance(thingToo).As<IXmlRpcHandler>();
var container = builder.Build();
var controller = container.Resolve<LiveWriterController>();
var result = controller.Manifest() as ContentResult;
Assert.That(result, Is.Not.Null);
Assert.That(result.Content, Is.StringContaining("<supportsGetTags>No</supportsGetTags>"));
Assert.That(result.Content, Is.StringContaining("<keywordsAsTags>Yes</keywordsAsTags>"));
Assert.That(result.Content, Is.StringContaining("<supportsKeywords>Maybe</supportsKeywords>"));
}
public class StubHandler : IXmlRpcHandler {
public void SetCapabilities(XElement options) {
const string manifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
options.SetElementValue(XName.Get("supportsGetTags", manifestUri), "No");
options.SetElementValue(XName.Get("keywordsAsTags", manifestUri), "Yes");
}
public void Process(XmlRpcContext context) { }
public int ProcessCalls { get; set; }
}
public class StubTooHandler : IXmlRpcHandler {
public void SetCapabilities(XElement options) {
const string manifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
options.SetElementValue(XName.Get("supportsKeywords", manifestUri), "Maybe");
}
public void Process(XmlRpcContext context) { }
public int ProcessCalls { get; set; }
}
}
}