diff --git a/.hgignore b/.hgignore
index 2f0b5b1d9..91673c801 100644
--- a/.hgignore
+++ b/.hgignore
@@ -14,3 +14,4 @@ glob:desktop.ini
glob:src/Orchard.Azure.suo
glob:src/Orchard.5.0.ReSharper
glob:log.xml
+glob:profiling
diff --git a/AzurePackage.proj b/AzurePackage.proj
index ad02d137d..0dade831c 100644
--- a/AzurePackage.proj
+++ b/AzurePackage.proj
@@ -109,6 +109,23 @@
+
+
+
+
+
+
+
+
+
+
$(MSBuildProjectDirectory)\lib
$(MSBuildProjectDirectory)\src$(MSBuildProjectDirectory)\build
+ $(MSBuildProjectDirectory)\artifacts\Source
+ $(MSBuildProjectDirectory)\artifacts\WebPI$(BuildFolder)\Compile$(CompileFolder)\_PublishedWebsites
@@ -116,6 +118,20 @@
+
+
+
+
+
+
+
+
@@ -146,8 +162,10 @@
-
-
+
+
+
+
diff --git a/build.cmd b/build.cmd
index 1e1be68bc..eeddd1991 100644
--- a/build.cmd
+++ b/build.cmd
@@ -1,3 +1,3 @@
if "%~1"=="" build Build
msbuild /t:%~1 Orchard.proj
-msbuild /t:%~1 AzurePackage.proj
+
diff --git a/src/Orchard.5.0.ReSharper b/src/Orchard.5.0.ReSharper
new file mode 100644
index 000000000..21ba39891
--- /dev/null
+++ b/src/Orchard.5.0.ReSharper
@@ -0,0 +1,103 @@
+
+
+
+
+ SOLUTION
+
+
+ END_OF_LINE
+ END_OF_LINE
+ ALWAYS_ADD
+ ALWAYS_ADD
+ ALWAYS_ADD
+ ALWAYS_ADD
+ ALWAYS_ADD
+ ALWAYS_ADD
+ END_OF_LINE
+ END_OF_LINE
+
+ public
+ protected
+ internal
+ private
+ new
+ abstract
+ virtual
+ override
+ sealed
+ static
+ readonly
+ extern
+ unsafe
+ volatile
+
+ END_OF_LINE
+ END_OF_LINE
+
+
+
+ $object$_On$event$
+ $event$Handler
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $object$_On$event$
+ $event$Handler
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $object$_On$event$
+ $event$Handler
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Orchard.Azure.Tests/Environment/Configuration/AzureShellSettingsManagerTests.cs b/src/Orchard.Azure.Tests/Environment/Configuration/AzureShellSettingsManagerTests.cs
index ccd2a82cb..8c63d172c 100644
--- a/src/Orchard.Azure.Tests/Environment/Configuration/AzureShellSettingsManagerTests.cs
+++ b/src/Orchard.Azure.Tests/Environment/Configuration/AzureShellSettingsManagerTests.cs
@@ -1,5 +1,4 @@
-using System.IO;
-using System.Linq;
+using System.Linq;
using Microsoft.WindowsAzure;
using NUnit.Framework;
using Orchard.Azure.Environment.Configuration;
@@ -15,7 +14,7 @@ namespace Orchard.Azure.Tests.Environment.Configuration {
CloudStorageAccount devAccount;
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount);
- Loader = new AzureShellSettingsManager(devAccount);
+ Loader = new AzureShellSettingsManager(devAccount, new Moq.Mock().Object);
}
[SetUp]
diff --git a/src/Orchard.Azure.Tests/Storage/AzureBlobStorageProviderTests.cs b/src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs
similarity index 94%
rename from src/Orchard.Azure.Tests/Storage/AzureBlobStorageProviderTests.cs
rename to src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs
index 8c43b9a15..2b2c5baab 100644
--- a/src/Orchard.Azure.Tests/Storage/AzureBlobStorageProviderTests.cs
+++ b/src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs
@@ -1,11 +1,12 @@
using System;
using System.IO;
using NUnit.Framework;
-using Orchard.Azure.Storage;
+using Orchard.Azure.FileSystems.Media;
using Microsoft.WindowsAzure;
using System.Linq;
+using Orchard.Environment.Configuration;
-namespace Orchard.Azure.Tests.Storage {
+namespace Orchard.Azure.Tests.FileSystems.Media {
[TestFixture]
public class AzureBlobStorageProviderTests : AzureVirtualEnvironmentTest {
@@ -15,7 +16,7 @@ namespace Orchard.Azure.Tests.Storage {
CloudStorageAccount devAccount;
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount);
- _azureBlobStorageProvider = new AzureBlobStorageProvider("default", devAccount);
+ _azureBlobStorageProvider = new AzureBlobStorageProvider(new ShellSettings { Name = "default" }, devAccount);
}
[SetUp]
@@ -150,4 +151,4 @@ namespace Orchard.Azure.Tests.Storage {
Assert.AreEqual(teststring, content);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj
index 393e8b820..1e1dc42b3 100644
--- a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj
+++ b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj
@@ -34,6 +34,10 @@
+
+ False
+ ..\..\lib\moq\Moq.dll
+ False..\..\lib\nunit\nunit.framework.dll
@@ -56,7 +60,7 @@
-
+
diff --git a/src/Orchard.Azure/AzureFileSystem.cs b/src/Orchard.Azure/AzureFileSystem.cs
index 4f66b1bc6..c2c16eded 100644
--- a/src/Orchard.Azure/AzureFileSystem.cs
+++ b/src/Orchard.Azure/AzureFileSystem.cs
@@ -4,26 +4,26 @@ using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using System.IO;
-using Orchard.Storage;
+using Orchard.FileSystems.Media;
namespace Orchard.Azure {
public class AzureFileSystem {
public string ContainerName { get; protected set; }
private readonly CloudStorageAccount _storageAccount;
- private readonly string _shellName;
+ private readonly string _root;
public CloudBlobClient BlobClient { get; private set; }
public CloudBlobContainer Container { get; private set; }
- public AzureFileSystem(string containerName, string shellName, bool isPrivate)
- : this(containerName, shellName, isPrivate, CloudStorageAccount.FromConfigurationSetting("DataConnectionString")) {
+ public AzureFileSystem(string containerName, string root, bool isPrivate)
+ : this(containerName, root, isPrivate, CloudStorageAccount.FromConfigurationSetting("DataConnectionString")) {
}
- public AzureFileSystem(string containerName, string shellName, bool isPrivate, CloudStorageAccount storageAccount) {
+ public AzureFileSystem(string containerName, string root, bool isPrivate, CloudStorageAccount storageAccount) {
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
ContainerName = containerName;
- _shellName = shellName;
+ _root = String.IsNullOrEmpty(root) || root == "/" ? String.Empty : root + "/";
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
@@ -47,20 +47,20 @@ namespace Orchard.Azure {
public IStorageFile GetFile(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
Container.EnsureBlobExists(path);
return new AzureBlobFileStorage(Container.GetBlockBlobReference(path));
}
public bool FileExists(string path) {
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
return Container.BlobExists(path);
}
public IEnumerable ListFiles(string path) {
EnsurePathIsRelative(path);
- string prefix = String.Concat(Container.Name, "/", _shellName, "/", path);
+ string prefix = String.Concat(Container.Name, "/", _root, path);
if ( !prefix.EndsWith("/") )
prefix += "/";
@@ -71,7 +71,7 @@ namespace Orchard.Azure {
public IEnumerable ListFolders(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
if ( !Container.DirectoryExists(path) ) {
try {
@@ -91,7 +91,7 @@ namespace Orchard.Azure {
public void CreateFolder(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
Container.EnsureDirectoryDoesNotExist(path);
Container.GetDirectoryReference(path);
@@ -99,7 +99,7 @@ namespace Orchard.Azure {
public void DeleteFolder(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
Container.EnsureDirectoryExists(path);
foreach ( var blob in Container.GetDirectoryReference(path).ListBlobs() ) {
@@ -107,7 +107,7 @@ namespace Orchard.Azure {
( (CloudBlob)blob ).Delete();
if ( blob is CloudBlobDirectory )
- DeleteFolder(blob.Uri.ToString().Substring(Container.Uri.ToString().Length + 2 + _shellName.Length));
+ DeleteFolder(blob.Uri.ToString().Substring(Container.Uri.ToString().Length + 1 + _root.Length));
}
}
@@ -122,7 +122,7 @@ namespace Orchard.Azure {
if ( !newPath.EndsWith("/") )
newPath += "/";
- foreach ( var blob in Container.GetDirectoryReference(_shellName + "/" + path).ListBlobs() ) {
+ foreach ( var blob in Container.GetDirectoryReference(_root + path).ListBlobs() ) {
if ( blob is CloudBlob ) {
string filename = Path.GetFileName(blob.Uri.ToString());
string source = String.Concat(path, filename);
@@ -142,7 +142,7 @@ namespace Orchard.Azure {
public void DeleteFile(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
Container.EnsureBlobExists(path);
var blob = Container.GetBlockBlobReference(path);
@@ -151,10 +151,10 @@ namespace Orchard.Azure {
public void RenameFile(string path, string newPath) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
EnsurePathIsRelative(newPath);
- newPath = String.Concat(_shellName, "/", newPath);
+ newPath = String.Concat(_root, newPath);
Container.EnsureBlobExists(path);
Container.EnsureBlobDoesNotExist(newPath);
@@ -167,7 +167,7 @@ namespace Orchard.Azure {
public IStorageFile CreateFile(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
if ( Container.BlobExists(path) ) {
throw new ArgumentException("File " + path + " already exists");
@@ -180,7 +180,7 @@ namespace Orchard.Azure {
public string GetPublicUrl(string path) {
EnsurePathIsRelative(path);
- path = String.Concat(_shellName, "/", path);
+ path = String.Concat(_root, path);
Container.EnsureBlobExists(path);
return Container.GetBlockBlobReference(path).Uri.ToString();
}
diff --git a/src/Orchard.Azure/Environment/Configuration/AzureShellSettingsManager.cs b/src/Orchard.Azure/Environment/Configuration/AzureShellSettingsManager.cs
index 9f98c658e..bd14c2a56 100644
--- a/src/Orchard.Azure/Environment/Configuration/AzureShellSettingsManager.cs
+++ b/src/Orchard.Azure/Environment/Configuration/AzureShellSettingsManager.cs
@@ -13,6 +13,7 @@ namespace Orchard.Azure.Environment.Configuration {
public class AzureShellSettingsManager : IShellSettingsManager {
public const string ContainerName = "sites"; // container names must be lower cased
+ private readonly IShellSettingsManagerEventHandler _events;
private readonly CloudStorageAccount _storageAccount;
public CloudBlobClient BlobClient { get; private set; }
@@ -21,14 +22,16 @@ namespace Orchard.Azure.Environment.Configuration {
Localizer T { get; [UsedImplicitly]
set; }
- public AzureShellSettingsManager() : this(CloudStorageAccount.FromConfigurationSetting("DataConnectionString"))
+ public AzureShellSettingsManager(IShellSettingsManagerEventHandler events)
+ : this(CloudStorageAccount.FromConfigurationSetting("DataConnectionString"), events)
{
}
- public AzureShellSettingsManager(CloudStorageAccount storageAccount)
+ public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events)
{
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
+ _events = events;
BlobClient = _storageAccount.CreateCloudBlobClient();
@@ -54,6 +57,8 @@ namespace Orchard.Azure.Environment.Configuration {
var filePath =String.Concat(settings.Name, "/", "Settings.txt");
var blob = Container.GetBlockBlobReference(filePath);
blob.UploadText(ComposeSettings(settings));
+
+ _events.Saved(settings);
}
IEnumerable LoadSettings() {
diff --git a/src/Orchard.Azure/Environment/Configuration/AzureAppDataFolder.cs b/src/Orchard.Azure/FileSystems/AppData/AzureAppDataFolder.cs
similarity index 87%
rename from src/Orchard.Azure/Environment/Configuration/AzureAppDataFolder.cs
rename to src/Orchard.Azure/FileSystems/AppData/AzureAppDataFolder.cs
index e108a5f05..ee4a5b190 100644
--- a/src/Orchard.Azure/Environment/Configuration/AzureAppDataFolder.cs
+++ b/src/Orchard.Azure/FileSystems/AppData/AzureAppDataFolder.cs
@@ -3,14 +3,15 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Orchard.Environment.Configuration;
+using Orchard.FileSystems.AppData;
-namespace Orchard.Azure.Environment.Configuration {
+namespace Orchard.Azure.FileSystems.AppData {
public class AzureAppDataFolder : IAppDataFolder {
private readonly AzureFileSystem _fs;
- public AzureAppDataFolder(string shellName) {
- _fs = new AzureFileSystem("appdata", shellName, true);
+ public AzureAppDataFolder() {
+ _fs = new AzureFileSystem("appdata", null, true);
}
public void CreateFile(string path, string content) {
@@ -62,4 +63,4 @@ namespace Orchard.Azure.Environment.Configuration {
throw new NotImplementedException();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs b/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs
new file mode 100644
index 000000000..e6fe9acac
--- /dev/null
+++ b/src/Orchard.Azure/FileSystems/Media/AzureBlobStorageProvider.cs
@@ -0,0 +1,14 @@
+using Microsoft.WindowsAzure;
+using Orchard.Environment.Configuration;
+using Orchard.FileSystems.Media;
+
+namespace Orchard.Azure.FileSystems.Media {
+ public class AzureBlobStorageProvider : AzureFileSystem, IStorageProvider {
+
+ public AzureBlobStorageProvider(ShellSettings shellSettings)
+ : this(shellSettings, CloudStorageAccount.FromConfigurationSetting("DataConnectionString")) {
+ }
+
+ public AzureBlobStorageProvider(ShellSettings shellSettings, CloudStorageAccount storageAccount) : base("media", shellSettings.Name, false, storageAccount) { }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Config/Diagnostics.config b/src/Orchard.Azure/Orchard.Azure.Web/Config/Diagnostics.config
index 124536a7d..d603238d2 100644
--- a/src/Orchard.Azure/Orchard.Azure.Web/Config/Diagnostics.config
+++ b/src/Orchard.Azure/Orchard.Azure.Web/Config/Diagnostics.config
@@ -3,25 +3,25 @@
-
+
-
+
-
+
-
+
diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Config/Host.config b/src/Orchard.Azure/Orchard.Azure.Web/Config/Host.config
index b56b3523b..1a081a020 100644
--- a/src/Orchard.Azure/Orchard.Azure.Web/Config/Host.config
+++ b/src/Orchard.Azure/Orchard.Azure.Web/Config/Host.config
@@ -14,19 +14,13 @@
-
-
-
+ type="Orchard.Azure.FileSystems.Media.AzureBlobStorageProvider, Orchard.Azure"
+ service="Orchard.FileSystems.Media.IStorageProvider">
-
-
-
+ type="Orchard.Azure.FileSystems.AppData.AzureAppDataFolder, Orchard.Azure"
+ service="Orchard.FileSystems.AppData.IAppDataFolder">
diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj b/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj
index 0f11fc754..2d5045c4d 100644
--- a/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj
+++ b/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj
@@ -34,20 +34,12 @@
False
- ..\..\lib\autofac\Autofac.dll
+ ..\..\..\lib\autofac\Autofac.dllFalse..\..\..\lib\autofac\Autofac.Configuration.dll
-
- False
- ..\..\lib\autofac\Autofac.Integration.Web.dll
-
-
- False
- ..\..\lib\autofac\Autofac.Integration.Web.Mvc.dll
- False..\..\..\lib\Castle Windsor 2.0\bin\Castle.Core.dll
@@ -59,10 +51,6 @@
-
- False
- ..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll
-
@@ -74,10 +62,6 @@
3.5
-
- False
- ..\..\lib\sqlite\x64\System.Data.SQLite.DLL
- False..\..\..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\\Assemblies\System.Web.Mvc.dll
@@ -96,14 +80,6 @@
-
- False
- bin\Orchard.Framework.dll
-
-
- False
- bin\Orchard.Azure.dll
-
@@ -123,6 +99,16 @@
+
+
+ {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}
+ Orchard.Framework
+
+
+ {2505AA84-65A6-43D0-9C27-4F44FD576284}
+ Orchard.Azure
+
+
diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Web.config b/src/Orchard.Azure/Orchard.Azure.Web/Web.config
index b1de2f004..722cd267a 100644
--- a/src/Orchard.Azure/Orchard.Azure.Web/Web.config
+++ b/src/Orchard.Azure/Orchard.Azure.Web/Web.config
@@ -8,151 +8,205 @@
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Orchard.Azure/Orchard.Azure.csproj b/src/Orchard.Azure/Orchard.Azure.csproj
index 21becee28..bdd1d9fc8 100644
--- a/src/Orchard.Azure/Orchard.Azure.csproj
+++ b/src/Orchard.Azure/Orchard.Azure.csproj
@@ -51,9 +51,9 @@
-
+
-
+
diff --git a/src/Orchard.Azure/Storage/AzureBlobStorageProvider.cs b/src/Orchard.Azure/Storage/AzureBlobStorageProvider.cs
deleted file mode 100644
index 938a16602..000000000
--- a/src/Orchard.Azure/Storage/AzureBlobStorageProvider.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Microsoft.WindowsAzure;
-using Orchard.Storage;
-
-namespace Orchard.Azure.Storage {
-
- public class AzureBlobStorageProvider : AzureFileSystem, IStorageProvider {
-
- public AzureBlobStorageProvider(string shellName)
- : this(shellName, CloudStorageAccount.FromConfigurationSetting("DataConnectionString")) {
- }
-
- public AzureBlobStorageProvider(string shellName, CloudStorageAccount storageAccount) : base("media", shellName, false, storageAccount) { }
- }
-}
-
-
diff --git a/src/Orchard.Core.Tests/Common/Providers/CommonAspectProviderTests.cs b/src/Orchard.Core.Tests/Common/Providers/CommonAspectProviderTests.cs
index 294b75f9b..d62bae234 100644
--- a/src/Orchard.Core.Tests/Common/Providers/CommonAspectProviderTests.cs
+++ b/src/Orchard.Core.Tests/Common/Providers/CommonAspectProviderTests.cs
@@ -6,6 +6,7 @@ using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement.Aspects;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.Core.Common;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -28,6 +29,7 @@ namespace Orchard.Core.Tests.Common.Providers {
public override void Register(ContainerBuilder builder) {
builder.RegisterType().As();
+ builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterType().As();
@@ -45,6 +47,8 @@ namespace Orchard.Core.Tests.Common.Providers {
get {
return new[] {
typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(CommonRecord),
diff --git a/src/Orchard.Core.Tests/Common/Services/RoutableServiceTests.cs b/src/Orchard.Core.Tests/Common/Services/RoutableServiceTests.cs
index 1a3b18f47..69bb981db 100644
--- a/src/Orchard.Core.Tests/Common/Services/RoutableServiceTests.cs
+++ b/src/Orchard.Core.Tests/Common/Services/RoutableServiceTests.cs
@@ -6,6 +6,7 @@ using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Services;
@@ -26,6 +27,8 @@ namespace Orchard.Core.Tests.Common.Services {
public override void Register(ContainerBuilder builder) {
builder.RegisterType().As();
+ builder.RegisterType().As();
+
builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterType().As();
@@ -68,7 +71,7 @@ namespace Orchard.Core.Tests.Common.Services {
Assert.That(_routableService.IsSlugValid("a" + c + "b"), Is.False);
}
}
-
+
[Test]
public void VeryLongStringTruncatedTo1000Chars() {
@@ -140,18 +143,15 @@ namespace Orchard.Core.Tests.Common.Services {
}
[Test]
- public void GeneratedSlugsShouldBeUniqueAmongContentType()
- {
+ public void GeneratedSlugsShouldBeUniqueAmongContentType() {
var contentManager = _container.Resolve();
- var thing1 = contentManager.Create(ThingDriver.ContentType.Name, t =>
- {
+ var thing1 = contentManager.Create(ThingDriver.ContentType.Name, t => {
t.As().Record = new RoutableRecord();
t.Title = "This Is Some Interesting Title";
});
-
- var thing2 = contentManager.Create(ThingDriver.ContentType.Name , t =>
- {
+
+ var thing2 = contentManager.Create(ThingDriver.ContentType.Name, t => {
t.As().Record = new RoutableRecord();
t.Title = "This Is Some Interesting Title";
});
@@ -160,18 +160,15 @@ namespace Orchard.Core.Tests.Common.Services {
}
[Test]
- public void SlugsCanBeDuplicatedAccrossContentTypes()
- {
+ public void SlugsCanBeDuplicatedAccrossContentTypes() {
var contentManager = _container.Resolve();
- var thing = contentManager.Create(ThingDriver.ContentType.Name, t =>
- {
+ var thing = contentManager.Create(ThingDriver.ContentType.Name, t => {
t.As().Record = new RoutableRecord();
t.Title = "This Is Some Interesting Title";
});
- var stuff = contentManager.Create(StuffDriver.ContentType.Name, s =>
- {
+ var stuff = contentManager.Create(StuffDriver.ContentType.Name, s => {
s.As().Record = new RoutableRecord();
s.Title = "This Is Some Interesting Title";
});
@@ -184,9 +181,11 @@ namespace Orchard.Core.Tests.Common.Services {
get {
return new[] {
typeof(RoutableRecord),
+ typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
- typeof(ContentTypeRecord),
typeof(CommonRecord),
typeof(CommonVersionRecord),
};
@@ -195,8 +194,7 @@ namespace Orchard.Core.Tests.Common.Services {
[UsedImplicitly]
public class ThingHandler : ContentHandler {
- public ThingHandler()
- {
+ public ThingHandler() {
Filters.Add(new ActivatingFilter(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter(ThingDriver.ContentType.Name));
@@ -217,7 +215,7 @@ namespace Orchard.Core.Tests.Common.Services {
set { this.As().Slug = value; }
}
}
-
+
public class ThingDriver : ContentItemDriver {
public readonly static ContentType ContentType = new ContentType {
Name = "thing",
@@ -226,10 +224,8 @@ namespace Orchard.Core.Tests.Common.Services {
}
[UsedImplicitly]
- public class StuffHandler : ContentHandler
- {
- public StuffHandler()
- {
+ public class StuffHandler : ContentHandler {
+ public StuffHandler() {
Filters.Add(new ActivatingFilter(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter>(StuffDriver.ContentType.Name));
Filters.Add(new ActivatingFilter(StuffDriver.ContentType.Name));
@@ -237,27 +233,22 @@ namespace Orchard.Core.Tests.Common.Services {
}
}
- public class Stuff : ContentPart
- {
+ public class Stuff : ContentPart {
public int Id { get { return ContentItem.Id; } }
- public string Title
- {
+ public string Title {
get { return this.As().Title; }
set { this.As().Title = value; }
}
- public string Slug
- {
+ public string Slug {
get { return this.As().Slug; }
set { this.As().Slug = value; }
}
}
- public class StuffDriver : ContentItemDriver
- {
- public readonly static ContentType ContentType = new ContentType
- {
+ public class StuffDriver : ContentItemDriver {
+ public readonly static ContentType ContentType = new ContentType {
Name = "stuff",
DisplayName = "Stuff"
};
diff --git a/src/Orchard.Core.Tests/Feeds/Controllers/FeedControllerTests.cs b/src/Orchard.Core.Tests/Feeds/Controllers/FeedControllerTests.cs
index 7be62219d..e8cdd485a 100644
--- a/src/Orchard.Core.Tests/Feeds/Controllers/FeedControllerTests.cs
+++ b/src/Orchard.Core.Tests/Feeds/Controllers/FeedControllerTests.cs
@@ -27,7 +27,8 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
var controller = new FeedController(
Enumerable.Empty(),
Enumerable.Empty(),
- Enumerable.Empty()) {
+ new StubItemBuilder()
+ ) {
ValueProvider = Values.From(new { })
};
@@ -54,7 +55,8 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
var controller = new FeedController(
new[] { queryProvider.Object },
new[] { formatProvider.Object },
- Enumerable.Empty()) {
+ new StubItemBuilder()
+ ) {
ValueProvider = Values.From(new { })
};
@@ -86,15 +88,20 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
}
}
+ class StubItemBuilder : IFeedItemBuilder {
+ public void Populate(FeedContext context) {
+ }
+ }
+
[Test]
public void RssFeedShouldBeStructuredAppropriately() {
var query = new StubQuery(Enumerable.Empty());
var builder = new ContainerBuilder();
- //builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType();
builder.RegisterType().As();
builder.RegisterInstance(query).As();
+ builder.RegisterInstance(new StubItemBuilder()).As();
var container = builder.Build();
var controller = container.Resolve();
@@ -117,9 +124,9 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
});
var builder = new ContainerBuilder();
- //builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType();
builder.RegisterType().As();
+ builder.RegisterInstance(new StubItemBuilder()).As();
builder.RegisterInstance(query).As();
var container = builder.Build();
diff --git a/src/Orchard.Core.Tests/Scheduling/ScheduledTaskExecutorTests.cs b/src/Orchard.Core.Tests/Scheduling/ScheduledTaskExecutorTests.cs
index 887fa244f..e7a7955dd 100644
--- a/src/Orchard.Core.Tests/Scheduling/ScheduledTaskExecutorTests.cs
+++ b/src/Orchard.Core.Tests/Scheduling/ScheduledTaskExecutorTests.cs
@@ -4,6 +4,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
@@ -28,7 +29,9 @@ namespace Orchard.Core.Tests.Scheduling {
_handler = new StubTaskHandler();
builder.RegisterInstance(new Mock().Object);
builder.RegisterType().As();
- builder.RegisterType().As().Named("ScheduledTaskExecutor", typeof (IBackgroundTask));
+ builder.RegisterType().As();
+
+ builder.RegisterType().As().Named("ScheduledTaskExecutor", typeof(IBackgroundTask));
builder.RegisterInstance(_handler).As();
}
@@ -36,6 +39,8 @@ namespace Orchard.Core.Tests.Scheduling {
get {
return new[] {
typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(ScheduledTaskRecord),
@@ -98,7 +103,7 @@ namespace Orchard.Core.Tests.Scheduling {
Assert.That(_handler.TaskContext, Is.Null);
_executor.Sweep();
Assert.That(_handler.TaskContext, Is.Not.Null);
-
+
Assert.That(_handler.TaskContext.Task.TaskType, Is.EqualTo("Ignore"));
Assert.That(_handler.TaskContext.Task.ContentItem, Is.Null);
}
diff --git a/src/Orchard.Core.Tests/Scheduling/ScheduledTaskManagerTests.cs b/src/Orchard.Core.Tests/Scheduling/ScheduledTaskManagerTests.cs
index a8db8cabd..baf3063c3 100644
--- a/src/Orchard.Core.Tests/Scheduling/ScheduledTaskManagerTests.cs
+++ b/src/Orchard.Core.Tests/Scheduling/ScheduledTaskManagerTests.cs
@@ -5,6 +5,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
@@ -26,12 +27,14 @@ namespace Orchard.Core.Tests.Scheduling {
_repository = _container.Resolve>();
_scheduledTaskManager = _container.Resolve();
_contentManager = _container.Resolve();
- _mockServices.SetupGet(x=>x.ContentManager).Returns(_contentManager);
+ _mockServices.SetupGet(x => x.ContentManager).Returns(_contentManager);
}
- public override void Register(ContainerBuilder builder) {
+ public override void Register(ContainerBuilder builder) {
builder.RegisterInstance(_mockServices.Object);
builder.RegisterType().As();
+ builder.RegisterType().As();
+
builder.RegisterType().As();
}
@@ -39,6 +42,8 @@ namespace Orchard.Core.Tests.Scheduling {
get {
return new[] {
typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(ScheduledTaskRecord),
@@ -86,7 +91,7 @@ namespace Orchard.Core.Tests.Scheduling {
public void TasksForAllVersionsOfContenItemShouldBeReturned() {
var hello1 = _contentManager.New("hello");
_contentManager.Create(hello1);
-
+
var hello2 = _contentManager.GetDraftRequired(hello1.Id);
Assert.That(hello1.Version, Is.EqualTo(1));
diff --git a/src/Orchard.Profile/Orchard.Profile.csproj b/src/Orchard.Profile/Orchard.Profile.csproj
index 422e4bf7a..4bf64ceba 100644
--- a/src/Orchard.Profile/Orchard.Profile.csproj
+++ b/src/Orchard.Profile/Orchard.Profile.csproj
@@ -40,7 +40,7 @@
DEBUG;TRACEprompt4
- AllRules.ruleset
+ x86pdbonly
diff --git a/src/Orchard.Profile/Tests/HttpClient.cs b/src/Orchard.Profile/Tests/HttpClient.cs
index 98e6b65f9..ec89c114d 100644
--- a/src/Orchard.Profile/Tests/HttpClient.cs
+++ b/src/Orchard.Profile/Tests/HttpClient.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Net;
using System.Text;
using System.Web;
+using NUnit.Framework;
using TechTalk.SpecFlow;
namespace Orchard.Profile.Tests {
@@ -17,7 +18,18 @@ namespace Orchard.Profile.Tests {
[Given(@"I am logged in")]
public void GivenIAmLoggedIn() {
- DoRequest("/Users/Account/LogOn", "userNameOrEmail=admin&password=profiling-secret&rememberMe=false");
+ DoRequest("/Users/Account/LogOn");
+
+ const string requestVerificationTokenName = "__RequestVerificationToken";
+ const string valueMarker = "value=\"";
+
+ var tokenIndex = _text.IndexOf(requestVerificationTokenName);
+ var valueIndex = _text.IndexOf(valueMarker, tokenIndex);
+ var valueStart = valueIndex + valueMarker.Length;
+ var valueEnd = _text.IndexOf("\"", valueStart);
+ var requestVerificationTokenValue = _text.Substring(valueStart, valueEnd - valueStart);
+
+ DoRequest("/Users/Account/LogOn", "userNameOrEmail=admin&password=profiling-secret&rememberMe=false&" + requestVerificationTokenName + "=" + requestVerificationTokenValue);
}
[When(@"I go to ""(.*)""")]
diff --git a/src/Orchard.Profile/Tests/Profiling.feature b/src/Orchard.Profile/Tests/Profiling.feature
index 692963c20..352c133c1 100644
--- a/src/Orchard.Profile/Tests/Profiling.feature
+++ b/src/Orchard.Profile/Tests/Profiling.feature
@@ -3,6 +3,24 @@
As a developer
I want to generate a fixed number of repeatable requests
+Scenario: Warmup
+ Given I am logged in
+ When I go to "/admin"
+ When I go to "/blog0"
+ When I go to "/"
+
Scenario: Dashboard
Given I am logged in
When I go to "/admin" 40 times
+
+Scenario: Hitting blogs
+ Given I am logged in
+ When I go to "/blog0" 10 times
+ When I go to "/blog1" 10 times
+ When I go to "/blog2" 10 times
+ When I go to "/blog3" 10 times
+ When I go to "/blog4" 10 times
+
+Scenario: Hitting home page
+ Given I am logged in
+ When I go to "/" 40 times
diff --git a/src/Orchard.Profile/Tests/Profiling.feature.cs b/src/Orchard.Profile/Tests/Profiling.feature.cs
index b84190450..8673be112 100644
--- a/src/Orchard.Profile/Tests/Profiling.feature.cs
+++ b/src/Orchard.Profile/Tests/Profiling.feature.cs
@@ -51,16 +51,73 @@ namespace Orchard.Profile.Tests
}
[NUnit.Framework.TestAttribute()]
- [NUnit.Framework.DescriptionAttribute("Dashboard")]
- public virtual void Dashboard()
+ [NUnit.Framework.DescriptionAttribute("Warmup")]
+ public virtual void Warmup()
{
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Dashboard", ((string[])(null)));
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Warmup", ((string[])(null)));
#line 6
this.ScenarioSetup(scenarioInfo);
#line 7
testRunner.Given("I am logged in");
#line 8
+ testRunner.When("I go to \"/admin\"");
+#line 9
+ testRunner.When("I go to \"/blog0\"");
+#line 10
+ testRunner.When("I go to \"/\"");
+#line hidden
+ testRunner.CollectScenarioErrors();
+ }
+
+ [NUnit.Framework.TestAttribute()]
+ [NUnit.Framework.DescriptionAttribute("Dashboard")]
+ public virtual void Dashboard()
+ {
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Dashboard", ((string[])(null)));
+#line 12
+this.ScenarioSetup(scenarioInfo);
+#line 13
+ testRunner.Given("I am logged in");
+#line 14
testRunner.When("I go to \"/admin\" 40 times");
+#line hidden
+ testRunner.CollectScenarioErrors();
+ }
+
+ [NUnit.Framework.TestAttribute()]
+ [NUnit.Framework.DescriptionAttribute("Hitting blogs")]
+ public virtual void HittingBlogs()
+ {
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Hitting blogs", ((string[])(null)));
+#line 16
+this.ScenarioSetup(scenarioInfo);
+#line 17
+ testRunner.Given("I am logged in");
+#line 18
+ testRunner.When("I go to \"/blog0\" 10 times");
+#line 19
+ testRunner.When("I go to \"/blog1\" 10 times");
+#line 20
+ testRunner.When("I go to \"/blog2\" 10 times");
+#line 21
+ testRunner.When("I go to \"/blog3\" 10 times");
+#line 22
+ testRunner.When("I go to \"/blog4\" 10 times");
+#line hidden
+ testRunner.CollectScenarioErrors();
+ }
+
+ [NUnit.Framework.TestAttribute()]
+ [NUnit.Framework.DescriptionAttribute("Hitting home page")]
+ public virtual void HittingHomePage()
+ {
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Hitting home page", ((string[])(null)));
+#line 24
+this.ScenarioSetup(scenarioInfo);
+#line 25
+ testRunner.Given("I am logged in");
+#line 26
+ testRunner.When("I go to \"/\" 40 times");
#line hidden
testRunner.CollectScenarioErrors();
}
diff --git a/src/Orchard.Profile/profiling-setup-commands.txt b/src/Orchard.Profile/profiling-setup-commands.txt
index 15f7607eb..f839517bc 100644
--- a/src/Orchard.Profile/profiling-setup-commands.txt
+++ b/src/Orchard.Profile/profiling-setup-commands.txt
@@ -1,6 +1,3 @@
-help commands
-setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLite /EnabledFeatures:Orchard.Framework,Common,Dashboard,Feeds,HomePage,Navigation,Scheduling,Settings,XmlRpc,Orchard.Users,Orchard.Roles,TinyMce,Orchard.Modules,Orchard.Themes,Orchard.MultiTenancy,Orchard.Pages,Orchard.Blogs,Orchard.Comments,Futures.Widgets,Orchard.Media,Orchard.Tags,Orchard.DevTools
-help commands
-tenant list
-feature list
+setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLite /EnabledFeatures:Orchard.Framework,Common,Dashboard,Feeds,HomePage,Navigation,Scheduling,Settings,XmlRpc,Orchard.Users,Orchard.Roles,TinyMce,Orchard.Modules,Orchard.Themes,Orchard.MultiTenancy,Orchard.Pages,Orchard.Blogs,Orchard.Comments,Futures.Widgets,Orchard.Media,Orchard.Tags,Orchard.DevTools
add profiling data
+feature disable Orchard.DevTools
diff --git a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs
index 0558fb854..2d0059b2f 100644
--- a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs
+++ b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs
@@ -16,7 +16,7 @@ namespace Orchard.Specs.Bindings {
var webApp = Binding();
webApp.GivenIHaveACleanSiteWith(TableData(
- new { extension = "module", names = "Orchard.Setup, Orchard.Modules, Orchard.Themes, Orchard.Users, Orchard.Roles, Orchard.Pages, Orchard.Comments, TinyMce" },
+ new { extension = "module", names = "Orchard.Setup, Orchard.Modules, Orchard.Themes, Orchard.Users, Orchard.Roles, Orchard.Pages, Orchard.Comments, Orchard.Tags, TinyMce" },
new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Scheduling, Settings, XmlRpc" },
new { extension = "theme", names = "SafeMode, Classic" }));
diff --git a/src/Orchard.Specs/Bindings/WebAppHosting.cs b/src/Orchard.Specs/Bindings/WebAppHosting.cs
index 99e439472..66e848aea 100644
--- a/src/Orchard.Specs/Bindings/WebAppHosting.cs
+++ b/src/Orchard.Specs/Bindings/WebAppHosting.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -157,22 +158,39 @@ namespace Orchard.Specs.Bindings {
foreach (var row in table.Rows) {
var r = row;
- var input = inputs.SingleOrDefault(x => x.GetAttributeValue("name", x.GetAttributeValue("id", "")) == r["name"]);
+ var input = inputs.First(x => x.GetAttributeValue("name", x.GetAttributeValue("id", "")) == r["name"]);
Assert.That(input, Is.Not.Null, "Unable to locate name {0} in page html:\r\n\r\n{1}", r["name"], Details.ResponseText);
- input.Attributes.Add("value", row["value"]);
+ var inputType = input.GetAttributeValue("type", "");
+ switch(inputType) {
+ case "radio":
+ var radios = inputs.Where(
+ x =>
+ x.GetAttributeValue("type", "") == "radio" &&
+ x.GetAttributeValue("name", x.GetAttributeValue("id", "")) == r["name"]);
+ foreach(var radio in radios) {
+ if (radio.GetAttributeValue("value", "") == row["value"])
+ radio.Attributes.Add("checked", "checked");
+ else if (radio.Attributes.Contains("checked"))
+ radio.Attributes.Remove("checked");
+ }
+ break;
+ default:
+ input.Attributes.Add("value", row["value"]);
+ break;
+ }
}
}
[When(@"I hit ""(.*)""")]
public void WhenIHit(string submitText) {
var submit = _doc.DocumentNode
- .SelectNodes("//input[@type='submit']")
- .Single(elt => elt.GetAttributeValue("value", null) == submitText);
+ .SelectSingleNode(string.Format("(//input[@type='submit'][@value='{0}']|//button[@type='submit'][text()='{0}'])", submitText));
var form = Form.LocateAround(submit);
var urlPath = form.Start.GetAttributeValue("action", Details.UrlPath);
var inputs = form.Children
.SelectMany(elt => elt.DescendantsAndSelf("input"))
+ .Where(node => !((node.GetAttributeValue("type", "") == "radio" || node.GetAttributeValue("type", "") == "checkbox") && node.GetAttributeValue("checked", "") != "checked"))
.GroupBy(elt => elt.GetAttributeValue("name", elt.GetAttributeValue("id", "")), elt => elt.GetAttributeValue("value", ""))
.ToDictionary(elt => elt.Key, elt => (IEnumerable)elt);
@@ -203,6 +221,11 @@ namespace Orchard.Specs.Bindings {
Assert.That(Details.ResponseText, Is.StringContaining(text));
}
+ [Then(@"I should not see ""(.*)""")]
+ public void ThenIShouldNotSee(string text) {
+ Assert.That(Details.ResponseText, Is.Not.StringContaining(text));
+ }
+
[Then(@"the title contains ""(.*)""")]
public void ThenTheTitleContainsText(string text) {
ScenarioContext.Current.Pending();
diff --git a/src/Orchard.Specs/Hosting/WebHost.cs b/src/Orchard.Specs/Hosting/WebHost.cs
index d834cbe01..d19119483 100644
--- a/src/Orchard.Specs/Hosting/WebHost.cs
+++ b/src/Orchard.Specs/Hosting/WebHost.cs
@@ -17,7 +17,12 @@ namespace Orchard.Specs.Hosting {
_tempSite = Path.Get(System.IO.Path.GetTempFileName()).Delete().CreateDirectory();
- _orchardWebPath = baseDir.Parent.Parent.Parent.Combine("Orchard.Web");
+ // Trying the two known relative paths to the Orchard.Web directory.
+ // The second one is for the target "spec" in orchard.proj.
+ _orchardWebPath = baseDir.Up(3).Combine("Orchard.Web");
+ if (!_orchardWebPath.Exists) {
+ _orchardWebPath = baseDir.Parent.Combine("stage");
+ }
baseDir.Combine("Hosting").Combine(templateName)
.DeepCopy(_tempSite);
diff --git a/src/Orchard.Specs/MultiTenancy.feature b/src/Orchard.Specs/MultiTenancy.feature
index b91693135..c8602abb4 100644
--- a/src/Orchard.Specs/MultiTenancy.feature
+++ b/src/Orchard.Specs/MultiTenancy.feature
@@ -8,7 +8,7 @@ Scenario: Default site is listed
And I have installed "Orchard.MultiTenancy"
When I go to "Admin/MultiTenancy"
Then I should see "List of Site's Tenants"
- And I should see "
Default
"
+ And I should see "Default"
And the status should be 200 OK
Scenario: New tenant fields are required
@@ -27,7 +27,7 @@ Scenario: A new tenant is created
| Name | Scott |
And I hit "Save"
And I am redirected
- Then I should see "
Scott
"
+ Then I should see "Scott"
And the status should be 200 OK
Scenario: A new tenant is created with uninitialized state
@@ -39,9 +39,9 @@ Scenario: A new tenant is created with uninitialized state
| Name | Scott |
And I hit "Save"
And I am redirected
- Then I should see "
Uninitialized
"
+ Then I should see "
"
And the status should be 200 OK
-
+
Scenario: A new tenant goes to the setup screen
Given I have installed Orchard
And I have installed "Orchard.MultiTenancy"
@@ -55,6 +55,23 @@ Scenario: A new tenant goes to the setup screen
Then I should see "Welcome to Orchard"
And I should see "Finish Setup"
And the status should be 200 OK
+
+Scenario: A new tenant with preconfigured database goes to the setup screen
+ Given I have installed Orchard
+ And I have installed "Orchard.MultiTenancy"
+ When I go to "Admin/MultiTenancy/Add"
+ And I fill in
+ | name | value |
+ | Name | Scott |
+ | RequestUrlHost | scott.example.org |
+ | DataProvider | SQLite |
+ And I hit "Save"
+ And I am redirected
+ And I go to "/Setup" on host scott.example.org
+ Then I should see "Welcome to Orchard"
+ And I should see "Finish Setup"
+ And I should not see "SQLite"
+ And the status should be 200 OK
Scenario: A new tenant runs the setup
Given I have installed Orchard
@@ -74,7 +91,75 @@ Scenario: A new tenant runs the setup
And I go to "/Default.aspx"
Then I should see "
Scott Site
"
And I should see "Welcome, admin!"
+
+Scenario: An existing initialized tenant cannot have its database option cleared
+ Given I have installed Orchard
+ And I have installed "Orchard.MultiTenancy"
+ When I go to "Admin/MultiTenancy/Add"
+ And I fill in
+ | name | value |
+ | Name | Scott |
+ | RequestUrlHost | scott.example.org |
+ And I hit "Save"
+ And I go to "/Setup" on host scott.example.org
+ And I fill in
+ | name | value |
+ | SiteName | Scott Site |
+ | AdminPassword | 6655321 |
+ And I hit "Finish Setup"
+ And I go to "/Admin/MultiTenancy/Edit/Scott" on host localhost
+ Then I should see "
Edit Tenant
"
+ And I should see "
Scott
"
+ And I should not see "Allow the tenant to set up the database"
+Scenario: Default tenant cannot be disabled
+ Given I have installed Orchard
+ And I have installed "Orchard.MultiTenancy"
+ When I go to "Admin/MultiTenancy"
+ Then I should not see "
-
- False..\..\lib\fluentnhibernate\NHibernate.dll
diff --git a/src/Orchard.Tests.Modules/Settings/Topology/ShellDescriptorManagerTests.cs b/src/Orchard.Tests.Modules/Settings/Topology/ShellDescriptorManagerTests.cs
index 17175465e..6c41371af 100644
--- a/src/Orchard.Tests.Modules/Settings/Topology/ShellDescriptorManagerTests.cs
+++ b/src/Orchard.Tests.Modules/Settings/Topology/ShellDescriptorManagerTests.cs
@@ -15,14 +15,17 @@ namespace Orchard.Tests.Modules.Settings.Topology {
public override void Register(ContainerBuilder builder) {
builder.RegisterType().As();
builder.RegisterType().As().SingleInstance();
-
+ builder.RegisterSource(new EventsRegistrationSource());
}
public class StubEventBus : IEventBus {
public string LastMessageName { get; set; }
- public IDictionary LastEventData { get; set; }
+ public IDictionary LastEventData { get; set; }
- public void Notify(string messageName, IDictionary eventData) {
+ public void Notify_Obsolete(string messageName, IDictionary eventData) {
+ }
+
+ public void Notify(string messageName, Dictionary eventData) {
LastMessageName = messageName;
LastEventData = eventData;
}
@@ -137,7 +140,7 @@ namespace Orchard.Tests.Modules.Settings.Topology {
Enumerable.Empty(),
Enumerable.Empty());
- Assert.That(eventBus.LastMessageName, Is.EqualTo("ShellDescriptor_Changed"));
+ Assert.That(eventBus.LastMessageName, Is.EqualTo("IShellDescriptorManagerEventHandler.Changed"));
}
}
}
diff --git a/src/Orchard.Tests.Modules/Users/Controllers/AdminControllerTests.cs b/src/Orchard.Tests.Modules/Users/Controllers/AdminControllerTests.cs
index 78ad1eaab..54dfd37f3 100644
--- a/src/Orchard.Tests.Modules/Users/Controllers/AdminControllerTests.cs
+++ b/src/Orchard.Tests.Modules/Users/Controllers/AdminControllerTests.cs
@@ -6,6 +6,7 @@ using System.Web.Routing;
using Autofac;
using Moq;
using NUnit.Framework;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data;
using Orchard.Environment;
using Orchard.ContentManagement;
@@ -30,6 +31,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
public override void Register(ContainerBuilder builder) {
builder.RegisterType().SingleInstance();
builder.RegisterType().As();
+ builder.RegisterType().As();
builder.RegisterType().As().InstancePerDependency();
builder.RegisterType().As();
builder.RegisterType().As();
@@ -43,7 +45,13 @@ namespace Orchard.Tests.Modules.Users.Controllers {
protected override IEnumerable DatabaseTypes {
get {
- return new[] { typeof(UserRecord), typeof(ContentItemRecord), typeof(ContentItemVersionRecord), typeof(ContentTypeRecord) };
+ return new[] { typeof(UserRecord),
+ typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
+ typeof(ContentItemRecord),
+ typeof(ContentItemVersionRecord),
+ };
}
}
diff --git a/src/Orchard.Tests.Modules/Users/Services/MembershipServiceTests.cs b/src/Orchard.Tests.Modules/Users/Services/MembershipServiceTests.cs
index 1b928a7c3..81551167c 100644
--- a/src/Orchard.Tests.Modules/Users/Services/MembershipServiceTests.cs
+++ b/src/Orchard.Tests.Modules/Users/Services/MembershipServiceTests.cs
@@ -3,6 +3,7 @@ using System.Web.Security;
using Autofac;
using NHibernate;
using NUnit.Framework;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
@@ -41,7 +42,9 @@ namespace Orchard.Tests.Modules.Users.Services {
typeof(UserRecord),
typeof(ContentItemVersionRecord),
typeof(ContentItemRecord),
- typeof(ContentTypeRecord));
+ typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord));
}
[TestFixtureTearDown]
@@ -55,6 +58,7 @@ namespace Orchard.Tests.Modules.Users.Services {
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType().As();
builder.RegisterType().As();
+ builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
diff --git a/src/Orchard.Tests/App.config b/src/Orchard.Tests/App.config
index 033282679..9c29a24c2 100644
--- a/src/Orchard.Tests/App.config
+++ b/src/Orchard.Tests/App.config
@@ -9,4 +9,15 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Orchard.Tests/Caching/CacheScopeTests.cs b/src/Orchard.Tests/Caching/CacheScopeTests.cs
new file mode 100644
index 000000000..569bd63e6
--- /dev/null
+++ b/src/Orchard.Tests/Caching/CacheScopeTests.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using Orchard.Caching;
+using Orchard.Environment;
+using Autofac;
+using Orchard.FileSystems.AppData;
+using Orchard.FileSystems.WebSite;
+using Orchard.Services;
+
+namespace Orchard.Tests.Caching {
+ [TestFixture]
+ public class CacheScopeTests {
+ private IContainer _hostContainer;
+
+ [SetUp]
+ public void Init() {
+ _hostContainer = OrchardStarter.CreateHostContainer(builder => {
+ builder.RegisterType().InstancePerDependency();
+ });
+
+ }
+
+ public class Alpha {
+ public ICacheManager CacheManager { get; set; }
+
+ public Alpha(ICacheManager cacheManager) {
+ CacheManager = cacheManager;
+ }
+ }
+
+ [Test]
+ public void ComponentsAtHostLevelHaveAccessToCache() {
+ var alpha = _hostContainer.Resolve();
+ Assert.That(alpha.CacheManager, Is.Not.Null);
+ }
+
+ [Test]
+ public void HostLevelHasAccessToGlobalVolatileProviders() {
+ Assert.That(_hostContainer.Resolve(), Is.Not.Null);
+ Assert.That(_hostContainer.Resolve(), Is.Not.Null);
+ Assert.That(_hostContainer.Resolve(), Is.Not.Null);
+ }
+
+ }
+}
diff --git a/src/Orchard.Tests/Caching/CacheTests.cs b/src/Orchard.Tests/Caching/CacheTests.cs
new file mode 100644
index 000000000..09bdf353a
--- /dev/null
+++ b/src/Orchard.Tests/Caching/CacheTests.cs
@@ -0,0 +1,97 @@
+using System;
+using Autofac;
+using NUnit.Framework;
+using Orchard.Caching;
+
+namespace Orchard.Tests.Caching {
+ [TestFixture]
+ public class CacheTests {
+ private IContainer _container;
+ private ICacheManager _cacheManager;
+
+ [SetUp]
+ public void Init() {
+ var builder = new ContainerBuilder();
+ builder.RegisterModule(new CacheModule());
+ builder.RegisterType().As();
+ builder.RegisterType().As().SingleInstance();
+ builder.RegisterType().As();
+ _container = builder.Build();
+ _cacheManager = _container.Resolve(new TypedParameter(typeof(Type), GetType()));
+ }
+
+ [Test]
+ public void CacheManagerShouldReturnCacheItem() {
+ var result = _cacheManager.Get("testItem", ctx => "testResult");
+ Assert.That(result, Is.EqualTo("testResult"));
+ }
+
+ [Test]
+ public void CacheManagerShouldReturnExistingCacheItem() {
+ _cacheManager.Get("testItem", ctx => "testResult");
+ var result = _cacheManager.Get("testItem", ctx => "");
+ Assert.That(result, Is.EqualTo("testResult"));
+ }
+
+ [Test]
+ public void CacheModuleProvidesTypeSpecificManager() {
+ var scope = _container.BeginLifetimeScope(builder => {
+ builder.RegisterModule(new CacheModule());
+ builder.RegisterType();
+ builder.RegisterType();
+ });
+
+ var c1 = scope.Resolve();
+ var c2 = scope.Resolve();
+ var w1a = c1.CacheManager.Get("hello", ctx => "world1");
+ var w1b = c1.CacheManager.Get("hello", ctx => "world2");
+ var w2a = c2.CacheManager.Get("hello", ctx => "world3");
+ var w2b = c2.CacheManager.Get("hello", ctx => "world4");
+
+ Assert.That(w1a, Is.EqualTo("world1"));
+ Assert.That(w1b, Is.EqualTo("world1"));
+ Assert.That(w2a, Is.EqualTo("world3"));
+ Assert.That(w2b, Is.EqualTo("world3"));
+
+ var c3 = scope.Resolve();
+ var c4 = scope.Resolve();
+ var w3a = c3.CacheManager.Get("hello", ctx => "world5");
+ var w3b = c3.CacheManager.Get("hello", ctx => "world6");
+ var w4a = c4.CacheManager.Get("hello", ctx => "world7");
+ var w4b = c4.CacheManager.Get("hello", ctx => "world8");
+
+ Assert.That(w3a, Is.EqualTo("world1"));
+ Assert.That(w3b, Is.EqualTo("world1"));
+ Assert.That(w4a, Is.EqualTo("world3"));
+ Assert.That(w4b, Is.EqualTo("world3"));
+
+ Assert.That(c1.CacheManager,
+ Is.Not.SameAs(c3.CacheManager));
+
+ Assert.That(c1.CacheManager.GetCache(),
+ Is.SameAs(c3.CacheManager.GetCache()));
+
+ Assert.That(c1.CacheManager,
+ Is.Not.SameAs(c2.CacheManager));
+
+ Assert.That(c1.CacheManager.GetCache(),
+ Is.Not.SameAs(c2.CacheManager.GetCache()));
+ }
+
+ class ComponentOne {
+ public ICacheManager CacheManager { get; set; }
+
+ public ComponentOne(ICacheManager cacheManager) {
+ CacheManager = cacheManager;
+ }
+ }
+
+ class ComponentTwo {
+ public ICacheManager CacheManager { get; set; }
+
+ public ComponentTwo(ICacheManager cacheManager) {
+ CacheManager = cacheManager;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Tests/ContentManagement/ContentQueryTests.cs b/src/Orchard.Tests/ContentManagement/ContentQueryTests.cs
index 71c22f209..55d9960e5 100644
--- a/src/Orchard.Tests/ContentManagement/ContentQueryTests.cs
+++ b/src/Orchard.Tests/ContentManagement/ContentQueryTests.cs
@@ -2,6 +2,7 @@
using Autofac;
using NHibernate;
using NUnit.Framework;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
@@ -27,7 +28,9 @@ namespace Orchard.Tests.ContentManagement {
typeof(EpsilonRecord),
typeof(ContentItemVersionRecord),
typeof(ContentItemRecord),
- typeof(ContentTypeRecord));
+ typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord));
}
[TestFixtureTearDown]
@@ -43,6 +46,8 @@ namespace Orchard.Tests.ContentManagement {
// builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterModule(new ContentModule());
builder.RegisterType().As().SingleInstance();
+ builder.RegisterType().As();
+
builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterType().As();
@@ -285,7 +290,7 @@ namespace Orchard.Tests.ContentManagement {
init.As().Record.Quad = "v3";
});
_session.Flush();
- _session.Clear();
+ _session.Clear();
}
[Test]
diff --git a/src/Orchard.Tests/ContentManagement/ContentTypeMetaDataTests.cs b/src/Orchard.Tests/ContentManagement/ContentTypeMetaDataTests.cs
new file mode 100644
index 000000000..94a31ebba
--- /dev/null
+++ b/src/Orchard.Tests/ContentManagement/ContentTypeMetaDataTests.cs
@@ -0,0 +1,62 @@
+using Autofac;
+using NHibernate;
+using NUnit.Framework;
+using Orchard.ContentManagement;
+using Orchard.ContentManagement.MetaData.Records;
+using Orchard.ContentManagement.MetaData.Services;
+using Orchard.ContentManagement.Records;
+using Orchard.Data;
+
+
+namespace Orchard.Tests.ContentManagement{
+ [TestFixture]
+ public class ContentTypeMetaDataTests
+ {
+ private IContainer _container;
+ private ISessionFactory _sessionFactory;
+ private ISession _session;
+
+ [TestFixtureSetUp]
+ public void InitFixture()
+ {
+ var databaseFileName = System.IO.Path.GetTempFileName();
+ _sessionFactory = DataUtility.CreateSessionFactory(
+ databaseFileName,
+ typeof(ContentTypeRecord),
+ typeof(ContentItemRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
+ typeof(ContentItemVersionRecord));
+ }
+
+ [TestFixtureTearDown]
+ public void TermFixture()
+ {
+
+ }
+
+ [SetUp]
+ public void Init()
+ {
+ var builder = new ContainerBuilder();
+ builder.RegisterType().As();
+ builder.RegisterType().As();
+ builder.RegisterType().As();
+ builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
+ _session = _sessionFactory.OpenSession();
+ builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As();
+
+ _container = builder.Build();
+ }
+
+ [Test]
+ public void MapandUnMapContentTypeToContentPart()
+ {
+ var contentTypeService = _container.Resolve();
+ contentTypeService.MapContentTypeToContentPart("foo", "bar");
+ Assert.IsTrue(contentTypeService.ValidateContentTypeToContentPartMapping("foo","bar"),"Content Type not successfully mapped");
+ contentTypeService.UnMapContentTypeToContentPart("foo", "bar");
+ Assert.IsFalse(contentTypeService.ValidateContentTypeToContentPartMapping("foo", "bar"), "Content Type mapping not successfully deleted");
+ }
+ }
+}
diff --git a/src/Orchard.Tests/ContentManagement/DefaultContentManagerTests.cs b/src/Orchard.Tests/ContentManagement/DefaultContentManagerTests.cs
index dff2a8180..6341d4f4c 100644
--- a/src/Orchard.Tests/ContentManagement/DefaultContentManagerTests.cs
+++ b/src/Orchard.Tests/ContentManagement/DefaultContentManagerTests.cs
@@ -4,6 +4,7 @@ using System.Linq;
using Autofac;
using NHibernate;
using NUnit.Framework;
+using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
@@ -25,6 +26,8 @@ namespace Orchard.Tests.ContentManagement {
_sessionFactory = DataUtility.CreateSessionFactory(
databaseFileName,
typeof(ContentTypeRecord),
+ typeof(ContentTypePartRecord),
+ typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(GammaRecord),
@@ -42,6 +45,8 @@ namespace Orchard.Tests.ContentManagement {
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType().As();
+ builder.RegisterType().As();
+
builder.RegisterType().As();
builder.RegisterType().As();
builder.RegisterType().As();
diff --git a/src/Orchard.Tests/Data/Builders/SessionFactoryBuilderTests.cs b/src/Orchard.Tests/Data/Builders/SessionFactoryBuilderTests.cs
index e907a7e04..c19520c8e 100644
--- a/src/Orchard.Tests/Data/Builders/SessionFactoryBuilderTests.cs
+++ b/src/Orchard.Tests/Data/Builders/SessionFactoryBuilderTests.cs
@@ -83,7 +83,7 @@ namespace Orchard.Tests.Data.Builders {
var manager = (ISessionFactoryBuilder)new SessionFactoryBuilder();
var sessionFactory = manager.BuildSessionFactory(new SessionFactoryParameters {
- Provider = "SQLite",
+ Provider = "SqlServer",
DataFolder = _tempDataFolder,
ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFileName=" + databasePath + ";Integrated Security=True;User Instance=True;",
UpdateSchema = true,
diff --git a/src/Orchard.Tests/Environment/Configuration/AppDataFolderTests.cs b/src/Orchard.Tests/Environment/Configuration/AppDataFolderTests.cs
index 5790f5820..fe37edc8c 100644
--- a/src/Orchard.Tests/Environment/Configuration/AppDataFolderTests.cs
+++ b/src/Orchard.Tests/Environment/Configuration/AppDataFolderTests.cs
@@ -1,7 +1,7 @@
using System.IO;
using System.Linq;
using NUnit.Framework;
-using Orchard.Environment.Configuration;
+using Orchard.FileSystems.AppData;
namespace Orchard.Tests.Environment.Configuration {
[TestFixture]
diff --git a/src/Orchard.Tests/Environment/Configuration/DefaultTenantManagerTests.cs b/src/Orchard.Tests/Environment/Configuration/DefaultTenantManagerTests.cs
index d47d66904..e33c5ed42 100644
--- a/src/Orchard.Tests/Environment/Configuration/DefaultTenantManagerTests.cs
+++ b/src/Orchard.Tests/Environment/Configuration/DefaultTenantManagerTests.cs
@@ -3,7 +3,7 @@ using System.Linq;
using Moq;
using NUnit.Framework;
using Orchard.Environment.Configuration;
-using Orchard.Events;
+using Orchard.FileSystems.AppData;
namespace Orchard.Tests.Environment.Configuration {
[TestFixture]
@@ -28,7 +28,7 @@ namespace Orchard.Tests.Environment.Configuration {
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
- IShellSettingsManager loader = new ShellSettingsManager(_appData, new Mock().Object);
+ IShellSettingsManager loader = new ShellSettingsManager(_appData, new Mock().Object);
var settings = loader.LoadSettings().Single();
Assert.That(settings, Is.Not.Null);
Assert.That(settings.Name, Is.EqualTo("Default"));
@@ -43,7 +43,7 @@ namespace Orchard.Tests.Environment.Configuration {
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
_appData.CreateFile("Sites\\Another\\Settings.txt", "Name: Another\r\nDataProvider: SQLite2\r\nDataConnectionString: something else2");
- IShellSettingsManager loader = new ShellSettingsManager(_appData, new Mock().Object);
+ IShellSettingsManager loader = new ShellSettingsManager(_appData, new Mock().Object);
var settings = loader.LoadSettings();
Assert.That(settings.Count(), Is.EqualTo(2));
@@ -62,7 +62,7 @@ namespace Orchard.Tests.Environment.Configuration {
public void NewSettingsCanBeStored() {
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
- IShellSettingsManager loader = new ShellSettingsManager(_appData, new Mock().Object);
+ IShellSettingsManager loader = new ShellSettingsManager(_appData, new Mock().Object);
var foo = new ShellSettings {Name = "Foo", DataProvider = "Bar", DataConnectionString = "Quux"};
Assert.That(loader.LoadSettings().Count(), Is.EqualTo(1));
diff --git a/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs b/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs
index 06b637a0f..9f1677811 100644
--- a/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs
+++ b/src/Orchard.Tests/Environment/DefaultOrchardHostTests.cs
@@ -18,6 +18,7 @@ using Orchard.Environment.Extensions.Models;
using Orchard.Environment.ShellBuilders;
using Orchard.Environment.Topology;
using Orchard.Environment.Topology.Models;
+using Orchard.FileSystems.AppData;
using Orchard.Mvc;
using Orchard.Mvc.ModelBinders;
using Orchard.Mvc.Routes;
@@ -149,21 +150,11 @@ namespace Orchard.Tests.Environment {
}
- [Test]
- public void DifferentShellInstanceShouldBeReturnedAfterEachCreate() {
- var host = _lifetime.Resolve();
- var runtime1 = host.CreateShell_Obsolete();
- host.Reinitialize_Obsolete();
- var runtime2 = host.CreateShell_Obsolete();
- Assert.That(runtime1, Is.Not.SameAs(runtime2));
- }
-
-
[Test]
public void NormalDependenciesShouldBeUniquePerRequestContainer() {
var host = _lifetime.Resolve();
var container1 = host.CreateShellContainer_Obsolete();
- host.Reinitialize_Obsolete();
+ ((IShellDescriptorManagerEventHandler)host).Changed(null);
var container2 = host.CreateShellContainer_Obsolete();
var requestContainer1a = container1.BeginLifetimeScope();
var requestContainer1b = container1.BeginLifetimeScope();
diff --git a/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs b/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs
index b023f2dd8..c80d090f6 100644
--- a/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs
+++ b/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs
@@ -1,7 +1,12 @@
-using System.IO;
+using System;
+using System.Collections.Generic;
+using System.IO;
using System.Linq;
using NUnit.Framework;
+using Orchard.Caching;
using Orchard.Environment.Extensions.Folders;
+using Orchard.FileSystems.WebSite;
+using Orchard.Tests.Stubs;
using Yaml.Grammar;
namespace Orchard.Tests.Environment.Extensions {
@@ -49,8 +54,8 @@ namespace Orchard.Tests.Environment.Extensions {
[Test]
public void NamesFromFoldersWithModuleTxtShouldBeListed() {
- var folders = new ModuleFolders(new[] { _tempFolderName });
- var names = folders.ListNames();
+ IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
+ var names = folders.AvailableExtensions().Select(d => d.Name);
Assert.That(names.Count(), Is.EqualTo(2));
Assert.That(names, Has.Some.EqualTo("Sample1"));
Assert.That(names, Has.Some.EqualTo("Sample3"));
@@ -58,14 +63,10 @@ namespace Orchard.Tests.Environment.Extensions {
[Test]
public void ModuleTxtShouldBeParsedAndReturnedAsYamlDocument() {
- var folders = new ModuleFolders(new[] { _tempFolderName });
- var sample1 = folders.ParseManifest("Sample1");
- var mapping = (Mapping)sample1.YamlDocument.Root;
- var entities = mapping.Entities
- .Where(x => x.Key is Scalar)
- .ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
- Assert.That(entities.Keys, Has.Some.EqualTo("name"));
- Assert.That(entities.Keys, Has.Some.EqualTo("author"));
+ IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
+ var sample1 = folders.AvailableExtensions().Single(d => d.Name == "Sample1");
+ Assert.That(sample1.Name, Is.Not.Empty);
+ Assert.That(sample1.Author, Is.EqualTo("Bertrand Le Roy"));
}
- }
+ }
}
\ No newline at end of file
diff --git a/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs b/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs
index 0e5026b09..8e1b0aa1a 100644
--- a/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs
+++ b/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs
@@ -34,22 +34,12 @@ namespace Orchard.Tests.Environment.Extensions {
public IDictionary Manifests { get; set; }
- public IEnumerable ListNames() {
- return Manifests.Keys;
- }
-
- public ParseResult ParseManifest(string name) {
- var parser = new YamlParser();
- bool success;
- var stream = parser.ParseYamlStream(new TextInput(Manifests[name]), out success);
- if (success) {
- return new ParseResult {
- Location = "~/InMemory",
- Name = name,
- YamlDocument = stream.Documents.Single()
- };
+ public IEnumerable AvailableExtensions() {
+ foreach(var e in Manifests) {
+ string name = e.Key;
+ var parseResult = ExtensionFolders.ParseManifest(Manifests[name]);
+ yield return ExtensionFolders.GetDescriptorForExtension("~/", name, "Module", parseResult);
}
- return null;
}
}
@@ -214,7 +204,7 @@ features:
Description: Contains the Phi type.
");
- ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
+ IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
var testFeature = extensionManager.AvailableExtensions()
.SelectMany(x => x.Features);
@@ -240,7 +230,7 @@ features:
Description: Contains the Phi type.
");
- ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
+ IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
var testFeature = extensionManager.AvailableExtensions()
.SelectMany(x => x.Features);
@@ -297,7 +287,7 @@ features:
Description: Contains the Phi type.
");
- ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
+ IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
var testFeature = extensionManager.AvailableExtensions()
.SelectMany(x => x.Features)
.Single(x => x.Name == "TestFeature");
@@ -325,7 +315,7 @@ features:
Description: Contains the Phi type.
");
- ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
+ IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
var testModule = extensionManager.AvailableExtensions()
.SelectMany(x => x.Features)
.Single(x => x.Name == "TestModule");
@@ -349,7 +339,7 @@ version: 1.0.3
orchardversion: 1
");
- ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
+ IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
var minimalisticModule = extensionManager.AvailableExtensions().Single(x => x.Name == "Minimalistic");
Assert.That(minimalisticModule.Features.Count(), Is.EqualTo(1));
diff --git a/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt b/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt
index 44bbc569e..dab08c839 100644
--- a/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt
+++ b/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt
@@ -1 +1 @@
-This is another test.txt
+name: This is another test.txt
diff --git a/src/Orchard.Tests/Environment/ShellBuilders/DefaultShellContainerFactoryTests.cs b/src/Orchard.Tests/Environment/ShellBuilders/DefaultShellContainerFactoryTests.cs
index bbf204a10..d32d3a3cb 100644
--- a/src/Orchard.Tests/Environment/ShellBuilders/DefaultShellContainerFactoryTests.cs
+++ b/src/Orchard.Tests/Environment/ShellBuilders/DefaultShellContainerFactoryTests.cs
@@ -26,6 +26,7 @@ namespace Orchard.Tests.Environment.ShellBuilders {
var builder = new ContainerBuilder();
builder.RegisterType().As();
builder.RegisterType();
+ builder.RegisterType().As();
_container = builder.Build();
}
diff --git a/src/Orchard.Tests/Environment/Topology/DefaultShellDescriptorCacheTests.cs b/src/Orchard.Tests/Environment/Topology/DefaultShellDescriptorCacheTests.cs
index 426d919a4..67ac3ffe9 100644
--- a/src/Orchard.Tests/Environment/Topology/DefaultShellDescriptorCacheTests.cs
+++ b/src/Orchard.Tests/Environment/Topology/DefaultShellDescriptorCacheTests.cs
@@ -3,9 +3,9 @@ using System.Runtime.Serialization;
using System.Xml;
using Autofac;
using NUnit.Framework;
-using Orchard.Environment.Configuration;
using Orchard.Environment.Topology;
using Orchard.Environment.Topology.Models;
+using Orchard.FileSystems.AppData;
namespace Orchard.Tests.Environment.Topology {
[TestFixture]
diff --git a/src/Orchard.Tests/Events/EventTests.cs b/src/Orchard.Tests/Events/EventTests.cs
index 58648fa80..1475d856a 100644
--- a/src/Orchard.Tests/Events/EventTests.cs
+++ b/src/Orchard.Tests/Events/EventTests.cs
@@ -2,6 +2,7 @@
using Autofac;
using NUnit.Framework;
using Orchard.Events;
+using System;
namespace Orchard.Tests.Events {
[TestFixture]
@@ -9,21 +10,181 @@ namespace Orchard.Tests.Events {
private IContainer _container;
private IEventBus _eventBus;
private StubEventBusHandler _eventBusHandler;
+ private StubEventHandler _eventHandler;
[SetUp]
public void Init() {
var builder = new ContainerBuilder();
_eventBusHandler = new StubEventBusHandler();
+ _eventHandler = new StubEventHandler();
builder.RegisterInstance(_eventBusHandler).As();
+ builder.RegisterInstance(_eventHandler).As();
builder.RegisterType().As();
_container = builder.Build();
_eventBus = _container.Resolve();
}
[Test]
- public void EventsAreCorrectlyDispatchedToHandlers() {
+ public void EventsAreCorrectlyDispatchedToEventHandlers() {
+ Assert.That(_eventHandler.Count, Is.EqualTo(0));
+ _eventBus.Notify("ITestEventHandler.Increment", new Dictionary());
+ Assert.That(_eventHandler.Count, Is.EqualTo(1));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToEventHandlers() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 5200;
+ arguments["b"] = 2600;
+ _eventBus.Notify("ITestEventHandler.Substract", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(2600));
+ }
+
+ [Test]
+ public void EventParametersArePassedInCorrectOrderToEventHandlers() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 2600;
+ arguments["b"] = 5200;
+ _eventBus.Notify("ITestEventHandler.Substract", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(-2600));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToMatchingMethod() {
+ Assert.That(_eventHandler.Summary, Is.Null);
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = "a";
+ arguments["b"] = "b";
+ arguments["c"] = "c";
+ _eventBus.Notify("ITestEventHandler.Concat", arguments);
+ Assert.That(_eventHandler.Summary, Is.EqualTo("abc"));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToExactlyMatchingMethod() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 1000;
+ arguments["b"] = 100;
+ arguments["c"] = 10;
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(1110));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 1000;
+ arguments["b"] = 100;
+ arguments["c"] = 10;
+ arguments["e"] = 1;
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(1110));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored2() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 1000;
+ arguments["e"] = 1;
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(3000));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 1000;
+ arguments["b"] = 100;
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(2200));
+ }
+
+ [Test]
+ public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne2() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["a"] = 1000;
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(3000));
+ }
+
+ [Test]
+ public void EventHandlerWontBeCalledWhenNoParameterMatchExists() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ arguments["e"] = 1;
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void EventHandlerWontBeCalledWhenNoParameterMatchExists2() {
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ Dictionary arguments = new Dictionary();
+ _eventBus.Notify("ITestEventHandler.Sum", arguments);
+ Assert.That(_eventHandler.Result, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void EventHandlerWontThrowIfMethodDoesNotExists() {
+ Dictionary arguments = new Dictionary();
+ Assert.DoesNotThrow(() => _eventBus.Notify("ITestEventHandler.NotExisting", arguments));
+ }
+
+ [Test]
+ public void EventBusThrowsIfMessageNameIsNotCorrectlyFormatted() {
+ Assert.Throws(() => _eventBus.Notify("StubEventHandlerIncrement", new Dictionary()));
+ }
+
+ public interface ITestEventHandler : IEventHandler {
+ void Increment();
+ void Sum(int a);
+ void Sum(int a, int b);
+ void Sum(int a, int b, int c);
+ void Substract(int a, int b);
+ void Concat(string a, string b, string c);
+ }
+
+ public class StubEventHandler : ITestEventHandler {
+ public int Count { get; set; }
+ public int Result { get; set; }
+ public string Summary { get; set; }
+
+ public void Increment() {
+ Count++;
+ }
+
+ public void Sum(int a) {
+ Result = 3 * a;
+ }
+
+ public void Sum(int a, int b) {
+ Result = 2 * ( a + b );
+ }
+
+ public void Sum(int a, int b, int c) {
+ Result = a + b + c;
+ }
+
+ public void Substract(int a, int b) {
+ Result = a - b;
+ }
+
+ public void Concat(string a, string b, string c) {
+ Summary = a + b + c;
+ }
+ }
+
+ [Test]
+ public void EventsAreCorrectlyDispatchedToHandlers_Obsolete() {
Assert.That(_eventBusHandler.LastMessageName, Is.Null);
- _eventBus.Notify("Notification", new Dictionary());
+ _eventBus.Notify_Obsolete("Notification", new Dictionary());
Assert.That(_eventBusHandler.LastMessageName, Is.EqualTo("Notification"));
}
diff --git a/src/Orchard.Tests/Orchard.Framework.Tests.csproj b/src/Orchard.Tests/Orchard.Framework.Tests.csproj
index 6d5f209c8..c624f53d3 100644
--- a/src/Orchard.Tests/Orchard.Framework.Tests.csproj
+++ b/src/Orchard.Tests/Orchard.Framework.Tests.csproj
@@ -78,8 +78,6 @@
False..\..\lib\fluentnhibernate\FluentNHibernate.dll
-
- False..\..\lib\moq\Moq.dll
@@ -141,12 +139,15 @@
+
+ Code
+ Code
@@ -193,6 +194,8 @@
+
+
diff --git a/src/Orchard.Tests/Storage/FileSystemStorageProviderTests.cs b/src/Orchard.Tests/Storage/FileSystemStorageProviderTests.cs
index fb87bbcb2..df7e4d10a 100644
--- a/src/Orchard.Tests/Storage/FileSystemStorageProviderTests.cs
+++ b/src/Orchard.Tests/Storage/FileSystemStorageProviderTests.cs
@@ -4,7 +4,7 @@ using System.Linq;
using NUnit.Framework;
using System;
using Orchard.Environment.Configuration;
-using Orchard.Storage;
+using Orchard.FileSystems.Media;
namespace Orchard.Tests.Storage {
[TestFixture]
diff --git a/src/Orchard.Tests/Stubs/StubCacheManager.cs b/src/Orchard.Tests/Stubs/StubCacheManager.cs
new file mode 100644
index 000000000..fd28e5083
--- /dev/null
+++ b/src/Orchard.Tests/Stubs/StubCacheManager.cs
@@ -0,0 +1,15 @@
+using System;
+using Orchard.Caching;
+
+namespace Orchard.Tests.Stubs {
+ public class StubCacheManager : ICacheManager {
+ public TResult Get(TKey key, Func, TResult> acquire) {
+ var cache = new Cache();
+ return cache.Get(key, acquire);
+ }
+
+ public ICache GetCache() {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Tests/Stubs/StubHttpContext.cs b/src/Orchard.Tests/Stubs/StubHttpContext.cs
index df66a262a..0337c90fe 100644
--- a/src/Orchard.Tests/Stubs/StubHttpContext.cs
+++ b/src/Orchard.Tests/Stubs/StubHttpContext.cs
@@ -12,10 +12,12 @@ namespace Orchard.Tests.Stubs {
public StubHttpContext() {
_appRelativeCurrentExecutionFilePath = "~/yadda";
+ _hostHeader = "localhost";
}
public StubHttpContext(string appRelativeCurrentExecutionFilePath) {
_appRelativeCurrentExecutionFilePath = appRelativeCurrentExecutionFilePath;
+ _hostHeader = "localhost";
}
public StubHttpContext(string appRelativeCurrentExecutionFilePath, string hostHeader) {
@@ -38,6 +40,7 @@ namespace Orchard.Tests.Stubs {
class StubHttpRequest : HttpRequestBase {
private readonly StubHttpContext _httpContext;
private NameValueCollection _serverVariables;
+ private NameValueCollection _headers;
public StubHttpRequest(StubHttpContext httpContext) {
_httpContext = httpContext;
@@ -54,7 +57,12 @@ namespace Orchard.Tests.Stubs {
public override string PathInfo {
get { return ""; }
}
-
+ public override NameValueCollection Headers {
+ get {
+ return _headers = _headers
+ ?? new NameValueCollection { { "Host", _httpContext._hostHeader } };
+ }
+ }
public override NameValueCollection ServerVariables {
get {
return _serverVariables = _serverVariables
diff --git a/src/Orchard.Tests/Stubs/StubWebSiteFolder.cs b/src/Orchard.Tests/Stubs/StubWebSiteFolder.cs
new file mode 100644
index 000000000..82e0446ee
--- /dev/null
+++ b/src/Orchard.Tests/Stubs/StubWebSiteFolder.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Orchard.Caching;
+using Orchard.FileSystems.WebSite;
+
+namespace Orchard.Tests.Stubs {
+ public class StubWebSiteFolder : IWebSiteFolder {
+ public IEnumerable ListDirectories(string path) {
+ if (!Directory.Exists(path))
+ return Enumerable.Empty();
+
+ return Directory.GetDirectories(path);
+ }
+
+ public string ReadFile(string path) {
+ if (!File.Exists(path))
+ return null;
+
+ return File.ReadAllText(path);
+ }
+
+ public IVolatileToken WhenPathChanges(string path) {
+ return new WebSiteFolder.Token(path);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Tests/Tasks/SweepGeneratorTests.cs b/src/Orchard.Tests/Tasks/SweepGeneratorTests.cs
index 02117ed32..2c7301c9d 100644
--- a/src/Orchard.Tests/Tasks/SweepGeneratorTests.cs
+++ b/src/Orchard.Tests/Tasks/SweepGeneratorTests.cs
@@ -1,6 +1,5 @@
using System;
using Autofac;
-using Autofac.Builder;
using Moq;
using NUnit.Framework;
using Orchard.Tasks;
diff --git a/src/Orchard.Tests/Utility/Extensions/StringExtensionsTests.cs b/src/Orchard.Tests/Utility/Extensions/StringExtensionsTests.cs
index 3240ab717..9266e08b6 100644
--- a/src/Orchard.Tests/Utility/Extensions/StringExtensionsTests.cs
+++ b/src/Orchard.Tests/Utility/Extensions/StringExtensionsTests.cs
@@ -4,6 +4,26 @@ using Orchard.Utility.Extensions;
namespace Orchard.Tests.Utility.Extensions {
[TestFixture]
public class StringExtensionsTests {
+ [Test]
+ public void HtmlClassify_ValidSimpleClassNameReturnsSame() {
+ const string toClassify = "some-class";
+ Assert.That(toClassify.HtmlClassify(), Is.StringMatching("some-class"));
+ }
+ [Test]
+ public void HtmlClassify_SimpleStringReturnsSimpleClassName() {
+ const string toClassify = "this is something";
+ Assert.That(toClassify.HtmlClassify(), Is.StringMatching("this-is-something"));
+ }
+ [Test]
+ public void HtmlClassify_ValidComplexClassNameReturnsSimpleClassName() {
+ const string toClassify = @"some-class\&some.other.class";
+ Assert.That(toClassify.HtmlClassify(), Is.StringMatching("some-class-some-other-class"));
+ }
+ [Test]
+ public void HtmlClassify_CompletelyInvalidClassNameReturnsEmptyString() {
+ const string toClassify = @"0_1234_12";
+ Assert.That(toClassify.HtmlClassify(), Is.StringMatching(""));
+ }
[Test]
public void OrDefault_ReturnsDefaultForNull() {
const string s = null;
diff --git a/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs b/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs
index 04d56dc88..f7a0a0264 100644
--- a/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs
+++ b/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs
@@ -104,6 +104,10 @@ namespace Orchard.Core.Common.Drivers {
// Can be moved somewhere else once we have IoC enabled body text filters.
private static string BbcodeReplace(string bodyText) {
+
+ if ( string.IsNullOrEmpty(bodyText) )
+ return string.Empty;
+
Regex urlRegex = new Regex(@"\[url\]([^\]]+)\[\/url\]");
Regex urlRegexWithLink = new Regex(@"\[url=([^\]]+)\]([^\]]+)\[\/url\]");
Regex imgRegex = new Regex(@"\[img\]([^\]]+)\[\/img\]");
diff --git a/src/Orchard.Web/Core/Common/Services/IRoutableService.cs b/src/Orchard.Web/Core/Common/Services/IRoutableService.cs
index 65f0fac1a..0519f07f2 100644
--- a/src/Orchard.Web/Core/Common/Services/IRoutableService.cs
+++ b/src/Orchard.Web/Core/Common/Services/IRoutableService.cs
@@ -11,7 +11,7 @@ namespace Orchard.Core.Common.Services {
///
/// Returns any content item of the specified content type with similar slugs
///
- string[] GetSimilarSlugs(string contentType, string slug);
+ IEnumerable GetSimilarSlugs(string contentType, string slug);
///
/// Validates the given slug
diff --git a/src/Orchard.Web/Core/Common/Services/RoutableService.cs b/src/Orchard.Web/Core/Common/Services/RoutableService.cs
index cfddb58b5..057ccf031 100644
--- a/src/Orchard.Web/Core/Common/Services/RoutableService.cs
+++ b/src/Orchard.Web/Core/Common/Services/RoutableService.cs
@@ -63,13 +63,13 @@ namespace Orchard.Core.Common.Services {
: null;
}
- public string[] GetSimilarSlugs(string contentType, string slug)
+ public IEnumerable GetSimilarSlugs(string contentType, string slug)
{
return
_contentManager.Query(contentType).Join()
.List()
- .Select(i => i.As().Slug)
- .Where(rr => rr.StartsWith(slug, StringComparison.OrdinalIgnoreCase)) // todo: for some reason the filter doesn't work within the query, even without StringComparison or StartsWith
+ .Select(i => i.As())
+ .Where(routable => routable.Slug.StartsWith(slug, StringComparison.OrdinalIgnoreCase)) // todo: for some reason the filter doesn't work within the query, even without StringComparison or StartsWith
.ToArray();
}
@@ -89,12 +89,17 @@ namespace Orchard.Core.Common.Services {
var slugsLikeThis = GetSimilarSlugs(part.ContentItem.ContentType, part.Slug);
+ // If the part is already a valid content item, don't include it in the list
+ // of slug to consider for conflict detection
+ if (part.ContentItem.Id != 0)
+ slugsLikeThis = slugsLikeThis.Where(p => p.ContentItem.Id != part.ContentItem.Id);
+
//todo: (heskew) need better messages
- if (slugsLikeThis.Length > 0)
+ if (slugsLikeThis.Count() > 0)
{
var originalSlug = part.Slug;
//todo: (heskew) make auto-uniqueness optional
- part.Slug = GenerateUniqueSlug(part.Slug, slugsLikeThis);
+ part.Slug = GenerateUniqueSlug(part.Slug, slugsLikeThis.Select(p => p.Slug));
if (originalSlug != part.Slug) {
return false;
diff --git a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts/Common.Routable.ascx b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts/Common.Routable.ascx
index 3b6a81b84..b699143bb 100644
--- a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts/Common.Routable.ascx
+++ b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts/Common.Routable.ascx
@@ -10,7 +10,7 @@
<%=Html.TextBoxFor(m => m.Title, new { @class = "large text" }) %>
<% using (this.Capture("end-of-page-scripts")) { %>
diff --git a/src/Orchard.Web/Core/Dashboard/Module.txt b/src/Orchard.Web/Core/Dashboard/Module.txt
index e646ae5c2..1fb19522a 100644
--- a/src/Orchard.Web/Core/Dashboard/Module.txt
+++ b/src/Orchard.Web/Core/Dashboard/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Dashboard:
Description: Standard admin dashboard.
- Dependencies: Common
Category: Core
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Feeds/Controllers/FeedController.cs b/src/Orchard.Web/Core/Feeds/Controllers/FeedController.cs
index 9004cb077..bde60e4a1 100644
--- a/src/Orchard.Web/Core/Feeds/Controllers/FeedController.cs
+++ b/src/Orchard.Web/Core/Feeds/Controllers/FeedController.cs
@@ -10,15 +10,15 @@ namespace Orchard.Core.Feeds.Controllers {
public class FeedController : Controller {
private readonly IEnumerable _feedFormatProviders;
private readonly IEnumerable _feedQueryProviders;
- private readonly IEnumerable _feedItemBuilders;
+ private readonly IFeedItemBuilder _feedItemBuilder;
public FeedController(
IEnumerable feedQueryProviders,
IEnumerable feedFormatProviders,
- IEnumerable feedItemBuilders) {
+ IFeedItemBuilder feedItemBuilder) {
_feedQueryProviders = feedQueryProviders;
_feedFormatProviders = feedFormatProviders;
- _feedItemBuilders = feedItemBuilders;
+ _feedItemBuilder = feedItemBuilder;
Logger = NullLogger.Instance;
}
@@ -49,7 +49,7 @@ namespace Orchard.Core.Feeds.Controllers {
return context.Builder.Process(context, () => {
bestQueryMatch.FeedQuery.Execute(context);
- _feedItemBuilders.Invoke(x => x.Populate(context), Logger);
+ _feedItemBuilder.Populate(context);
foreach (var contextualizer in context.Response.Contextualizers) {
if (ControllerContext != null &&
ControllerContext.RequestContext != null) {
diff --git a/src/Orchard.Web/Core/Feeds/IFeedItemBuilder.cs b/src/Orchard.Web/Core/Feeds/IFeedItemBuilder.cs
index d0c5abed2..ea082e49b 100644
--- a/src/Orchard.Web/Core/Feeds/IFeedItemBuilder.cs
+++ b/src/Orchard.Web/Core/Feeds/IFeedItemBuilder.cs
@@ -1,7 +1,8 @@
using Orchard.Core.Feeds.Models;
+using Orchard.Events;
namespace Orchard.Core.Feeds {
- public interface IFeedItemBuilder : IEvents {
+ public interface IFeedItemBuilder : IEventHandler {
void Populate(FeedContext context);
}
}
diff --git a/src/Orchard.Web/Core/Feeds/Module.txt b/src/Orchard.Web/Core/Feeds/Module.txt
index 1b2ba39c1..eb1f5b157 100644
--- a/src/Orchard.Web/Core/Feeds/Module.txt
+++ b/src/Orchard.Web/Core/Feeds/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Feeds:
Description: RSS feeds for content items.
- Dependencies: Common
Category: Syndication
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/HomePage/Module.txt b/src/Orchard.Web/Core/HomePage/Module.txt
index b4a95af7e..63404f28d 100644
--- a/src/Orchard.Web/Core/HomePage/Module.txt
+++ b/src/Orchard.Web/Core/HomePage/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
HomePage:
Description: Standard site home page that allows a specified content type or container to *be* the home page.
- Dependencies: Common
Category: Core
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Navigation/Module.txt b/src/Orchard.Web/Core/Navigation/Module.txt
index adbfd4438..31ec9b758 100644
--- a/src/Orchard.Web/Core/Navigation/Module.txt
+++ b/src/Orchard.Web/Core/Navigation/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Navigation:
Description: Menu management.
- Dependencies: Common
Category: Core
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Scheduling/Module.txt b/src/Orchard.Web/Core/Scheduling/Module.txt
index 848b44124..e5026374d 100644
--- a/src/Orchard.Web/Core/Scheduling/Module.txt
+++ b/src/Orchard.Web/Core/Scheduling/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Scheduling:
Description: Scheduled background tasks.
- Dependencies: Common
Category: Core
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Scheduling/Services/PublishingTaskHandler.cs b/src/Orchard.Web/Core/Scheduling/Services/PublishingTaskHandler.cs
index 273f97862..2c870d405 100644
--- a/src/Orchard.Web/Core/Scheduling/Services/PublishingTaskHandler.cs
+++ b/src/Orchard.Web/Core/Scheduling/Services/PublishingTaskHandler.cs
@@ -1,16 +1,18 @@
using JetBrains.Annotations;
+using Orchard.ContentManagement;
using Orchard.Logging;
using Orchard.Tasks.Scheduling;
namespace Orchard.Core.Scheduling.Services {
[UsedImplicitly]
public class PublishingTaskHandler : IScheduledTaskHandler {
- public PublishingTaskHandler(IOrchardServices services) {
- Services = services;
+ private readonly IContentManager _contentManager;
+
+ public PublishingTaskHandler(IContentManager contentManager) {
+ _contentManager = contentManager;
Logger = NullLogger.Instance;
}
- public IOrchardServices Services { get; set; }
public ILogger Logger { get; set; }
public void Process(ScheduledTaskContext context) {
@@ -20,7 +22,7 @@ namespace Orchard.Core.Scheduling.Services {
context.Task.ContentItem.Version,
context.Task.ScheduledUtc);
- Services.ContentManager.Publish(context.Task.ContentItem);
+ _contentManager.Publish(context.Task.ContentItem);
}
else if (context.Task.TaskType == "Unpublish") {
Logger.Information("Unpublishing item #{0} version {1} scheduled at {2} utc",
@@ -28,7 +30,7 @@ namespace Orchard.Core.Scheduling.Services {
context.Task.ContentItem.Version,
context.Task.ScheduledUtc);
- Services.ContentManager.Unpublish(context.Task.ContentItem);
+ _contentManager.Unpublish(context.Task.ContentItem);
}
}
}
diff --git a/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskExecutor.cs b/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskExecutor.cs
index 3b7f74ed0..94e7ac005 100644
--- a/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskExecutor.cs
+++ b/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskExecutor.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
+using Orchard.ContentManagement;
using Orchard.Core.Scheduling.Models;
using Orchard.Data;
using Orchard.Logging;
@@ -15,20 +16,20 @@ namespace Orchard.Core.Scheduling.Services {
private readonly IClock _clock;
private readonly IRepository _repository;
private readonly IEnumerable _handlers;
+ private readonly IContentManager _contentManager;
public ScheduledTaskExecutor(
- IOrchardServices services,
IClock clock,
IRepository repository,
- IEnumerable handlers) {
+ IEnumerable handlers,
+ IContentManager contentManager) {
_clock = clock;
_repository = repository;
_handlers = handlers;
- Services = services;
+ _contentManager = contentManager;
Logger = NullLogger.Instance;
}
- public IOrchardServices Services { get; set; }
public ILogger Logger { get; set; }
public void Sweep() {
@@ -52,7 +53,7 @@ namespace Orchard.Core.Scheduling.Services {
_repository.Delete(taskRecord);
var context = new ScheduledTaskContext {
- Task = new Task(Services.ContentManager, taskRecord)
+ Task = new Task(_contentManager, taskRecord)
};
// dispatch to standard or custom handlers
diff --git a/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskManager.cs b/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskManager.cs
index 90276ef52..19c73dce7 100644
--- a/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskManager.cs
+++ b/src/Orchard.Web/Core/Scheduling/Services/ScheduledTaskManager.cs
@@ -12,17 +12,17 @@ using Orchard.Utility.Extensions;
namespace Orchard.Core.Scheduling.Services {
[UsedImplicitly]
public class ScheduledTaskManager : IScheduledTaskManager {
+ private readonly IContentManager _contentManager;
private readonly IRepository _repository;
public ScheduledTaskManager(
- IOrchardServices services,
+ IContentManager contentManager,
IRepository repository) {
_repository = repository;
- Services = services;
+ _contentManager = contentManager;
Logger = NullLogger.Instance;
}
- public IOrchardServices Services { get; set; }
public ILogger Logger { get; set; }
public void CreateTask(string action, DateTime scheduledUtc, ContentItem contentItem) {
@@ -39,7 +39,7 @@ namespace Orchard.Core.Scheduling.Services {
public IEnumerable GetTasks(ContentItem contentItem) {
return _repository
.Fetch(x => x.ContentItemVersionRecord.ContentItemRecord == contentItem.Record)
- .Select(x => new Task(Services.ContentManager, x))
+ .Select(x => new Task(_contentManager, x))
.Cast()
.ToReadOnlyCollection();
}
@@ -50,7 +50,7 @@ namespace Orchard.Core.Scheduling.Services {
.Fetch(x => x.ContentItemVersionRecord.ContentItemRecord == contentItem.Record);
foreach (var task in tasks) {
- if (predicate(new Task(Services.ContentManager, task))) {
+ if (predicate(new Task(_contentManager, task))) {
_repository.Delete(task);
}
}
diff --git a/src/Orchard.Web/Core/Settings/Module.txt b/src/Orchard.Web/Core/Settings/Module.txt
index b5cd0527d..5e4f413c7 100644
--- a/src/Orchard.Web/Core/Settings/Module.txt
+++ b/src/Orchard.Web/Core/Settings/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Settings:
Description: Site settings.
- Dependencies: Common
Category: Core
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Settings/Services/SiteService.cs b/src/Orchard.Web/Core/Settings/Services/SiteService.cs
index 4c95ec5eb..451bfb84b 100644
--- a/src/Orchard.Web/Core/Settings/Services/SiteService.cs
+++ b/src/Orchard.Web/Core/Settings/Services/SiteService.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using JetBrains.Annotations;
+using Orchard.Caching;
using Orchard.Core.Settings.Models;
using Orchard.Data;
using Orchard.Logging;
@@ -10,30 +11,38 @@ using Orchard.Settings;
namespace Orchard.Core.Settings.Services {
[UsedImplicitly]
public class SiteService : ISiteService {
- private readonly IRepository _siteSettingsRepository;
private readonly IContentManager _contentManager;
+ private readonly ICacheManager _cacheManager;
- public SiteService(IRepository siteSettingsRepository, IContentManager contentManager) {
- _siteSettingsRepository = siteSettingsRepository;
+ public SiteService(
+ IRepository siteSettingsRepository,
+ IContentManager contentManager,
+ ICacheManager cacheManager) {
_contentManager = contentManager;
+ _cacheManager = cacheManager;
Logger = NullLogger.Instance;
}
public ILogger Logger { get; set; }
public ISite GetSiteSettings() {
- SiteSettingsRecord record = _siteSettingsRepository.Table.FirstOrDefault();
- if (record == null) {
- ISite site = _contentManager.Create("site", item => {
- item.Record.SiteSalt = Guid.NewGuid().ToString("N");
- item.Record.SiteName = "My Orchard Project Application";
- item.Record.PageTitleSeparator = " - ";
- });
- // ensure subsequent calls will locate this object
- _contentManager.Flush();
- return site;
- }
- return _contentManager.Get(record.Id);
+ var siteId = _cacheManager.Get("SiteId", ctx => {
+ var site = _contentManager.Query("site")
+ .Slice(0, 1)
+ .FirstOrDefault();
+
+ if (site == null) {
+ site = _contentManager.Create("site", item => {
+ item.Record.SiteSalt = Guid.NewGuid().ToString("N");
+ item.Record.SiteName = "My Orchard Project Application";
+ item.Record.PageTitleSeparator = " - ";
+ }).ContentItem;
+ }
+
+ return site.Id;
+ });
+
+ return _contentManager.Get(siteId);
}
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Settings/Topology/ShellDescriptorManager.cs b/src/Orchard.Web/Core/Settings/Topology/ShellDescriptorManager.cs
index 98bcddd67..5f56cf48e 100644
--- a/src/Orchard.Web/Core/Settings/Topology/ShellDescriptorManager.cs
+++ b/src/Orchard.Web/Core/Settings/Topology/ShellDescriptorManager.cs
@@ -11,13 +11,13 @@ using Orchard.Localization;
namespace Orchard.Core.Settings.Topology {
public class ShellDescriptorManager : IShellDescriptorManager {
private readonly IRepository _topologyRecordRepository;
- private readonly IEventBus _eventBus;
+ private readonly IShellDescriptorManagerEventHandler _events;
public ShellDescriptorManager(
IRepository repository,
- IEventBus eventBus) {
+ IShellDescriptorManagerEventHandler events) {
_topologyRecordRepository = repository;
- _eventBus = eventBus;
+ _events = events;
T = NullLocalizer.Instance;
}
@@ -85,9 +85,7 @@ namespace Orchard.Core.Settings.Topology {
});
}
- _eventBus.Notify(
- "ShellDescriptor_Changed",
- null);
+ _events.Changed(GetShellTopologyDescriptorFromRecord(topologyRecord));
}
}
}
diff --git a/src/Orchard.Web/Core/XmlRpc/Module.txt b/src/Orchard.Web/Core/XmlRpc/Module.txt
index 5db3d574c..6ab5a799d 100644
--- a/src/Orchard.Web/Core/XmlRpc/Module.txt
+++ b/src/Orchard.Web/Core/XmlRpc/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
XmlRpc:
Description: XML-RPC opt-in implementation.
- Dependencies: Common
- Category: Core
\ No newline at end of file
+ Category: Content Publishing
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/XmlRpc/Views/Home/Index.aspx b/src/Orchard.Web/Core/XmlRpc/Views/Home/Index.aspx
index 1be46f753..56e93b956 100644
--- a/src/Orchard.Web/Core/XmlRpc/Views/Home/Index.aspx
+++ b/src/Orchard.Web/Core/XmlRpc/Views/Home/Index.aspx
@@ -1,9 +1,6 @@
-<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
-
-
- Home Page
-
-
-
-
Use this url for LiveWriter
-
+<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
+
+
+Use this url for LiveWriter
+
Use this url for LiveWriter
+
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Module.txt b/src/Orchard.Web/Modules/Futures.Widgets/Module.txt
index ccc415c58..827ac7017 100644
--- a/src/Orchard.Web/Modules/Futures.Widgets/Module.txt
+++ b/src/Orchard.Web/Modules/Futures.Widgets/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Futures.Widgets:
Description: Widgets container with simple inline content editing widget.
- Dependencies: Common
Category: Widget
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs
index ed0a60822..c0aad6773 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs
@@ -98,7 +98,7 @@ namespace Orchard.Blogs.Controllers {
var options = new XElement(
XName.Get("service", manifestUri),
- new XElement(XName.Get("engineName", manifestUri), "Orchar CMS"),
+ new XElement(XName.Get("engineName", manifestUri), "Orchard CMS"),
new XElement(XName.Get("engineLink", manifestUri), "http://orchardproject.net"),
new XElement(XName.Get("homePageLink", manifestUri), "http://orchardproject.net"),
new XElement(XName.Get("apis", manifestUri),
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Module.txt b/src/Orchard.Web/Modules/Orchard.Blogs/Module.txt
index 52f596e33..f1e73406c 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Module.txt
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Module.txt
@@ -7,5 +7,8 @@ orchardversion: 0.1.2010.0312
features:
Orchard.Blogs:
Description: A simple web log.
- Dependencies: Common, XmlRpc
- Category: Content
\ No newline at end of file
+ Category: Content
+ Remote Blog Publishing:
+ Description: Blog easier using a dedicated MetaWeblogAPI-compatible publishing tool.
+ Dependencies: XmlRpc
+ Category: Content Publishing
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Services/XmlRpcHandler.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Services/XmlRpcHandler.cs
index da6094ea8..2c14b76de 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Services/XmlRpcHandler.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Services/XmlRpcHandler.cs
@@ -8,6 +8,7 @@ using Orchard.Blogs.Models;
using Orchard.ContentManagement;
using Orchard.Core.XmlRpc;
using Orchard.Core.XmlRpc.Models;
+using Orchard.Environment.Extensions;
using Orchard.Logging;
using Orchard.Mvc.Extensions;
using Orchard.Security;
@@ -15,6 +16,7 @@ using Orchard.Blogs.Extensions;
namespace Orchard.Blogs.Services {
[UsedImplicitly]
+ [OrchardFeature("Remote Blog Publishing")]
public class XmlRpcHandler : IXmlRpcHandler {
private readonly IBlogService _blogService;
private readonly IBlogPostService _blogPostService;
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs b/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs
index 51c9ed94c..f519b9517 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Extensions/HtmlHelperExtensions.cs
@@ -2,6 +2,7 @@ using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.ContentManagement;
using Orchard.Localization;
+using Orchard.Utility.Extensions;
namespace Orchard.Comments.Extensions {
public static class HtmlHelperExtensions {
@@ -23,7 +24,7 @@ namespace Orchard.Comments.Extensions {
Area = "Orchard.Comments",
Controller = "Admin",
id = item.Id,
- returnUrl = html.ViewContext.HttpContext.Request.Url
+ returnUrl = html.ViewContext.HttpContext.Request.ToUrlString()
});
}
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsHandler.cs b/src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsHandler.cs
index 6797e787b..dfa82586e 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsHandler.cs
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsHandler.cs
@@ -14,29 +14,24 @@ namespace Orchard.Comments.Handlers {
IRepository hasCommentsRepository,
ICommentService commentService) {
- Filters.Add(new ActivatingFilter("sandboxpage"));
- Filters.Add(new ActivatingFilter("blogpost"));
- Filters.Add(new ActivatingFilter("page"));
Filters.Add(StorageFilter.For(hasCommentsRepository));
OnActivated((ctx, x) => {
- x.CommentsActive = true;
- x.CommentsShown = true;
- });
+ x.CommentsActive = true;
+ x.CommentsShown = true;
+ });
OnLoading((context, comments) => {
- //TODO: lazy loading?
- comments.Comments = contentManager
- .Query()
- .Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved)
- .List().ToList();
+ comments._comments.Loader(list => contentManager
+ .Query()
+ .Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved)
+ .List().ToList());
- //TODO: lazy loading?
- comments.PendingComments = contentManager
- .Query()
- .Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Pending)
- .List().ToList();
- });
+ comments._pendingComments.Loader(list => contentManager
+ .Query()
+ .Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Pending)
+ .List().ToList());
+ });
OnRemoved(
(context, c) => {
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Models/HasComments.cs b/src/Orchard.Web/Modules/Orchard.Comments/Models/HasComments.cs
index f5cc28197..724fc99f0 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Models/HasComments.cs
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Models/HasComments.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
+using Orchard.ContentManagement.Utilities;
namespace Orchard.Comments.Models {
public class HasComments : ContentPart {
@@ -8,8 +9,11 @@ namespace Orchard.Comments.Models {
PendingComments = new List();
}
- public IList Comments { get; set; }
- public IList PendingComments { get; set; }
+ public readonly LazyField> _comments = new LazyField>();
+ public readonly LazyField> _pendingComments = new LazyField>();
+
+ public IList Comments { get { return _comments.Value; } set { _comments.Value = value; } }
+ public IList PendingComments { get { return _pendingComments.Value; } set { _pendingComments.Value = value; } }
public bool CommentsShown {
get { return Record.CommentsShown; }
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Module.txt b/src/Orchard.Web/Modules/Orchard.Comments/Module.txt
index 7936c3af0..d863f49bb 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Module.txt
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Orchard.Comments:
Description: Standard content item comments.
- Dependencies: Common
- Category: User Interaction
\ No newline at end of file
+ Category: Social
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/DisplayTemplates/Parts/Comments.HasComments.ascx b/src/Orchard.Web/Modules/Orchard.Comments/Views/DisplayTemplates/Parts/Comments.HasComments.ascx
index 49d4a3c35..79cb8e5ca 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Views/DisplayTemplates/Parts/Comments.HasComments.ascx
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/DisplayTemplates/Parts/Comments.HasComments.ascx
@@ -2,6 +2,7 @@
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>
+<%@ Import Namespace="Orchard.Utility.Extensions" %>
<%-- todo: clean up this template - waaay too much going on in here :/ --%><%
if (Model.Comments.Count > 0) { %>
- <%=Html.ActionLink(T("Edit").ToString(), "edit", new {moduleName = module.ModuleName, area = "Orchard.Modules"}) %><%=_Encoded(" | ")%>
- Delete
-
--%>
<%
if (!string.IsNullOrEmpty(module.Description)) { %>
<%=Html.Encode(module.Description) %>
<%
@@ -30,5 +27,7 @@
<%
} %>
+
+
<%
} %>
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Modules/styles/admin.css b/src/Orchard.Web/Modules/Orchard.Modules/styles/admin.css
new file mode 100644
index 000000000..3041b4688
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.Modules/styles/admin.css
@@ -0,0 +1,85 @@
+.orchard-modules #main h2 {
+ border:0;
+ margin-bottom:.2em;
+}
+
+.features .category {
+ overflow:hidden;
+}
+.features .feature {
+ border:1px solid #EAEAEA;
+ display:block;
+ float:left;
+ height:5em;
+ margin:0 .5% 1% .5%;
+ position:relative;
+ width:32.1%;
+}
+.features .feature:nth-child(3n+1),
+.features .feature:nth-child(3n+2),
+.features .feature:nth-child(3n) {
+ width:32.55%;
+}
+.features .feature:nth-child(3n+1) {
+ margin-left:0;
+}
+.features .feature:nth-child(3n+2) {
+ margin-right:0;
+}
+.features .feature:nth-child(3n) {
+ float:right;
+ margin-left:0;
+ margin-right:0;
+}
+
+.features .enabled.feature {
+ background:#FFF;
+ border-color:#CFE493;cfe493
+}
+.features .disabled.feature {
+ background:#EAEAEA;
+ border-color:#CCC;
+}
+.features .feature .summary {
+ overflow:hidden;
+ padding:.4em .5em;
+}
+.features .dependencies li,
+.features .actions {
+ font-size:1.4em;
+}
+.features .dependencies {
+ font-size:.9em;
+ margin:.44em 0 0;
+}
+.features .dependencies>* {
+ display:inline;
+}
+.features .dependencies li {
+ display:inline;
+ margin-left:.5em;
+}
+.features .dependencies li::after {
+ content:", ";
+}
+.features .dependencies li:last-child::after {
+ content:"";
+}
+.features .feature .actions {
+ position:absolute;
+ right:.4em;
+ top:.6em;
+}
+
+.cathedral {
+ bottom:0;
+ font-size:.8em;
+ position:absolute;
+ right:3px;
+}
+.cathedral a,
+.cathedral a:link,
+.cathedral a:visited,
+.cathedral form.inline.link button {
+ color:#aeaeae;
+}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/AdminMenu.cs
index a62de0bd8..aab63b491 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/AdminMenu.cs
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/AdminMenu.cs
@@ -5,7 +5,7 @@ namespace Orchard.MultiTenancy {
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
- builder.Add("MultiTenancy", "2",
+ builder.Add("Tenants", "22",
menu => menu
.Add("Manage Tenants", "1.0", item => item.Action("Index", "Admin", new { area = "Orchard.MultiTenancy" }).Permission(Permissions.ManageTenants))
.Add("Add New Tenant", "1.1", item => item.Action("Add", "Admin", new { area = "Orchard.MultiTenancy" }).Permission(Permissions.ManageTenants)));
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Annotations/SqlDatabaseConnectionStringAttribute.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Annotations/SqlDatabaseConnectionStringAttribute.cs
new file mode 100644
index 000000000..47112ad02
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Annotations/SqlDatabaseConnectionStringAttribute.cs
@@ -0,0 +1,21 @@
+using System.ComponentModel.DataAnnotations;
+using System.Data.SqlClient;
+
+namespace Orchard.MultiTenancy.Annotations {
+ public class SqlDatabaseConnectionStringAttribute : ValidationAttribute {
+ public override bool IsValid(object value) {
+ if (value is string && ((string) value).Length > 0) {
+ try {
+ var connectionStringBuilder = new SqlConnectionStringBuilder(value as string);
+
+ //TODO: (erikpo) Should the keys be checked here to ensure that a valid combination was entered? Needs investigation.
+ }
+ catch {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Content/Admin/images/disabled.gif b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Content/Admin/images/disabled.gif
new file mode 100644
index 000000000..42c8bde22
Binary files /dev/null and b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Content/Admin/images/disabled.gif differ
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Content/Admin/images/enabled.gif b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Content/Admin/images/enabled.gif
new file mode 100644
index 000000000..f55c73a2f
Binary files /dev/null and b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Content/Admin/images/enabled.gif differ
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Controllers/AdminController.cs
index 65c5a56c0..eade140b8 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Controllers/AdminController.cs
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Controllers/AdminController.cs
@@ -1,18 +1,23 @@
using System;
+using System.Linq;
using System.Web.Mvc;
using Orchard.Environment.Configuration;
using Orchard.Localization;
using Orchard.MultiTenancy.Services;
using Orchard.MultiTenancy.ViewModels;
+using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.MultiTenancy.Controllers {
[ValidateInput(false)]
public class AdminController : Controller {
private readonly ITenantService _tenantService;
+ private readonly ShellSettings _thisShellSettings;
- public AdminController(ITenantService tenantService, IOrchardServices orchardServices) {
+ public AdminController(ITenantService tenantService, IOrchardServices orchardServices, ShellSettings shellSettings) {
_tenantService = tenantService;
+ _thisShellSettings = shellSettings;
+
Services = orchardServices;
T = NullLocalizer.Instance;
}
@@ -25,19 +30,25 @@ namespace Orchard.MultiTenancy.Controllers {
}
public ActionResult Add() {
- return View(new TenantsAddViewModel());
+ if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Cannot create tenant")))
+ return new HttpUnauthorizedResult();
+ return View(new TenantAddViewModel());
}
[HttpPost, ActionName("Add")]
- public ActionResult AddPOST(TenantsAddViewModel viewModel) {
+ public ActionResult AddPOST(TenantAddViewModel viewModel) {
try {
if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Couldn't create tenant")))
return new HttpUnauthorizedResult();
+
_tenantService.CreateTenant(
new ShellSettings {
Name = viewModel.Name,
RequestUrlHost = viewModel.RequestUrlHost,
RequestUrlPrefix = viewModel.RequestUrlPrefix,
+ DataProvider = viewModel.DataProvider,
+ DataConnectionString = viewModel.DatabaseConnectionString,
+ DataTablePrefix = viewModel.DatabaseTablePrefix,
State = new TenantState("Uninitialized")
});
@@ -48,5 +59,83 @@ namespace Orchard.MultiTenancy.Controllers {
return View(viewModel);
}
}
+
+ public ActionResult Edit(string name) {
+ if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Cannot edit tenant")))
+ return new HttpUnauthorizedResult();
+
+ var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == name);
+ if (tenant == null)
+ return new NotFoundResult();
+
+ return View(new TenantEditViewModel {
+ Name = tenant.Name,
+ RequestUrlHost = tenant.RequestUrlHost,
+ RequestUrlPrefix = tenant.RequestUrlPrefix,
+ DataProvider = tenant.DataProvider,
+ DatabaseConnectionString = tenant.DataConnectionString,
+ DatabaseTablePrefix = tenant.DataTablePrefix,
+ State = tenant.State
+ });
+ }
+
+ [HttpPost, ActionName("Edit")]
+ public ActionResult EditPost(TenantEditViewModel viewModel) {
+ try {
+ if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Couldn't edit tenant")))
+ return new HttpUnauthorizedResult();
+
+ var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == viewModel.Name);
+ if (tenant == null)
+ return new NotFoundResult();
+
+ _tenantService.UpdateTenant(
+ new ShellSettings {
+ Name = tenant.Name,
+ RequestUrlHost = viewModel.RequestUrlHost,
+ RequestUrlPrefix = viewModel.RequestUrlPrefix,
+ DataProvider = viewModel.DataProvider,
+ DataConnectionString = viewModel.DatabaseConnectionString,
+ DataTablePrefix = viewModel.DatabaseTablePrefix,
+ State = tenant.State
+ });
+
+ return RedirectToAction("Index");
+ }
+ catch (Exception exception) {
+ Services.Notifier.Error(T("Failed to edit tenant: ") + exception.Message);
+ return View(viewModel);
+ }
+ }
+
+ [HttpPost]
+ public ActionResult Disable(string name) {
+ if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Couldn't disable tenant")))
+ return new HttpUnauthorizedResult();
+
+ var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == name);
+
+ if (tenant != null && tenant.Name != _thisShellSettings.Name) {
+ tenant.State.CurrentState = TenantState.State.Disabled;
+ _tenantService.UpdateTenant(tenant);
+ }
+
+ return RedirectToAction("index");
+ }
+
+ [HttpPost]
+ public ActionResult Enable(string name) {
+ if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Couldn't enable tenant")))
+ return new HttpUnauthorizedResult();
+
+ var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == name);
+
+ if (tenant != null && tenant.Name != _thisShellSettings.Name) {
+ tenant.State.CurrentState = TenantState.State.Running;
+ _tenantService.UpdateTenant(tenant);
+ }
+
+ return RedirectToAction("index");
+ }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs
new file mode 100644
index 000000000..236d45d23
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs
@@ -0,0 +1,21 @@
+using System.Web.Mvc;
+using Orchard.Environment.Configuration;
+
+namespace Orchard.MultiTenancy.Extensions {
+ public static class UrlHelperExtensions {
+ public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) {
+ //info: (heskew) might not keep the port insertion around beyond...
+ var port = string.Empty;
+ string host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"];
+
+ if(host.Contains(":"))
+ port = host.Substring(host.IndexOf(":"));
+
+ return string.Format(
+ "http://{0}/{1}",
+ !string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
+ ? tenantShellSettings.RequestUrlHost + port : host,
+ tenantShellSettings.RequestUrlPrefix);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Module.txt b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Module.txt
index 53c124af0..fd00b570b 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Module.txt
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Module.txt
@@ -7,5 +7,4 @@ orchardversion: 0.1.2010.0312
features:
Orchard.MultiTenancy:
Description: Configure multiple site tenants.
- Dependencies: Common
- Category: Core
\ No newline at end of file
+ Category: Hosting
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Orchard.MultiTenancy.csproj b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Orchard.MultiTenancy.csproj
index d5c698117..6ab56cf17 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Orchard.MultiTenancy.csproj
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Orchard.MultiTenancy.csproj
@@ -65,18 +65,29 @@
+
+
+
-
+
+
+
+
+
+
+
+
+
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Routes.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Routes.cs
new file mode 100644
index 000000000..bf389bf31
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Routes.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using System.Web.Mvc;
+using System.Web.Routing;
+using Orchard.Mvc.Routes;
+
+namespace Orchard.MultiTenancy {
+ public class Routes : IRouteProvider {
+ public IEnumerable GetRoutes() {
+ return new[] {
+ new RouteDescriptor {
+ Route = new Route(
+ "Admin/MultiTenancy/Edit/{name}",
+ new RouteValueDictionary {
+ {"area", "Orchard.MultiTenancy"},
+ {"controller", "Admin"},
+ {"action", "Edit"}
+ },
+ new RouteValueDictionary {
+ {"name", ".+"}
+ },
+ new RouteValueDictionary {
+ {"area", "Orchard.MultiTenancy"}
+ },
+ new MvcRouteHandler())
+ }
+ };
+ }
+
+ public void GetRoutes(ICollection routes) {
+ foreach (RouteDescriptor routeDescriptor in GetRoutes()) {
+ routes.Add(routeDescriptor);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/ITenantService.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/ITenantService.cs
index d6fbb6862..f1f5ac508 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/ITenantService.cs
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/ITenantService.cs
@@ -5,5 +5,6 @@ namespace Orchard.MultiTenancy.Services {
public interface ITenantService : IDependency {
IEnumerable GetTenants();
void CreateTenant(ShellSettings settings);
+ void UpdateTenant(ShellSettings settings);
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/TenantService.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/TenantService.cs
index d838927e1..7d2a87eac 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/TenantService.cs
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Services/TenantService.cs
@@ -1,15 +1,14 @@
using System.Collections.Generic;
+using System.Linq;
using Orchard.Environment;
using Orchard.Environment.Configuration;
namespace Orchard.MultiTenancy.Services {
public class TenantService : ITenantService {
private readonly IShellSettingsManager _shellSettingsManager;
- private readonly IOrchardHost _orchardHost;
- public TenantService(IShellSettingsManager shellSettingsManager, IOrchardHost orchardHost) {
+ public TenantService(IShellSettingsManager shellSettingsManager) {
_shellSettingsManager = shellSettingsManager;
- _orchardHost = orchardHost;
}
public IEnumerable GetTenants() {
@@ -19,5 +18,12 @@ namespace Orchard.MultiTenancy.Services {
public void CreateTenant(ShellSettings settings) {
_shellSettingsManager.SaveSettings(settings);
}
+
+ public void UpdateTenant(ShellSettings settings) {
+ var tenant = GetTenants().FirstOrDefault(ss => ss.Name == settings.Name);
+ if ( tenant != null ) {
+ _shellSettingsManager.SaveSettings(settings);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantAddViewModel.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantAddViewModel.cs
new file mode 100644
index 000000000..72c677dc2
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantAddViewModel.cs
@@ -0,0 +1,17 @@
+using System.ComponentModel.DataAnnotations;
+using Orchard.MultiTenancy.Annotations;
+using Orchard.Mvc.ViewModels;
+
+namespace Orchard.MultiTenancy.ViewModels {
+ public class TenantAddViewModel : BaseViewModel {
+ [Required]
+ public string Name { get; set; }
+ public string RequestUrlHost { get; set; }
+ public string RequestUrlPrefix { get; set; }
+ public string DataProvider { get; set; }
+ [SqlDatabaseConnectionString]
+ public string DatabaseConnectionString { get; set; }
+ public string DatabaseTablePrefix { get; set; }
+ }
+}
+
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantEditViewModel.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantEditViewModel.cs
new file mode 100644
index 000000000..b0a2edfa6
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantEditViewModel.cs
@@ -0,0 +1,20 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Orchard.Environment.Configuration;
+using Orchard.MultiTenancy.Annotations;
+using Orchard.Mvc.ViewModels;
+
+namespace Orchard.MultiTenancy.ViewModels {
+ public class TenantEditViewModel : BaseViewModel {
+ [Required]
+ public string Name { get; set; }
+ public string RequestUrlHost { get; set; }
+ public string RequestUrlPrefix { get; set; }
+ public string DataProvider { get; set; }
+ [SqlDatabaseConnectionString]
+ public string DatabaseConnectionString { get; set; }
+ public string DatabaseTablePrefix { get; set; }
+ public TenantState State { get; set; }
+ }
+}
+
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantsAddViewModel.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantsAddViewModel.cs
deleted file mode 100644
index 98ac2ade8..000000000
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/ViewModels/TenantsAddViewModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
-using Orchard.Mvc.ViewModels;
-
-namespace Orchard.MultiTenancy.ViewModels {
- public class TenantsAddViewModel : BaseViewModel {
- [Required, DisplayName("Tenant Name:")]
- public string Name { get; set; }
- public string RequestUrlHost { get; set; }
- public string RequestUrlPrefix { get; set; }
- }
-}
-
diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Views/Admin/Add.ascx b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Views/Admin/Add.ascx
index eb6aca4dc..08988e70f 100644
--- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Views/Admin/Add.ascx
+++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Views/Admin/Add.ascx
@@ -1,16 +1,43 @@
-<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
+<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.MultiTenancy.ViewModels"%>
-
-
<%=Html.TitleForPage(T("Add a Tenant to your Site").ToString()) %>
-
+
<%=Html.TitleForPage(T("Add New Tenant").ToString()) %>
<%using (Html.BeginFormAntiForgeryPost()) { %>
- <%= Html.ValidationSummary() %>
+ <%=Html.ValidationSummary() %>
+
-
diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs
index f7a985e63..2cf512548 100644
--- a/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs
@@ -1,5 +1,8 @@
-namespace Orchard.Setup.Services {
+using Orchard.Environment.Configuration;
+
+namespace Orchard.Setup.Services {
public interface ISetupService : IDependency {
+ ShellSettings Prime();
void Setup(SetupContext context);
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs
index 65f9f6e9a..77007d0fa 100644
--- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs
+++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs
@@ -14,6 +14,7 @@ using Orchard.Environment.ShellBuilders;
using Orchard.Environment.Topology;
using Orchard.Environment.Topology.Models;
using Orchard.Localization;
+using Orchard.ContentManagement.MetaData.Services;
using Orchard.Security;
using Orchard.Settings;
using Orchard.Themes;
@@ -44,12 +45,45 @@ namespace Orchard.Setup.Services {
private Localizer T { get; set; }
+ public ShellSettings Prime() {
+ return _shellSettings;
+ }
+
public void Setup(SetupContext context) {
- var shellSettings = new ShellSettings(_shellSettings) {
- DataProvider = context.DatabaseProvider,
- DataConnectionString = context.DatabaseConnectionString,
- DataTablePrefix = context.DatabaseTablePrefix,
- };
+ // The vanilla Orchard distibution has the following features enabled.
+ if (context.EnabledFeatures == null || context.EnabledFeatures.Count() == 0) {
+ string[] hardcoded = {
+ "Orchard.Framework",
+ "Common",
+ "Dashboard",
+ "Feeds",
+ "HomePage",
+ "Navigation",
+ "Scheduling",
+ "Settings",
+ "XmlRpc",
+ "Orchard.Users",
+ "Orchard.Roles",
+ "TinyMce",
+ "Orchard.Modules",
+ "Orchard.Themes",
+ "Orchard.Pages",
+ "Orchard.Blogs",
+ "Orchard.Comments",
+ "Orchard.Tags",
+ "Orchard.Media",
+ "Futures.Widgets"};
+
+ context.EnabledFeatures = hardcoded;
+ }
+
+ var shellSettings = new ShellSettings(_shellSettings);
+
+ if (string.IsNullOrEmpty(shellSettings.DataProvider)) {
+ shellSettings.DataProvider = context.DatabaseProvider;
+ shellSettings.DataConnectionString = context.DatabaseConnectionString;
+ shellSettings.DataTablePrefix = context.DatabaseTablePrefix;
+ }
var shellDescriptor = new ShellDescriptor {
EnabledFeatures = context.EnabledFeatures.Select(name => new ShellFeature { Name = name })
@@ -107,8 +141,10 @@ namespace Orchard.Setup.Services {
page.As().Text = "
Welcome to Orchard!
Congratulations, you've successfully set-up your Orchard site.
This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.
One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.
You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site.
Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".
Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.
--The Orchard Crew
";
page.As().Slug = "home";
page.As().Title = T("Home").ToString();
- page.As().CommentsShown = false;
page.As().Owner = user;
+ if (page.Has()) {
+ page.As().CommentsShown = false;
+ }
contentManager.Publish(page);
siteSettings.Record.HomePage = "PageHomePageProvider;" + page.Id;
@@ -124,6 +160,24 @@ namespace Orchard.Setup.Services {
var authenticationService = environment.Resolve();
authenticationService.SignIn(user, true);
}
+
+ //Add ContentType mappings
+ var contentTypeService = environment.Resolve();
+
+ //Add ContentTypePartNames to MetaData
+ contentTypeService.AddContentTypePartNameToMetaData("HasComments");
+ contentTypeService.AddContentTypePartNameToMetaData("HasTags");
+
+ //Add mappings from ContentTypes to ContentParts to MetaData
+ contentTypeService.MapContentTypeToContentPart("blogpost","HasComments");
+ contentTypeService.MapContentTypeToContentPart("page", "HasComments");
+ contentTypeService.MapContentTypeToContentPart("sandboxpage", "HasComments");
+ contentTypeService.MapContentTypeToContentPart("blogpost", "HasTags");
+ contentTypeService.MapContentTypeToContentPart("page", "HasTags");
+ contentTypeService.MapContentTypeToContentPart("sandboxpage", "HasTags");
+
+
+
}
catch {
environment.Resolve().Cancel();
diff --git a/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs b/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs
index cc48b2e49..086aebf52 100644
--- a/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs
+++ b/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs
@@ -1,4 +1,3 @@
-using System;
using System.ComponentModel.DataAnnotations;
using Orchard.Setup.Annotations;
using Orchard.Mvc.ViewModels;
@@ -18,7 +17,7 @@ namespace Orchard.Setup.ViewModels {
public bool DatabaseOptions { get; set; }
[SqlDatabaseConnectionString]
public string DatabaseConnectionString { get; set; }
-
public string DatabaseTablePrefix { get; set; }
+ public bool DatabaseIsPreconfigured { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx
index cfc7135e3..8ac805bab 100644
--- a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx
+++ b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.ascx
@@ -1,5 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
-<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.Setup.ViewModels"%>
@@ -23,5 +23,4 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
" />
<%
-} %><%
-using (this.Capture("end-of-page-scripts")) { %><% } %>
\ No newline at end of file
+} %>
\ No newline at end of file
diff --git a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Pages.Page.ascx b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Pages.Page.ascx
index c38404c4e..92d580be8 100644
--- a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Pages.Page.ascx
+++ b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Pages.Page.ascx
@@ -5,12 +5,12 @@
<%=Html.TitleForPage(Model.Item.Title)%>
-<% if (Html.Resolve().GetAuthenticatedUser() != null){ %>
-<%} %>
+<%--<% if (Html.Resolve().GetAuthenticatedUser() != null){ %>
+<%} %>--%>
<% Html.Zone("primary");
Html.ZonesAny(); %>
-<% if (Html.Resolve().GetAuthenticatedUser() != null){ %>
+<%--<% if (Html.Resolve().GetAuthenticatedUser() != null){ %>
-<%} %>
\ No newline at end of file
+<%} %>--%>
\ No newline at end of file
diff --git a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Comments.HasComments.ascx b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Comments.HasComments.ascx
index b6f3d75c3..60253b6d4 100644
--- a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Comments.HasComments.ascx
+++ b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Comments.HasComments.ascx
@@ -51,7 +51,7 @@ else { %>