mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -50,7 +50,7 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
|
||||
|
||||
Assert.AreEqual(".txt", storageFile.GetFileType());
|
||||
Assert.AreEqual("foo.txt", storageFile.GetName());
|
||||
Assert.That(storageFile.GetPath().EndsWith("/default/foo.txt"), Is.True);
|
||||
Assert.AreEqual("foo.txt", storageFile.GetPath());
|
||||
Assert.AreEqual(0, storageFile.GetSize());
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
|
||||
var files = _azureBlobStorageProvider.ListFiles("");
|
||||
|
||||
Assert.AreEqual(1, files.Count());
|
||||
Assert.That(files.First().GetPath().EndsWith("foo2.txt"), Is.True);
|
||||
Assert.That(files.First().GetPath().Equals("foo2.txt"), Is.True);
|
||||
Assert.That(files.First().GetName().Equals("foo2.txt"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -82,17 +83,28 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
|
||||
|
||||
Assert.AreEqual(1, _azureBlobStorageProvider.ListFiles("").Count());
|
||||
Assert.AreEqual(1, _azureBlobStorageProvider.ListFiles("folder").Count());
|
||||
Assert.AreEqual("folder/foo.txt", _azureBlobStorageProvider.ListFiles("folder").First().GetPath());
|
||||
Assert.AreEqual("foo.txt", _azureBlobStorageProvider.ListFiles("folder").First().GetName());
|
||||
Assert.AreEqual(1, _azureBlobStorageProvider.ListFiles("folder/folder").Count());
|
||||
Assert.AreEqual("folder/folder/foo.txt", _azureBlobStorageProvider.ListFiles("folder/folder").First().GetPath());
|
||||
Assert.AreEqual("foo.txt", _azureBlobStorageProvider.ListFiles("folder/folder").First().GetName());
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void CreateFolderThatExistsShouldThrow() {
|
||||
// sebros: In Azure, the folder concept is just about checking files prefix. So until a file exists, a folder is nothing
|
||||
_azureBlobStorageProvider.CreateFile("folder/foo.txt");
|
||||
_azureBlobStorageProvider.CreateFolder("folder");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ListFolderShouldAcceptNullPath() {
|
||||
_azureBlobStorageProvider.CreateFolder("folder");
|
||||
Assert.AreEqual(1, _azureBlobStorageProvider.ListFolders(null).Count());
|
||||
Assert.AreEqual("folder", _azureBlobStorageProvider.ListFolders(null).First().GetName());
|
||||
Assert.AreEqual("folder", _azureBlobStorageProvider.ListFolders(null).First().GetPath());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteFolderShouldDeleteFilesAlso() {
|
||||
_azureBlobStorageProvider.CreateFile("folder/foo1.txt");
|
||||
|
@@ -8,11 +8,15 @@ using Microsoft.WindowsAzure.StorageClient;
|
||||
using Orchard.FileSystems.Media;
|
||||
|
||||
namespace Orchard.Azure {
|
||||
public class AzureFileSystem {
|
||||
public class AzureFileSystem
|
||||
{
|
||||
private const string FolderEntry = "$$$ORCHARD$$$.$$$";
|
||||
|
||||
public string ContainerName { get; protected set; }
|
||||
|
||||
private readonly CloudStorageAccount _storageAccount;
|
||||
private readonly string _root;
|
||||
private readonly string _absoluteRoot;
|
||||
public CloudBlobClient BlobClient { get; private set; }
|
||||
public CloudBlobContainer Container { get; private set; }
|
||||
|
||||
@@ -25,6 +29,7 @@ namespace Orchard.Azure {
|
||||
_storageAccount = storageAccount;
|
||||
ContainerName = containerName;
|
||||
_root = String.IsNullOrEmpty(root) || root == "/" ? String.Empty : root + "/";
|
||||
_absoluteRoot = _storageAccount.BlobEndpoint.AbsoluteUri + containerName + "/" + root + "/";
|
||||
|
||||
using ( new HttpContextWeaver() ) {
|
||||
|
||||
@@ -46,66 +51,65 @@ namespace Orchard.Azure {
|
||||
}
|
||||
|
||||
private static void EnsurePathIsRelative(string path) {
|
||||
if ( path.StartsWith("/") || path.StartsWith("http://"))
|
||||
if (path.StartsWith("/") || path.StartsWith("http://"))
|
||||
throw new ArgumentException("Path must be relative");
|
||||
}
|
||||
|
||||
public IStorageFile GetFile(string path) {
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
Container.EnsureBlobExists(path);
|
||||
return new AzureBlobFileStorage(Container.GetBlockBlobReference(path));
|
||||
using ( new HttpContextWeaver() ) {
|
||||
Container.EnsureBlobExists(String.Concat(_root, path));
|
||||
return new AzureBlobFileStorage(Container.GetBlockBlobReference(path), _absoluteRoot);
|
||||
}
|
||||
}
|
||||
|
||||
public bool FileExists(string path) {
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
path = String.Concat(_root, path);
|
||||
return Container.BlobExists(path);
|
||||
using ( new HttpContextWeaver() ) {
|
||||
return Container.BlobExists(String.Concat(_root, path));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IStorageFile> ListFiles(string path) {
|
||||
path = path ?? String.Empty;
|
||||
|
||||
EnsurePathIsRelative(path);
|
||||
|
||||
string prefix = String.Concat(Container.Name, "/", _root, path);
|
||||
|
||||
if ( !prefix.EndsWith("/") )
|
||||
prefix += "/";
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
foreach (var blobItem in BlobClient.ListBlobsWithPrefix(prefix).OfType<CloudBlockBlob>())
|
||||
{
|
||||
yield return new AzureBlobFileStorage(blobItem);
|
||||
|
||||
using ( new HttpContextWeaver() ) {
|
||||
foreach (var blobItem in BlobClient.ListBlobsWithPrefix(prefix).OfType<CloudBlockBlob>()) {
|
||||
// ignore directory entries
|
||||
if(blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
|
||||
continue;
|
||||
|
||||
yield return new AzureBlobFileStorage(blobItem, _absoluteRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IStorageFolder> ListFolders(string path) {
|
||||
path = path ?? String.Empty;
|
||||
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
if (!Container.DirectoryExists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
CreateFolder(path);
|
||||
using ( new HttpContextWeaver() ) {
|
||||
if ( !Container.DirectoryExists(String.Concat(_root, path)) ) {
|
||||
try {
|
||||
CreateFolder(String.Concat(_root, path));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch ( Exception ex ) {
|
||||
throw new ArgumentException(string.Format("The folder could not be created at path: {0}. {1}",
|
||||
path, ex));
|
||||
}
|
||||
}
|
||||
|
||||
return Container.GetDirectoryReference(path)
|
||||
return Container.GetDirectoryReference(String.Concat(_root, path))
|
||||
.ListBlobs()
|
||||
.OfType<CloudBlobDirectory>()
|
||||
.Select<CloudBlobDirectory, IStorageFolder>(d => new AzureBlobFolderStorage(d))
|
||||
.Select<CloudBlobDirectory, IStorageFolder>(d => new AzureBlobFolderStorage(d, _absoluteRoot))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -113,23 +117,20 @@ namespace Orchard.Azure {
|
||||
public void CreateFolder(string path)
|
||||
{
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
using (new HttpContextWeaver())
|
||||
{
|
||||
Container.EnsureDirectoryDoesNotExist(path);
|
||||
Container.GetDirectoryReference(path);
|
||||
using (new HttpContextWeaver()) {
|
||||
Container.EnsureDirectoryDoesNotExist(String.Concat(_root, path));
|
||||
|
||||
// Creating a virtually hidden file to make the directory an existing concept
|
||||
CreateFile(path + "/" + FolderEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteFolder(string path) {
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
Container.EnsureDirectoryExists(path);
|
||||
foreach (var blob in Container.GetDirectoryReference(path).ListBlobs())
|
||||
{
|
||||
using ( new HttpContextWeaver() ) {
|
||||
Container.EnsureDirectoryExists(String.Concat(_root, path));
|
||||
foreach ( var blob in Container.GetDirectoryReference(String.Concat(_root, path)).ListBlobs() ) {
|
||||
if (blob is CloudBlob)
|
||||
((CloudBlob) blob).Delete();
|
||||
|
||||
@@ -141,7 +142,6 @@ namespace Orchard.Azure {
|
||||
|
||||
public void RenameFolder(string path, string newPath) {
|
||||
EnsurePathIsRelative(path);
|
||||
|
||||
EnsurePathIsRelative(newPath);
|
||||
|
||||
if ( !path.EndsWith("/") )
|
||||
@@ -149,20 +149,16 @@ namespace Orchard.Azure {
|
||||
|
||||
if ( !newPath.EndsWith("/") )
|
||||
newPath += "/";
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
foreach (var blob in Container.GetDirectoryReference(_root + path).ListBlobs())
|
||||
{
|
||||
if (blob is CloudBlob)
|
||||
{
|
||||
using ( new HttpContextWeaver() ) {
|
||||
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);
|
||||
string destination = String.Concat(newPath, filename);
|
||||
RenameFile(source, destination);
|
||||
}
|
||||
|
||||
if (blob is CloudBlobDirectory)
|
||||
{
|
||||
if (blob is CloudBlobDirectory) {
|
||||
string foldername = blob.Uri.Segments.Last();
|
||||
string source = String.Concat(path, foldername);
|
||||
string destination = String.Concat(newPath, foldername);
|
||||
@@ -174,29 +170,24 @@ namespace Orchard.Azure {
|
||||
|
||||
public void DeleteFile(string path) {
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
|
||||
using ( new HttpContextWeaver() ) {
|
||||
Container.EnsureBlobExists(path);
|
||||
var blob = Container.GetBlockBlobReference(path);
|
||||
var blob = Container.GetBlockBlobReference(String.Concat(_root, path));
|
||||
blob.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public void RenameFile(string path, string newPath) {
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
|
||||
EnsurePathIsRelative(newPath);
|
||||
newPath = String.Concat(_root, newPath);
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
Container.EnsureBlobExists(path);
|
||||
Container.EnsureBlobDoesNotExist(newPath);
|
||||
|
||||
var blob = Container.GetBlockBlobReference(path);
|
||||
var newBlob = Container.GetBlockBlobReference(newPath);
|
||||
using ( new HttpContextWeaver() ) {
|
||||
Container.EnsureBlobExists(String.Concat(_root, path));
|
||||
Container.EnsureBlobDoesNotExist(String.Concat(_root, newPath));
|
||||
|
||||
var blob = Container.GetBlockBlobReference(String.Concat(_root, path));
|
||||
var newBlob = Container.GetBlockBlobReference(String.Concat(_root, newPath));
|
||||
newBlob.CopyFromBlob(blob);
|
||||
blob.Delete();
|
||||
}
|
||||
@@ -204,36 +195,36 @@ namespace Orchard.Azure {
|
||||
|
||||
public IStorageFile CreateFile(string path) {
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
|
||||
if ( Container.BlobExists(path) ) {
|
||||
if ( Container.BlobExists(String.Concat(_root, path)) ) {
|
||||
throw new ArgumentException("File " + path + " already exists");
|
||||
}
|
||||
|
||||
var blob = Container.GetBlockBlobReference(path);
|
||||
var blob = Container.GetBlockBlobReference(String.Concat(_root, path));
|
||||
blob.OpenWrite().Dispose(); // force file creation
|
||||
return new AzureBlobFileStorage(blob);
|
||||
return new AzureBlobFileStorage(blob, _absoluteRoot);
|
||||
}
|
||||
|
||||
public string GetPublicUrl(string path) {
|
||||
EnsurePathIsRelative(path);
|
||||
path = String.Concat(_root, path);
|
||||
using ( new HttpContextWeaver() )
|
||||
{
|
||||
Container.EnsureBlobExists(path);
|
||||
return Container.GetBlockBlobReference(path).Uri.ToString();
|
||||
|
||||
using ( new HttpContextWeaver() ) {
|
||||
Container.EnsureBlobExists(String.Concat(_root, path));
|
||||
return Container.GetBlockBlobReference(String.Concat(_root, path)).Uri.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private class AzureBlobFileStorage : IStorageFile {
|
||||
private readonly CloudBlockBlob _blob;
|
||||
private readonly string _rootPath;
|
||||
|
||||
public AzureBlobFileStorage(CloudBlockBlob blob) {
|
||||
public AzureBlobFileStorage(CloudBlockBlob blob, string rootPath) {
|
||||
_blob = blob;
|
||||
_rootPath = rootPath;
|
||||
}
|
||||
|
||||
public string GetPath() {
|
||||
return _blob.Uri.ToString();
|
||||
return _blob.Uri.ToString().Substring(_rootPath.Length+1);
|
||||
}
|
||||
|
||||
public string GetName() {
|
||||
@@ -264,17 +255,19 @@ namespace Orchard.Azure {
|
||||
|
||||
private class AzureBlobFolderStorage : IStorageFolder {
|
||||
private readonly CloudBlobDirectory _blob;
|
||||
private readonly string _rootPath;
|
||||
|
||||
public AzureBlobFolderStorage(CloudBlobDirectory blob) {
|
||||
public AzureBlobFolderStorage(CloudBlobDirectory blob, string rootPath) {
|
||||
_blob = blob;
|
||||
_rootPath = rootPath;
|
||||
}
|
||||
|
||||
public string GetName() {
|
||||
return Path.GetDirectoryName(_blob.Uri.ToString());
|
||||
return Path.GetDirectoryName(GetPath() + "/");
|
||||
}
|
||||
|
||||
public string GetPath() {
|
||||
return _blob.Uri.ToString();
|
||||
return _blob.Uri.ToString().Substring(_rootPath.Length + 1).TrimEnd('/');
|
||||
}
|
||||
|
||||
public long GetSize() {
|
||||
@@ -287,7 +280,7 @@ namespace Orchard.Azure {
|
||||
|
||||
public IStorageFolder GetParent() {
|
||||
if ( _blob.Parent != null ) {
|
||||
return new AzureBlobFolderStorage(_blob.Parent);
|
||||
return new AzureBlobFolderStorage(_blob.Parent, _rootPath);
|
||||
}
|
||||
throw new ArgumentException("Directory " + _blob.Uri + " does not have a parent directory");
|
||||
}
|
||||
|
@@ -8,6 +8,11 @@ namespace Orchard.Azure.Web {
|
||||
public override bool OnStart() {
|
||||
DiagnosticMonitor.Start("DiagnosticsConnectionString");
|
||||
|
||||
CloudStorageAccount.SetConfigurationSettingPublisher(
|
||||
(configName, configSetter) =>
|
||||
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))
|
||||
);
|
||||
|
||||
// For information on handling configuration changes
|
||||
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
|
||||
RoleEnvironment.Changing += RoleEnvironmentChanging;
|
||||
|
@@ -21,6 +21,7 @@ using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Security;
|
||||
using Orchard.Tests.Modules;
|
||||
using System.Web.Mvc;
|
||||
@@ -45,6 +46,8 @@ namespace Orchard.Core.Tests.Routable.Services {
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
|
||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
|
||||
builder.RegisterType<ThingHandler>().As<IContentHandler>();
|
||||
|
@@ -2,9 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*.aspx" verb="*" type="System.Web.HttpNotFoundHandler"/>
|
||||
<add path="*.ascx" verb="*" type="System.Web.HttpNotFoundHandler"/>
|
||||
<add path="*.master" verb="*" type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -28,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*.aspx,*.ascx,*.master" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -0,0 +1,63 @@
|
||||
using NUnit.Framework;
|
||||
using Orchard.Media.Extensions;
|
||||
|
||||
namespace Orchard.Tests.Modules.Media.Extensions {
|
||||
[TestFixture]
|
||||
public class LongExtensionsTests {
|
||||
[Test]
|
||||
public void BytesAreFriendly() {
|
||||
long size = 123;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("123 B"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KilobytesAreFriendly() {
|
||||
long size = 93845;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("92 KB"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MegabytesAreFriendly() {
|
||||
long size = 6593528;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("6.3 MB"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GigabytesAreFriendly() {
|
||||
long size = 46896534657;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("43.68 GB"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TerabytesAreFriendly() {
|
||||
long size = 386594723458690;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("351.606 TB"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PetabytesAreSlightlyFriendlyAsTerabytes() {
|
||||
long size = 56794738495678965;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("51654.514 TB"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VeryLargeSizeDoesNotCauseFailure() {
|
||||
long size = 5679473849567896593;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("5165451.375 TB"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NegativeSizeDoesNotCauseFailure(){
|
||||
long size = -2598;
|
||||
string friendly = size.ToFriendlySizeString();
|
||||
Assert.That(friendly, Is.EqualTo("-2598 B"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -126,6 +126,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="CodeGeneration\Commands\CodeGenerationCommandsTests.cs" />
|
||||
<Compile Include="DatabaseEnabledTestsBase.cs" />
|
||||
<Compile Include="Media\Extensions\LongExtensionsTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Roles\Controllers\AdminControllerTests.cs" />
|
||||
<Compile Include="Roles\Services\RoleServiceTests.cs" />
|
||||
@@ -155,6 +156,10 @@
|
||||
<Project>{C0C45321-B51D-4D8D-9B7B-AA4C2E0B2962}</Project>
|
||||
<Name>Orchard.CodeGeneration</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Media\Orchard.Media.csproj">
|
||||
<Project>{D9A7B330-CD22-4DA1-A95A-8DE1982AD8EB}</Project>
|
||||
<Name>Orchard.Media</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Modules\Orchard.Modules.csproj">
|
||||
<Project>{17F86780-9A1F-4AA1-86F1-875EEC2730C7}</Project>
|
||||
<Name>Orchard.Modules</Name>
|
||||
|
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Xml.Linq;
|
||||
using Autofac;
|
||||
using Moq;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Caching;
|
||||
@@ -28,6 +29,7 @@ using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules;
|
||||
using Orchard.Modules.Services;
|
||||
@@ -35,6 +37,7 @@ using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Tests.Utility;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Themes.Handlers;
|
||||
using Orchard.Themes.Models;
|
||||
@@ -42,12 +45,15 @@ using Orchard.Themes.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Tests.Modules.Themes.Services {
|
||||
[TestFixture]
|
||||
#if REFACTORING
|
||||
[TestFixture, Ignore]
|
||||
public class ThemeServiceTests {
|
||||
private IThemeService _themeService;
|
||||
private ISiteThemeService _siteThemeService;
|
||||
private IContainer _container;
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
private IFeatureManager _featureManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void InitFixture() {
|
||||
@@ -67,12 +73,11 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
public void Init() {
|
||||
var context = new DynamicProxyContext();
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterModule(new SettingsModule());
|
||||
builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
|
||||
builder.RegisterType<ThemeService>().EnableDynamicProxy(context).As<IThemeService>();
|
||||
builder.RegisterType<SettingsModuleInterceptor>().As<ISettingsModuleInterceptor>();
|
||||
builder.RegisterType<SiteService>().As<ISiteService>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
builder.RegisterType<Orchard.Localization.Text>().As<IText>();
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
|
||||
@@ -83,7 +88,8 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
|
||||
builder.RegisterType<SiteSettingsPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<ThemeSiteSettingsPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<ModuleService>().As<IModuleService>();
|
||||
//builder.RegisterType<ModuleService>().As<IModuleService>();
|
||||
builder.RegisterType<ShellDescriptor>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterType<StubShellDescriptorManager>().As<IShellDescriptorManager>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<TransactionManager>().As<ITransactionManager>();
|
||||
@@ -95,68 +101,71 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
.As(typeof(IMapper<SettingsDictionary, XElement>));
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterAutoMocking(MockBehavior.Loose);
|
||||
_container = builder.Build();
|
||||
_themeService = _container.Resolve<IThemeService>();
|
||||
_siteThemeService = _container.Resolve<ISiteThemeService>();
|
||||
_featureManager = _container.Resolve<IFeatureManager>();
|
||||
}
|
||||
|
||||
//todo: test theme feature enablement
|
||||
|
||||
[Test]
|
||||
public void ThemeWithNoBaseThemeCanBeSetAsSiteTheme() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeOne"));
|
||||
_siteThemeService.SetSiteTheme("ThemeOne");
|
||||
var siteTheme = _siteThemeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.Name, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThemeWithAvailableBaseThemeCanBeSetAsSiteTheme() {
|
||||
_themeService.SetSiteTheme("ThemeTwo");
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeTwo"));
|
||||
_siteThemeService.SetSiteTheme("ThemeTwo");
|
||||
var siteTheme = _siteThemeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.Name, Is.EqualTo("ThemeTwo"));
|
||||
Assert.That(siteTheme.BaseTheme, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThemeWithUnavailableBaseThemeCanBeSetAsSiteTheme() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
_themeService.SetSiteTheme("ThemeThree");
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeOne"));
|
||||
_siteThemeService.SetSiteTheme("ThemeOne");
|
||||
_siteThemeService.SetSiteTheme("ThemeThree");
|
||||
var siteTheme = _siteThemeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.Name, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThemeWithCircularBaseDepTrowsExceptionOnActivation() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
_siteThemeService.SetSiteTheme("ThemeOne");
|
||||
try {
|
||||
_themeService.SetSiteTheme("ThemeFourBasedOnFive");
|
||||
_siteThemeService.SetSiteTheme("ThemeFourBasedOnFive");
|
||||
} catch (InvalidOperationException ex) {
|
||||
Assert.That(ex.Message, Is.StringMatching("ThemeFiveBasedOnFour"));
|
||||
}
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeOne"));
|
||||
var siteTheme = _siteThemeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.Name, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanEnableAndDisableThemes() {
|
||||
_themeService.EnableTheme("ThemeOne");
|
||||
_featureManager.EnableFeature("ThemeOne");
|
||||
Assert.IsTrue(_themeService.GetThemeByName("ThemeOne").Enabled);
|
||||
Assert.IsTrue(_container.Resolve<IShellDescriptorManager>().GetShellDescriptor().Features.Any(sf => sf.Name == "ThemeOne"));
|
||||
_themeService.DisableTheme("ThemeOne");
|
||||
_featureManager.DisableFeature("ThemeOne");
|
||||
Assert.IsFalse(_themeService.GetThemeByName("ThemeOne").Enabled);
|
||||
Assert.IsFalse(_container.Resolve<IShellDescriptorManager>().GetShellDescriptor().Features.Any(sf => sf.Name == "ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ActivatingThemeEnablesIt() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
_siteThemeService.SetSiteTheme("ThemeOne");
|
||||
Assert.IsTrue(_themeService.GetThemeByName("ThemeOne").Enabled);
|
||||
Assert.IsTrue(_container.Resolve<IShellDescriptorManager>().GetShellDescriptor().Features.Any(sf => sf.Name == "ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ActivatingThemeDoesNotDisableOldTheme() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
_themeService.SetSiteTheme("ThemeTwo");
|
||||
_siteThemeService.SetSiteTheme("ThemeOne");
|
||||
_siteThemeService.SetSiteTheme("ThemeTwo");
|
||||
Assert.IsTrue(_themeService.GetThemeByName("ThemeOne").Enabled);
|
||||
Assert.IsTrue(_themeService.GetThemeByName("ThemeTwo").Enabled);
|
||||
Assert.IsTrue(_container.Resolve<IShellDescriptorManager>().GetShellDescriptor().Features.Any(sf => sf.Name == "ThemeOne"));
|
||||
@@ -269,4 +278,5 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
builder.RegisterType<MembershipService>().As<IMembershipService>();
|
||||
builder.RegisterType<UserService>().As<IUserService>();
|
||||
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterType<TransactionManager>().As<ITransactionManager>();
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
@@ -116,16 +117,17 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
|
||||
|
||||
[Test]
|
||||
[Ignore("Needs to instead be a specflow test.")]
|
||||
public void CreateShouldAddUserAndRedirect() {
|
||||
_authorizer.Setup(x => x.Authorize(It.IsAny<Permission>(), It.IsAny<LocalizedString>())).Returns(true);
|
||||
|
||||
var controller = _container.Resolve<AdminController>();
|
||||
var result = controller.CreatePOST(new UserCreateViewModel {
|
||||
UserName = "four",
|
||||
Email = "six@example.org",
|
||||
Password = "five",
|
||||
ConfirmPassword = "five"
|
||||
});
|
||||
ActionResult result = null; // controller.CreatePOST(new UserCreateViewModel {
|
||||
// UserName = "four",
|
||||
// Email = "six@example.org",
|
||||
// Password = "five",
|
||||
// ConfirmPassword = "five"
|
||||
//});
|
||||
Assert.That(result, Is.TypeOf<RedirectToRouteResult>());
|
||||
|
||||
var redirect = (RedirectToRouteResult)result;
|
||||
@@ -136,7 +138,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Needs fixing")]
|
||||
[Ignore("Needs fixing. Needs to instead be a specflow test.")]
|
||||
public void EditShouldDisplayUserAndStoreChanges() {
|
||||
_authorizer.Setup(x => x.Authorize(It.IsAny<Permission>(), It.IsAny<LocalizedString>())).Returns(true);
|
||||
|
||||
@@ -144,7 +146,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
var id = repository.Get(x => x.UserName == "two").Id;
|
||||
var result = (ViewResult)_container.Resolve<AdminController>().Edit(id);
|
||||
var model = (UserEditViewModel)result.ViewData.Model;
|
||||
Assert.That(model.UserName, Is.EqualTo("two"));
|
||||
//Assert.That(model.UserName, Is.EqualTo("two"));
|
||||
|
||||
var controller = _container.Resolve<AdminController>();
|
||||
controller.ValueProvider = Values.From(new {
|
||||
|
@@ -17,11 +17,13 @@ using Orchard.ContentManagement.Records;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Messaging.Events;
|
||||
using Orchard.Messaging.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Tests.Utility;
|
||||
using Orchard.Users.Handlers;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
@@ -76,6 +78,9 @@ namespace Orchard.Tests.Modules.Users.Services {
|
||||
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterAutoMocking(MockBehavior.Loose);
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
builder.RegisterInstance(new Mock<IMessageEventHandler>().Object);
|
||||
builder.RegisterType<DefaultMessageManager>().As<IMessageManager>();
|
||||
|
@@ -16,6 +16,8 @@ using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Security;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Themes;
|
||||
@@ -25,7 +27,7 @@ using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
|
||||
namespace Orchard.Tests.Modules.Widgets.Services {
|
||||
|
||||
|
||||
[TestFixture]
|
||||
public class WidgetsServiceTest : DatabaseEnabledTestsBase {
|
||||
|
||||
@@ -76,28 +78,32 @@ namespace Orchard.Tests.Modules.Widgets.Services {
|
||||
}
|
||||
|
||||
public override void Register(ContainerBuilder builder) {
|
||||
var mockFeatureManager = new Mock<IFeatureManager>();
|
||||
|
||||
var theme1 = new FeatureDescriptor {Extension = new ExtensionDescriptor {Zones = ThemeZoneName1}};
|
||||
var theme2 = new FeatureDescriptor {Extension = new ExtensionDescriptor {Zones = ThemeZoneName2}};
|
||||
mockFeatureManager.Setup(x => x.GetEnabledFeatures())
|
||||
.Returns(new[] { theme1, theme2 });
|
||||
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(mockFeatureManager.Object);
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
builder.RegisterType<WidgetsService>().As<IWidgetsService>();
|
||||
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
|
||||
Theme theme1 = new Theme { Zones = ThemeZoneName1 };
|
||||
Theme theme2 = new Theme { Zones = ThemeZoneName2 };
|
||||
Mock<IThemeService> themeServiceMock = new Mock<IThemeService>();
|
||||
themeServiceMock.Setup(x => x.GetInstalledThemes()).Returns(
|
||||
(new ITheme[] { theme1, theme2 }));
|
||||
|
||||
builder.RegisterInstance(themeServiceMock.Object).As<IThemeService>();
|
||||
|
||||
builder.RegisterType<StubWidgetPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<StubLayerPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
|
||||
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -153,7 +159,7 @@ namespace Orchard.Tests.Modules.Widgets.Services {
|
||||
|
||||
WidgetPart widgetPart = _widgetService.CreateWidget(layerPart.Id, "HtmlWidget", WidgetTitle1, "1", "");
|
||||
Assert.That(widgetPart, Is.Not.Null);
|
||||
|
||||
|
||||
widgetResult = _widgetService.GetWidget(0);
|
||||
Assert.That(widgetResult, Is.Null, "Still yields null on an invalid identifier");
|
||||
|
||||
@@ -225,7 +231,7 @@ namespace Orchard.Tests.Modules.Widgets.Services {
|
||||
|
||||
widgetPart1 = _widgetService.GetWidget(widgetPart1.Id);
|
||||
Assert.That(widgetPart1.Position, Is.EqualTo(Position2), "First widget moved to second widget position");
|
||||
|
||||
|
||||
widgetPart2 = _widgetService.GetWidget(widgetPart2.Id);
|
||||
Assert.That(widgetPart2.Position, Is.EqualTo(Position1), "Second widget moved to first widget position");
|
||||
|
||||
|
85
src/Orchard.Tests/Caching/ClockCachingTests.cs
Normal file
85
src/Orchard.Tests/Caching/ClockCachingTests.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Caching;
|
||||
using Orchard.Services;
|
||||
using Orchard.Tests.Stubs;
|
||||
|
||||
namespace Orchard.Tests.Caching {
|
||||
[TestFixture]
|
||||
public class ClockCachingTests {
|
||||
private IContainer _container;
|
||||
private ICacheManager _cacheManager;
|
||||
private StubClock _clock;
|
||||
|
||||
[SetUp]
|
||||
public void Init() {
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterModule(new CacheModule());
|
||||
builder.RegisterType<DefaultCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterType<DefaultCacheHolder>().As<ICacheHolder>().SingleInstance();
|
||||
builder.RegisterType<DefaultCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterInstance<IClock>(_clock = new StubClock());
|
||||
builder.RegisterType<DefaultCacheManager>().As<ICacheManager>();
|
||||
_container = builder.Build();
|
||||
_cacheManager = _container.Resolve<ICacheManager>(new TypedParameter(typeof(Type), GetType()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenAbsoluteShouldHandleAbsoluteTime() {
|
||||
var inOneSecond = _clock.UtcNow.AddSeconds(1);
|
||||
var cached = 0;
|
||||
|
||||
// each call after the specified datetime will be reevaluated
|
||||
Func<int> retrieve = ()
|
||||
=> _cacheManager.Get("testItem",
|
||||
ctx => {
|
||||
ctx.Monitor(_clock.WhenUtc(inOneSecond));
|
||||
return ++cached;
|
||||
});
|
||||
|
||||
Assert.That(retrieve(), Is.EqualTo(1));
|
||||
|
||||
for ( var i = 0; i < 10; i++ ) {
|
||||
Assert.That(retrieve(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
_clock.Advance(TimeSpan.FromSeconds(1));
|
||||
|
||||
Assert.That(retrieve(), Is.EqualTo(2));
|
||||
Assert.That(retrieve(), Is.EqualTo(3));
|
||||
Assert.That(retrieve(), Is.EqualTo(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenAbsoluteShouldHandleAbsoluteTimeSpan() {
|
||||
var cached = 0;
|
||||
|
||||
// each cached value has a lifetime of the specified duration
|
||||
Func<int> retrieve = ()
|
||||
=> _cacheManager.Get("testItem",
|
||||
ctx => {
|
||||
ctx.Monitor(_clock.When(TimeSpan.FromSeconds(1)));
|
||||
return ++cached;
|
||||
});
|
||||
|
||||
Assert.That(retrieve(), Is.EqualTo(1));
|
||||
|
||||
for ( var i = 0; i < 10; i++ ) {
|
||||
Assert.That(retrieve(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
_clock.Advance(TimeSpan.FromSeconds(1));
|
||||
|
||||
for ( var i = 0; i < 10; i++ ) {
|
||||
Assert.That(retrieve(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
_clock.Advance(TimeSpan.FromSeconds(1));
|
||||
|
||||
for ( var i = 0; i < 10; i++ ) {
|
||||
Assert.That(retrieve(), Is.EqualTo(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -26,6 +26,7 @@ namespace Orchard.Tests.DataMigration {
|
||||
private string _tempFolder;
|
||||
private SchemaBuilder _schemaBuilder;
|
||||
private DefaultDataMigrationInterpreter _interpreter;
|
||||
private ISession _session;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() {
|
||||
@@ -38,7 +39,7 @@ namespace Orchard.Tests.DataMigration {
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
var session = _sessionFactory.OpenSession();
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
|
||||
builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>();
|
||||
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
|
||||
@@ -46,7 +47,7 @@ namespace Orchard.Tests.DataMigration {
|
||||
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>();
|
||||
builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>();
|
||||
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
builder.RegisterInstance(new ShellBlueprint { Records = Enumerable.Empty<RecordBlueprint>() }).As<ShellBlueprint>();
|
||||
builder.RegisterInstance(new ShellSettings { Name = "temp", DataProvider = "SqlCe", DataTablePrefix = "TEST" }).As<ShellSettings>();
|
||||
builder.RegisterModule(new DataModule());
|
||||
@@ -133,10 +134,24 @@ namespace Orchard.Tests.DataMigration {
|
||||
.AlterTable("User", table => table
|
||||
.AddColumn("Age", DbType.Int32))
|
||||
.AlterTable("User", table => table
|
||||
.AlterColumn("Lastname", column => column.WithDefault("John")))
|
||||
.AlterColumn("Lastname", column => column.WithDefault("Doe")))
|
||||
.AlterTable("User", table => table
|
||||
.DropColumn("Firstname")
|
||||
);
|
||||
|
||||
// creating a new row should assign a default value to Firstname and Age
|
||||
_schemaBuilder
|
||||
.ExecuteSql("insert into TEST_User VALUES (DEFAULT, DEFAULT)");
|
||||
|
||||
// ensure wehave one record woth the default value
|
||||
var command = _session.Connection.CreateCommand();
|
||||
command.CommandText = "SELECT count(*) FROM TEST_User WHERE Lastname = 'Doe'";
|
||||
Assert.That(command.ExecuteScalar(), Is.EqualTo(1));
|
||||
|
||||
// ensure this is not a false positive
|
||||
command = _session.Connection.CreateCommand();
|
||||
command.CommandText = "SELECT count(*) FROM TEST_User WHERE Lastname = 'Foo'";
|
||||
Assert.That(command.ExecuteScalar(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -8,6 +8,7 @@ using NUnit.Framework;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Tests.DisplayManagement {
|
||||
@@ -22,7 +23,7 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
Bindings = new Dictionary<string, ShapeBinding>(StringComparer.OrdinalIgnoreCase)
|
||||
};
|
||||
_workContext = new TestWorkContext {
|
||||
CurrentTheme = new Theme { ThemeName = "Hello" }
|
||||
CurrentTheme = new ExtensionDescriptor { Name = "Hello" }
|
||||
};
|
||||
|
||||
|
||||
@@ -45,18 +46,6 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
void IShapeDisplayEvents.Displayed(ShapeDisplayedContext context) { Displayed(context); }
|
||||
}
|
||||
|
||||
public class Theme : ITheme {
|
||||
public bool Enabled { get; set; }
|
||||
public string ThemeName { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string Author { get; set; }
|
||||
public string HomePage { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public string Zones { get; set; }
|
||||
public string BaseTheme { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TestShapeTableManager : IShapeTableManager {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -83,6 +82,10 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
_availableFeautures = availableFeautures;
|
||||
}
|
||||
|
||||
public ExtensionDescriptor GetExtension(string name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@@ -94,14 +97,6 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void UninstallExtension(string extensionType, string extensionName) {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestShapeProvider : IShapeTableProvider {
|
||||
|
@@ -35,7 +35,7 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
|
||||
var workContext = new DefaultDisplayManagerTests.TestWorkContext
|
||||
{
|
||||
CurrentTheme = new DefaultDisplayManagerTests.Theme { ThemeName = "Hello" }
|
||||
CurrentTheme = new ExtensionDescriptor { Name = "Hello" }
|
||||
};
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
@@ -81,9 +80,15 @@ namespace Orchard.Tests.Environment {
|
||||
_container.Mock<IOrchardShellEvents>()
|
||||
.Setup(e => e.Activated());
|
||||
|
||||
_container.Mock<IOrchardShellEvents>()
|
||||
.Setup(e => e.Terminating()).Callback(() => new object());
|
||||
}
|
||||
|
||||
public class StubExtensionManager : IExtensionManager {
|
||||
public ExtensionDescriptor GetExtension(string name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
|
||||
var ext = new ExtensionDescriptor { Name = "Orchard.Framework" };
|
||||
ext.Features = new[] { new FeatureDescriptor { Extension = ext, Name = ext.Name } };
|
||||
@@ -114,14 +119,6 @@ namespace Orchard.Tests.Environment {
|
||||
};
|
||||
}
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UninstallExtension(string extensionType, string extensionName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Monitor(Action<IVolatileToken> monitor) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@@ -4,13 +4,24 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Autofac;
|
||||
using Moq;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Localization.Records;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Security;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Tests.Localization {
|
||||
[TestFixture]
|
||||
@@ -32,6 +43,18 @@ namespace Orchard.Tests.Localization {
|
||||
[SetUp]
|
||||
public void Init() {
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
|
||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterType<TestCultureSelector>().As<ICultureSelector>();
|
||||
builder.RegisterType<DefaultCultureManager>().As<ICultureManager>();
|
||||
builder.RegisterType<Signals>().As<ISignals>();
|
||||
|
@@ -4,6 +4,7 @@ using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Tests.DisplayManagement;
|
||||
using Orchard.Tests.Stubs;
|
||||
@@ -19,8 +20,21 @@ namespace Orchard.Tests.Mvc {
|
||||
[SetUp]
|
||||
public void Init() {
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterType<FooController>()
|
||||
.Keyed<IController>("/foo")
|
||||
.Keyed<IController>(typeof(FooController))
|
||||
.WithMetadata("ControllerType", typeof(FooController))
|
||||
.InstancePerDependency();
|
||||
builder.RegisterType<BarController>()
|
||||
.Keyed<IController>("/bar")
|
||||
.Keyed<IController>(typeof(BarController))
|
||||
.WithMetadata("ControllerType", typeof(BarController))
|
||||
.InstancePerDependency();
|
||||
|
||||
builder.RegisterType<ReplacementFooController>()
|
||||
.Keyed<IController>("/foo")
|
||||
.Keyed<IController>(typeof(ReplacementFooController))
|
||||
.WithMetadata("ControllerType", typeof(ReplacementFooController))
|
||||
.InstancePerDependency();
|
||||
|
||||
var container = builder.Build();
|
||||
@@ -28,7 +42,7 @@ namespace Orchard.Tests.Mvc {
|
||||
|
||||
var workContext = new DefaultDisplayManagerTests.TestWorkContext
|
||||
{
|
||||
CurrentTheme = new DefaultDisplayManagerTests.Theme { ThemeName = "Hello" },
|
||||
CurrentTheme = new ExtensionDescriptor { Name = "Hello" },
|
||||
ContainerProvider = _containerProvider
|
||||
};
|
||||
_workContextAccessor = new DefaultDisplayManagerTests.TestWorkContextAccessor(workContext);
|
||||
@@ -46,6 +60,7 @@ namespace Orchard.Tests.Mvc {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("OrchardControllerFactory depends on metadata, calling base when no context is causing errors.")]
|
||||
public void WhenNullOrMissingContainerNormalControllerFactoryRulesShouldBeUsedAsFallback() {
|
||||
var requestContext = GetRequestContext(null);
|
||||
var controller = _controllerFactory.CreateController(requestContext, "foo");
|
||||
|
@@ -160,6 +160,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Caching\CacheScopeTests.cs" />
|
||||
<Compile Include="Caching\CacheTests.cs" />
|
||||
<Compile Include="Caching\ClockCachingTests.cs" />
|
||||
<Compile Include="Commands\CommandHandlerDescriptorBuilderTests.cs" />
|
||||
<Compile Include="Commands\CommandHandlerTests.cs" />
|
||||
<Compile Include="Commands\CommandManagerTests.cs" />
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Orchard.Caching;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Tests.Stubs {
|
||||
@@ -16,5 +17,14 @@ namespace Orchard.Tests.Stubs {
|
||||
public DateTime FutureMoment(TimeSpan span) {
|
||||
return UtcNow.Add(span);
|
||||
}
|
||||
|
||||
|
||||
public IVolatileToken When(TimeSpan duration) {
|
||||
return new Clock.AbsoluteExpirationToken(this, duration);
|
||||
}
|
||||
|
||||
public IVolatileToken WhenUtc(DateTime absoluteUtc) {
|
||||
return new Clock.AbsoluteExpirationToken(this, absoluteUtc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.Stubs {
|
||||
public class StubExtensionManager : IExtensionManager {
|
||||
public ExtensionDescriptor GetExtension(string name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@@ -18,13 +20,5 @@ namespace Orchard.Tests.Stubs {
|
||||
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void UninstallExtension(string extensionType, string extensionName) {
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Autofac;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Tests.Stubs {
|
||||
public class StubWorkContextAccessor : IWorkContextAccessor {
|
||||
private readonly ILifetimeScope _lifetimeScope;
|
||||
private WorkContext _workContext;
|
||||
|
||||
public StubWorkContextAccessor(ILifetimeScope lifetimeScope) {
|
||||
_lifetimeScope = lifetimeScope;
|
||||
_workContext = new WorkContextImpl(_lifetimeScope);
|
||||
}
|
||||
|
||||
public class WorkContextImpl : WorkContext {
|
||||
private readonly ILifetimeScope _lifetimeScope;
|
||||
private Dictionary<string, object> _contextDictonary;
|
||||
|
||||
public WorkContextImpl(ILifetimeScope lifetimeScope) {
|
||||
_contextDictonary = new Dictionary<string, object>();
|
||||
CurrentUser = new StubUser();
|
||||
var ci = new ContentItem();
|
||||
ci.Weld(new StubSite());
|
||||
CurrentSite = ci.As<ISite>();
|
||||
_lifetimeScope = lifetimeScope;
|
||||
}
|
||||
|
||||
public class StubSite : ContentPart, ISite {
|
||||
public string PageTitleSeparator {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string SiteName {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string SiteSalt {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string SuperUser {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string HomePage {
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string SiteCulture {
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public ResourceDebugMode ResourceDebugMode {
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
public class StubUser : IUser {
|
||||
public ContentItem ContentItem {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public int Id {
|
||||
get { return 5; }
|
||||
}
|
||||
|
||||
public string UserName {
|
||||
get { return "Fake"; }
|
||||
}
|
||||
|
||||
public string Email {
|
||||
get { return "Fake@fake.com"; }
|
||||
}
|
||||
}
|
||||
|
||||
public override T Resolve<T>() {
|
||||
return _lifetimeScope.Resolve<T>();
|
||||
}
|
||||
|
||||
public override bool TryResolve<T>(out T service) {
|
||||
return _lifetimeScope.TryResolve<T>(out service);
|
||||
}
|
||||
|
||||
public override T GetState<T>(string name) {
|
||||
return (T) _contextDictonary[name];
|
||||
}
|
||||
|
||||
public override void SetState<T>(string name, T value) {
|
||||
_contextDictonary[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public WorkContext GetContext(HttpContextBase httpContext) {
|
||||
throw new NotSupportedException();
|
||||
return _workContext;
|
||||
}
|
||||
|
||||
public IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext) {
|
||||
@@ -12,7 +106,7 @@ namespace Orchard.Tests.Stubs {
|
||||
}
|
||||
|
||||
public WorkContext GetContext() {
|
||||
return null;
|
||||
return _workContext;
|
||||
}
|
||||
|
||||
public IWorkContextScope CreateWorkContextScope() {
|
||||
|
@@ -1,20 +1,25 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Tests.UI.Navigation {
|
||||
[TestFixture]
|
||||
public class NavigationManagerTests {
|
||||
[Test]
|
||||
public void EmptyMenuIfNameDoesntMatch() {
|
||||
var manager = new NavigationManager(new[] { new StubProvider() }, new StubAuth(), new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())));
|
||||
var manager = new NavigationManager(new[] { new StubProvider() }, new StubAuth(), new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubOrchardServices());
|
||||
|
||||
var menuItems = manager.BuildMenu("primary");
|
||||
Assert.That(menuItems.Count(), Is.EqualTo(0));
|
||||
@@ -31,7 +36,7 @@ namespace Orchard.Tests.UI.Navigation {
|
||||
|
||||
[Test]
|
||||
public void NavigationManagerShouldUseProvidersToBuildNamedMenu() {
|
||||
var manager = new NavigationManager(new[] { new StubProvider() }, new StubAuth(), new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())));
|
||||
var manager = new NavigationManager(new[] { new StubProvider() }, new StubAuth(), new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubOrchardServices());
|
||||
|
||||
var menuItems = manager.BuildMenu("admin");
|
||||
Assert.That(menuItems.Count(), Is.EqualTo(2));
|
||||
@@ -43,7 +48,7 @@ namespace Orchard.Tests.UI.Navigation {
|
||||
|
||||
[Test]
|
||||
public void NavigationManagerShouldMergeAndOrderNavigation() {
|
||||
var manager = new NavigationManager(new INavigationProvider[] { new StubProvider(), new Stub2Provider() }, new StubAuth(), new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())));
|
||||
var manager = new NavigationManager(new INavigationProvider[] { new StubProvider(), new Stub2Provider() }, new StubAuth(), new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubOrchardServices());
|
||||
|
||||
var menuItems = manager.BuildMenu("admin");
|
||||
Assert.That(menuItems.Count(), Is.EqualTo(3));
|
||||
@@ -90,4 +95,38 @@ namespace Orchard.Tests.UI.Navigation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class StubOrchardServices : IOrchardServices {
|
||||
private readonly ILifetimeScope _lifetimeScope;
|
||||
|
||||
public StubOrchardServices() {}
|
||||
|
||||
public StubOrchardServices(ILifetimeScope lifetimeScope) {
|
||||
_lifetimeScope = lifetimeScope;
|
||||
}
|
||||
|
||||
public IContentManager ContentManager {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public ITransactionManager TransactionManager {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public IAuthorizer Authorizer {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public INotifier Notifier {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public dynamic New {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public WorkContext WorkContext {
|
||||
get { return new StubWorkContextAccessor(_lifetimeScope).GetContext(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -147,50 +147,5 @@ namespace Orchard.Core.Common.Handlers {
|
||||
if (part.ContainerField.Value != null)
|
||||
part.ContainerField.Value = part.ContainerField.Value;
|
||||
}
|
||||
|
||||
|
||||
//private void GetEditor(BuildEditorContext context, CommonPart instance) {
|
||||
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
||||
// return;
|
||||
// }
|
||||
// var viewModel = new OwnerEditorViewModel();
|
||||
// if (instance.Owner != null)
|
||||
// viewModel.Owner = instance.Owner.UserName;
|
||||
|
||||
// context.AddEditor(new TemplateViewModel(viewModel, "CommonPart") { TemplateName = "Parts/Common.Owner", ZoneName = "Content", Position = "999" });
|
||||
//}
|
||||
|
||||
|
||||
//private void UpdateEditor(UpdateEditorContext context, CommonPart instance) {
|
||||
// // this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||
// // kind of a loose rule of thumb. may not be sufficient
|
||||
// instance.ModifiedUtc = _clock.UtcNow;
|
||||
// instance.VersionModifiedUtc = _clock.UtcNow;
|
||||
|
||||
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var viewModel = new OwnerEditorViewModel();
|
||||
// if (instance.Owner != null)
|
||||
// viewModel.Owner = instance.Owner.UserName;
|
||||
|
||||
// var priorOwner = viewModel.Owner;
|
||||
// context.Updater.TryUpdateModel(viewModel, "CommonPart", null, null);
|
||||
|
||||
// if (viewModel.Owner != null && viewModel.Owner != priorOwner) {
|
||||
// var newOwner = _membershipService.GetUser(viewModel.Owner);
|
||||
// if (newOwner == null) {
|
||||
// context.Updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
|
||||
// }
|
||||
// else {
|
||||
// instance.Owner = newOwner;
|
||||
// }
|
||||
// }
|
||||
|
||||
// context.AddEditor(new TemplateViewModel(viewModel, "CommonPart") { TemplateName = "Parts/Common.Owner", ZoneName = "Content", Position = "999" });
|
||||
//}
|
||||
}
|
||||
}
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
45
src/Orchard.Web/Core/Containers/ContainersPathConstraint.cs
Normal file
45
src/Orchard.Web/Core/Containers/ContainersPathConstraint.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Orchard.Core.Containers {
|
||||
public interface IContainersPathConstraint : IRouteConstraint, ISingletonDependency {
|
||||
void SetPaths(IEnumerable<string> paths);
|
||||
string FindPath(string path);
|
||||
void AddPath(string path);
|
||||
}
|
||||
|
||||
public class ContainersPathConstraint : IContainersPathConstraint {
|
||||
private IDictionary<string, string> _paths = new Dictionary<string, string>();
|
||||
|
||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {
|
||||
if (routeDirection == RouteDirection.UrlGeneration)
|
||||
return true;
|
||||
|
||||
object value;
|
||||
if (values.TryGetValue(parameterName, out value)) {
|
||||
var parameterValue = Convert.ToString(value);
|
||||
return _paths.ContainsKey(parameterValue);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetPaths(IEnumerable<string> paths) {
|
||||
// Note: this does not need to be synchronized as long as the dictionary itself is treated as immutable.
|
||||
// do not add or remove to the dictionary instance once created. recreate and reassign instead.
|
||||
_paths = paths.Distinct().ToDictionary(path => path, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public string FindPath(string path) {
|
||||
string actual;
|
||||
return _paths.TryGetValue(path, out actual) ? actual : path;
|
||||
}
|
||||
|
||||
public void AddPath(string path) {
|
||||
SetPaths(_paths.Keys.Concat(new[] { path }));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Core.Containers.Controllers {
|
||||
public class ItemController : Controller {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IContainersPathConstraint _containersPathConstraint;
|
||||
|
||||
public ItemController(IContentManager contentManager, IContainersPathConstraint containersPathConstraint, IShapeFactory shapeFactory) {
|
||||
_contentManager = contentManager;
|
||||
_containersPathConstraint = containersPathConstraint;
|
||||
New = shapeFactory;
|
||||
}
|
||||
|
||||
dynamic New { get; set; }
|
||||
|
||||
[Themed]
|
||||
public ActionResult Display(string path, int? page) {
|
||||
var matchedPath = _containersPathConstraint.FindPath(path);
|
||||
if (string.IsNullOrEmpty(matchedPath)) {
|
||||
throw new ApplicationException("404 - should not have passed path constraint");
|
||||
}
|
||||
|
||||
var hits = _contentManager
|
||||
.Query<RoutePart, RoutePartRecord>(VersionOptions.Published)
|
||||
.Where(r => r.Path == matchedPath)
|
||||
.Slice(0, 2);
|
||||
|
||||
if (hits.Count() == 0) {
|
||||
throw new ApplicationException("404 - should not have passed path constraint");
|
||||
}
|
||||
|
||||
if (hits.Count() != 1) {
|
||||
throw new ApplicationException("Ambiguous content");
|
||||
}
|
||||
|
||||
var containerId = hits.Single().Id;
|
||||
var items = _contentManager
|
||||
.Query<ContentPart<CommonPartRecord>, CommonPartRecord>(VersionOptions.Published)
|
||||
.Where(x => x.Container.Id == containerId)
|
||||
.List();
|
||||
|
||||
var itemDisplays = items.Select(item => _contentManager.BuildDisplay(item, "Summary"));
|
||||
var list = New.List();
|
||||
list.AddRange(itemDisplays);
|
||||
|
||||
return View(list);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Containers.ViewModels;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Core.Containers.Drivers {
|
||||
public class ContainablePartDriver : ContentPartDriver<ContainablePart> {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public ContainablePartDriver(IContentManager contentManager) {
|
||||
_contentManager = contentManager;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(ContainablePart part, dynamic shapeHelper) {
|
||||
return Editor(part, null, shapeHelper);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContainablePart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ContentShape(
|
||||
"Parts_Containable_Edit",
|
||||
() => {
|
||||
var commonPart = part.As<ICommonPart>();
|
||||
|
||||
var model = new ContainableViewModel();
|
||||
if (commonPart.Container != null) {
|
||||
model.ContainerId = commonPart.Container.Id;
|
||||
}
|
||||
|
||||
if (updater != null) {
|
||||
var oldContainerId = model.ContainerId;
|
||||
updater.TryUpdateModel(model, "Containable", null, null);
|
||||
if (oldContainerId != model.ContainerId) {
|
||||
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
|
||||
}
|
||||
}
|
||||
|
||||
var containers = _contentManager.Query<ContainerPart, ContainerPartRecord>(VersionOptions.Latest).List();
|
||||
var listItems = new[] { new SelectListItem { Text = T("(None)").Text, Value = "0" } }
|
||||
.Concat(containers.Select(x => new SelectListItem {
|
||||
Value = Convert.ToString(x.Id),
|
||||
Text = x.ContentItem.TypeDefinition.DisplayName + ": " + x.As<IRoutableAspect>().Title,
|
||||
Selected = x.Id == model.ContainerId,
|
||||
}))
|
||||
.ToList();
|
||||
|
||||
model.AvailableContainers = new SelectList(listItems, "Value", "Text", model.ContainerId);
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Containable", Model: model, Prefix: "Containable");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Data;
|
||||
|
||||
namespace Orchard.Core.Containers.Drivers {
|
||||
public class ContainerPartDriver : ContentPartDriver<ContainerPart> {
|
||||
protected override DriverResult Editor(ContainerPart part, dynamic shapeHelper) {
|
||||
return Editor(part, null, shapeHelper);
|
||||
}
|
||||
protected override DriverResult Editor(ContainerPart part, ContentManagement.IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ContentShape(
|
||||
"Parts_Container_Edit",
|
||||
() => {
|
||||
if (updater != null)
|
||||
updater.TryUpdateModel(part, "Container", null, null);
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Container", Model: part, Prefix: "Container");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerPartHandler : ContentHandler {
|
||||
public ContainerPartHandler(IRepository<ContainerPartRecord> repository, IOrchardServices orchardServices) {
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
OnInitializing<ContainerPart>((context, part) => {
|
||||
var containerSiteSettings = orchardServices.WorkContext.CurrentSite.As<ContainerSettingsPart>().Record;
|
||||
part.Record.PageSize = containerSiteSettings.DefaultPageSize;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Core.Containers.Drivers {
|
||||
public class ContainerSettingsPartDriver : ContentPartDriver<ContainerSettingsPart> {
|
||||
public ContainerSettingsPartDriver() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override string Prefix { get { return "ContainerSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(ContainerSettingsPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Container_SiteSettings",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Container.SiteSettings", Model: part.Record, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContainerSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part.Record, Prefix, null, null);
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerSettingsPartHandler : ContentHandler {
|
||||
public ContainerSettingsPartHandler(IRepository<ContainerSettingsPartRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<ContainerSettingsPart>("Site"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
}
|
||||
}
|
||||
}
|
28
src/Orchard.Web/Core/Containers/Migrations.cs
Normal file
28
src/Orchard.Web/Core/Containers/Migrations.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Core.Contents.Extensions;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Containers {
|
||||
public class Migrations : DataMigrationImpl {
|
||||
public int Create() {
|
||||
SchemaBuilder.CreateTable("ContainerPartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
.Column<bool>("Paginated")
|
||||
.Column<int>("PageSize")
|
||||
.Column<string>("OrderByProperty")
|
||||
.Column<int>("OrderByDirection"));
|
||||
|
||||
SchemaBuilder.CreateTable("ContainerSettingsPartRecord", table => table
|
||||
.ContentPartRecord()
|
||||
.Column<int>("DefaultPageSize", column => column.WithDefault(10))
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition("ContainerPart", builder => builder.Attachable());
|
||||
ContentDefinitionManager.AlterPartDefinition("ContainablePart", builder => builder.Attachable());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Containers.Models {
|
||||
public class ContainablePart : ContentPart {
|
||||
}
|
||||
}
|
19
src/Orchard.Web/Core/Containers/Models/ContainerPart.cs
Normal file
19
src/Orchard.Web/Core/Containers/Models/ContainerPart.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Containers.Models {
|
||||
public class ContainerPart : ContentPart<ContainerPartRecord> {
|
||||
}
|
||||
|
||||
public class ContainerPartRecord : ContentPartRecord {
|
||||
public virtual int Paginated { get; set; }
|
||||
public virtual int PageSize { get; set; }
|
||||
public virtual string OrderByProperty { get; set; }
|
||||
public virtual int OrderByDirection { get; set; }
|
||||
}
|
||||
|
||||
public enum OrderByDirection {
|
||||
Ascending,
|
||||
Descending,
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Containers.Models {
|
||||
public class ContainerSettingsPart : ContentPart<ContainerSettingsPartRecord> {
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Containers.Models {
|
||||
public class ContainerSettingsPartRecord : ContentPartRecord {
|
||||
private int _defaultPageSize = 10;
|
||||
public virtual int DefaultPageSize {
|
||||
get { return _defaultPageSize; }
|
||||
set { _defaultPageSize = value; }
|
||||
}
|
||||
}
|
||||
}
|
12
src/Orchard.Web/Core/Containers/Module.txt
Normal file
12
src/Orchard.Web/Core/Containers/Module.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Name: Containers
|
||||
AntiForgery: enabled
|
||||
Author: The Orchard Team
|
||||
Website: http://orchardproject.net
|
||||
Version: 0.8.0
|
||||
OrchardVersion: 0.8.0
|
||||
Description: The common module introduces container and containable behaviors for content items
|
||||
Features:
|
||||
Containers:
|
||||
Description: Container content parts.
|
||||
Dependencies: Contents, Routable
|
||||
Category: Content
|
5
src/Orchard.Web/Core/Containers/Placement.info
Normal file
5
src/Orchard.Web/Core/Containers/Placement.info
Normal file
@@ -0,0 +1,5 @@
|
||||
<Placement>
|
||||
<Place Parts_Containable_Edit="Content:before.3"/>
|
||||
<Place Parts_Container_Edit="Content:5"/>
|
||||
<Place Parts_Container_SiteSettings="Content:10"/>
|
||||
</Placement>
|
42
src/Orchard.Web/Core/Containers/Routes.cs
Normal file
42
src/Orchard.Web/Core/Containers/Routes.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Core.Containers {
|
||||
public class Routes : IRouteProvider {
|
||||
private readonly IContainersPathConstraint _containersPathConstraint;
|
||||
|
||||
public Routes(IContainersPathConstraint containersPathConstraint) {
|
||||
_containersPathConstraint = containersPathConstraint;
|
||||
}
|
||||
|
||||
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||
foreach (var routeDescriptor in GetRoutes())
|
||||
routes.Add(routeDescriptor);
|
||||
}
|
||||
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
return new[] {
|
||||
new RouteDescriptor {
|
||||
Priority = 15,
|
||||
Route = new Route(
|
||||
"{*path}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Containers"},
|
||||
{"controller", "Item"},
|
||||
{"action", "Display"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"path", _containersPathConstraint}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Containers"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Tasks;
|
||||
|
||||
namespace Orchard.Core.Containers.Services {
|
||||
public class ContainersPathConstraintUpdater : IOrchardShellEvents, IBackgroundTask {
|
||||
private readonly IContainersPathConstraint _containersPathConstraint;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public ContainersPathConstraintUpdater(IContainersPathConstraint containersPathConstraint, IContentManager contentManager) {
|
||||
_containersPathConstraint = containersPathConstraint;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
void IOrchardShellEvents.Activated() {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void IOrchardShellEvents.Terminating() {
|
||||
}
|
||||
|
||||
void IBackgroundTask.Sweep() {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void Refresh() {
|
||||
var routeParts = _contentManager.Query<RoutePart, RoutePartRecord>().Join<ContainerPartRecord>().List();
|
||||
_containersPathConstraint.SetPaths(routeParts.Select(x=>x.Path));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Core.Containers.ViewModels {
|
||||
public class ContainableViewModel {
|
||||
public int ContainerId { get; set; }
|
||||
public SelectList AvailableContainers { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
@model Orchard.Core.Containers.ViewModels.ContainableViewModel
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.ContainerId, T("Add to"))
|
||||
@Html.DropDownListFor(m => m.ContainerId, Model.AvailableContainers)
|
||||
</fieldset>
|
@@ -0,0 +1,11 @@
|
||||
@model Orchard.Core.Containers.Models.ContainerSettingsPartRecord
|
||||
@using Orchard.Core.Containers.Models;
|
||||
|
||||
<fieldset>
|
||||
<legend>@T("Content Container")</legend>
|
||||
<div>
|
||||
<label for="@ViewData.TemplateInfo.GetFullHtmlFieldId("DefaultPageSize")">@T("Default page size")</label>
|
||||
@Html.EditorFor(m => m.DefaultPageSize)
|
||||
@Html.ValidationMessageFor(m => m.DefaultPageSize)
|
||||
</div>
|
||||
</fieldset>
|
@@ -0,0 +1,21 @@
|
||||
@model Orchard.Core.Containers.Models.ContainerPart
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.Record.PageSize, T("Page Size"))
|
||||
@Html.TextBoxFor(m => m.Record.PageSize)
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.Record.Paginated, T("Paginated"))
|
||||
@Html.TextBoxFor(m => m.Record.Paginated)
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.Record.OrderByProperty, T("OrderByProperty"))
|
||||
@Html.TextBoxFor(m => m.Record.OrderByProperty)
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.Record.OrderByDirection, T("OrderByDirection"))
|
||||
@Html.TextBoxFor(m => m.Record.OrderByDirection)
|
||||
</fieldset>
|
@@ -0,0 +1 @@
|
||||
@Display(Model)
|
@@ -8,6 +8,7 @@ using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Contents.Settings;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
@@ -67,12 +68,14 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
|
||||
switch (model.Options.OrderBy) {
|
||||
case ContentsOrder.Modified:
|
||||
//query = query.OrderByDescending<ContentPartRecord, int>(ci => ci.ContentItemRecord.Versions.Single(civr => civr.Latest).Id);
|
||||
query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
|
||||
break;
|
||||
case ContentsOrder.Published:
|
||||
query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
|
||||
break;
|
||||
case ContentsOrder.Created:
|
||||
//query = query.OrderByDescending<ContentPartRecord, int>(ci => ci.Id);
|
||||
query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
|
||||
break;
|
||||
}
|
||||
@@ -189,24 +192,39 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Create")]
|
||||
[FormValueRequired("submit.Save")]
|
||||
public ActionResult CreatePOST(string id) {
|
||||
return CreatePOST(id, contentItem => {
|
||||
if (!contentItem.Has<IPublishingControlAspect>() && !contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
|
||||
_contentManager.Publish(contentItem);
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Create")]
|
||||
public ActionResult CreatePOST(string id) {
|
||||
[FormValueRequired("submit.Publish")]
|
||||
public ActionResult CreateAndPublishPOST(string id) {
|
||||
return CreatePOST(id, contentItem => _contentManager.Publish(contentItem));
|
||||
}
|
||||
|
||||
private ActionResult CreatePOST(string id, Action<ContentItem> conditionallyPublish) {
|
||||
var contentItem = _contentManager.New(id);
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't create content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_contentManager.Create(contentItem, VersionOptions.Draft);
|
||||
var model = _contentManager.UpdateEditor(contentItem, this);
|
||||
var isDraftable = contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable;
|
||||
_contentManager.Create(
|
||||
contentItem,
|
||||
isDraftable ? VersionOptions.Draft : VersionOptions.Published);
|
||||
|
||||
var model = _contentManager.UpdateEditor(contentItem, this);
|
||||
if (!ModelState.IsValid) {
|
||||
_transactionManager.Cancel();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
if (!contentItem.Has<IPublishingControlAspect>())
|
||||
_contentManager.Publish(contentItem);
|
||||
conditionallyPublish(contentItem);
|
||||
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(contentItem.TypeDefinition.DisplayName)
|
||||
? T("Your content has been created.")
|
||||
@@ -229,7 +247,21 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
[FormValueRequired("submit.Save")]
|
||||
public ActionResult EditPOST(int id, string returnUrl) {
|
||||
return EditPOST(id, returnUrl, contentItem => {
|
||||
if (!contentItem.Has<IPublishingControlAspect>() && !contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
|
||||
_contentManager.Publish(contentItem);
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
[FormValueRequired("submit.Publish")]
|
||||
public ActionResult EditAndPublishPOST(int id, string returnUrl) {
|
||||
return EditPOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem));
|
||||
}
|
||||
|
||||
private ActionResult EditPOST(int id, string returnUrl, Action<ContentItem> conditionallyPublish) {
|
||||
var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired);
|
||||
|
||||
if (contentItem == null)
|
||||
@@ -244,9 +276,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return View("Edit", model);
|
||||
}
|
||||
|
||||
//need to go about this differently - to know when to publish (IPlublishableAspect ?)
|
||||
if (!contentItem.Has<IPublishingControlAspect>())
|
||||
_contentManager.Publish(contentItem);
|
||||
conditionallyPublish(contentItem);
|
||||
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(contentItem.TypeDefinition.DisplayName)
|
||||
? T("Your content has been saved.")
|
||||
|
@@ -1,5 +1,7 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Contents.Settings;
|
||||
|
||||
namespace Orchard.Core.Contents.Drivers {
|
||||
public class ContentsDriver : ContentPartDriver<ContentPart> {
|
||||
@@ -13,5 +15,18 @@ namespace Orchard.Core.Contents.Drivers {
|
||||
() => shapeHelper.Parts_Contents_Publish_SummaryAdmin(ContentPart: part))
|
||||
);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, dynamic shapeHelper) {
|
||||
var results = new List<DriverResult> { ContentShape("Content_SaveButton", saveButton => saveButton) };
|
||||
|
||||
if (part.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
|
||||
results.Add(ContentShape("Content_PublishButton", publishButton => publishButton));
|
||||
|
||||
return Combined(results.ToArray());
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return Editor(part, updater);
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,6 +6,9 @@ namespace Orchard.Core.Contents.Extensions {
|
||||
public static ContentTypeDefinitionBuilder Creatable(this ContentTypeDefinitionBuilder builder, bool creatable = true) {
|
||||
return builder.WithSetting("ContentTypeSettings.Creatable", creatable.ToString());
|
||||
}
|
||||
public static ContentTypeDefinitionBuilder Draftable(this ContentTypeDefinitionBuilder builder, bool draftable = true) {
|
||||
return builder.WithSetting("ContentTypeSettings.Draftable", draftable.ToString());
|
||||
}
|
||||
public static ContentPartDefinitionBuilder Attachable(this ContentPartDefinitionBuilder builder, bool attachable = true) {
|
||||
return builder.WithSetting("ContentPartSettings.Attachable", attachable.ToString());
|
||||
}
|
||||
|
@@ -4,6 +4,9 @@
|
||||
Parts_Contents_Publish
|
||||
Parts_Contents_Publish_SummaryAdmin
|
||||
-->
|
||||
<!-- edit "shape" -->
|
||||
<Place Content_PublishButton="Sidebar:24"/>
|
||||
<Place Content_SaveButton="Sidebar:23"/>
|
||||
<Match DisplayType="Detail">
|
||||
<Place Parts_Contents_Publish="Content:5"/>
|
||||
</Match>
|
||||
|
@@ -1,8 +1,12 @@
|
||||
namespace Orchard.Core.Contents.Settings {
|
||||
public class ContentTypeSettings {
|
||||
/// <summary>
|
||||
/// This setting is used to display a Content Type in Content Management menu like
|
||||
/// Used to determine if an instance of this content type can be created through the UI
|
||||
/// </summary>
|
||||
public bool Creatable { get; set; }
|
||||
/// <summary>
|
||||
/// Used to determine if this content type supports draft versions
|
||||
/// </summary>
|
||||
public bool Draftable { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<fieldset class="publish-button">
|
||||
<button type="submit" name="submit.Publish" value="submit.Publish">@T("Publish Now")</button>
|
||||
</fieldset>
|
@@ -0,0 +1,3 @@
|
||||
<fieldset class="save-button">
|
||||
<button class="primaryAction" type="submit" name="submit.Save" value="submit.Save">@T("Save")</button>
|
||||
</fieldset>
|
@@ -1,12 +1,21 @@
|
||||
<div class="sections">
|
||||
<div class="primary">
|
||||
@Display(Model.Content)
|
||||
<div class="edit-item">
|
||||
<div class="edit-item-primary">
|
||||
@if (Model.Content != null) {
|
||||
<div class="edit-item-content">
|
||||
@Display(Model.Content)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="secondary">
|
||||
@Display(Model.Sidebar)
|
||||
@* todo: (heskew) remove when the CommonPart is adding the save button *@
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit" name="submit.Save" value="submit.Save">@T("Save")</button>
|
||||
</fieldset>
|
||||
<div class="edit-item-secondary group">
|
||||
@if (Model.Actions != null) {
|
||||
<div class="edit-item-actions">
|
||||
@Display(Model.Actions)
|
||||
</div>
|
||||
}
|
||||
@if (Model.Sidebar != null) {
|
||||
<div class="edit-item-sidebar group">
|
||||
@Display(Model.Sidebar)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -8,8 +8,8 @@ namespace Orchard.Core.Dashboard {
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.Add(T("Dashboard"), "0",
|
||||
menu => menu.Add(T("Orchard"), "0", item => item.Action("Index", "Admin", new { area = "Dashboard" })
|
||||
builder.Add(T("Dashboard"), "-5",
|
||||
menu => menu.Add(T("Orchard"), "-5", item => item.Action("Index", "Admin", new { area = "Dashboard" })
|
||||
.Permission(StandardPermissions.AccessAdminPanel)));
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -1,29 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Core.HomePage.Controllers {
|
||||
[HandleError]
|
||||
public class HomeController : Controller {
|
||||
private readonly IEnumerable<IHomePageProvider> _homePageProviders;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public HomeController(IEnumerable<IHomePageProvider> homePageProviders) {
|
||||
public HomeController(IEnumerable<IHomePageProvider> homePageProviders, IOrchardServices orchardServices) {
|
||||
_homePageProviders = homePageProviders;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
[Themed]
|
||||
public ActionResult Index() {
|
||||
try {
|
||||
var homepage = CurrentSite.HomePage;
|
||||
var homepage = _orchardServices.WorkContext.CurrentSite.HomePage;
|
||||
if (String.IsNullOrEmpty(homepage))
|
||||
return View();
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
Parts_Localization_ContentTranslations_SummaryAdmin
|
||||
-->
|
||||
<!-- edit shape just gets default placement -->
|
||||
<Place Parts_Localization_ContentTranslations_Edit="Content:before.1"/>
|
||||
<Place Parts_Localization_ContentTranslations_Edit="Content:0"/>
|
||||
<Match DisplayType="Detail">
|
||||
<Place Parts_Localization_ContentTranslations="Content:2"/>
|
||||
</Match>
|
||||
|
18
src/Orchard.Web/Core/Localization/Styles/Web.config
Normal file
18
src/Orchard.Web/Core/Localization/Styles/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -1,10 +1,6 @@
|
||||
.summary .content-localization {
|
||||
margin: .7em 0;
|
||||
}
|
||||
.content-localization .content-localizations li,
|
||||
.content-localization .add-localization {
|
||||
font-size:1.4em;
|
||||
}
|
||||
.content-localization .culture-selected {
|
||||
margin-bottom:.5em;
|
||||
}
|
||||
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -1,36 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Messaging.Models;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Messaging.Events;
|
||||
using Orchard.Messaging.Models;
|
||||
using Orchard.Messaging.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Messaging.Services {
|
||||
public class DefaultMessageManager : IMessageManager {
|
||||
private readonly IMessageEventHandler _messageEventHandler;
|
||||
private readonly IEnumerable<IMessagingChannel> _channels;
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public DefaultMessageManager(
|
||||
IMessageEventHandler messageEventHandler,
|
||||
IEnumerable<IMessagingChannel> channels) {
|
||||
IEnumerable<IMessagingChannel> channels,
|
||||
IOrchardServices orchardServices) {
|
||||
_messageEventHandler = messageEventHandler;
|
||||
_channels = channels;
|
||||
_orchardServices = orchardServices;
|
||||
}
|
||||
|
||||
public void Send(ContentItemRecord recipient, string type, string service = null, Dictionary<string, string> properties = null) {
|
||||
if ( !HasChannels() )
|
||||
return;
|
||||
|
||||
var messageSettings = CurrentSite.As<MessageSettingsPart>().Record;
|
||||
var messageSettings = _orchardServices.WorkContext.CurrentSite.As<MessageSettingsPart>().Record;
|
||||
|
||||
if ( messageSettings == null || String.IsNullOrWhiteSpace(messageSettings.DefaultChannelService) ) {
|
||||
return;
|
||||
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
@@ -12,18 +12,19 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
public class MenuPartDriver : ContentPartDriver<MenuPart> {
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly INavigationManager _navigationManager;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public MenuPartDriver(IAuthorizationService authorizationService, INavigationManager navigationManager) {
|
||||
public MenuPartDriver(IAuthorizationService authorizationService, INavigationManager navigationManager, IOrchardServices orchardServices) {
|
||||
_authorizationService = authorizationService;
|
||||
_navigationManager = navigationManager;
|
||||
_orchardServices = orchardServices;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(MenuPart part, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentShape("Parts_Navigation_Menu_Edit",
|
||||
@@ -31,7 +32,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MenuPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrEmpty(part.MenuPosition))
|
||||
|
@@ -35,7 +35,7 @@
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<fieldset class="actions"><button type="submit" class="button primaryAction">@T("Update All")</button></fieldset>
|
||||
<fieldset class="actions"><button type="submit" class="primaryAction">@T("Update All")</button></fieldset>
|
||||
}
|
||||
|
||||
<h2>@T("Add New Item")</h2>
|
||||
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -61,17 +61,34 @@
|
||||
<HintPath>..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\aspnetmvc\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Containers\Controllers\ItemController.cs" />
|
||||
<Compile Include="Containers\Drivers\ContainablePartDriver.cs" />
|
||||
<Compile Include="Containers\Drivers\ContainerPartDriver.cs" />
|
||||
<Compile Include="Common\Migrations.cs" />
|
||||
<Compile Include="Common\Drivers\BodyPartDriver.cs" />
|
||||
<Compile Include="Common\Drivers\CommonPartDriver.cs" />
|
||||
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
|
||||
<Compile Include="Containers\ContainersPathConstraint.cs" />
|
||||
<Compile Include="Containers\Migrations.cs" />
|
||||
<Compile Include="Containers\Drivers\ContainerSettingsPartDriver.cs" />
|
||||
<Compile Include="Containers\Models\ContainerSettingsPart.cs" />
|
||||
<Compile Include="Containers\Models\ContainerSettingsPartRecord.cs" />
|
||||
<Compile Include="Containers\Models\ContainablePart.cs" />
|
||||
<Compile Include="Containers\Models\ContainerPart.cs" />
|
||||
<Compile Include="Common\Shapes.cs" />
|
||||
<Compile Include="Common\Fields\TextField.cs" />
|
||||
<Compile Include="Containers\Routes.cs" />
|
||||
<Compile Include="Containers\Services\ContainersPathConstraintUpdater.cs" />
|
||||
<Compile Include="Containers\ViewModels\ContainableViewModel.cs" />
|
||||
<Compile Include="Contents\Security\AuthorizationEventHandler.cs" />
|
||||
<Compile Include="Common\Services\BbcodeFilter.cs" />
|
||||
<Compile Include="Common\Services\ICommonService.cs" />
|
||||
@@ -242,6 +259,7 @@
|
||||
<Content Include="Common\Views\Parts\Common.Body.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\Parts\Common.Metadata.cshtml" />
|
||||
<Content Include="Common\Views\Parts\Common.Metadata.SummaryAdmin.cshtml" />
|
||||
<Content Include="Containers\Module.txt" />
|
||||
<Content Include="Contents\Views\Admin\Create.cshtml" />
|
||||
<Content Include="Contents\Views\Admin\Edit.cshtml" />
|
||||
<Content Include="Contents\Views\Admin\List.cshtml" />
|
||||
@@ -274,12 +292,8 @@
|
||||
<Content Include="Settings\Views\Admin\Index.cshtml" />
|
||||
<Content Include="Settings\Views\Admin\Culture.cshtml" />
|
||||
<Content Include="Contents\Views\Items\Content.Edit.cshtml" />
|
||||
<Content Include="Routable\Placement.info">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Settings\Placement.info">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Routable\Placement.info" />
|
||||
<Content Include="Settings\Placement.info" />
|
||||
<Content Include="Settings\Views\DisplayTemplates\CurrentCulture.cshtml" />
|
||||
<Content Include="Settings\Views\DisplayTemplates\RemovableCulture.cshtml" />
|
||||
<Content Include="Shapes\Module.txt" />
|
||||
@@ -298,8 +312,6 @@
|
||||
<Content Include="Shapes\Views\HeadPreload.cshtml" />
|
||||
<Content Include="Shapes\Views\Message.cshtml" />
|
||||
<Content Include="Shapes\Views\NotFound.cshtml" />
|
||||
<Content Include="Shapes\Views\UI\Switchable.cshtml" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="XmlRpc\Module.txt" />
|
||||
<Content Include="Settings\Views\EditorTemplates\Parts\Settings.SiteSettingsPart.cshtml" />
|
||||
</ItemGroup>
|
||||
@@ -355,22 +367,42 @@
|
||||
<Content Include="Shapes\Views\Web.config" />
|
||||
<Content Include="Common\Placement.info" />
|
||||
<Content Include="Common\Views\Parts\Common.Metadata.Summary.cshtml" />
|
||||
<Content Include="Contents\Placement.info" />
|
||||
<Content Include="Contents\Placement.info">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Contents\Views\Content.ControlWrapper.cshtml" />
|
||||
<Content Include="Contents\Views\Item\Display.cshtml" />
|
||||
<Content Include="Localization\Placement.info" />
|
||||
<Content Include="Messaging\Placement.info">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Navigation\Placement.info">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Messaging\Placement.info" />
|
||||
<Content Include="Navigation\Placement.info" />
|
||||
<Content Include="Routable\Views\Parts\RoutableTitle.cshtml" />
|
||||
<Content Include="Routable\Views\Item\Display.cshtml" />
|
||||
<Content Include="Routable\Views\Routable.HomePage.cshtml" />
|
||||
<Content Include="Localization\Views\Parts\Localization.ContentTranslations.SummaryAdmin.cshtml" />
|
||||
<Content Include="Contents\Views\Items\Content.Summary.cshtml" />
|
||||
<Content Include="Shapes\Views\Pager.cshtml" />
|
||||
<Content Include="Contents\Views\Content.SaveButton.cshtml" />
|
||||
<Content Include="Contents\Views\Content.PublishButton.cshtml" />
|
||||
<Content Include="Shapes\Scripts\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Shapes\Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Routable\Scripts\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Localization\Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Settings\Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Containers\Placement.info" />
|
||||
<Content Include="Containers\Views\EditorTemplates\Containable.cshtml" />
|
||||
<Content Include="Containers\Views\EditorTemplates\Container.cshtml" />
|
||||
<Content Include="Containers\Views\Item\Display.cshtml" />
|
||||
<Content Include="Containers\Views\EditorTemplates\Container.SiteSettings.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@@ -32,3 +33,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.0")]
|
||||
[assembly: SecurityTransparent]
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
@@ -10,7 +9,6 @@ using Orchard.Core.Routable.Services;
|
||||
using Orchard.Core.Routable.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.Routable.Drivers {
|
||||
@@ -29,7 +27,6 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
private const string TemplateName = "Parts/Routable.RoutePart";
|
||||
|
||||
public Localizer T { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
protected override string Prefix {
|
||||
get { return "Routable"; }
|
||||
@@ -70,7 +67,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
: "";
|
||||
}
|
||||
|
||||
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||
return ContentShape("Parts_Routable_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
@@ -102,7 +99,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
part.Path = part.GetPathWithSlug(part.Slug);
|
||||
|
||||
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null) {
|
||||
CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||
}
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
|
18
src/Orchard.Web/Core/Routable/Scripts/Web.config
Normal file
18
src/Orchard.Web/Core/Routable/Scripts/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
18
src/Orchard.Web/Core/Settings/Styles/Web.config
Normal file
18
src/Orchard.Web/Core/Settings/Styles/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -3,7 +3,6 @@
|
||||
@Html.ValidationSummary()
|
||||
@Display(Model.Content)
|
||||
<fieldset>
|
||||
<input class="button primaryAction" type="submit" value="@T("Save")" />
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
}
|
@@ -33,6 +33,6 @@
|
||||
<div>
|
||||
<label for="SiteDebugMode">@T("Resource Debug Mode")</label>
|
||||
@Html.DropDownList("ResourceDebugMode", resourceDebugMode)
|
||||
<p>@T("Determines whether scripts and stylesheets load in their debuggable or minified form.")</p>
|
||||
<span class="hint">@T("Determines whether scripts and stylesheets load in their debuggable or minified form.")</span>
|
||||
</div>
|
||||
</fieldset>
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -7,7 +7,7 @@ using Orchard.Mvc.Html;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Core.Shapes {
|
||||
public class DateTimeShapes : IDependency {
|
||||
public class DateTimeShapes : ISingletonDependency {
|
||||
private readonly IClock _clock;
|
||||
|
||||
public DateTimeShapes(IClock clock) {
|
||||
|
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Orchard.UI.Resources;
|
||||
|
||||
namespace Orchard.Core.Shapes {
|
||||
@@ -11,6 +7,11 @@ namespace Orchard.Core.Shapes {
|
||||
manifest.DefineScript("ShapesBase").SetUrl("base.js").SetDependencies("jQuery");
|
||||
manifest.DefineStyle("Shapes").SetUrl("site.css"); // todo: missing
|
||||
manifest.DefineStyle("ShapesSpecial").SetUrl("special.css");
|
||||
|
||||
manifest.DefineScript("Switchable").SetUrl("jquery.switchable.js")
|
||||
.SetDependencies("jQuery")
|
||||
.SetDependencies("ShapesBase");
|
||||
manifest.DefineStyle("Switchable").SetUrl("jquery.switchable.css");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
src/Orchard.Web/Core/Shapes/Scripts/Web.config
Normal file
18
src/Orchard.Web/Core/Shapes/Scripts/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -85,15 +85,48 @@
|
||||
var firstError = _this.find(".input-validation-error").first();
|
||||
// try to focus the first error on the page
|
||||
if (firstError.size() === 1) {
|
||||
return firstError.focus();
|
||||
firstError.focus();
|
||||
return _this;
|
||||
}
|
||||
// or, give it up to the browser to autofocus
|
||||
if ('autofocus' in document.createElement('input')) {
|
||||
return;
|
||||
return _this;
|
||||
}
|
||||
// otherwise, make the autofocus attribute work
|
||||
var autofocus = _this.find(":input[autofocus]").first();
|
||||
return autofocus.focus();
|
||||
autofocus.focus();
|
||||
|
||||
return _this;
|
||||
},
|
||||
helpfullyPlacehold: function () {
|
||||
var _this = $(this);
|
||||
|
||||
// give it up to the browser to handle placeholder text
|
||||
if ('placeholder' in document.createElement('input')) {
|
||||
return _this;
|
||||
}
|
||||
// otherwise, make the placeholder attribute work
|
||||
$(":input[placeholder]")
|
||||
.each(function () {
|
||||
var _this = $(this);
|
||||
if (_this.val() === "") {
|
||||
_this.val(_this.attr("placeholder")).addClass("placeholderd");
|
||||
}
|
||||
})
|
||||
.live("focus", function () {
|
||||
var _this = $(this);
|
||||
if (_this.val() === _this.attr("placeholder")) {
|
||||
_this.val("").removeClass("placeholderd");
|
||||
}
|
||||
})
|
||||
.live("blur", function () {
|
||||
var _this = $(this);
|
||||
if (_this.val() === "") {
|
||||
_this.val(_this.attr("placeholder")).addClass("placeholderd");
|
||||
}
|
||||
});
|
||||
|
||||
return _this;
|
||||
},
|
||||
toggleWhatYouControl: function () {
|
||||
var _this = $(this);
|
||||
@@ -103,14 +136,14 @@
|
||||
_controllees.hide(); // <- unhook this when the following comment applies
|
||||
$(_controllees.show()[0]).find("input").focus(); // <- aaaand a slideDown there...eventually
|
||||
} else if (!(_this.is(":checked") && _controlleesAreHidden)) {
|
||||
//_controllees.slideUp(200); <- hook this back up when chrome behaves, or when I care less
|
||||
//_controllees.slideUp(200); <- hook this back up when chrome behaves, or when I care less...or when chrome behaves
|
||||
_controllees.hide()
|
||||
}
|
||||
return this;
|
||||
return _this;
|
||||
}
|
||||
});
|
||||
// collapsable areas - anything with a data-controllerid attribute has its visibility controlled by the id-ed radio/checkbox
|
||||
(function () {
|
||||
$(function () {
|
||||
$("[data-controllerid]").each(function () {
|
||||
var controller = $("#" + $(this).attr("data-controllerid"));
|
||||
if (controller.data("isControlling")) {
|
||||
@@ -126,9 +159,9 @@
|
||||
$("[name=" + controller.attr("name") + "]").click(function () { $("[name=" + $(this).attr("name") + "]").each($(this).toggleWhatYouControl); });
|
||||
}
|
||||
});
|
||||
})();
|
||||
});
|
||||
// inline form link buttons (form.inline.link button) swapped out for a link that submits said form
|
||||
(function () {
|
||||
$(function () {
|
||||
$("form.inline.link").each(function () {
|
||||
var _this = $(this);
|
||||
var link = $("<a class='wasFormInlineLink' href='.'/>");
|
||||
@@ -141,10 +174,12 @@
|
||||
_this.css({ "position": "absolute", "left": "-9999em" });
|
||||
$("body").append(_this);
|
||||
});
|
||||
})();
|
||||
// (do) a little better autofocus
|
||||
});
|
||||
// some default value add behavior
|
||||
$(function () {
|
||||
$("body").helpfullyFocus();
|
||||
$("body").helpfullyFocus() // (do) a little better autofocus
|
||||
.helpfullyPlacehold(); // pick up on placeholders
|
||||
|
||||
});
|
||||
// UnsafeUrl links -> form POST
|
||||
//todo: need some real microdata support eventually (incl. revisiting usage of data-* attributes)
|
||||
|
18
src/Orchard.Web/Core/Shapes/Styles/Web.config
Normal file
18
src/Orchard.Web/Core/Shapes/Styles/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -1,5 +0,0 @@
|
||||
@{
|
||||
Style.Require("Switchable");
|
||||
Script.Require("Switchable");
|
||||
}
|
||||
@string.Format("{0} switchable", Model)
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.0">
|
||||
<assemblies>
|
||||
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
|
||||
</assemblies>
|
||||
</compilation>
|
||||
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web>
|
||||
<system.web.extensions/>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@@ -37,6 +37,7 @@ namespace Orchard.Web {
|
||||
|
||||
protected void Application_EndRequest() {
|
||||
_host.EndRequest();
|
||||
//GC.Collect();
|
||||
}
|
||||
|
||||
static void MvcSingletons(ContainerBuilder builder) {
|
||||
|
18
src/Orchard.Web/Media/web.config
Normal file
18
src/Orchard.Web/Media/web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -80,9 +80,6 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@@ -33,3 +33,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.0")]
|
||||
[assembly: SecurityTransparent]
|
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.0">
|
||||
<assemblies>
|
||||
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL"/>
|
||||
</assemblies>
|
||||
</compilation>
|
||||
|
||||
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web>
|
||||
<system.web.extensions/>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -106,6 +106,16 @@
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@@ -32,3 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.0")]
|
||||
[assembly: SecurityTransparent]
|
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
@@ -27,8 +25,6 @@
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
|
18
src/Orchard.Web/Modules/Orchard.Blogs/Content/Web.config
Normal file
18
src/Orchard.Web/Modules/Orchard.Blogs/Content/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -135,7 +135,6 @@
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="Views\Items\Content-Blog.SummaryAdmin.cshtml" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -159,10 +158,18 @@
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.BlogArchives.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.DetailAdmin.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.Edit.cshtml" />
|
||||
<Content Include="Views\Items\Content-BlogPost.Editor.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.BlogPost.List.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.RecentBlogPosts.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.Blog.BlogPostCount.cshtml" />
|
||||
<Content Include="Scripts\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Content\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@@ -32,3 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.0")]
|
||||
[assembly: SecurityTransparent]
|
18
src/Orchard.Web/Modules/Orchard.Blogs/Scripts/Web.config
Normal file
18
src/Orchard.Web/Modules/Orchard.Blogs/Scripts/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
18
src/Orchard.Web/Modules/Orchard.Blogs/Styles/Web.config
Normal file
18
src/Orchard.Web/Modules/Orchard.Blogs/Styles/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -1,6 +1,6 @@
|
||||
@using Orchard.Blogs.Extensions;
|
||||
@using Orchard.Blogs.Models;
|
||||
<h1><a href="@Url.BlogForAdmin((string)Model.Slug)">@Html.TitleForPage((string)Model.Title)</a></h1>
|
||||
<h1>@Html.TitleForPage((string)Model.Title)</h1>
|
||||
@Display(Model.Header)
|
||||
@Display(Model.Actions)
|
||||
<div class="manage"><a href="@Url.BlogPostCreate((BlogPart)Model.ContentItem.Get(typeof(BlogPart)))" class="add button primaryAction">@T("New Post")</a></div>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user