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:
15
Orchard.proj
15
Orchard.proj
@@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
<Target Name="Clean">
|
<Target Name="Clean">
|
||||||
<MSBuild Projects="$(SrcFolder)\Orchard.sln" Targets="Clean" />
|
<MSBuild Projects="$(SrcFolder)\Orchard.sln" Targets="Clean" />
|
||||||
<RemoveDir Directories="$(BuildFolder)" />
|
<RemoveDir Directories="$(BuildFolder)" ContinueOnError="true"/>
|
||||||
<RemoveDir Directories="$(ArtifactsFolder)" />
|
<RemoveDir Directories="$(ArtifactsFolder)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
<Target Name="Package-Stage">
|
<Target Name="Package-Stage">
|
||||||
<CallTarget Targets="CompileMsBuildTasks"/>
|
<CallTarget Targets="CompileMsBuildTasks"/>
|
||||||
<CallTarget Targets="ValidateProjectFiles"/>
|
<CallTarget Targets="ValidateProjectFiles"/>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<SqlCe-Native-Binaries-x86 Include="$(SqlCeFolder)\x86\*"/>
|
<SqlCe-Native-Binaries-x86 Include="$(SqlCeFolder)\x86\*"/>
|
||||||
<SqlCe-Native-Binaries-amd64 Include="$(SqlCeFolder)\amd64\*"/>
|
<SqlCe-Native-Binaries-amd64 Include="$(SqlCeFolder)\amd64\*"/>
|
||||||
@@ -293,10 +293,18 @@
|
|||||||
|
|
||||||
<Copy SourceFiles="@(Profiling-Web)" DestinationFolder="$(ProfilingFolder)\%(RecursiveDir)"/>
|
<Copy SourceFiles="@(Profiling-Web)" DestinationFolder="$(ProfilingFolder)\%(RecursiveDir)"/>
|
||||||
|
|
||||||
|
<XmlUpdate XmlFileName="$(ProfilingFolder)\web.config"
|
||||||
|
XPath="/configuration/system.web/trust/@level"
|
||||||
|
Value="Full" />
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="Profiling-Setup">
|
<Target Name="Profiling-Setup">
|
||||||
<Exec Command="$(ProfilingFolder)\bin\Orchard.exe @$(SrcFolder)\Orchard.Profile\profiling-setup-commands.txt" WorkingDirectory="$(ProfilingFolder)"/>
|
<ReadLinesFromFile File="$(SrcFolder)\Orchard.Profile\profiling-setup-commands.txt">
|
||||||
|
<Output TaskParameter="Lines" ItemName="ProfilingSetupCommands"/>
|
||||||
|
</ReadLinesFromFile>
|
||||||
|
|
||||||
|
<Exec Command="$(ProfilingFolder)\bin\Orchard.exe %(ProfilingSetupCommands.Identity)" WorkingDirectory="$(ProfilingFolder)"/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<!-- Gallery Packaging -->
|
<!-- Gallery Packaging -->
|
||||||
@@ -307,7 +315,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Copy SourceFiles="@(Gallery-Web)" DestinationFolder="$(GalleryFolder)\%(RecursiveDir)"/>
|
<Copy SourceFiles="@(Gallery-Web)" DestinationFolder="$(GalleryFolder)\%(RecursiveDir)"/>
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="Gallery-Setup">
|
<Target Name="Gallery-Setup">
|
||||||
|
@@ -46,7 +46,7 @@ namespace Orchard.Core.Tests.Routable.Services {
|
|||||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||||
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
|
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||||
|
|
||||||
builder.RegisterType<ThingHandler>().As<IContentHandler>();
|
builder.RegisterType<ThingHandler>().As<IContentHandler>();
|
||||||
|
@@ -22,5 +22,8 @@ Scenario: Hitting blogs
|
|||||||
When I go to "/blog4" 10 times
|
When I go to "/blog4" 10 times
|
||||||
|
|
||||||
Scenario: Hitting home page
|
Scenario: Hitting home page
|
||||||
Given I am logged in
|
//Given I am logged in
|
||||||
When I go to "/" 40 times
|
When I go to "/" 10 times
|
||||||
|
When I go to "/" 10 times
|
||||||
|
When I go to "/" 10 times
|
||||||
|
When I go to "/" 10 times
|
||||||
|
42
src/Orchard.Profile/Tests/Profiling.feature.cs
generated
42
src/Orchard.Profile/Tests/Profiling.feature.cs
generated
@@ -1,7 +1,7 @@
|
|||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by SpecFlow (http://www.specflow.org/).
|
// This code was generated by SpecFlow (http://www.specflow.org/).
|
||||||
// SpecFlow Version:1.3.2.0
|
// SpecFlow Version:1.4.0.0
|
||||||
// Runtime Version:4.0.30319.1
|
// Runtime Version:4.0.30319.1
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
#region Designer generated code
|
#region Designer generated code
|
||||||
namespace Orchard.Specs.Le.Tests
|
namespace Orchard.Profile.Tests
|
||||||
{
|
{
|
||||||
using TechTalk.SpecFlow;
|
using TechTalk.SpecFlow;
|
||||||
|
|
||||||
|
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.4.0.0")]
|
||||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[NUnit.Framework.TestFixtureAttribute()]
|
[NUnit.Framework.TestFixtureAttribute()]
|
||||||
[NUnit.Framework.DescriptionAttribute("Profiling")]
|
[NUnit.Framework.DescriptionAttribute("Profiling")]
|
||||||
@@ -31,7 +31,7 @@ namespace Orchard.Specs.Le.Tests
|
|||||||
{
|
{
|
||||||
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
|
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
|
||||||
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Profiling", "In order to profile the site\r\nAs a developer\r\nI want to generate a fixed number o" +
|
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Profiling", "In order to profile the site\r\nAs a developer\r\nI want to generate a fixed number o" +
|
||||||
"f repeatable requests", ((string[])(null)));
|
"f repeatable requests", GenerationTargetLanguage.CSharp, ((string[])(null)));
|
||||||
testRunner.OnFeatureStart(featureInfo);
|
testRunner.OnFeatureStart(featureInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,13 +61,13 @@ namespace Orchard.Specs.Le.Tests
|
|||||||
#line 6
|
#line 6
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 7
|
#line 7
|
||||||
testRunner.Given("I am logged in");
|
testRunner.Given("I am logged in");
|
||||||
#line 8
|
#line 8
|
||||||
testRunner.When("I go to \"/admin\"");
|
testRunner.When("I go to \"/admin\"");
|
||||||
#line 9
|
#line 9
|
||||||
testRunner.When("I go to \"/blog0\"");
|
testRunner.When("I go to \"/blog0\"");
|
||||||
#line 10
|
#line 10
|
||||||
testRunner.When("I go to \"/\"");
|
testRunner.When("I go to \"/\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
@@ -80,9 +80,9 @@ testRunner.When("I go to \"/\"");
|
|||||||
#line 12
|
#line 12
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 13
|
#line 13
|
||||||
testRunner.Given("I am logged in");
|
testRunner.Given("I am logged in");
|
||||||
#line 14
|
#line 14
|
||||||
testRunner.When("I go to \"/admin\" 40 times");
|
testRunner.When("I go to \"/admin\" 40 times");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
@@ -95,17 +95,17 @@ testRunner.When("I go to \"/admin\" 40 times");
|
|||||||
#line 16
|
#line 16
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 17
|
#line 17
|
||||||
testRunner.Given("I am logged in");
|
testRunner.Given("I am logged in");
|
||||||
#line 18
|
#line 18
|
||||||
testRunner.When("I go to \"/blog0\" 10 times");
|
testRunner.When("I go to \"/blog0\" 10 times");
|
||||||
#line 19
|
#line 19
|
||||||
testRunner.When("I go to \"/blog1\" 10 times");
|
testRunner.When("I go to \"/blog1\" 10 times");
|
||||||
#line 20
|
#line 20
|
||||||
testRunner.When("I go to \"/blog2\" 10 times");
|
testRunner.When("I go to \"/blog2\" 10 times");
|
||||||
#line 21
|
#line 21
|
||||||
testRunner.When("I go to \"/blog3\" 10 times");
|
testRunner.When("I go to \"/blog3\" 10 times");
|
||||||
#line 22
|
#line 22
|
||||||
testRunner.When("I go to \"/blog4\" 10 times");
|
testRunner.When("I go to \"/blog4\" 10 times");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,14 @@ testRunner.When("I go to \"/blog4\" 10 times");
|
|||||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Hitting home page", ((string[])(null)));
|
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Hitting home page", ((string[])(null)));
|
||||||
#line 24
|
#line 24
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 25
|
|
||||||
testRunner.Given("I am logged in");
|
|
||||||
#line 26
|
#line 26
|
||||||
testRunner.When("I go to \"/\" 40 times");
|
testRunner.When("I go to \"/\" 10 times");
|
||||||
|
#line 27
|
||||||
|
testRunner.When("I go to \"/\" 10 times");
|
||||||
|
#line 28
|
||||||
|
testRunner.When("I go to \"/\" 10 times");
|
||||||
|
#line 29
|
||||||
|
testRunner.When("I go to \"/\" 10 times");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
|
@@ -17,11 +17,12 @@ namespace Orchard.Specs.Bindings {
|
|||||||
public void GivenIHaveInstalledOrchard(string virtualDirectory) {
|
public void GivenIHaveInstalledOrchard(string virtualDirectory) {
|
||||||
var webApp = Binding<WebAppHosting>();
|
var webApp = Binding<WebAppHosting>();
|
||||||
|
|
||||||
webApp.GivenIHaveACleanSiteWith(TableData(
|
webApp.GivenIHaveACleanSiteWith(
|
||||||
|
virtualDirectory,
|
||||||
|
TableData(
|
||||||
new { extension = "module", names = "Orchard.Setup, Orchard.Pages, Orchard.Blogs, Orchard.Messaging, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce" },
|
new { extension = "module", names = "Orchard.Setup, Orchard.Pages, Orchard.Blogs, Orchard.Messaging, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce" },
|
||||||
new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, Routable, Scheduling, Settings, Shapes, XmlRpc" },
|
new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, Routable, Scheduling, Settings, Shapes, XmlRpc" },
|
||||||
new { extension = "theme", names = "SafeMode, TheAdmin, TheThemeMachine" }),
|
new { extension = "theme", names = "SafeMode, TheAdmin, TheThemeMachine" }));
|
||||||
virtualDirectory);
|
|
||||||
|
|
||||||
webApp.WhenIGoTo("Setup");
|
webApp.WhenIGoTo("Setup");
|
||||||
|
|
||||||
|
@@ -74,7 +74,7 @@ namespace Orchard.Specs.Bindings {
|
|||||||
GivenIHaveACleanSiteBasedOn(siteFolder, "/");
|
GivenIHaveACleanSiteBasedOn(siteFolder, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Given(@"I have a clean site based on (.*) at ""(.*)\""")]
|
[Given(@"I have a clean site based on (.*) at ""(.*)""")]
|
||||||
public void GivenIHaveACleanSiteBasedOn(string siteFolder, string virtualDirectory) {
|
public void GivenIHaveACleanSiteBasedOn(string siteFolder, string virtualDirectory) {
|
||||||
_webHost = new WebHost(_orchardTemp);
|
_webHost = new WebHost(_orchardTemp);
|
||||||
Host.Initialize(siteFolder, virtualDirectory ?? "/");
|
Host.Initialize(siteFolder, virtualDirectory ?? "/");
|
||||||
@@ -129,7 +129,13 @@ namespace Orchard.Specs.Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Given(@"I have a clean site with")]
|
[Given(@"I have a clean site with")]
|
||||||
public void GivenIHaveACleanSiteWith(Table table, string virtualDirectory = "/") {
|
public void GivenIHaveACleanSiteWith(Table table) {
|
||||||
|
GivenIHaveACleanSiteWith("/", table);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Given(@"I have a clean site at ""(.*)"" with")]
|
||||||
|
public void GivenIHaveACleanSiteWith(string virtualDirectory, Table table) {
|
||||||
GivenIHaveACleanSite(virtualDirectory);
|
GivenIHaveACleanSite(virtualDirectory);
|
||||||
foreach (var row in table.Rows) {
|
foreach (var row in table.Rows) {
|
||||||
foreach (var name in row["names"].Split(',').Select(x => x.Trim())) {
|
foreach (var name in row["names"].Split(',').Select(x => x.Trim())) {
|
||||||
@@ -207,6 +213,23 @@ namespace Orchard.Specs.Bindings {
|
|||||||
else if (radio.Attributes.Contains("checked"))
|
else if (radio.Attributes.Contains("checked"))
|
||||||
radio.Attributes.Remove("checked");
|
radio.Attributes.Remove("checked");
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "checkbox":
|
||||||
|
if (string.Equals(row["value"], "true", StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
input.Attributes.Add("checked", "checked");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
input.Attributes.Remove("checked");
|
||||||
|
}
|
||||||
|
|
||||||
|
var hiddenForCheckbox = inputs.Where(
|
||||||
|
x =>
|
||||||
|
x.GetAttributeValue("type", "") == "hidden" &&
|
||||||
|
x.GetAttributeValue("name", x.GetAttributeValue("id", "")) == r["name"]
|
||||||
|
).FirstOrDefault();
|
||||||
|
if (hiddenForCheckbox != null)
|
||||||
|
hiddenForCheckbox.Attributes.Add("value", row["value"]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
input.Attributes.Add("value", row["value"]);
|
input.Attributes.Add("value", row["value"]);
|
||||||
|
@@ -39,4 +39,30 @@ Scenario: If I create a page which gets a conflicting path generated its path is
|
|||||||
And I hit "Publish Now"
|
And I hit "Publish Now"
|
||||||
And I go to "super-duper-2"
|
And I go to "super-duper-2"
|
||||||
Then I should see "<h1[^>]*>.*?Super Duper.*?</h1>"
|
Then I should see "<h1[^>]*>.*?Super Duper.*?</h1>"
|
||||||
And I should see "This is super number two."
|
And I should see "This is super number two."
|
||||||
|
|
||||||
|
Scenario: A new page marked to be the home page and publish does take over the home page and is not accessible from its own standard path.
|
||||||
|
Given I have installed Orchard
|
||||||
|
When I go to "admin/contents/create/page"
|
||||||
|
And I fill in
|
||||||
|
| name | value |
|
||||||
|
| Routable.Title | Super Duper |
|
||||||
|
| Body.Text | This is a draft of the new home page. |
|
||||||
|
| Routable.PromoteToHomePage | true |
|
||||||
|
And I hit "Publish Now"
|
||||||
|
And I go to "/Default.aspx"
|
||||||
|
Then I should see "<h1>Super Duper</h1>"
|
||||||
|
When I go to "super-duper"
|
||||||
|
Then the status should be 404 "Not Found"
|
||||||
|
|
||||||
|
Scenario: A new page marked to be the home page but only saved as draft does not take over the home page
|
||||||
|
Given I have installed Orchard
|
||||||
|
When I go to "admin/contents/create/page"
|
||||||
|
And I fill in
|
||||||
|
| name | value |
|
||||||
|
| Routable.Title | Drafty |
|
||||||
|
| Body.Text | This is a draft of the new home page. |
|
||||||
|
| Routable.PromoteToHomePage | true |
|
||||||
|
And I hit "Save"
|
||||||
|
And I go to "/Default.aspx"
|
||||||
|
Then I should see "<h1>Welcome to Orchard!</h1>"
|
||||||
|
132
src/Orchard.Specs/Pages.feature.cs
generated
132
src/Orchard.Specs/Pages.feature.cs
generated
@@ -1,7 +1,7 @@
|
|||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by SpecFlow (http://www.specflow.org/).
|
// This code was generated by SpecFlow (http://www.specflow.org/).
|
||||||
// SpecFlow Version:1.3.2.0
|
// SpecFlow Version:1.4.0.0
|
||||||
// Runtime Version:4.0.30319.1
|
// Runtime Version:4.0.30319.1
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
@@ -14,7 +14,7 @@ namespace Orchard.Specs
|
|||||||
using TechTalk.SpecFlow;
|
using TechTalk.SpecFlow;
|
||||||
|
|
||||||
|
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.4.0.0")]
|
||||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[NUnit.Framework.TestFixtureAttribute()]
|
[NUnit.Framework.TestFixtureAttribute()]
|
||||||
[NUnit.Framework.DescriptionAttribute("Pages")]
|
[NUnit.Framework.DescriptionAttribute("Pages")]
|
||||||
@@ -31,7 +31,7 @@ namespace Orchard.Specs
|
|||||||
{
|
{
|
||||||
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
|
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
|
||||||
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Pages", "In order to add content pages to my site\r\nAs an author\r\nI want to create, publish" +
|
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Pages", "In order to add content pages to my site\r\nAs an author\r\nI want to create, publish" +
|
||||||
" and edit pages", ((string[])(null)));
|
" and edit pages", GenerationTargetLanguage.CSharp, ((string[])(null)));
|
||||||
testRunner.OnFeatureStart(featureInfo);
|
testRunner.OnFeatureStart(featureInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +61,11 @@ namespace Orchard.Specs
|
|||||||
#line 6
|
#line 6
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 7
|
#line 7
|
||||||
testRunner.Given("I have installed Orchard");
|
testRunner.Given("I have installed Orchard");
|
||||||
#line 8
|
#line 8
|
||||||
testRunner.When("I go to \"admin\"");
|
testRunner.When("I go to \"admin\"");
|
||||||
#line 9
|
#line 9
|
||||||
testRunner.Then("I should see \"<a href=\"/Admin/Contents/Create/Page\">Page</a>\"");
|
testRunner.Then("I should see \"<a href=\"/Admin/Contents/Create/Page\">Page</a>\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,9 @@ testRunner.Then("I should see \"<a href=\"/Admin/Contents/Create/Page\">Page</a>
|
|||||||
#line 11
|
#line 11
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 12
|
#line 12
|
||||||
testRunner.Given("I have installed Orchard");
|
testRunner.Given("I have installed Orchard");
|
||||||
#line 13
|
#line 13
|
||||||
testRunner.When("I go to \"admin/contents/create/page\"");
|
testRunner.When("I go to \"admin/contents/create/page\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
|
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
"name",
|
"name",
|
||||||
@@ -92,15 +92,15 @@ testRunner.When("I go to \"admin/contents/create/page\"");
|
|||||||
"Body.Text",
|
"Body.Text",
|
||||||
"This is super."});
|
"This is super."});
|
||||||
#line 14
|
#line 14
|
||||||
testRunner.And("I fill in", ((string)(null)), table1);
|
testRunner.And("I fill in", ((string)(null)), table1);
|
||||||
#line 18
|
#line 18
|
||||||
testRunner.And("I hit \"Publish Now\"");
|
testRunner.And("I hit \"Publish Now\"");
|
||||||
#line 19
|
#line 19
|
||||||
testRunner.And("I go to \"super-duper\"");
|
testRunner.And("I go to \"super-duper\"");
|
||||||
#line 20
|
#line 20
|
||||||
testRunner.Then("I should see \"<h1[^>]*>.*?Super Duper.*?</h1>\"");
|
testRunner.Then("I should see \"<h1[^>]*>.*?Super Duper.*?</h1>\"");
|
||||||
#line 21
|
#line 21
|
||||||
testRunner.And("I should see \"This is super.\"");
|
testRunner.And("I should see \"This is super.\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
@@ -115,9 +115,9 @@ testRunner.And("I should see \"This is super.\"");
|
|||||||
#line 23
|
#line 23
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 24
|
#line 24
|
||||||
testRunner.Given("I have installed Orchard");
|
testRunner.Given("I have installed Orchard");
|
||||||
#line 25
|
#line 25
|
||||||
testRunner.When("I go to \"admin/contents/create/page\"");
|
testRunner.When("I go to \"admin/contents/create/page\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
|
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
"name",
|
"name",
|
||||||
@@ -129,17 +129,17 @@ testRunner.When("I go to \"admin/contents/create/page\"");
|
|||||||
"Body.Text",
|
"Body.Text",
|
||||||
"This is super."});
|
"This is super."});
|
||||||
#line 26
|
#line 26
|
||||||
testRunner.And("I fill in", ((string)(null)), table2);
|
testRunner.And("I fill in", ((string)(null)), table2);
|
||||||
#line 30
|
#line 30
|
||||||
testRunner.And("I hit \"Publish Now\"");
|
testRunner.And("I hit \"Publish Now\"");
|
||||||
#line 31
|
#line 31
|
||||||
testRunner.And("I go to \"super-duper\"");
|
testRunner.And("I go to \"super-duper\"");
|
||||||
#line 32
|
#line 32
|
||||||
testRunner.Then("I should see \"<h1[^>]*>.*?Super Duper.*?</h1>\"");
|
testRunner.Then("I should see \"<h1[^>]*>.*?Super Duper.*?</h1>\"");
|
||||||
#line 33
|
#line 33
|
||||||
testRunner.And("I should see \"This is super.\"");
|
testRunner.And("I should see \"This is super.\"");
|
||||||
#line 34
|
#line 34
|
||||||
testRunner.When("I go to \"admin/contents/create/page\"");
|
testRunner.When("I go to \"admin/contents/create/page\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
|
TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
"name",
|
"name",
|
||||||
@@ -151,15 +151,95 @@ testRunner.When("I go to \"admin/contents/create/page\"");
|
|||||||
"Body.Text",
|
"Body.Text",
|
||||||
"This is super number two."});
|
"This is super number two."});
|
||||||
#line 35
|
#line 35
|
||||||
testRunner.And("I fill in", ((string)(null)), table3);
|
testRunner.And("I fill in", ((string)(null)), table3);
|
||||||
#line 39
|
#line 39
|
||||||
testRunner.And("I hit \"Publish Now\"");
|
testRunner.And("I hit \"Publish Now\"");
|
||||||
#line 40
|
#line 40
|
||||||
testRunner.And("I go to \"super-duper-2\"");
|
testRunner.And("I go to \"super-duper-2\"");
|
||||||
#line 41
|
#line 41
|
||||||
testRunner.Then("I should see \"<h1[^>]*>.*?Super Duper.*?</h1>\"");
|
testRunner.Then("I should see \"<h1[^>]*>.*?Super Duper.*?</h1>\"");
|
||||||
#line 42
|
#line 42
|
||||||
testRunner.And("I should see \"This is super number two.\"");
|
testRunner.And("I should see \"This is super number two.\"");
|
||||||
|
#line hidden
|
||||||
|
testRunner.CollectScenarioErrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TestAttribute()]
|
||||||
|
[NUnit.Framework.DescriptionAttribute("A new page marked to be the home page and publish does take over the home page an" +
|
||||||
|
"d is not accessible from its own standard path.")]
|
||||||
|
public virtual void ANewPageMarkedToBeTheHomePageAndPublishDoesTakeOverTheHomePageAndIsNotAccessibleFromItsOwnStandardPath_()
|
||||||
|
{
|
||||||
|
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new page marked to be the home page and publish does take over the home page an" +
|
||||||
|
"d is not accessible from its own standard path.", ((string[])(null)));
|
||||||
|
#line 44
|
||||||
|
this.ScenarioSetup(scenarioInfo);
|
||||||
|
#line 45
|
||||||
|
testRunner.Given("I have installed Orchard");
|
||||||
|
#line 46
|
||||||
|
testRunner.When("I go to \"admin/contents/create/page\"");
|
||||||
|
#line hidden
|
||||||
|
TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
|
"name",
|
||||||
|
"value"});
|
||||||
|
table4.AddRow(new string[] {
|
||||||
|
"Routable.Title",
|
||||||
|
"Super Duper"});
|
||||||
|
table4.AddRow(new string[] {
|
||||||
|
"Body.Text",
|
||||||
|
"This is a draft of the new home page."});
|
||||||
|
table4.AddRow(new string[] {
|
||||||
|
"Routable.PromoteToHomePage",
|
||||||
|
"true"});
|
||||||
|
#line 47
|
||||||
|
testRunner.And("I fill in", ((string)(null)), table4);
|
||||||
|
#line 52
|
||||||
|
testRunner.And("I hit \"Publish Now\"");
|
||||||
|
#line 53
|
||||||
|
testRunner.And("I go to \"/Default.aspx\"");
|
||||||
|
#line 54
|
||||||
|
testRunner.Then("I should see \"<h1>Super Duper</h1>\"");
|
||||||
|
#line 55
|
||||||
|
testRunner.When("I go to \"super-duper\"");
|
||||||
|
#line 56
|
||||||
|
testRunner.Then("the status should be 404 \"Not Found\"");
|
||||||
|
#line hidden
|
||||||
|
testRunner.CollectScenarioErrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TestAttribute()]
|
||||||
|
[NUnit.Framework.DescriptionAttribute("A new page marked to be the home page but only saved as draft does not take over " +
|
||||||
|
"the home page")]
|
||||||
|
public virtual void ANewPageMarkedToBeTheHomePageButOnlySavedAsDraftDoesNotTakeOverTheHomePage()
|
||||||
|
{
|
||||||
|
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new page marked to be the home page but only saved as draft does not take over " +
|
||||||
|
"the home page", ((string[])(null)));
|
||||||
|
#line 58
|
||||||
|
this.ScenarioSetup(scenarioInfo);
|
||||||
|
#line 59
|
||||||
|
testRunner.Given("I have installed Orchard");
|
||||||
|
#line 60
|
||||||
|
testRunner.When("I go to \"admin/contents/create/page\"");
|
||||||
|
#line hidden
|
||||||
|
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
|
"name",
|
||||||
|
"value"});
|
||||||
|
table5.AddRow(new string[] {
|
||||||
|
"Routable.Title",
|
||||||
|
"Drafty"});
|
||||||
|
table5.AddRow(new string[] {
|
||||||
|
"Body.Text",
|
||||||
|
"This is a draft of the new home page."});
|
||||||
|
table5.AddRow(new string[] {
|
||||||
|
"Routable.PromoteToHomePage",
|
||||||
|
"true"});
|
||||||
|
#line 61
|
||||||
|
testRunner.And("I fill in", ((string)(null)), table5);
|
||||||
|
#line 66
|
||||||
|
testRunner.And("I hit \"Save\"");
|
||||||
|
#line 67
|
||||||
|
testRunner.And("I go to \"/Default.aspx\"");
|
||||||
|
#line 68
|
||||||
|
testRunner.Then("I should see \"<h1>Welcome to Orchard!</h1>\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ namespace Orchard.Tests.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void Register(ContainerBuilder builder) {
|
protected override void Register(ContainerBuilder builder) {
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterAutoMocking();
|
builder.RegisterAutoMocking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ namespace Orchard.Tests.Environment.ShellBuilders {
|
|||||||
public void Init() {
|
public void Init() {
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>();
|
builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>();
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterAutoMocking(Moq.MockBehavior.Strict);
|
builder.RegisterAutoMocking(Moq.MockBehavior.Strict);
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ namespace Orchard.Tests.Environment.State {
|
|||||||
public void Init() {
|
public void Init() {
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterType<DefaultProcessingEngine>().As<IProcessingEngine>();
|
builder.RegisterType<DefaultProcessingEngine>().As<IProcessingEngine>();
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterAutoMocking();
|
builder.RegisterAutoMocking();
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ namespace Orchard.Tests.Localization {
|
|||||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||||
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
|
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||||
|
@@ -36,7 +36,7 @@ namespace Orchard.Tests.Mvc.Routes {
|
|||||||
rootBuilder.Register(ctx => _routes);
|
rootBuilder.Register(ctx => _routes);
|
||||||
rootBuilder.RegisterType<ShellRoute>().InstancePerDependency();
|
rootBuilder.RegisterType<ShellRoute>().InstancePerDependency();
|
||||||
rootBuilder.RegisterType<RunningShellTable>().As<IRunningShellTable>().SingleInstance();
|
rootBuilder.RegisterType<RunningShellTable>().As<IRunningShellTable>().SingleInstance();
|
||||||
rootBuilder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
rootBuilder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
||||||
rootBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
|
rootBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
|
||||||
|
|
||||||
_rootContainer = rootBuilder.Build();
|
_rootContainer = rootBuilder.Build();
|
||||||
|
@@ -12,7 +12,7 @@ namespace Orchard.Tests.Tasks {
|
|||||||
public class SweepGeneratorTests : ContainerTestBase {
|
public class SweepGeneratorTests : ContainerTestBase {
|
||||||
protected override void Register(ContainerBuilder builder) {
|
protected override void Register(ContainerBuilder builder) {
|
||||||
builder.RegisterAutoMocking(MockBehavior.Loose);
|
builder.RegisterAutoMocking(MockBehavior.Loose);
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterType<SweepGenerator>();
|
builder.RegisterType<SweepGenerator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Tests.UI {
|
|||||||
|
|
||||||
protected override void Register(ContainerBuilder builder) {
|
protected override void Register(ContainerBuilder builder) {
|
||||||
builder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
|
builder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>();
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>();
|
||||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||||
builder.RegisterType<LayoutWorkContext>().As<IWorkContextStateProvider>();
|
builder.RegisterType<LayoutWorkContext>().As<IWorkContextStateProvider>();
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -67,9 +66,11 @@ namespace Orchard.Core.Common.Handlers {
|
|||||||
bool ContentTypeWithACommonPart(string typeName) {
|
bool ContentTypeWithACommonPart(string typeName) {
|
||||||
//Note: What about content type handlers which activate "CommonPart" in code?
|
//Note: What about content type handlers which activate "CommonPart" in code?
|
||||||
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName);
|
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName);
|
||||||
if (contentTypeDefinition == null)
|
|
||||||
return false;
|
if (contentTypeDefinition != null)
|
||||||
return contentTypeDefinition.Parts.Any(part => part.PartDefinition.Name == "CommonPart");
|
return contentTypeDefinition.Parts.Any(part => part.PartDefinition.Name == "CommonPart");
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignCreatingOwner(InitializingContentContext context, CommonPart part) {
|
void AssignCreatingOwner(InitializingContentContext context, CommonPart part) {
|
||||||
|
@@ -70,7 +70,7 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
var containerUrl = new UriBuilder(request.ToRootUrlString()) { Path = (request.ApplicationPath ?? "").TrimEnd('/') + "/" + (part.GetContainerPath() ?? "") };
|
var containerUrl = new UriBuilder(request.ToRootUrlString()) { Path = (request.ApplicationPath ?? "").TrimEnd('/') + "/" + (part.GetContainerPath() ?? "") };
|
||||||
model.ContainerAbsoluteUrl = containerUrl.Uri.ToString().TrimEnd('/');
|
model.ContainerAbsoluteUrl = containerUrl.Uri.ToString().TrimEnd('/');
|
||||||
|
|
||||||
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
model.PromoteToHomePage = model.Id != 0 && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||||
return ContentShape("Parts_Routable_Edit",
|
return ContentShape("Parts_Routable_Edit",
|
||||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||||
}
|
}
|
||||||
@@ -81,6 +81,7 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
|
|
||||||
part.Title = model.Title;
|
part.Title = model.Title;
|
||||||
part.Slug = model.Slug;
|
part.Slug = model.Slug;
|
||||||
|
part.PromoteToHomePage = model.PromoteToHomePage;
|
||||||
|
|
||||||
if ( !_routableService.IsSlugValid(part.Slug) ) {
|
if ( !_routableService.IsSlugValid(part.Slug) ) {
|
||||||
var slug = (part.Slug ?? String.Empty);
|
var slug = (part.Slug ?? String.Empty);
|
||||||
@@ -90,9 +91,6 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\". No spaces are allowed (please use dashes or underscores instead)."));
|
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null)
|
|
||||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
|
||||||
|
|
||||||
return Editor(part, shapeHelper);
|
return Editor(part, shapeHelper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
@@ -6,6 +8,7 @@ using Orchard.Core.Routable.Models;
|
|||||||
using Orchard.Core.Routable.Services;
|
using Orchard.Core.Routable.Services;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
using Orchard.Services;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.Core.Routable.Handlers {
|
namespace Orchard.Core.Routable.Handlers {
|
||||||
@@ -13,11 +16,18 @@ namespace Orchard.Core.Routable.Handlers {
|
|||||||
private readonly IOrchardServices _services;
|
private readonly IOrchardServices _services;
|
||||||
private readonly IRoutablePathConstraint _routablePathConstraint;
|
private readonly IRoutablePathConstraint _routablePathConstraint;
|
||||||
private readonly IRoutableService _routableService;
|
private readonly IRoutableService _routableService;
|
||||||
|
private readonly IHomePageProvider _routableHomePageProvider;
|
||||||
|
|
||||||
public RoutePartHandler(IOrchardServices services, IRepository<RoutePartRecord> repository, IRoutablePathConstraint routablePathConstraint, IRoutableService routableService) {
|
public RoutePartHandler(
|
||||||
|
IOrchardServices services,
|
||||||
|
IRepository<RoutePartRecord> repository,
|
||||||
|
IRoutablePathConstraint routablePathConstraint,
|
||||||
|
IRoutableService routableService,
|
||||||
|
IEnumerable<IHomePageProvider> homePageProviders) {
|
||||||
_services = services;
|
_services = services;
|
||||||
_routablePathConstraint = routablePathConstraint;
|
_routablePathConstraint = routablePathConstraint;
|
||||||
_routableService = routableService;
|
_routableService = routableService;
|
||||||
|
_routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
|
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
@@ -34,21 +44,10 @@ namespace Orchard.Core.Routable.Handlers {
|
|||||||
OnUpdateEditorShape<RoutePart>(SetModelProperties);
|
OnUpdateEditorShape<RoutePart>(SetModelProperties);
|
||||||
|
|
||||||
OnPublished<RoutePart>((context, route) => {
|
OnPublished<RoutePart>((context, route) => {
|
||||||
var path = route.Path;
|
FinalizePath(route, context, processSlug);
|
||||||
route.Path = route.GetPathWithSlug(route.Slug);
|
|
||||||
|
|
||||||
if (context.PublishingItemVersionRecord != null)
|
if (route.ContentItem.Id != 0 && route.PromoteToHomePage && _routableHomePageProvider != null)
|
||||||
processSlug(route);
|
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id);
|
||||||
|
|
||||||
// if the path has changed by having the slug changed on the way in (e.g. user input) or to avoid conflict
|
|
||||||
// then update and publish all contained items
|
|
||||||
if (path != route.Path) {
|
|
||||||
_routablePathConstraint.RemovePath(path);
|
|
||||||
_routableService.FixContainedPaths(route);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(route.Path))
|
|
||||||
_routablePathConstraint.AddPath(route.Path);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
OnRemoved<RoutePart>((context, route) => {
|
OnRemoved<RoutePart>((context, route) => {
|
||||||
@@ -59,6 +58,24 @@ namespace Orchard.Core.Routable.Handlers {
|
|||||||
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
|
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FinalizePath(RoutePart route, PublishContentContext context, Action<RoutePart> processSlug) {
|
||||||
|
var path = route.Path;
|
||||||
|
route.Path = route.GetPathWithSlug(route.Slug);
|
||||||
|
|
||||||
|
if (context.PublishingItemVersionRecord != null)
|
||||||
|
processSlug(route);
|
||||||
|
|
||||||
|
// if the path has changed by having the slug changed on the way in (e.g. user input) or to avoid conflict
|
||||||
|
// then update and publish all contained items
|
||||||
|
if (path != route.Path) {
|
||||||
|
_routablePathConstraint.RemovePath(path);
|
||||||
|
_routableService.FixContainedPaths(route);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(route.Path))
|
||||||
|
_routablePathConstraint.AddPath(route.Path);
|
||||||
|
}
|
||||||
|
|
||||||
private static void SetModelProperties(BuildShapeContext context, RoutePart routable) {
|
private static void SetModelProperties(BuildShapeContext context, RoutePart routable) {
|
||||||
var item = context.Shape;
|
var item = context.Shape;
|
||||||
item.Title = routable.Title;
|
item.Title = routable.Title;
|
||||||
|
@@ -3,7 +3,6 @@ using Orchard.ContentManagement.Aspects;
|
|||||||
|
|
||||||
namespace Orchard.Core.Routable.Models {
|
namespace Orchard.Core.Routable.Models {
|
||||||
public class RoutePart : ContentPart<RoutePartRecord>, IRoutableAspect {
|
public class RoutePart : ContentPart<RoutePartRecord>, IRoutableAspect {
|
||||||
|
|
||||||
public string Title {
|
public string Title {
|
||||||
get { return Record.Title; }
|
get { return Record.Title; }
|
||||||
set { Record.Title = value; }
|
set { Record.Title = value; }
|
||||||
@@ -18,5 +17,7 @@ namespace Orchard.Core.Routable.Models {
|
|||||||
get { return Record.Path; }
|
get { return Record.Path; }
|
||||||
set { Record.Path = value; }
|
set { Record.Path = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool PromoteToHomePage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,6 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.Core.Routable.Models;
|
using Orchard.Core.Routable.Models;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.Localization;
|
|
||||||
using Orchard.Services;
|
using Orchard.Services;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
|
||||||
@@ -10,24 +9,16 @@ namespace Orchard.Core.Routable.Services {
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class RoutableHomePageProvider : IHomePageProvider {
|
public class RoutableHomePageProvider : IHomePageProvider {
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
private readonly IWorkContextAccessor _workContextAccessor;
|
|
||||||
public const string Name = "RoutableHomePageProvider";
|
public const string Name = "RoutableHomePageProvider";
|
||||||
|
|
||||||
public RoutableHomePageProvider(
|
public RoutableHomePageProvider(
|
||||||
IOrchardServices services,
|
|
||||||
IContentManager contentManager,
|
IContentManager contentManager,
|
||||||
IShapeFactory shapeFactory,
|
IShapeFactory shapeFactory) {
|
||||||
IWorkContextAccessor workContextAccessor) {
|
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
_workContextAccessor = workContextAccessor;
|
|
||||||
Services = services;
|
|
||||||
T = NullLocalizer.Instance;
|
|
||||||
Shape = shapeFactory;
|
Shape = shapeFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic Shape { get; set; }
|
dynamic Shape { get; set; }
|
||||||
public IOrchardServices Services { get; private set; }
|
|
||||||
public Localizer T { get; set; }
|
|
||||||
|
|
||||||
public string GetProviderName() {
|
public string GetProviderName() {
|
||||||
return Name;
|
return Name;
|
||||||
@@ -37,8 +28,8 @@ namespace Orchard.Core.Routable.Services {
|
|||||||
return GetProviderName() + ";" + id;
|
return GetProviderName() + ";" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult GetHomePage(int itemId) {
|
public ActionResult GetHomePage(int id) {
|
||||||
var contentItem = _contentManager.Get(itemId, VersionOptions.Published);
|
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
||||||
if (contentItem == null || !contentItem.Is<RoutePart>())
|
if (contentItem == null || !contentItem.Is<RoutePart>())
|
||||||
return new HttpNotFoundResult();
|
return new HttpNotFoundResult();
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
@if (HasText(Model.Description)) {
|
@if (HasText(Model.Description)) {
|
||||||
<div class="blog-description">
|
<div class="content-description blog-description">
|
||||||
<p>@Model.Description</p>
|
<p>@Model.Description</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
@@ -31,9 +31,6 @@
|
|||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.culture-selection div {
|
|
||||||
font-size:1.4em;
|
|
||||||
}
|
|
||||||
.culture-selection dl {
|
.culture-selection dl {
|
||||||
margin:.2em 0;
|
margin:.2em 0;
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,8 @@ namespace Orchard.Setup {
|
|||||||
// standard services needed in setup mode
|
// standard services needed in setup mode
|
||||||
builder.RegisterModule(new MvcModule());
|
builder.RegisterModule(new MvcModule());
|
||||||
builder.RegisterModule(new CommandModule());
|
builder.RegisterModule(new CommandModule());
|
||||||
|
builder.RegisterModule(new WorkContextModule());
|
||||||
|
|
||||||
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerLifetimeScope();
|
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>().InstancePerLifetimeScope();
|
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<WebFormViewEngineProvider>().As<IViewEngineProvider>().As<IShapeTemplateViewEngine>().InstancePerLifetimeScope();
|
builder.RegisterType<WebFormViewEngineProvider>().As<IViewEngineProvider>().As<IShapeTemplateViewEngine>().InstancePerLifetimeScope();
|
||||||
@@ -58,7 +60,7 @@ namespace Orchard.Setup {
|
|||||||
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>().InstancePerLifetimeScope();
|
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<DefaultCommandManager>().As<ICommandManager>().InstancePerLifetimeScope();
|
builder.RegisterType<DefaultCommandManager>().As<ICommandManager>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<HelpCommand>().As<ICommandHandler>().InstancePerLifetimeScope();
|
builder.RegisterType<HelpCommand>().As<ICommandHandler>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
||||||
builder.RegisterType<ResourceManifest>().As<IResourceManifestProvider>().InstancePerLifetimeScope();
|
builder.RegisterType<ResourceManifest>().As<IResourceManifestProvider>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<ResourceManager>().As<IResourceManager>().InstancePerLifetimeScope();
|
builder.RegisterType<ResourceManager>().As<IResourceManager>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
||||||
|
@@ -38,32 +38,30 @@ namespace Orchard.Users.Services {
|
|||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public string VerifyUserUnicity(string userName, string email) {
|
public string VerifyUserUnicity(string userName, string email) {
|
||||||
IEnumerable<UserPart> allUsers = _contentManager.Query<UserPart, UserPartRecord>().List();
|
string normalizedUserName = userName.ToLower();
|
||||||
|
|
||||||
foreach (var user in allUsers) {
|
if (_contentManager.Query<UserPart, UserPartRecord>()
|
||||||
if (String.Equals(userName.ToLower(), user.NormalizedUserName, StringComparison.OrdinalIgnoreCase)) {
|
.Where(user =>
|
||||||
return "A user with that name already exists";
|
user.NormalizedUserName == normalizedUserName ||
|
||||||
}
|
user.Email == email)
|
||||||
if (String.Equals(email, user.Email, StringComparison.OrdinalIgnoreCase)) {
|
.List().Any()) {
|
||||||
return "A user with that email already exists";
|
return "User with that username and/or email already exists.";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VerifyUserUnicity(int id, string userName, string email) {
|
public string VerifyUserUnicity(int id, string userName, string email) {
|
||||||
IEnumerable<UserPart> allUsers = _contentManager.Query<UserPart, UserPartRecord>().List();
|
string normalizedUserName = userName.ToLower();
|
||||||
foreach (var user in allUsers) {
|
|
||||||
if (user.Id == id)
|
if (_contentManager.Query<UserPart, UserPartRecord>()
|
||||||
continue;
|
.Where(user =>
|
||||||
if (String.Equals(userName.ToLower(), user.NormalizedUserName, StringComparison.OrdinalIgnoreCase)) {
|
user.NormalizedUserName == normalizedUserName ||
|
||||||
return "A user with that name already exists";
|
user.Email == email)
|
||||||
}
|
.List().Any(user => user.Id != id)) {
|
||||||
if (String.Equals(email, user.Email, StringComparison.OrdinalIgnoreCase)) {
|
return "User with that username and/or email already exists.";
|
||||||
return "A user with that email already exists";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -854,7 +854,8 @@ table.items th, table.items td {
|
|||||||
}
|
}
|
||||||
/* Core Contents and Orchard.PublishLater */
|
/* Core Contents and Orchard.PublishLater */
|
||||||
|
|
||||||
.orchard-blogs .edit-item-sidebar, .contents .edit-item-sidebar
|
|
||||||
|
.edit-item-sidebar
|
||||||
{
|
{
|
||||||
border:1px solid #d3d3d3;
|
border:1px solid #d3d3d3;
|
||||||
padding:8px;
|
padding:8px;
|
||||||
|
@@ -321,26 +321,25 @@ nav ul
|
|||||||
/* Main
|
/* Main
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
/* Blogs */
|
/* Content lists and details */
|
||||||
.blog-description { font-size: 1.231em; }
|
.content-description { font-size: 1.154em; }
|
||||||
.blog-post .tags { margin-top: 12px; }
|
.content-items { padding: 0; margin: 0; list-style: none; }
|
||||||
.blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
.content-items li { padding: 0; margin: 0; }
|
||||||
.blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; }
|
.content-items .content-item { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
||||||
.blog-posts { padding: 0; margin: 0; list-style: none; }
|
.content-items .content-item header {}
|
||||||
.blog-posts li { padding: 0; margin: 0; }
|
.content-items .content-item header h1 { font-size: 1.308em; color:#ff0000; }
|
||||||
.blog-posts .blog-post { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
.content-items .content-item header h1 a { color: #434343; }
|
||||||
.blog-posts .blog-post header {}
|
.content-items .content-item header h1 a:hover {}
|
||||||
.blog-posts .blog-post header h1 { font-size: 1.308em; }
|
|
||||||
.blog-posts .blog-post header h1 a { color: #434343; }
|
/* Tags */
|
||||||
.blog-posts .blog-post header h1 a:hover {}
|
.tags { margin-top: 12px; }
|
||||||
.blog-posts .blog-post .tags { margin-top: 12px; }
|
.tags a { background-color: #dbdbdb; padding: 3px 6px; color: #434343; }
|
||||||
.blog-posts .blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
.tags a:hover { background-color: #434343; padding: 3px; color: #fff; }
|
||||||
.blog-posts .blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; text-decoration: none; }
|
|
||||||
.blog-posts .blog-post .metadata { margin: 0 0 12px 0; color: #999; font-size: 0.846em; }
|
/* Metadata */
|
||||||
.blog-posts .blog-post .metadata .published { display: inline; margin: 0 6px 0 0; }
|
.metadata { margin: 0 0 12px 0; color: #999; font-size: 0.846em; }
|
||||||
.blog-posts .blog-post .metadata .commentcount { display: inline; }
|
.metadata .published { display: inline; margin: 0 6px 0 0; }
|
||||||
.blog-post {}
|
.metadata .commentcount { display: inline; }
|
||||||
.blog-post-title {}
|
|
||||||
.meta {}
|
.meta {}
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
@@ -359,38 +358,6 @@ nav ul
|
|||||||
.comment-disabled {}
|
.comment-disabled {}
|
||||||
.comment-count { font-size: 1.231em; }
|
.comment-count { font-size: 1.231em; }
|
||||||
|
|
||||||
/* Tag Search */
|
|
||||||
.tagged-posts {}
|
|
||||||
.tagged-posts { padding: 0; margin: 0; list-style: none; }
|
|
||||||
.tagged-posts li { padding: 0; margin: 0; }
|
|
||||||
.tagged-posts .blog-post { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
|
||||||
.tagged-posts .blog-post header {}
|
|
||||||
.tagged-posts .blog-post header h1 { font-size: 1.308em; }
|
|
||||||
.tagged-posts .blog-post header h1 a { color: #434343; }
|
|
||||||
.tagged-posts .blog-post header h1 a:hover {}
|
|
||||||
.tagged-posts .blog-post .tags { margin-top: 12px; }
|
|
||||||
.tagged-posts .blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
|
||||||
.tagged-posts .blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; text-decoration: none; }
|
|
||||||
.tagged-posts .blog-post .metadata { margin: 0 0 12px 0; color: #999; font-size: 1.1em; }
|
|
||||||
.tagged-posts .blog-post .metadata .published { display: inline; margin: 0 6px 0 0; }
|
|
||||||
.tagged-posts .blog-post .metadata .commentcount { display: inline; }
|
|
||||||
|
|
||||||
/* Search Results */
|
|
||||||
.search-results {}
|
|
||||||
.search-results { padding: 0; margin: 0; list-style: none; }
|
|
||||||
.search-results li { padding: 0; margin: 0; }
|
|
||||||
.search-results .blog-post { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
|
||||||
.search-results .blog-post header {}
|
|
||||||
.search-results .blog-post header h1 { font-size: 1.308em; }
|
|
||||||
.search-results .blog-post header h1 a { color: #434343; }
|
|
||||||
.search-results .blog-post header h1 a:hover {}
|
|
||||||
.search-results .blog-post .tags { margin-top: 12px; }
|
|
||||||
.search-results .blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
|
||||||
.search-results .blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; text-decoration: none; }
|
|
||||||
.search-results .blog-post .metadata { margin: 0 0 12px 0; color: #999; font-size: 0.846em; }
|
|
||||||
.search-results .blog-post .metadata .published { display: inline; margin: 0 6px 0 0; }
|
|
||||||
.search-results .blog-post .metadata .commentcount { display: inline; }
|
|
||||||
|
|
||||||
/* Confirmations */
|
/* Confirmations */
|
||||||
.message, .validation-summary-errors { margin:10px 0 4px 0; padding:4px; }
|
.message, .validation-summary-errors { margin:10px 0 4px 0; padding:4px; }
|
||||||
.messages a { font-weight:bold; }
|
.messages a { font-weight:bold; }
|
||||||
@@ -455,18 +422,11 @@ nav ul
|
|||||||
/* Widgets
|
/* Widgets
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
.widgets {}
|
.widgets {}
|
||||||
|
.widget h1 { font-size: 1.077em; }
|
||||||
|
|
||||||
/* Search */
|
/* Search */
|
||||||
/* Search widget shuld go into the sidebar for proper styling */
|
/* Search widget shuld go into the sidebar for proper styling */
|
||||||
/* TODO: (mibach) Generic any zone compatible search widget */
|
/* TODO: (mibach) Generic any zone compatible search widget */
|
||||||
.widget-search-form
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
top: 30px;
|
|
||||||
right: 12px;
|
|
||||||
}
|
|
||||||
.widget-search-form h1 { font-size: 1.077em; }
|
|
||||||
|
|
||||||
.search-form {}
|
.search-form {}
|
||||||
.search-form input[type="text"] { float: left; }
|
.search-form input[type="text"] { float: left; }
|
||||||
.search-form button[type="submit"] { float: left; margin: 0; margin-left: 6px; }
|
.search-form button[type="submit"] { float: left; margin: 0; margin-left: 6px; }
|
||||||
@@ -477,12 +437,6 @@ nav ul
|
|||||||
.widget-control .manage-actions { position:absolute; top: 0px; right: 0px; }
|
.widget-control .manage-actions { position:absolute; top: 0px; right: 0px; }
|
||||||
.widget-control .manage-actions a { display: block; background-color: #dbdbdb; color: #434343; padding: 3px 6px; }
|
.widget-control .manage-actions a { display: block; background-color: #dbdbdb; color: #434343; padding: 3px 6px; }
|
||||||
.widget-control .manage-actions a:hover { background-color: #434343; color: #fff; text-decoration: none; }
|
.widget-control .manage-actions a:hover { background-color: #434343; color: #fff; text-decoration: none; }
|
||||||
.widget-control .widget-search-form /* TODO: (mibach) Remove special case for Search Widget */
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
top: 0px;
|
|
||||||
right: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Content Mode */
|
/* Content Mode */
|
||||||
.content-control { position: relative; border: 1px dotted #5f97af; }
|
.content-control { position: relative; border: 1px dotted #5f97af; }
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Orchard.Mvc;
|
using Orchard.Mvc;
|
||||||
|
|
||||||
namespace Orchard.Environment {
|
namespace Orchard.Environment {
|
||||||
public class DefaultWorkContextAccessor : IWorkContextAccessor {
|
public class WorkContextAccessor : IWorkContextAccessor {
|
||||||
readonly ILifetimeScope _lifetimeScope;
|
readonly ILifetimeScope _lifetimeScope;
|
||||||
|
|
||||||
readonly IHttpContextAccessor _httpContextAccessor;
|
readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
@@ -18,7 +16,7 @@ namespace Orchard.Environment {
|
|||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
static ConcurrentDictionary<object, WorkContext> _threadStaticContexts;
|
static ConcurrentDictionary<object, WorkContext> _threadStaticContexts;
|
||||||
|
|
||||||
public DefaultWorkContextAccessor(
|
public WorkContextAccessor(
|
||||||
IHttpContextAccessor httpContextAccessor,
|
IHttpContextAccessor httpContextAccessor,
|
||||||
ILifetimeScope lifetimeScope) {
|
ILifetimeScope lifetimeScope) {
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
@@ -39,36 +37,23 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext) {
|
public IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext) {
|
||||||
|
var workLifetime = _lifetimeScope.BeginLifetimeScope("work");
|
||||||
|
workLifetime.Resolve<WorkContextProperty<HttpContextBase>>().Value = httpContext;
|
||||||
|
|
||||||
var workLifetime = SpawnWorkLifetime(builder => {
|
|
||||||
builder.Register(ctx => httpContext)
|
|
||||||
.As<HttpContextBase>();
|
|
||||||
|
|
||||||
builder.Register(ctx => new WorkContextImplementation(ctx))
|
|
||||||
.As<WorkContext>()
|
|
||||||
.InstancePerMatchingLifetimeScope("work");
|
|
||||||
});
|
|
||||||
return new HttpContextScopeImplementation(
|
return new HttpContextScopeImplementation(
|
||||||
workLifetime,
|
workLifetime,
|
||||||
httpContext,
|
httpContext,
|
||||||
_workContextKey);
|
_workContextKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IWorkContextScope CreateWorkContextScope() {
|
public IWorkContextScope CreateWorkContextScope() {
|
||||||
var httpContext = _httpContextAccessor.Current();
|
var httpContext = _httpContextAccessor.Current();
|
||||||
if (httpContext != null)
|
if (httpContext != null)
|
||||||
return CreateWorkContextScope(httpContext);
|
return CreateWorkContextScope(httpContext);
|
||||||
|
|
||||||
var workLifetime = SpawnWorkLifetime(builder => {
|
|
||||||
builder.Register(ctx => httpContext)
|
|
||||||
.As<HttpContextBase>();
|
|
||||||
|
|
||||||
builder.Register(ctx => new WorkContextImplementation(ctx))
|
|
||||||
.As<WorkContext>()
|
|
||||||
.InstancePerMatchingLifetimeScope("work");
|
|
||||||
});
|
|
||||||
return new ThreadStaticScopeImplementation(
|
return new ThreadStaticScopeImplementation(
|
||||||
workLifetime,
|
_lifetimeScope.BeginLifetimeScope("work"),
|
||||||
EnsureThreadStaticContexts(),
|
EnsureThreadStaticContexts(),
|
||||||
_workContextKey);
|
_workContextKey);
|
||||||
}
|
}
|
||||||
@@ -77,49 +62,6 @@ namespace Orchard.Environment {
|
|||||||
return _threadStaticContexts ?? (_threadStaticContexts = new ConcurrentDictionary<object, WorkContext>());
|
return _threadStaticContexts ?? (_threadStaticContexts = new ConcurrentDictionary<object, WorkContext>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ILifetimeScope SpawnWorkLifetime(Action<ContainerBuilder> configurationAction) {
|
|
||||||
return _lifetimeScope.BeginLifetimeScope("work", configurationAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
class WorkContextImplementation : WorkContext {
|
|
||||||
readonly IComponentContext _componentContext;
|
|
||||||
readonly ConcurrentDictionary<string, Func<object>> _stateResolvers = new ConcurrentDictionary<string, Func<object>>();
|
|
||||||
readonly IEnumerable<IWorkContextStateProvider> _workContextStateProviders;
|
|
||||||
|
|
||||||
public WorkContextImplementation(IComponentContext componentContext) {
|
|
||||||
_componentContext = componentContext;
|
|
||||||
_workContextStateProviders = componentContext.Resolve<IEnumerable<IWorkContextStateProvider>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override T Resolve<T>() {
|
|
||||||
return _componentContext.Resolve<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool TryResolve<T>(out T service) {
|
|
||||||
return _componentContext.TryResolve(out service);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override T GetState<T>(string name) {
|
|
||||||
var resolver = _stateResolvers.GetOrAdd(name, FindResolverForState<T>);
|
|
||||||
return (T)resolver();
|
|
||||||
}
|
|
||||||
|
|
||||||
Func<object> FindResolverForState<T>(string name) {
|
|
||||||
var resolver = _workContextStateProviders.Select(wcsp => wcsp.Get<T>(name))
|
|
||||||
.FirstOrDefault(value => !Equals(value, default(T)));
|
|
||||||
|
|
||||||
if (resolver == null) {
|
|
||||||
return () => default(T);
|
|
||||||
}
|
|
||||||
return () => resolver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void SetState<T>(string name, T value) {
|
|
||||||
_stateResolvers[name] = () => value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class HttpContextScopeImplementation : IWorkContextScope {
|
class HttpContextScopeImplementation : IWorkContextScope {
|
||||||
readonly WorkContext _workContext;
|
readonly WorkContext _workContext;
|
45
src/Orchard/Environment/WorkContextImplementation.cs
Normal file
45
src/Orchard/Environment/WorkContextImplementation.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Autofac;
|
||||||
|
|
||||||
|
namespace Orchard.Environment {
|
||||||
|
class WorkContextImplementation : WorkContext {
|
||||||
|
readonly IComponentContext _componentContext;
|
||||||
|
readonly ConcurrentDictionary<string, Func<object>> _stateResolvers = new ConcurrentDictionary<string, Func<object>>();
|
||||||
|
readonly IEnumerable<IWorkContextStateProvider> _workContextStateProviders;
|
||||||
|
|
||||||
|
public WorkContextImplementation(IComponentContext componentContext) {
|
||||||
|
_componentContext = componentContext;
|
||||||
|
_workContextStateProviders = componentContext.Resolve<IEnumerable<IWorkContextStateProvider>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override T Resolve<T>() {
|
||||||
|
return _componentContext.Resolve<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryResolve<T>(out T service) {
|
||||||
|
return _componentContext.TryResolve(out service);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override T GetState<T>(string name) {
|
||||||
|
var resolver = _stateResolvers.GetOrAdd(name, FindResolverForState<T>);
|
||||||
|
return (T)resolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
Func<object> FindResolverForState<T>(string name) {
|
||||||
|
var resolver = Enumerable.FirstOrDefault(_workContextStateProviders.Select(wcsp => wcsp.Get<T>(name)), value => !Equals(value, default(T)));
|
||||||
|
|
||||||
|
if (resolver == null) {
|
||||||
|
return () => default(T);
|
||||||
|
}
|
||||||
|
return () => resolver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void SetState<T>(string name, T value) {
|
||||||
|
_stateResolvers[name] = () => value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
src/Orchard/Environment/WorkContextModule.cs
Normal file
24
src/Orchard/Environment/WorkContextModule.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Web;
|
||||||
|
using Autofac;
|
||||||
|
|
||||||
|
namespace Orchard.Environment {
|
||||||
|
public class WorkContextModule : Module {
|
||||||
|
protected override void Load(ContainerBuilder builder) {
|
||||||
|
builder.RegisterType<WorkContextAccessor>()
|
||||||
|
.As<IWorkContextAccessor>()
|
||||||
|
.InstancePerMatchingLifetimeScope("shell");
|
||||||
|
|
||||||
|
builder.Register(ctx => new WorkContextImplementation(ctx))
|
||||||
|
.As<WorkContext>()
|
||||||
|
.InstancePerMatchingLifetimeScope("work");
|
||||||
|
|
||||||
|
builder.RegisterType<WorkContextProperty<HttpContextBase>>()
|
||||||
|
.As<WorkContextProperty<HttpContextBase>>()
|
||||||
|
.InstancePerMatchingLifetimeScope("work");
|
||||||
|
|
||||||
|
builder.Register(ctx => ctx.Resolve<WorkContextProperty<HttpContextBase>>().Value)
|
||||||
|
.As<HttpContextBase>()
|
||||||
|
.InstancePerDependency();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/Orchard/Environment/WorkContextProperty.cs
Normal file
5
src/Orchard/Environment/WorkContextProperty.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Orchard.Environment {
|
||||||
|
class WorkContextProperty<T> {
|
||||||
|
public T Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
|
|
||||||
namespace Orchard {
|
namespace Orchard {
|
||||||
public interface IWorkContextAccessor : ISingletonDependency {
|
public interface IWorkContextAccessor {
|
||||||
WorkContext GetContext(HttpContextBase httpContext);
|
WorkContext GetContext(HttpContextBase httpContext);
|
||||||
IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext);
|
IWorkContextScope CreateWorkContextScope(HttpContextBase httpContext);
|
||||||
|
|
||||||
|
@@ -36,10 +36,10 @@ namespace Orchard.Mvc {
|
|||||||
var serviceKey = (areaName + "/" + controllerName).ToLowerInvariant();
|
var serviceKey = (areaName + "/" + controllerName).ToLowerInvariant();
|
||||||
|
|
||||||
// Now that the request container is known - try to resolve the controller information
|
// Now that the request container is known - try to resolve the controller information
|
||||||
Lazy<Meta<IController>> info;
|
Meta<Lazy<IController>> info;
|
||||||
var workContext = requestContext.GetWorkContext();
|
var workContext = requestContext.GetWorkContext();
|
||||||
if (TryResolve(workContext, serviceKey, out info)) {
|
if (TryResolve(workContext, serviceKey, out info)) {
|
||||||
return (Type) info.Value.Metadata["ControllerType"];
|
return (Type) info.Metadata["ControllerType"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@@ -158,6 +158,9 @@
|
|||||||
<Compile Include="Environment\Extensions\Loaders\RawThemeExtensionLoader.cs" />
|
<Compile Include="Environment\Extensions\Loaders\RawThemeExtensionLoader.cs" />
|
||||||
<Compile Include="Environment\Features\FeatureManager.cs" />
|
<Compile Include="Environment\Features\FeatureManager.cs" />
|
||||||
<Compile Include="Environment\IAssemblyLoader.cs" />
|
<Compile Include="Environment\IAssemblyLoader.cs" />
|
||||||
|
<Compile Include="Environment\WorkContextImplementation.cs" />
|
||||||
|
<Compile Include="Environment\WorkContextModule.cs" />
|
||||||
|
<Compile Include="Environment\WorkContextProperty.cs" />
|
||||||
<Compile Include="Localization\Services\CurrentCultureWorkContext.cs" />
|
<Compile Include="Localization\Services\CurrentCultureWorkContext.cs" />
|
||||||
<Compile Include="Localization\Services\DefaultLocalizedStringManager.cs" />
|
<Compile Include="Localization\Services\DefaultLocalizedStringManager.cs" />
|
||||||
<Compile Include="Localization\Services\ILocalizedStringManager.cs" />
|
<Compile Include="Localization\Services\ILocalizedStringManager.cs" />
|
||||||
@@ -419,7 +422,7 @@
|
|||||||
<Compile Include="DisplayManagement\Implementation\IDisplayManager.cs" />
|
<Compile Include="DisplayManagement\Implementation\IDisplayManager.cs" />
|
||||||
<Compile Include="DisplayManagement\IShapeFactory.cs" />
|
<Compile Include="DisplayManagement\IShapeFactory.cs" />
|
||||||
<Compile Include="DisplayManagement\Descriptors\Interfaces.cs" />
|
<Compile Include="DisplayManagement\Descriptors\Interfaces.cs" />
|
||||||
<Compile Include="Environment\DefaultWorkContextAccessor.cs" />
|
<Compile Include="Environment\WorkContextAccessor.cs" />
|
||||||
<Compile Include="Environment\IHostLocalRestart.cs" />
|
<Compile Include="Environment\IHostLocalRestart.cs" />
|
||||||
<Compile Include="Environment\IShellContainerRegistrations.cs" />
|
<Compile Include="Environment\IShellContainerRegistrations.cs" />
|
||||||
<Compile Include="FileSystems\Dependencies\DynamicModuleVirtualPathProvider.cs" />
|
<Compile Include="FileSystems\Dependencies\DynamicModuleVirtualPathProvider.cs" />
|
||||||
|
Reference in New Issue
Block a user