Merge dev => perf

--HG--
branch : perf
This commit is contained in:
Louis DeJardin
2010-11-24 13:58:53 -08:00
121 changed files with 772 additions and 437 deletions

View File

@@ -44,6 +44,18 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
_azureBlobStorageProvider.DeleteFile("notexisting");
}
[Test]
public void RootFolderAreNotCropped() {
_azureBlobStorageProvider.CreateFolder("default");
_azureBlobStorageProvider.CreateFolder("foo");
var folders = _azureBlobStorageProvider.ListFolders("");
Assert.That(folders.Count(), Is.EqualTo(2));
Assert.That(folders.Any(f => f.GetName() == "default"), Is.True);
Assert.That(folders.Any(f => f.GetName() == "foo"), Is.True);
}
[Test]
public void CreateFileShouldReturnCorrectStorageFile() {
var storageFile = _azureBlobStorageProvider.CreateFile("foo.txt");
@@ -105,6 +117,17 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
Assert.AreEqual("folder", _azureBlobStorageProvider.ListFolders(null).First().GetPath());
}
[Test]
public void CreateFolderWithSubFolder() {
_azureBlobStorageProvider.CreateFolder("folder");
Assert.AreEqual(0, _azureBlobStorageProvider.ListFolders("folder").Count());
_azureBlobStorageProvider.CreateFolder("folder/folder");
Assert.AreEqual(1, _azureBlobStorageProvider.ListFolders("folder").Count());
Assert.AreEqual(0, _azureBlobStorageProvider.ListFiles("folder/folder").Count());
Assert.AreEqual("folder", _azureBlobStorageProvider.ListFolders("folder").First().GetName());
}
[Test]
public void DeleteFolderShouldDeleteFilesAlso() {
_azureBlobStorageProvider.CreateFile("folder/foo1.txt");

View File

@@ -51,10 +51,42 @@ namespace Orchard.Azure {
}
private static void EnsurePathIsRelative(string path) {
if (path.StartsWith("/") || path.StartsWith("http://"))
if ( path.StartsWith("/") || path.StartsWith("http://") || path.StartsWith("https://") )
throw new ArgumentException("Path must be relative");
}
public string Combine(string path1, string path2) {
if ( path1 == null) {
throw new ArgumentNullException("path1");
}
if ( path2 == null ) {
throw new ArgumentNullException("path2");
}
if ( String.IsNullOrEmpty(path2) ) {
return path1;
}
if ( String.IsNullOrEmpty(path1) ) {
return path2;
}
if ( path2.StartsWith("http://") || path2.StartsWith("https://") )
{
return path2;
}
var ch = path1[path1.Length - 1];
if (ch != '/')
{
return (path1.TrimEnd('/') + '/' + path2.TrimStart('/'));
}
return (path1 + path2);
}
public IStorageFile GetFile(string path) {
EnsurePathIsRelative(path);
@@ -75,7 +107,7 @@ namespace Orchard.Azure {
EnsurePathIsRelative(path);
string prefix = String.Concat(Container.Name, "/", _root, path);
string prefix = String.Concat(Combine(Container.Name, _root), path);
if ( !prefix.EndsWith("/") )
prefix += "/";
@@ -121,7 +153,7 @@ namespace Orchard.Azure {
Container.EnsureDirectoryDoesNotExist(String.Concat(_root, path));
// Creating a virtually hidden file to make the directory an existing concept
CreateFile(path + "/" + FolderEntry);
CreateFile(Combine(path, FolderEntry));
}
}
@@ -224,7 +256,7 @@ namespace Orchard.Azure {
}
public string GetPath() {
return _blob.Uri.ToString().Substring(_rootPath.Length+1);
return _blob.Uri.ToString().Substring(_rootPath.Length).Trim('/');
}
public string GetName() {
@@ -263,11 +295,12 @@ namespace Orchard.Azure {
}
public string GetName() {
return Path.GetDirectoryName(GetPath() + "/");
var path = GetPath();
return path.Substring(path.LastIndexOf('/') +1 );
}
public string GetPath() {
return _blob.Uri.ToString().Substring(_rootPath.Length + 1).TrimEnd('/');
return _blob.Uri.ToString().Substring(_rootPath.Length).Trim('/');
}
public long GetSize() {

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Yaml.Serialization;
using JetBrains.Annotations;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.ServiceRuntime;
@@ -95,33 +94,60 @@ namespace Orchard.Azure.Environment.Configuration {
}
static ShellSettings ParseSettings(string text) {
var ser = new YamlSerializer();
var content = ser.Deserialize(text, typeof(Content)).Cast<Content>().Single();
return new ShellSettings {
Name = content.Name,
DataProvider = content.DataProvider,
DataConnectionString = content.DataConnectionString,
DataTablePrefix = content.DataPrefix,
RequestUrlHost = content.RequestUrlHost,
RequestUrlPrefix = content.RequestUrlPrefix,
State = new TenantState(content.State)
};
var shellSettings = new ShellSettings();
if ( String.IsNullOrEmpty(text) )
return shellSettings;
string[] settings = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach ( var setting in settings ) {
string[] settingFields = setting.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
int fieldsLength = settingFields.Length;
if ( fieldsLength != 2 )
continue;
for ( int i = 0; i < fieldsLength; i++ ) {
settingFields[i] = settingFields[i].Trim();
}
if ( settingFields[1] != "null" ) {
switch ( settingFields[0] ) {
case "Name":
shellSettings.Name = settingFields[1];
break;
case "DataProvider":
shellSettings.DataProvider = settingFields[1];
break;
case "State":
shellSettings.State = new TenantState(settingFields[1]);
break;
case "DataConnectionString":
shellSettings.DataConnectionString = settingFields[1];
break;
case "DataPrefix":
shellSettings.DataTablePrefix = settingFields[1];
break;
case "RequestUrlHost":
shellSettings.RequestUrlHost = settingFields[1];
break;
case "RequestUrlPrefix":
shellSettings.RequestUrlPrefix = settingFields[1];
break;
}
}
}
return shellSettings;
}
static string ComposeSettings(ShellSettings settings) {
if ( settings == null )
return "";
var ser = new YamlSerializer();
return ser.Serialize(new Content {
Name = settings.Name,
DataProvider = settings.DataProvider,
DataConnectionString = settings.DataConnectionString,
DataPrefix = settings.DataTablePrefix,
RequestUrlHost = settings.RequestUrlHost,
RequestUrlPrefix = settings.RequestUrlPrefix,
State = settings.State != null ? settings.State.ToString() : String.Empty
});
return string.Format("Name: {0}\r\nDataProvider: {1}\r\nDataConnectionString: {2}\r\nDataPrefix: {3}\r\nRequestUrlHost: {4}\r\nRequestUrlPrefix: {5}\r\nState: {6}\r\n",
settings.Name,
settings.DataProvider,
settings.DataConnectionString ?? "null",
settings.DataTablePrefix ?? "null",
settings.RequestUrlHost ?? "null",
settings.RequestUrlPrefix ?? "null",
settings.State != null ? settings.State.ToString() : String.Empty);
}
}
}

View File

@@ -68,10 +68,6 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="YamlSerializer, Version=0.9.0.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\yaml\YamlSerializer.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CloudBlobContainerExtensions.cs" />

View File

@@ -1,13 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Routing;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Drivers.Coordinators;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common;
using Orchard.Core.Common.Drivers;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement;
@@ -27,6 +31,7 @@ using Orchard.Tests.Modules;
using Orchard.Core.Common.ViewModels;
using System.Web.Mvc;
using Orchard.Tests.Stubs;
using Orchard.Themes;
namespace Orchard.Core.Tests.Common.Providers {
[TestFixture]
@@ -41,12 +46,19 @@ namespace Orchard.Core.Tests.Common.Providers {
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<TestHandler>().As<IContentHandler>();
builder.RegisterType<CommonPartHandler>().As<IContentHandler>();
builder.RegisterType<CommonPartDriver>().As<IContentPartDriver>();
builder.RegisterType<ContentPartDriverCoordinator>().As<IContentHandler>();
builder.RegisterType<CommonService>().As<ICommonService>();
builder.RegisterType<ScheduledTaskManager>().As<IScheduledTaskManager>();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterInstance(new Mock<IThemeManager>().Object);
builder.RegisterInstance(new Mock<IOrchardServices>().Object);
builder.RegisterInstance(new Mock<RequestContext>().Object);
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
_authn = new Mock<IAuthenticationService>();
_authz = new Mock<IAuthorizationService>();
@@ -152,7 +164,7 @@ namespace Orchard.Core.Tests.Common.Providers {
contentManager.UpdateEditor(item.ContentItem, updater);
}
[Test, Ignore("Fix pending")]
[Test]
public void PublishingShouldFailIfOwnerIsEmpty()
{
var contentManager = _container.Resolve<IContentManager>();
@@ -222,9 +234,9 @@ namespace Orchard.Core.Tests.Common.Providers {
Assert.That(item1.CreatedUtc, Is.EqualTo(createUtc));
Assert.That(item2.CreatedUtc, Is.EqualTo(createUtc));
// both instances non-versioned dates show the most recent publish
Assert.That(item1.PublishedUtc, Is.EqualTo(publish2Utc));
Assert.That(item2.PublishedUtc, Is.EqualTo(publish2Utc));
// both instances non-versioned dates show the earliest publish date
Assert.That(item1.PublishedUtc, Is.EqualTo(publish1Utc));
Assert.That(item2.PublishedUtc, Is.EqualTo(publish1Utc));
// version1 versioned dates show create was upfront and publish was oldest
Assert.That(item1.VersionCreatedUtc, Is.EqualTo(createUtc));

View File

@@ -166,7 +166,7 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
var mockContentManager = new Mock<IContentManager>();
mockContentManager.Setup(x => x.GetItemMetadata(It.IsAny<IContent>()))
.Returns(new ContentItemMetadata(hello) { DisplayText = "foo" });
.Returns(new ContentItemMetadata() { DisplayText = "foo" });
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());

View File

@@ -19,6 +19,7 @@ namespace Orchard.Specs.Bindings {
private HtmlDocument _doc;
private MessageSink _messages;
private static readonly Path _orchardTemp = Path.Get(System.IO.Path.GetTempPath()).Combine("Orchard.Specs");
private ExtensionDeploymentOptions _moduleDeploymentOptions = ExtensionDeploymentOptions.CompiledAssembly;
public WebHost Host {
get { return _webHost; }
@@ -63,6 +64,10 @@ namespace Orchard.Specs.Bindings {
GivenIHaveACleanSiteBasedOn("Orchard.Web");
}
[Given(@"I have chosen to deploy modules as source files only")]
public void GivenIHaveChosenToDeployModulesAsSourceFilesOnly() {
_moduleDeploymentOptions = ExtensionDeploymentOptions.SourceCode;
}
[Given(@"I have a clean site based on (.*)")]
public void GivenIHaveACleanSiteBasedOn(string siteFolder) {
@@ -105,17 +110,17 @@ namespace Orchard.Specs.Bindings {
[Given(@"I have module ""(.*)""")]
public void GivenIHaveModule(string moduleName) {
Host.CopyExtension("Modules", moduleName);
Host.CopyExtension("Modules", moduleName, _moduleDeploymentOptions);
}
[Given(@"I have theme ""(.*)""")]
public void GivenIHaveTheme(string themeName) {
Host.CopyExtension("Themes", themeName);
Host.CopyExtension("Themes", themeName, ExtensionDeploymentOptions.CompiledAssembly);
}
[Given(@"I have core ""(.*)""")]
public void GivenIHaveCore(string moduleName) {
Host.CopyExtension("Core", moduleName);
Host.CopyExtension("Core", moduleName, ExtensionDeploymentOptions.CompiledAssembly);
}
[Given(@"I have a clean site with")]

View File

@@ -0,0 +1,9 @@
using System;
namespace Orchard.Specs.Hosting {
[Flags]
public enum ExtensionDeploymentOptions {
CompiledAssembly = 0x01,
SourceCode = 0x02,
}
}

View File

@@ -19,7 +19,8 @@ namespace Orchard.Specs.Hosting {
var baseDir = Path.Get(AppDomain.CurrentDomain.BaseDirectory);
_tempSite = Path.Get(_orchardTemp).Combine(System.IO.Path.GetRandomFileName());
try { _tempSite.Delete(); } catch {}
try { _tempSite.Delete(); }
catch { }
// Trying the two known relative paths to the Orchard.Web directory.
// The second one is for the target "spec" in orchard.proj.
@@ -76,30 +77,47 @@ namespace Orchard.Specs.Hosting {
catch { }
}
public void CopyExtension(string extensionFolder, string extensionName) {
public void CopyExtension(string extensionFolder, string extensionName, ExtensionDeploymentOptions deploymentOptions) {
var sourceModule = _orchardWebPath.Combine(extensionFolder).Combine(extensionName);
var targetModule = _tempSite.Combine(extensionFolder).Combine(extensionName);
sourceModule.ShallowCopy("*.txt", targetModule);
sourceModule.ShallowCopy("*.info", targetModule);
//sourceModule.ShallowCopy("*.csproj", targetModule);
//sourceModule.DeepCopy("*.cs", targetModule);)
if ((deploymentOptions & ExtensionDeploymentOptions.SourceCode) == ExtensionDeploymentOptions.SourceCode) {
sourceModule.ShallowCopy("*.csproj", targetModule);
sourceModule.DeepCopy("*.cs", targetModule);
}
if (sourceModule.Combine("bin").IsDirectory) {
sourceModule.Combine("bin").ShallowCopy("*.dll", targetModule.Combine("bin"));
sourceModule.Combine("bin").ShallowCopy("*.exe", targetModule.Combine("bin"));
sourceModule.Combine("bin").ShallowCopy("*.pdb", targetModule.Combine("bin"));
sourceModule.Combine("bin").ShallowCopy(path => IsExtensionBinaryFile(path, extensionName, deploymentOptions), targetModule.Combine("bin"));
}
if (sourceModule.Combine("Views").IsDirectory)
sourceModule.Combine("Views").DeepCopy(targetModule.Combine("Views"));
}
private bool IsExtensionBinaryFile(Path path, string extensionName, ExtensionDeploymentOptions deploymentOptions) {
bool isValidExtension =
StringComparer.OrdinalIgnoreCase.Equals(path.Extension, ".exe") ||
StringComparer.OrdinalIgnoreCase.Equals(path.Extension, ".dll") ||
StringComparer.OrdinalIgnoreCase.Equals(path.Extension, ".pdb");
if (!isValidExtension)
return false;
bool isExtensionAssembly = StringComparer.OrdinalIgnoreCase.Equals(path.FileNameWithoutExtension, extensionName);
bool copyExtensionAssembly = (deploymentOptions & ExtensionDeploymentOptions.CompiledAssembly) == ExtensionDeploymentOptions.CompiledAssembly;
if (isExtensionAssembly && !copyExtensionAssembly)
return false;
return true;
}
public string HostName { get; set; }
public string PhysicalDirectory { get; private set; }
public string VirtualDirectory { get; private set; }
public string Cookies { get; set; }

View File

@@ -142,6 +142,12 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Hosting\ExtensionDeploymentOptions.cs" />
<Compile Include="SiteCompilation.feature.cs">
<DependentUpon>SiteCompilation.feature</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Hosting\MessageSink.cs" />
<Compile Include="Hosting\HostingTraceListener.cs" />
<Compile Include="Hosting\TraceEnabledDataServicesProviderFactory.cs" />
@@ -222,6 +228,10 @@
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>ContentRights.feature.cs</LastGenOutput>
</None>
<None Include="SiteCompilation.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>SiteCompilation.feature.cs</LastGenOutput>
</None>
<None Include="Hosting\Orchard.Web\Config\Diagnostics.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@@ -0,0 +1,10 @@
Feature: The compilation of modules installed in a site
In order to install on Orchard site
As a privileged user
I want to have the modules compiled/installed properly
Scenario: Dynamic compilation support: modules can be deployed as source files only
Given I have chosen to deploy modules as source files only
And I have installed Orchard
When I go to "admin"
Then I should see "<div id="orchard-version">Orchard v(?:\.\d+){2,4}</div>"

View File

@@ -0,0 +1,76 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.3.2.0
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
namespace Orchard.Specs
{
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("The compilation of modules installed in a site")]
public partial class TheCompilationOfModulesInstalledInASiteFeature
{
private static TechTalk.SpecFlow.ITestRunner testRunner;
#line 1 "SiteCompilation.feature"
#line hidden
[NUnit.Framework.TestFixtureSetUpAttribute()]
public virtual void FeatureSetup()
{
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "The compilation of modules installed in a site", "In order to install on Orchard site\r\nAs a privileged user\r\nI want to have the mod" +
"ules compiled/installed properly", ((string[])(null)));
testRunner.OnFeatureStart(featureInfo);
}
[NUnit.Framework.TestFixtureTearDownAttribute()]
public virtual void FeatureTearDown()
{
testRunner.OnFeatureEnd();
testRunner = null;
}
public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
{
testRunner.OnScenarioStart(scenarioInfo);
}
[NUnit.Framework.TearDownAttribute()]
public virtual void ScenarioTearDown()
{
testRunner.OnScenarioEnd();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Dynamic compilation support: modules can be deployed as source files only")]
public virtual void DynamicCompilationSupportModulesCanBeDeployedAsSourceFilesOnly()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Dynamic compilation support: modules can be deployed as source files only", ((string[])(null)));
#line 6
this.ScenarioSetup(scenarioInfo);
#line 7
testRunner.Given("I have chosen to deploy modules as source files only");
#line 8
testRunner.And("I have installed Orchard");
#line 9
testRunner.When("I go to \"admin\"");
#line 10
testRunner.Then("I should see \"<div id=\"orchard-version\">Orchard v(?:\\.\\d+){2,4}</div>\"");
#line hidden
testRunner.CollectScenarioErrors();
}
}
}
#endregion

View File

@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using Path = Bleroy.FluentPath.Path;
namespace Orchard.Specs.Util {
@@ -35,6 +36,13 @@ namespace Orchard.Specs.Util {
return sourcePath;
}
public static Path ShallowCopy(this Path sourcePath, Predicate<Path> predicatePath, Path targetPath) {
sourcePath
.GetFiles(predicatePath, false /*recursive*/)
.ForEach(file => FileCopy(sourcePath, targetPath, file));
return sourcePath;
}
private static void FileCopy(Path sourcePath, Path targetPath, Path sourceFile) {
var targetFile = targetPath.Combine(sourceFile.GetRelativePath(sourcePath));
targetFile.Parent.CreateDirectory();

View File

@@ -9,12 +9,14 @@ using Orchard.Commands;
using Orchard.Data;
using Orchard.Data.Migration.Generator;
using Orchard.Data.Providers;
using Orchard.Environment;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
using Orchard.Environment.ShellBuilders;
using Orchard.Environment.ShellBuilders.Models;
using Orchard.FileSystems.AppData;
using Orchard.Localization;
using Orchard.Tests.Environment;
using Orchard.Tests.FileSystems.AppData;
using Orchard.Tests.Stubs;
@@ -49,6 +51,7 @@ namespace Orchard.Tests.Modules.CodeGeneration.Commands {
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<SchemaCommandGenerator>().As<ISchemaCommandGenerator>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
_container = builder.Build();
_extensionManager = _container.Resolve<IExtensionManager>();

View File

@@ -32,6 +32,8 @@ using Orchard.Tests.FileSystems.AppData;
using Orchard.Tests.Modules.Migrations.Orchard.Tests.DataMigration.Records;
using Path = Bleroy.FluentPath.Path;
using Orchard.Tests.Stubs;
using Orchard.Tests.Environment;
using Orchard.Environment;
namespace Orchard.Tests.Modules.Migrations {
[TestFixture]
@@ -85,6 +87,7 @@ namespace Orchard.Tests.Modules.Migrations {
builder.RegisterType<SchemaCommandGenerator>().As<ISchemaCommandGenerator>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();

View File

@@ -61,5 +61,13 @@ namespace Orchard.Tests.Modules.Widgets.RuleEngine {
_urlRuleProvider.Process(context);
Assert.That(context.Result, Is.True);
}
[Test]
public void UrlForAboutPageWithEndingSlashMatchesAboutPagePath() {
_stubContextAccessor.StubContext = new StubHttpContext("~/About/");
var context = new RuleContext { FunctionName = "url", Arguments = new[] { "~/about" } };
_urlRuleProvider.Process(context);
Assert.That(context.Result, Is.True);
}
}
}

View File

@@ -8,12 +8,14 @@ using Orchard.Data;
using Orchard.Data.Migration.Interpreters;
using Orchard.Data.Migration.Schema;
using Orchard.Data.Providers;
using Orchard.Environment;
using Orchard.Environment.Configuration;
using Orchard.Environment.ShellBuilders.Models;
using Orchard.FileSystems.AppData;
using Orchard.Reports.Services;
using Orchard.Tests.ContentManagement;
using System.IO;
using Orchard.Tests.Environment;
using Orchard.Tests.FileSystems.AppData;
using Orchard.Tests.Stubs;
@@ -47,6 +49,7 @@ namespace Orchard.Tests.DataMigration {
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>();
builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>();
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
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>();

View File

@@ -0,0 +1,9 @@
using Orchard.Environment;
namespace Orchard.Tests.Environment {
public class StubHostEnvironment : HostEnvironment {
public override void ResetSiteCompilation() {
}
}
}

View File

@@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Diagnostics;
using Autofac;
using NUnit.Framework;
using Orchard.Environment;
using Orchard.Logging;
using Orchard.Tests.Environment;
namespace Orchard.Tests.Logging {
[TestFixture]
@@ -13,6 +15,7 @@ namespace Orchard.Tests.Logging {
var builder = new ContainerBuilder();
builder.RegisterModule(new LoggingModule());
builder.RegisterType<Thing>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
var container = builder.Build();
var thing = container.Resolve<Thing>();
Assert.That(thing.Logger, Is.Not.Null);
@@ -46,6 +49,7 @@ namespace Orchard.Tests.Logging {
var builder = new ContainerBuilder();
builder.RegisterModule(new LoggingModule());
builder.RegisterType<Thing>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
var container = builder.Build();
var thing = container.Resolve<Thing>();
Assert.That(thing.Logger, Is.Not.Null);

View File

@@ -226,6 +226,7 @@
<Compile Include="Environment\Extensions\ExtensionLoaderCoordinatorTests.cs" />
<Compile Include="Environment\State\DefaultProcessingEngineTests.cs" />
<Compile Include="Environment\RunningShellTableTests.cs" />
<Compile Include="Environment\StubHostEnvironment.cs" />
<Compile Include="Environment\Utility\Build.cs" />
<Compile Include="FileSystems\AppData\AppDataFolderTests.cs" />
<Compile Include="Environment\Configuration\DefaultTenantManagerTests.cs" />

View File

@@ -51,14 +51,10 @@ namespace Orchard.Core.Common.Drivers {
ContainerEditor(part, null, shapeHelper));
}
protected override DriverResult Editor(CommonPart instance, IUpdateModel updater, dynamic shapeHelper) {
// this event is hooked so the modified timestamp is changed when an edit-post occurs.
instance.ModifiedUtc = _clock.UtcNow;
instance.VersionModifiedUtc = _clock.UtcNow;
protected override DriverResult Editor(CommonPart part, IUpdateModel updater, dynamic shapeHelper) {
return Combined(
OwnerEditor(instance, updater, shapeHelper),
ContainerEditor(instance, updater, shapeHelper));
OwnerEditor(part, updater, shapeHelper),
ContainerEditor(part, updater, shapeHelper));
}
DriverResult OwnerEditor(CommonPart part, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -1,4 +1,6 @@
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.Localization;
@@ -13,40 +15,40 @@ namespace Orchard.Core.Common.Handlers {
private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService;
private readonly IContentManager _contentManager;
private readonly IContentDefinitionManager _contentDefinitionManager;
public CommonPartHandler(
IRepository<CommonPartRecord> commonRepository,
IRepository<CommonPartVersionRecord> commonVersionRepository,
IClock clock,
IAuthenticationService authenticationService,
IContentManager contentManager) {
IContentManager contentManager,
IContentDefinitionManager contentDefinitionManager) {
_clock = clock;
_authenticationService = authenticationService;
_contentManager = contentManager;
_contentDefinitionManager = contentDefinitionManager;
T = NullLocalizer.Instance;
Filters.Add(StorageFilter.For(commonRepository));
Filters.Add(StorageFilter.For(commonVersionRepository));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ContentTypeWithACommonPart));
OnInitializing<CommonPart>(PropertySetHandlers);
OnInitializing<CommonPart>(AssignCreatingOwner);
OnInitializing<ContentPart<CommonPartRecord>>(AssignCreatingDates);
OnInitializing<CommonPart>(AssignCreatingDates);
OnInitializing<ContentPart<CommonPartVersionRecord>>(AssignCreatingDates);
OnLoaded<CommonPart>(LazyLoadHandlers);
OnVersioning<CommonPart>(CopyOwnerAndContainer);
OnVersioned<CommonPart>(AssignVersioningDates);
OnVersioned<ContentPart<CommonPartVersionRecord>>(AssignVersioningDates);
OnPublishing<ContentPart<CommonPartRecord>>(AssignPublishingDates);
OnPublishing<CommonPart>(AssignPublishingDates);
OnPublishing<ContentPart<CommonPartVersionRecord>>(AssignPublishingDates);
//OnGetDisplayViewModel<CommonPart>();
//OnGetEditorViewModel<CommonPart>(GetEditor);
//OnUpdateEditorViewModel<CommonPart>(UpdateEditor);
OnIndexing<CommonPart>((context, commonPart) => context.DocumentIndex
.Add("type", commonPart.ContentItem.ContentType).Store()
.Add("author", commonPart.Owner.UserName).Store()
@@ -58,6 +60,9 @@ namespace Orchard.Core.Common.Handlers {
public Localizer T { get; set; }
bool ContentTypeWithACommonPart(string typeName) {
return _contentDefinitionManager.GetTypeDefinition(typeName).Parts.Any(part => part.PartDefinition.Name == "CommonPart");
}
void AssignCreatingOwner(InitializingContentContext context, CommonPart part) {
// and use the current user as Owner
@@ -66,10 +71,10 @@ namespace Orchard.Core.Common.Handlers {
}
}
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonPartRecord> part) {
void AssignCreatingDates(InitializingContentContext context, CommonPart part) {
// assign default create/modified dates
part.Record.CreatedUtc = _clock.UtcNow;
part.Record.ModifiedUtc = _clock.UtcNow;
part.CreatedUtc = _clock.UtcNow;
part.ModifiedUtc = _clock.UtcNow;
}
void AssignCreatingDates(InitializingContentContext context, ContentPart<CommonPartVersionRecord> part) {
@@ -78,22 +83,31 @@ namespace Orchard.Core.Common.Handlers {
part.Record.ModifiedUtc = _clock.UtcNow;
}
void AssignVersioningDates(VersionContentContext context, ContentPart<CommonPartVersionRecord> existing, ContentPart<CommonPartVersionRecord> building) {
// assign create/modified dates for the new version
building.Record.CreatedUtc = _clock.UtcNow;
building.Record.ModifiedUtc = _clock.UtcNow;
void AssignVersioningDates(VersionContentContext context, CommonPart existing, CommonPart building) {
// assign the created
building.CreatedUtc = existing.CreatedUtc ?? _clock.UtcNow;
// persist and published dates
building.PublishedUtc = existing.PublishedUtc;
// assign modified date for the new version
building.ModifiedUtc = _clock.UtcNow;
}
void AssignVersioningDates(VersionContentContext context, ContentPart<CommonPartVersionRecord> existing, ContentPart<CommonPartVersionRecord> building) {
// assign the created date
building.Record.CreatedUtc = _clock.UtcNow;
// assign modified date for the new version
building.Record.ModifiedUtc = _clock.UtcNow;
// publish date should be null until publish method called
building.Record.PublishedUtc = null;
}
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonPartRecord> part) {
void AssignPublishingDates(PublishContentContext context, CommonPart part) {
// don't assign dates when unpublishing
if (context.PublishingItemVersionRecord == null)
return;
// assign version-agnostic publish date
part.Record.PublishedUtc = _clock.UtcNow;
// set the initial published date
part.PublishedUtc = part.PublishedUtc ?? _clock.UtcNow;
}
void AssignPublishingDates(PublishContentContext context, ContentPart<CommonPartVersionRecord> part) {
@@ -101,13 +115,8 @@ namespace Orchard.Core.Common.Handlers {
if (context.PublishingItemVersionRecord == null)
return;
// assign version-specific publish date
part.Record.PublishedUtc = _clock.UtcNow;
}
private static void CopyOwnerAndContainer(VersionContentContext c, CommonPart c1, CommonPart c2) {
c2.Owner = c1.Owner;
c2.Container = c1.Container;
// assign the version's published date
part.Record.PublishedUtc = part.Record.PublishedUtc ?? _clock.UtcNow;
}
void LazyLoadHandlers(LoadContentContext context, CommonPart part) {
@@ -120,28 +129,22 @@ namespace Orchard.Core.Common.Handlers {
// add handlers that will update records when part properties are set
part.OwnerField.Setter(user => {
if (user == null) {
part.Record.OwnerId = 0;
}
else {
part.Record.OwnerId = user.ContentItem.Id;
}
return user;
});
part.Record.OwnerId = user == null
? 0
: user.ContentItem.Id;
return user;
});
// Force call to setter if we had already set a value
if (part.OwnerField.Value != null)
part.OwnerField.Value = part.OwnerField.Value;
part.ContainerField.Setter(container => {
if (container == null) {
part.Record.Container = null;
}
else {
part.Record.Container = container.ContentItem.Record;
}
return container;
});
part.Record.Container = container == null
? null
: container.ContentItem.Record;
return container;
});
// Force call to setter if we had already set a value
if (part.ContainerField.Value != null)

View File

@@ -1,9 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Handlers {
public class ItemReferenceContentFieldHandler : ContentFieldHandler {
public ItemReferenceContentFieldHandler(IEnumerable<IContentFieldDriver> contentFieldDrivers) : base(contentFieldDrivers) { }
}
}

View File

@@ -50,9 +50,8 @@ namespace Orchard.Core.Common.Models {
return PartVersionRecord == null ? CreatedUtc : PartVersionRecord.CreatedUtc;
}
set {
if (PartVersionRecord != null) {
if (PartVersionRecord != null)
PartVersionRecord.CreatedUtc = value;
}
}
}
@@ -61,9 +60,8 @@ namespace Orchard.Core.Common.Models {
return PartVersionRecord == null ? PublishedUtc : PartVersionRecord.PublishedUtc;
}
set {
if (PartVersionRecord != null) {
if (PartVersionRecord != null)
PartVersionRecord.PublishedUtc = value;
}
}
}
@@ -72,9 +70,8 @@ namespace Orchard.Core.Common.Models {
return PartVersionRecord == null ? ModifiedUtc : PartVersionRecord.ModifiedUtc;
}
set {
if (PartVersionRecord != null) {
if (PartVersionRecord != null)
PartVersionRecord.ModifiedUtc = value;
}
}
}
}

View File

@@ -1 +1 @@
<div class="published">@Display.PublishedState(dateTimeUtc: Model.ContentPart.VersionPublishedUtc)</div>
<div class="published">@Display.PublishedState(dateTimeUtc: Model.ContentPart.PublishedUtc)</div>

View File

@@ -1 +1 @@
<div class="published">@Display.PublishedState(dateTimeUtc: Model.ContentPart.VersionPublishedUtc)</div>
<div class="published">@Display.PublishedState(dateTimeUtc: Model.ContentPart.PublishedUtc)</div>

View File

@@ -7,8 +7,9 @@ namespace Orchard.Core.Contents.Handlers {
if (context.Metadata.CreateRouteValues == null) {
context.Metadata.CreateRouteValues = new RouteValueDictionary {
{"Area", "Contents"},
{"Controller", "Item"},
{"Action", "Create"}
{"Controller", "Admin"},
{"Action", "Create"},
{"Id", context.ContentItem.ContentType}
};
}
if (context.Metadata.EditorRouteValues == null) {
@@ -30,8 +31,9 @@ namespace Orchard.Core.Contents.Handlers {
if (context.Metadata.RemoveRouteValues == null) {
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
{"Area", "Contents"},
{"Controller", "Item"},
{"Action", "Remove"}
{"Controller", "Admin"},
{"Action", "Remove"},
{"Id", context.ContentItem.Id}
};
}
}

View File

@@ -61,6 +61,7 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\Models\CommonPartVersionRecord.cs" />
<Compile Include="Containers\Controllers\ItemController.cs" />
<Compile Include="Containers\Drivers\ContainablePartDriver.cs" />
<Compile Include="Containers\Drivers\ContainerPartDriver.cs" />
@@ -122,7 +123,6 @@
<Compile Include="Routable\IRoutablePathConstraint.cs" />
<Compile Include="Routable\Models\RoutePart.cs" />
<Compile Include="Common\Permissions.cs" />
<Compile Include="Common\Models\CommonPartVersionRecord.cs" />
<Compile Include="Common\Utilities\LazyField.cs" />
<Compile Include="Common\Handlers\CommonPartHandler.cs" />
<Compile Include="Common\Models\CommonPart.cs" />

View File

@@ -22,7 +22,7 @@ namespace Orchard.Core.Shapes {
var time = _clock.UtcNow - dateTimeUtc;
if (time.TotalDays > 7)
return Html.DateTime(dateTimeUtc, T("'on' MMM d yyyy 'at' h:mm tt"));
return Html.DateTime(dateTimeUtc.ToLocalTime(), T("'on' MMM d yyyy 'at' h:mm tt"));
if (time.TotalHours > 24)
return T.Plural("1 day ago", "{0} days ago", time.Days);
if (time.TotalMinutes > 60)

View File

@@ -60,7 +60,7 @@
<ItemGroup>
<Content Include="Content\Admin\images\scheduled.gif" />
<Content Include="Module.txt" />
<Content Include="Styles\datetime.css" />
<Content Include="Styles\orchard-archivelater-datetime.css" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Web.config" />

View File

@@ -7,7 +7,7 @@ using Orchard.UI.Resources;
namespace Orchard.ArchiveLater {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("ArchiveLater_DatePicker").SetUrl("datetime.css");
builder.Add().DefineStyle("ArchiveLater_DatePicker").SetUrl("orchard-archivelater-datetime.css");
}
}
}

View File

@@ -135,7 +135,7 @@ namespace Orchard.Blogs.Controllers {
public ActionResult List() {
var list = Services.New.List();
list.AddRange(_blogService.Get()
list.AddRange(_blogService.Get(VersionOptions.Latest)
.Select(b => {
var blog = Services.ContentManager.BuildDisplay(b, "SummaryAdmin");
blog.TotalPostCount = _blogPostService.Get(b, VersionOptions.Latest).Count();

View File

@@ -1,5 +1,7 @@
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Blogs.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
@@ -14,5 +16,30 @@ namespace Orchard.Blogs.Handlers {
context.Shape.PostCount = blog.PostCount;
});
}
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
var blog = context.ContentItem.As<BlogPart>();
if (blog == null)
return;
context.Metadata.CreateRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogAdmin"},
{"Action", "Create"}
};
context.Metadata.EditorRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogAdmin"},
{"Action", "Edit"},
{"Id", context.ContentItem.Id}
};
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogAdmin"},
{"Action", "Remove"},
{"Id", context.ContentItem.Id}
};
}
}
}

View File

@@ -6,18 +6,15 @@ using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Localization;
using Orchard.Core.Routable.Models;
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogPostPartHandler : ContentHandler {
private readonly IBlogPostService _blogPostService;
private readonly IOrchardServices _orchardServices;
public BlogPostPartHandler(IBlogService blogService, IBlogPostService blogPostService, IOrchardServices orchardServices, RequestContext requestContext) {
public BlogPostPartHandler(IBlogService blogService, IBlogPostService blogPostService, RequestContext requestContext) {
_blogPostService = blogPostService;
_orchardServices = orchardServices;
T = NullLocalizer.Instance;
Action<BlogPart> updateBlogPostCount =
(blog => {
@@ -65,6 +62,32 @@ namespace Orchard.Blogs.Handlers {
context.Shape.Blog = blogPost.BlogPart;
}
Localizer T { get; set; }
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
var blogPost = context.ContentItem.As<BlogPostPart>();
if (blogPost == null)
return;
context.Metadata.CreateRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogPostAdmin"},
{"Action", "Create"},
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug}
};
context.Metadata.EditorRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogPostAdmin"},
{"Action", "Edit"},
{"postId", context.ContentItem.Id},
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug}
};
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"},
{"Controller", "BlogPostAdmin"},
{"Action", "Delete"},
{"postId", context.ContentItem.Id},
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug}
};
}
}
}

View File

@@ -103,9 +103,9 @@
<Content Include="Content\Admin\images\published.gif" />
<Content Include="Content\Admin\images\scheduled.gif" />
<Content Include="Module.txt" />
<Content Include="Scripts\archives.js" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\archives.css" />
<Content Include="Scripts\orchard-blogs-archives.js" />
<Content Include="Styles\orchard-blogs-admin.css" />
<Content Include="Styles\orchard-blogs-archives.css" />
<Content Include="Views\BlogAdmin\Create.cshtml" />
<Content Include="Views\BlogAdmin\Edit.cshtml" />
<Content Include="Views\BlogAdmin\Item.cshtml" />
@@ -136,7 +136,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App_Data\Localization\fr-FR\orchard.module.po" />
<Content Include="Placement.info">
<SubType>Designer</SubType>
</Content>

View File

@@ -4,10 +4,10 @@ namespace Orchard.Blogs {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
manifest.DefineStyle("BlogsAdmin").SetUrl("admin.css");
manifest.DefineStyle("BlogsArchives").SetUrl("archives.css");
manifest.DefineStyle("BlogsAdmin").SetUrl("orchard-blogs-admin.css");
manifest.DefineStyle("BlogsArchives").SetUrl("orchard-blogs-archives.css");
manifest.DefineScript("BlogsArchives").SetUrl("archives.js").SetDependencies("jQuery");
manifest.DefineScript("BlogsArchives").SetUrl("orchard-blogs-archives.js").SetDependencies("jQuery");
}
}
}

View File

@@ -29,7 +29,11 @@ namespace Orchard.Blogs.Services {
}
public IEnumerable<BlogPart> Get() {
return _contentManager.Query<BlogPart, BlogPartRecord>()
return Get(VersionOptions.Published);
}
public IEnumerable<BlogPart> Get(VersionOptions versionOptions) {
return _contentManager.Query<BlogPart, BlogPartRecord>(versionOptions)
.Join<RoutePartRecord>()
.OrderBy(br => br.Title)
.List();

View File

@@ -7,6 +7,7 @@ namespace Orchard.Blogs.Services {
BlogPart Get(string slug);
ContentItem Get(int id, VersionOptions versionOptions);
IEnumerable<BlogPart> Get();
IEnumerable<BlogPart> Get(VersionOptions versionOptions);
void Delete(ContentItem blog);
}
}

View File

@@ -21,7 +21,6 @@
</div>
<div class="related">
@Display(Model.Actions)
<a href="@Url.Blog(blog)" title="@T("View")">@T("View")</a>@T(" | ")
<a href="@Url.BlogForAdmin(blog)" title="@T("List Posts")">@T("List Posts")</a>@T(" | ")
<a href="@Url.BlogPostCreate(blog)" title="@T("New Post")">@T("New Post")</a>@T(" | ")
<a href="@Url.BlogEdit(blog)" title="@T("Edit")">@T("Edit")</a>@T(" | ")

View File

@@ -7,8 +7,6 @@ using Orchard.Comments.ViewModels;
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.UI.Notify;
using Orchard.Utility.Extensions;
using System.Text.RegularExpressions;
namespace Orchard.Comments.Controllers {
public class CommentController : Controller {
@@ -33,16 +31,19 @@ namespace Orchard.Comments.Controllers {
: Redirect("~/");
var viewModel = new CommentsCreateViewModel();
if (TryUpdateModel(viewModel)) {
var context = new CreateCommentContext {
Author = viewModel.Name,
CommentText = viewModel.CommentText,
Email = viewModel.Email,
SiteName = viewModel.SiteName,
CommentedOn = viewModel.CommentedOn
};
TryUpdateModel(viewModel);
var context = new CreateCommentContext {
Author = viewModel.Name,
CommentText = viewModel.CommentText,
Email = viewModel.Email,
SiteName = viewModel.SiteName,
CommentedOn = viewModel.CommentedOn
};
if (ModelState.IsValid) {
if (!String.IsNullOrEmpty(context.SiteName) && !context.SiteName.StartsWith("http://") && !context.SiteName.StartsWith("https://")) {
context.SiteName = "http://" + context.SiteName;
}
@@ -58,6 +59,13 @@ namespace Orchard.Comments.Controllers {
}
}
if(!ModelState.IsValid) {
TempData["CreateCommentContext.Name"] = context.Author;
TempData["CreateCommentContext.CommentText"] = context.CommentText;
TempData["CreateCommentContext.Email"] = context.Email;
TempData["CreateCommentContext.SiteName"] = context.SiteName;
}
return !String.IsNullOrEmpty(returnUrl)
? Redirect(returnUrl)
: Redirect("~/");

View File

@@ -65,6 +65,7 @@
<Compile Include="Drivers\CommentsContainerPartDriver.cs" />
<Compile Include="Drivers\CommentSettingsPartDriver.cs" />
<Compile Include="Drivers\CommentsPartDriver.cs" />
<Compile Include="ResourceManifest.cs" />
<Compile Include="Shapes.cs" />
<Compile Include="Models\ClosedCommentsRecord.cs" />
<Compile Include="Models\CommentPart.cs" />
@@ -97,7 +98,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\orchard-comments-admin.css" />
<Content Include="Views\Admin\Details.cshtml" />
<Content Include="Views\Web.config" />
</ItemGroup>
@@ -126,7 +127,11 @@
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Styles\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.

View File

@@ -0,0 +1,10 @@
using Orchard.UI.Resources;
namespace Orchard.Comments {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
manifest.DefineStyle("Admin").SetUrl("orchard-comments-admin.css");
}
}
}

View File

@@ -75,7 +75,7 @@ namespace Orchard.Comments.Services {
comment.Record.CommentText = context.CommentText;
comment.Record.Email = context.Email;
comment.Record.SiteName = context.SiteName;
comment.Record.UserName = (_orchardServices.WorkContext.CurrentUser == null ? context.Author : _orchardServices.WorkContext.CurrentUser.UserName);
comment.Record.UserName = (_orchardServices.WorkContext.CurrentUser != null ? _orchardServices.WorkContext.CurrentUser.UserName : null);
comment.Record.CommentedOn = context.CommentedOn;
comment.Record.Status = _commentValidator.ValidateComment(comment)

View 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>

View File

@@ -1,3 +0,0 @@
table.items .actions {
white-space:nowrap;
}

View File

@@ -0,0 +1,13 @@
table.items .actions {
white-space:nowrap;
}
table.items tr {
background:#f7f7f7;
}
table.items tr.anonymous {
background:#fff;
}
.anonymous-commenter-id,
.authenticated-commenter-id {
font-style:italic;
}

View File

@@ -11,7 +11,7 @@
</div>
<div>
<label for="Email">@T("Email")</label>
<input id="Email" class="text" name="Email" type="text" value="@Model.Email" />
<input id="Email" class="text" name="Email" type="text" value="@Model.Email" />
</div>
<div>
<label for="SiteName">@T("Url")</label>

View File

@@ -4,7 +4,7 @@
@using Orchard.Mvc.Html;
@using Orchard.Utility.Extensions;
@{
Style.Include("admin.css");
Style.Require("Admin");
Script.Require("ShapesBase");
}
<h1>@Html.TitleForPage(T("Manage Comments").ToString())</h1>
@@ -53,7 +53,11 @@
</thead>
@{var commentIndex = 0;}
@foreach (var commentEntry in Model.Comments) {
<tr itemscope="itemscope" itemid="@Model.Comments[commentIndex].Comment.Id" itemtype="http://orchardproject.net/data/Comment">
var commentClass = "";
if (!HasText(commentEntry.Comment.UserName)) {
commentClass = "anonymous";
}
<tr itemscope="itemscope" itemid="@Model.Comments[commentIndex].Comment.Id" itemtype="http://orchardproject.net/data/Comment" class="@commentClass">
<td>
<input type="hidden" value="@Model.Comments[commentIndex].Comment.Id" name="@Html.NameOf(m => m.Comments[commentIndex].Comment.Id)"/>
<input type="checkbox" value="true" name="@Html.NameOf(m => m.Comments[commentIndex].IsChecked)"/>
@@ -63,7 +67,12 @@
else if (commentEntry.Comment.Status == CommentStatus.Pending) { @T("Pending") }
else { @T("Approved") }
</td>
<td>@commentEntry.Comment.UserName</td>
<td>
<div>@commentEntry.Comment.Author</div>
@if (HasText(commentEntry.Comment.UserName) && commentEntry.Comment.Author != commentEntry.Comment.UserName) {
<div class="authenticated-commenter-id">@commentEntry.Comment.UserName</div>
}
</td>
<td>
@* would ideally have permalinks for individual comments *@
<p><a href="@Url.ItemDisplayUrl(commentEntry.CommentedOn)#comments"><time>@Html.DateTime(commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</time></a></p>

View File

@@ -7,7 +7,7 @@
<article class="comment">
<header>
<h4>
<span class="who">@Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })
<span class="who">@Html.LinkOrDefault(comment.Record.Author, comment.Record.SiteName, new { rel = "nofollow" })
</span>
<span class="when">said <time datetime="@comment.Record.CommentDateUtc.GetValueOrDefault()">@Html.Link((string)Display.DateTimeRelative(dateTimeUtc: comment.Record.CommentDateUtc.GetValueOrDefault()).ToString(), "#")</time>
</span>

View File

@@ -3,6 +3,14 @@
@using Orchard.Security;
@using Orchard.Utility.Extensions;
@{
var contextExists = TempData["CreateCommentContext.Name"] != null;
var name = Convert.ToString(TempData["CreateCommentContext.Name"]);
var commentText = Convert.ToString(TempData["CreateCommentContext.CommentText"]);
var email = Convert.ToString(TempData["CreateCommentContext.Email"]);
var siteName = Convert.ToString(TempData["CreateCommentContext.SiteName"]);
}
@if (Model.ContentPart.Comments.Count > 0) {
<div id="comments">
<h2 class="comment-count">@T.Plural("1 Comment", "{0} Comments", (int)Model.ContentPart.Comments.Count)</h2>
@@ -30,15 +38,15 @@ using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, Fo
<ol>
<li>
<label for="Name">@T("Name")</label>
<input id="Name" class="text" name="Name" type="text" />
<input id="Name" class="text" name="Name" type="text" value="@(contextExists ? name : String.Empty)" />
</li>
<li>
<label for="Email">@T("Email")</label>
<input id="Email" class="text" name="Email" type="text" />
<input id="Email" class="text" name="Email" type="text" value="@(contextExists ? email : String.Empty)"/>
</li>
<li>
<label for="SiteName">@T("Url")</label>
<input id="SiteName" class="text" name="SiteName" type="text" />
<input id="SiteName" class="text" name="SiteName" type="text" value="@(contextExists ? siteName : String.Empty)"/>
</li>
</ol>
</fieldset>
@@ -52,7 +60,7 @@ using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, Fo
<ol>
<li>
<label for="comment-text">@T("Comment")</label>
<textarea id="comment-text" rows="10" cols="30" name="CommentText"></textarea>
<textarea id="comment-text" rows="10" cols="30" name="CommentText">@(contextExists ? commentText : String.Empty)</textarea>
</li>
<li>
<button class="primaryAction" type="submit">@T("Submit Comment")</button>

View File

@@ -52,13 +52,13 @@ namespace Orchard.ContentTypes.Controllers {
ModelState.AddModelError("DisplayName", T("A type with the same name already exists.").ToString());
}
var typeViewModel = _contentDefinitionService.AddType(viewModel);
if (!ModelState.IsValid) {
Services.TransactionManager.Cancel();
return View(viewModel);
}
var typeViewModel = _contentDefinitionService.AddType(viewModel);
Services.Notifier.Information(T("The \"{0}\" content type has been created.", typeViewModel.DisplayName));
return RedirectToAction("Edit", new { id = typeViewModel.Name });

View File

@@ -36,6 +36,7 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
@@ -71,7 +72,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\orchard-contenttypes-admin.css" />
<Content Include="Views\Admin\AddFieldTo.cshtml" />
<Content Include="Views\Admin\AddPartsTo.cshtml" />
<Content Include="Views\Admin\CreatePart.cshtml" />

View File

@@ -7,7 +7,7 @@ using Orchard.UI.Resources;
namespace Orchard.ContentTypes {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("ContentTypesAdmin").SetUrl("admin.css");
builder.Add().DefineStyle("ContentTypesAdmin").SetUrl("orchard-contenttypes-admin.css");
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
@@ -22,6 +23,7 @@ namespace Orchard.ContentTypes.ViewModels {
public string Prefix { get { return "PartDefinition"; } }
public string Name { get; set; }
private string _displayName;
[Required]
public string DisplayName {
get { return !string.IsNullOrWhiteSpace(_displayName) ? _displayName : Name.TrimEnd("Part").CamelFriendly(); }
set { _displayName = value; }

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
@@ -22,6 +23,7 @@ namespace Orchard.ContentTypes.ViewModels {
}
public string Name { get; set; }
[Required]
public string DisplayName { get; set; }
public SettingsDictionary Settings { get; set; }
public IEnumerable<EditPartFieldViewModel> Fields { get; set; }

View File

@@ -1,22 +1,30 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using Orchard.Commands;
using Orchard.Experimental.ViewModels;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.Themes;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
namespace Orchard.Experimental.Controllers {
[Themed, Admin, OrchardFeature("Orchard.Experimental.WebCommandLine")]
public class CommandsController : Controller {
private readonly ICommandManager _commandManager;
public CommandsController(ICommandManager commandManager) {
public CommandsController(ICommandManager commandManager, IOrchardServices services) {
_commandManager = commandManager;
Services = services;
T = NullLocalizer.Instance;
}
public IOrchardServices Services { get; set; }
public Localizer T { get; set; }
public ActionResult Index() {
return Execute();
}
@@ -27,16 +35,22 @@ namespace Orchard.Experimental.Controllers {
[HttpPost]
public ActionResult Execute(CommandsExecuteViewModel model) {
using (var writer = new StringWriter()) {
var commandLine = model.CommandLine.Trim();
CommandParameters parameters = GetCommandParameters(commandLine, writer);
try {
using (var writer = new StringWriter()) {
var commandLine = model.CommandLine.Trim();
CommandParameters parameters = GetCommandParameters(commandLine, writer);
_commandManager.Execute(parameters);
model.History = (model.History ?? Enumerable.Empty<string>())
.Concat(new[] { model.CommandLine })
.Distinct()
.ToArray();
model.Results = writer.ToString();
_commandManager.Execute(parameters);
model.History = (model.History ?? Enumerable.Empty<string>())
.Concat(new[] {model.CommandLine})
.Distinct()
.ToArray();
model.Results = writer.ToString();
}
}
catch(Exception exception) {
Services.Notifier.Error(T("Error executing command: {0}", exception.Message));
Services.TransactionManager.Cancel();
}
return View(model);
}

View File

@@ -61,8 +61,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\base.css" />
<Content Include="Styles\orchard-localization-admin.css" />
<Content Include="Styles\orchard-localization-base.css" />
</ItemGroup>
<ItemGroup>
<Content Include="Styles\Web.config">

View File

@@ -4,8 +4,8 @@ namespace Orchard.Localization {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
manifest.DefineStyle("Localization").SetUrl("base.css");
manifest.DefineStyle("LocalizationAdmin").SetUrl("admin.css");
manifest.DefineStyle("Localization").SetUrl("orchard-localization-base.css");
manifest.DefineStyle("LocalizationAdmin").SetUrl("orchard-localization-admin.css");
}
}
}

View File

@@ -1,5 +1,5 @@
@model AddLocalizationViewModel
@using Orchard.Core.Localization.ViewModels;
@using Orchard.Localization.ViewModels;
@{
dynamic content = Model.Content;
content.Zones.Content.Add(New.Partial(TemplateName: "CultureSelection", Model: Model), "0");

View File

@@ -1,4 +1,4 @@
@model Orchard.Core.Localization.ViewModels.AddLocalizationViewModel
@model Orchard.Localization.ViewModels.AddLocalizationViewModel
@{
Style.Require("LocalizationAdmin");
}

View File

@@ -1,4 +1,4 @@
@model Orchard.Core.Localization.ViewModels.EditLocalizationViewModel
@model Orchard.Localization.ViewModels.EditLocalizationViewModel
@if (Model.ContentItem.ContentItem.Id > 0 && Model.SelectedCulture != null && Model.ContentLocalizations.Localizations.Count() > 0) {
Style.Require("LocalizationAdmin");
<fieldset class="localization culture-selection">

View File

@@ -1,5 +1,5 @@
@using Orchard.Core.Contents;
@using Orchard.Core.Localization.Models;
@using Orchard.Localization.Models;
@if (AuthorizedFor(Permissions.PublishContent)) {
Style.Require("LocalizationAdmin");
IEnumerable<LocalizationPart> localizations = Model.Localizations;

View File

@@ -1,5 +1,5 @@
@using Orchard.Core.Contents;
@using Orchard.Core.Localization.Models;
@using Orchard.Localization.Models;
@if (AuthorizedFor(Permissions.PublishContent)) {
Style.Require("LocalizationAdmin");
IEnumerable<LocalizationPart> localizations = Model.Localizations;
@@ -8,6 +8,6 @@ var localizationLinks = Html.UnorderedList(localizations, (c, i) => Html.ItemEdi
@if (localizations.Count() > 0) {
<div class="content-localizations"><h4>@T("Translations:")</h4>@localizationLinks</div>
}
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Localization", id = Model.MasterId }, null)</div>
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.MasterId }, null)</div>
</div>
}

View File

@@ -1,4 +1,4 @@
@using Orchard.Core.Localization.Models;
@using Orchard.Localization.Models;
@{
Style.Require("Localization");
IEnumerable<LocalizationPart> localizations = Model.Localizations;

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using Orchard.Media.Models;
namespace Orchard.Media.Helpers {
@@ -9,12 +10,12 @@ namespace Orchard.Media.Helpers {
if (String.IsNullOrEmpty(mediaPath)) {
return navigations;
}
if (!mediaPath.Contains("\\")) {
if ( !mediaPath.Contains(Path.DirectorySeparatorChar.ToString()) && !mediaPath.Contains(Path.AltDirectorySeparatorChar.ToString()) ) {
navigations.Add(new FolderNavigation { FolderName = mediaPath, FolderPath = mediaPath });
return navigations;
}
string[] navigationParts = mediaPath.Split(new[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
string[] navigationParts = mediaPath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries);
string currentPath = String.Empty;
foreach (string navigationPart in navigationParts) {
currentPath = (string.IsNullOrEmpty(currentPath) ? navigationPart : currentPath + "\\" + navigationPart);

View File

@@ -81,7 +81,7 @@
<ItemGroup>
<Content Include="Content\Admin\images\folder.gif" />
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\orchard-media-admin.css" />
<Content Include="Content\Site.css" />
<Content Include="Views\Web.config" />
</ItemGroup>

View File

@@ -1,11 +1,9 @@
using Orchard.Localization;
using Orchard.UI.Navigation;
using Orchard.UI.Resources;
using Orchard.UI.Resources;
namespace Orchard.Media {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("MediaAdmin").SetUrl("admin.css");
builder.Add().DefineStyle("MediaAdmin").SetUrl("orchard-media-admin.css");
}
}
}

View File

@@ -66,7 +66,7 @@ namespace Orchard.Media.Services {
_storageProvider.CreateFolder(name);
return;
}
_storageProvider.CreateFolder(mediaPath + "\\" + name);
_storageProvider.CreateFolder(_storageProvider.Combine(mediaPath, name));
}
public void DeleteFolder(string name) {
@@ -79,12 +79,12 @@ namespace Orchard.Media.Services {
}
public void DeleteFile(string name, string folderName) {
_storageProvider.DeleteFile(folderName + "\\" + name);
_storageProvider.DeleteFile(_storageProvider.Combine(folderName, name));
}
public void RenameFile(string name, string newName, string folderName) {
if (FileAllowed(newName, false)) {
_storageProvider.RenameFile(folderName + "\\" + name, folderName + "\\" + newName);
_storageProvider.RenameFile(_storageProvider.Combine(folderName, name), _storageProvider.Combine(folderName, newName));
}
}
@@ -193,14 +193,14 @@ namespace Orchard.Media.Services {
}
}
private static string RenameFolderPath(string path, string newName) {
var lastIndex = path.LastIndexOf("\\");
private string RenameFolderPath(string path, string newName) {
var lastIndex = Math.Max(path.LastIndexOf(Path.DirectorySeparatorChar), path.LastIndexOf(Path.AltDirectorySeparatorChar));
if (lastIndex == -1) {
return newName;
}
return path.Substring(0, lastIndex) + "\\" + newName;
return _storageProvider.Combine(path.Substring(0, lastIndex), newName);
}
}
}

View File

@@ -8,7 +8,7 @@
<p>@Html.ActionLink(T("Media Folders").ToString(), "Index") &#62;
@foreach (FolderNavigation navigation in MediaHelpers.GetFolderNavigationHierarchy(Model.MediaPath)) {
@Html.ActionLink(navigation.FolderName, "Edit",
new {name = navigation.FolderName, mediaPath = navigation.FolderPath})
new {name = navigation.FolderName, mediaPath = navigation.FolderPath}) <text>&#62;</text>
}
@T("Folder Properties")</p>

View File

@@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using Orchard.Commands;
using Orchard.Data.Migration;
using Orchard.Data.Migration.Generator;
using Orchard.Data.Migration.Interpreters;
using Orchard.Environment.Extensions;
namespace Orchard.Migrations.Commands {
@@ -44,60 +42,4 @@ namespace Orchard.Migrations.Commands {
return "Database upgraded";
}
}
[OrchardFeature("DatabaseUpdate")]
public class DatabaseUpdateCommands : DefaultOrchardCommandHandler {
private readonly IDataMigrationInterpreter _dataMigrationInterpreter;
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
[OrchardSwitch]
public bool Drop { get; set; }
public DatabaseUpdateCommands(
IDataMigrationInterpreter dataMigrationInterpreter,
ISchemaCommandGenerator schemaCommandGenerator
) {
_dataMigrationInterpreter = dataMigrationInterpreter;
_schemaCommandGenerator = schemaCommandGenerator;
}
[CommandName("update database")]
[CommandHelp("update database \r\n\t" + "Automatically updates the database schema for the enabled features")]
public string UpdateDatabase() {
try {
_schemaCommandGenerator.UpdateDatabase();
}
catch ( Exception ex ) {
Context.Output.WriteLine(T("An error occured while updating the database: " + ex.Message));
return "Update terminated.";
}
return "Database updated";
}
[CommandName("create tables")]
[CommandHelp("create tables <feature-name> [/Drop:true|false] \r\n\t" + "Creates the database tables for the <feature-name> and optionally drops them before if specified")]
[OrchardSwitches("Drop")]
public string CreateTables(string featureName) {
var stringInterpreter = new StringCommandInterpreter(Context.Output);
try {
var commands = _schemaCommandGenerator.GetCreateFeatureCommands(featureName, Drop).ToList();
if ( commands.Any() ) {
foreach (var command in commands) {
stringInterpreter.Visit(command);
_dataMigrationInterpreter.Visit(command);
}
}
else {
return "There are no tables to create for this feature.";
}
}
catch ( Exception ex ) {
Context.Output.WriteLine(T("An error occured while creating the tables: " + ex.Message));
return "Tables creation terminated.";
}
return "Tables created";
}
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Linq;
using Orchard.Commands;
using Orchard.Data.Migration.Generator;
using Orchard.Data.Migration.Interpreters;
using Orchard.Environment.Extensions;
namespace Orchard.Migrations.Commands {
[OrchardFeature("DatabaseUpdate")]
public class DatabaseUpdateCommands : DefaultOrchardCommandHandler {
private readonly IDataMigrationInterpreter _dataMigrationInterpreter;
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
[OrchardSwitch]
public bool Drop { get; set; }
public DatabaseUpdateCommands(
IDataMigrationInterpreter dataMigrationInterpreter,
ISchemaCommandGenerator schemaCommandGenerator
) {
_dataMigrationInterpreter = dataMigrationInterpreter;
_schemaCommandGenerator = schemaCommandGenerator;
}
[CommandName("update database")]
[CommandHelp("update database \r\n\t" + "Automatically updates the database schema according to the defintion of the \"Record\" types in code for the enabled features.")]
public string UpdateDatabase() {
try {
_schemaCommandGenerator.UpdateDatabase();
}
catch ( Exception ex ) {
Context.Output.WriteLine(T("An error occured while updating the database: " + ex.Message));
return "Update terminated.";
}
return "Database updated";
}
[CommandName("create tables")]
[CommandHelp("create tables <feature-name> [/Drop:true|false] \r\n\t" + "Creates the database tables according to the defintion of the \"Record\" types in code for the <feature-name> and optionally drops them before if specified.")]
[OrchardSwitches("Drop")]
public string CreateTables(string featureName) {
var stringInterpreter = new StringCommandInterpreter(Context.Output);
try {
var commands = _schemaCommandGenerator.GetCreateFeatureCommands(featureName, Drop).ToList();
if ( commands.Any() ) {
foreach (var command in commands) {
stringInterpreter.Visit(command);
_dataMigrationInterpreter.Visit(command);
}
}
else {
return "There are no tables to create for this feature.";
}
}
catch ( Exception ex ) {
Context.Output.WriteLine(T("An error occured while creating the tables: " + ex.Message));
return "Tables creation terminated.";
}
return "Tables created";
}
}
}

View File

@@ -9,3 +9,6 @@ Features:
Orchard.Migrations:
Description: Data migration commands.
Category: Developer
DatabaseUpdate:
Description: Commands for updating the database schema according to the definition of the "Record" classes in code.
Category: Developer

View File

@@ -46,6 +46,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\DatabaseUpdateCommands.cs" />
<Compile Include="Commands\DataMigrationCommands.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -83,7 +83,7 @@
<ItemGroup>
<Content Include="Content\Admin\images\disabled.gif" />
<Content Include="Content\Admin\images\enabled.gif" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\orchard-modules-admin.css" />
<Content Include="Views\Admin\Features.cshtml" />
<Content Include="Views\Web.config" />
</ItemGroup>

View File

@@ -7,7 +7,7 @@ using Orchard.UI.Resources;
namespace Orchard.Modules {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("ModulesAdmin").SetUrl("admin.css");
builder.Add().DefineStyle("ModulesAdmin").SetUrl("orchard-modules-admin.css");
}
}
}

View File

@@ -70,7 +70,7 @@
<Content Include="Content\Admin\images\disabled.gif" />
<Content Include="Content\Admin\images\enabled.gif" />
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\orchard-multitenancy-admin.css" />
<Content Include="Views\Admin\Add.cshtml" />
<Content Include="Views\Admin\Edit.cshtml" />
<Content Include="Views\Admin\DisplayTemplates\ActionsForUninitialized.cshtml" />

View File

@@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.UI.Resources;
namespace Orchard.MultiTenancy {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("MultiTenancyAdmin").SetUrl("admin.css");
builder.Add().DefineStyle("MultiTenancyAdmin").SetUrl("orchard-multitenancy-admin.css");
}
}
}

View File

@@ -87,7 +87,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\orchard-packaging-admin.css" />
<Content Include="Views\Gallery\AddSource.cshtml" />
<Content Include="Views\Gallery\Modules.cshtml" />
<Content Include="Views\Gallery\Sources.cshtml" />

View File

@@ -5,7 +5,7 @@ namespace Orchard.Packaging {
[OrchardFeature("Gallery")]
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("PackagingAdmin").SetUrl("admin.css");
builder.Add().DefineStyle("PackagingAdmin").SetUrl("orchard-packaging-admin.css");
}
}
}

View File

@@ -83,7 +83,7 @@
<Content Include="Content\Admin\images\published.gif" />
<Content Include="Content\Admin\images\scheduled.gif" />
<Content Include="Module.txt" />
<Content Include="Styles\datetime.css" />
<Content Include="Styles\orchard-publishlater-datetime.css" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\EditorTemplates\Parts\PublishLater.cshtml" />

View File

@@ -7,7 +7,7 @@ using Orchard.UI.Resources;
namespace Orchard.PublishLater {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("PublishLater_DatePicker").SetUrl("datetime.css");
builder.Add().DefineStyle("PublishLater_DatePicker").SetUrl("orchard-publishlater-datetime.css");
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.PublishLater.Models;
namespace Orchard.PublishLater.ViewModels {
@@ -30,8 +29,6 @@ namespace Orchard.PublishLater.ViewModels {
get { return IsPublished || ContentItem.ContentManager.Get(ContentItem.Id, VersionOptions.Published) != null; }
}
public DateTime? VersionPublishedUtc { get { return ContentItem.As<CommonPart>() == null ? null : ContentItem.As<CommonPart>().VersionPublishedUtc; } }
public DateTime? ScheduledPublishUtc { get; set; }
public string ScheduledPublishDate { get; set; }

View File

@@ -3,8 +3,8 @@
@using Orchard.PublishLater.Models;
@{
PublishLaterPart publishLaterPart = Model.ContentPart;
DateTime? versionPublishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().VersionPublishedUtc;
DateTime? publishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().PublishedUtc;
}
@if (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue) {
@T("Published: {0}", Display.DateTimeRelative(dateTimeUtc: versionPublishedUtc.Value)) @T(" | ")
@if (publishLaterPart.IsPublished() && publishedUtc.HasValue) {
@T("Published: {0}", Display.DateTimeRelative(dateTimeUtc: publishedUtc.Value)) @T(" | ")
}

View File

@@ -3,8 +3,8 @@
@using Orchard.PublishLater.Models;
@{
PublishLaterPart publishLaterPart = Model.ContentPart;
DateTime? versionPublishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().VersionPublishedUtc;
DateTime? publishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().PublishedUtc;
}
@if (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue) {
@T("Published: {0}", Display.DateTimeRelative(dateTimeUtc: versionPublishedUtc.Value))
@if (publishLaterPart.IsPublished() && publishedUtc.HasValue) {
@T("Published: {0}", Display.DateTimeRelative(dateTimeUtc: publishedUtc.Value))
}

View File

@@ -1,9 +1,11 @@
using System.Linq;
using System;
using System.Linq;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Indexing;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Search.Services;
using Orchard.Search.ViewModels;
using Orchard.Search.Models;
@@ -29,26 +31,29 @@ namespace Orchard.Search.Controllers {
_contentManager = contentManager;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
Shape = shapeFactory;
}
private IOrchardServices Services { get; set; }
public Localizer T { get; set; }
public ILogger Logger { get; set; }
dynamic Shape { get; set; }
public ActionResult Index(Pager pager, string q = "") {
var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;
IPageOfItems<ISearchHit> searchHits;
if (q.Trim().StartsWith("?") || q.Trim().StartsWith("*")) {
searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
Services.Notifier.Error(T("'*' or '?' not allowed as first character in WildcardQuery"));
}
else {
IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
try {
searchHits = _searchService.Query(q, pager.Page, pager.PageSize,
Services.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
searchFields,
searchHit => searchHit);
Services.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
searchFields,
searchHit => searchHit);
}
catch(Exception e) {
Services.Notifier.Error(T("Invalid search query: {0}", q));
Logger.Error(e, "Invalid search query: " + q);
}
var list = Shape.List();

View File

@@ -70,8 +70,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Styles\search.css" />
<Content Include="Styles\orchard-search-admin.css" />
<Content Include="Styles\orchard-search-search.css" />
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>

View File

@@ -7,8 +7,8 @@ using Orchard.UI.Resources;
namespace Orchard.Search {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("SearchAdmin").SetUrl("admin.css"); // todo: this does not appear to be used anywhere
builder.Add().DefineStyle("Search").SetUrl("search.css");
builder.Add().DefineStyle("SearchAdmin").SetUrl("orchard-search-admin.css"); // todo: this does not appear to be used anywhere
builder.Add().DefineStyle("Search").SetUrl("orchard-search-search.css");
}
}
}

Some files were not shown because too many files have changed in this diff Show More