This commit is contained in:
Daniel Stolt
2014-05-23 00:30:40 +02:00
25 changed files with 294 additions and 290 deletions

View File

@@ -104,6 +104,8 @@ namespace Orchard.Specs.Bindings {
using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) {
environment.Resolve<IShellSettingsManager>().SaveSettings(shellSettings);
}
MvcApplication.RestartTenant(shellName);
});
webApp.WhenIGoToPathOnHost("Setup", hostName);

View File

@@ -43,21 +43,14 @@ Scenario: HTML markup in any given comment is encoded
Then I should see "This is&lt;br id=&quot;bad-anon-br&quot; /&gt;a &lt;a href"
And I should not see "<br id="bad-anon-br" />"
Scenario: Moderated comments are not displayed
Given I have installed Orchard
When I go to "admin/blogs/create"
# Moderated comments are not displayed
When I go to "users/account/logon"
And I fill in
| name | value |
| Title.Title | My Blog |
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Title.Title | My Post |
| Body.Text | Hi there. |
And I hit "Publish Now"
| userNameOrEmail | admin |
| password | 6655321 |
And I hit "Sign In"
And I am redirected
And I go to "admin/settings/comments"
And I fill in
| name | value |

View File

@@ -154,94 +154,66 @@ this.ScenarioSetup(scenarioInfo);
testRunner.Then("I should see \"This is&lt;br id=&quot;bad-anon-br&quot; /&gt;a &lt;a href\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 44
testRunner.And("I should not see \"<br id=\"bad-anon-br\" />\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
this.ScenarioCleanup();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Moderated comments are not displayed")]
public virtual void ModeratedCommentsAreNotDisplayed()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Moderated comments are not displayed", ((string[])(null)));
#line 46
this.ScenarioSetup(scenarioInfo);
#line 47
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 48
testRunner.When("I go to \"admin/blogs/create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.When("I go to \"users/account/logon\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table5.AddRow(new string[] {
"Title.Title",
"My Blog"});
#line 49
"userNameOrEmail",
"admin"});
table5.AddRow(new string[] {
"password",
"6655321"});
#line 48
testRunner.And("I fill in", ((string)(null)), table5, "And ");
#line 52
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I hit \"Sign In\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 53
testRunner.And("I go to \"admin/blogs\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 54
testRunner.And("I follow \"My Blog\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 55
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I go to \"admin/settings/comments\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table6.AddRow(new string[] {
"Title.Title",
"My Post"});
table6.AddRow(new string[] {
"Body.Text",
"Hi there."});
#line 56
testRunner.And("I fill in", ((string)(null)), table6, "And ");
"CommentSettings.ModerateComments",
"true"});
#line 55
testRunner.And("I fill in", ((string)(null)), table6, "And ");
#line 58
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 59
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 60
testRunner.And("I hit \"Publish Now\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.Then("I should see \"Settings updated\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 61
testRunner.And("I go to \"admin/settings/comments\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.When("I go to \"users/account/logoff\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 62
testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table7.AddRow(new string[] {
"CommentSettings.ModerateComments",
"true"});
#line 62
testRunner.And("I fill in", ((string)(null)), table7, "And ");
#line 65
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 66
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 67
testRunner.Then("I should see \"Settings updated\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 68
testRunner.When("I go to \"users/account/logoff\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 69
testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table8.AddRow(new string[] {
"Comments.Author",
"Bill"});
table8.AddRow(new string[] {
table7.AddRow(new string[] {
"Comments.CommentText",
"This is a moderated comment."});
#line 70
testRunner.And("I fill in", ((string)(null)), table8, "And ");
#line 74
#line 63
testRunner.And("I fill in", ((string)(null)), table7, "And ");
#line 67
testRunner.And("I hit \"Submit Comment\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 75
#line 68
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 77
#line 70
testRunner.And("I go to \"my-blog/my-post\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 78
#line 71
testRunner.Then("I should see \"Hi there\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 79
#line 72
testRunner.And("I should not see \"This is a moderated comment\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
this.ScenarioCleanup();

View File

@@ -36,20 +36,20 @@ Scenario: Creating and using Date fields
Then I should see "Date of the event"
When I fill in
| name | value |
| Event.EventDate.Date | 31/01/2012 |
| Event.EventDate.Time | 12:00 AM |
| Event.EventDate.Editor.Date | 31/01/2012 |
| Event.EventDate.Editor.Time | 12:00 AM |
And I hit "Save"
Then I should see "Date of the event is an invalid date and time"
Then I should see "Date of the event could not be parsed as a valid date and time"
# Creating an Event content item
When I go to "Admin/Contents/Create/Event"
Then I should see "Date of the event"
When I fill in
| name | value |
| Event.EventDate.Date | 01/31/2012 |
| Event.EventDate.Editor.Date | 01/31/2012 |
And I fill in
| name | value |
| Event.EventDate.Time | 12:00 AM |
| Event.EventDate.Editor.Time | 12:00 AM |
And I hit "Save"
And I am redirected
Then I should see "Your Event has been created."
@@ -73,8 +73,8 @@ Scenario: Creating and using Date fields
| Fields[0].DateTimeFieldSettings.Display | DateOnly |
And I hit "Save"
And I go to "Admin/Contents/Create/Event"
Then I should see "Event.EventDate.Date"
And I should not see "Event.EventDate.Time"
Then I should see "Event.EventDate.Editor.Date"
And I should not see "Event.EventDate.Editor.Time"
# Display = TimeOnly
When I go to "Admin/ContentTypes/Edit/Event"
@@ -83,8 +83,8 @@ Scenario: Creating and using Date fields
| Fields[0].DateTimeFieldSettings.Display | TimeOnly |
And I hit "Save"
And I go to "Admin/Contents/Create/Event"
Then I should see "Event.EventDate.Time"
And I should not see "Event.EventDate.Date"
Then I should see "Event.EventDate.Editor.Time"
And I should not see "Event.EventDate.Editor.Date"
# Required & Date and Time
When I go to "Admin/ContentTypes/Edit/Event"
@@ -94,24 +94,24 @@ Scenario: Creating and using Date fields
| Fields[0].DateTimeFieldSettings.Required | true |
And I hit "Save"
And I go to "Admin/Contents/Create/Event"
Then I should see "Event.EventDate.Date"
Then I should see "Event.EventDate.Editor.Date"
When I fill in
| name | value |
| Event.EventDate.Date | 01/31/2012 |
| Event.EventDate.Time | 12:00 AM |
| Event.EventDate.Editor.Date | 01/31/2012 |
| Event.EventDate.Editor.Time | 12:00 AM |
And I hit "Save"
And I am redirected
Then I should see "Your Event has been created."
When I go to "Admin/Contents/Create/Event"
And I fill in
| name | value |
| Event.EventDate.Date | 01/31/2012 |
| Event.EventDate.Editor.Date | 01/31/2012 |
And I hit "Save"
Then I should see "Date of the event is required."
When I go to "Admin/Contents/Create/Event"
And I fill in
| name | value |
| Event.EventDate.Time | 12:00 AM |
| Event.EventDate.Editor.Time | 12:00 AM |
And I hit "Save"
Then I should see "Date of the event is required."
@@ -123,7 +123,7 @@ Scenario: Creating and using Date fields
| Fields[0].DateTimeFieldSettings.Required | true |
And I hit "Save"
And I go to "Admin/Contents/Create/Event"
Then I should see "Event.EventDate.Date"
Then I should see "Event.EventDate.Editor.Date"
When I hit "Save"
Then I should see "Date of the event is required."
@@ -135,7 +135,7 @@ Scenario: Creating and using Date fields
| Fields[0].DateTimeFieldSettings.Required | true |
And I hit "Save"
And I go to "Admin/Contents/Create/Event"
Then I should see "Event.EventDate.Date"
Then I should see "Event.EventDate.Editor.Date"
When I hit "Save"
Then I should see "Date of the event is required."
@@ -179,15 +179,15 @@ Scenario: Creating and using date time fields in another culture
When I go to "Admin/Contents/Create/Event"
And I fill in
| name | value |
| Event.EventDate.Date | 01/31/2012 |
| Event.EventDate.Time | 12:00 AM |
| Event.EventDate.Editor.Date | 01/31/2012 |
| Event.EventDate.Editor.Time | 12:00 AM |
And I hit "Save"
Then I should see "Date of the event is an invalid date and time"
Then I should see "Date of the event could not be parsed as a valid date and time"
When I go to "Admin/Contents/Create/Event"
And I fill in
| name | value |
| Event.EventDate.Date | 31/01/2012 |
| Event.EventDate.Time | 18:00 |
| Event.EventDate.Editor.Date | 31/01/2012 |
| Event.EventDate.Editor.Time | 18:00 |
And I hit "Save"
And I am redirected
Then I should see "Your Event has been created."

View File

@@ -3,7 +3,7 @@
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.9.0.77
// SpecFlow Generator Version:1.9.0.0
// Runtime Version:4.0.30319.33440
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -134,17 +134,17 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table3.AddRow(new string[] {
"Event.EventDate.Date",
"Event.EventDate.Editor.Date",
"31/01/2012"});
table3.AddRow(new string[] {
"Event.EventDate.Time",
"Event.EventDate.Editor.Time",
"12:00 AM"});
#line 37
testRunner.When("I fill in", ((string)(null)), table3, "When ");
#line 41
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 42
testRunner.Then("I should see \"Date of the event is an invalid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Date of the event could not be parsed as a valid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 45
testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 46
@@ -154,7 +154,7 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table4.AddRow(new string[] {
"Event.EventDate.Date",
"Event.EventDate.Editor.Date",
"01/31/2012"});
#line 47
testRunner.When("I fill in", ((string)(null)), table4, "When ");
@@ -163,7 +163,7 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table5.AddRow(new string[] {
"Event.EventDate.Time",
"Event.EventDate.Editor.Time",
"12:00 AM"});
#line 50
testRunner.And("I fill in", ((string)(null)), table5, "And ");
@@ -212,9 +212,9 @@ this.ScenarioSetup(scenarioInfo);
#line 75
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 76
testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 77
testRunner.And("I should not see \"Event.EventDate.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I should not see \"Event.EventDate.Editor.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 80
testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
@@ -231,9 +231,9 @@ this.ScenarioSetup(scenarioInfo);
#line 85
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 86
testRunner.Then("I should see \"Event.EventDate.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Event.EventDate.Editor.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 87
testRunner.And("I should not see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I should not see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 90
testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
@@ -253,16 +253,16 @@ this.ScenarioSetup(scenarioInfo);
#line 96
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 97
testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table10.AddRow(new string[] {
"Event.EventDate.Date",
"Event.EventDate.Editor.Date",
"01/31/2012"});
table10.AddRow(new string[] {
"Event.EventDate.Time",
"Event.EventDate.Editor.Time",
"12:00 AM"});
#line 98
testRunner.When("I fill in", ((string)(null)), table10, "When ");
@@ -279,7 +279,7 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table11.AddRow(new string[] {
"Event.EventDate.Date",
"Event.EventDate.Editor.Date",
"01/31/2012"});
#line 106
testRunner.And("I fill in", ((string)(null)), table11, "And ");
@@ -294,7 +294,7 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table12.AddRow(new string[] {
"Event.EventDate.Time",
"Event.EventDate.Editor.Time",
"12:00 AM"});
#line 112
testRunner.And("I fill in", ((string)(null)), table12, "And ");
@@ -321,7 +321,7 @@ this.ScenarioSetup(scenarioInfo);
#line 125
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 126
testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 127
testRunner.When("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 128
@@ -345,7 +345,7 @@ this.ScenarioSetup(scenarioInfo);
#line 137
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 138
testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Event.EventDate.Editor.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 139
testRunner.When("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 140
@@ -442,17 +442,17 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table18.AddRow(new string[] {
"Event.EventDate.Date",
"Event.EventDate.Editor.Date",
"01/31/2012"});
table18.AddRow(new string[] {
"Event.EventDate.Time",
"Event.EventDate.Editor.Time",
"12:00 AM"});
#line 180
testRunner.And("I fill in", ((string)(null)), table18, "And ");
#line 184
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 185
testRunner.Then("I should see \"Date of the event is an invalid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("I should see \"Date of the event could not be parsed as a valid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 186
testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
@@ -460,10 +460,10 @@ this.ScenarioSetup(scenarioInfo);
"name",
"value"});
table19.AddRow(new string[] {
"Event.EventDate.Date",
"Event.EventDate.Editor.Date",
"31/01/2012"});
table19.AddRow(new string[] {
"Event.EventDate.Time",
"Event.EventDate.Editor.Time",
"18:00"});
#line 187
testRunner.And("I fill in", ((string)(null)), table19, "And ");

View File

@@ -181,7 +181,7 @@ namespace Orchard.Specs.Hosting {
}
public override void SendUnknownResponseHeader(string name, string value) {
_details.ResponseHeaders.Add(name, value);
_details.ResponseHeaders[name] = value;
base.SendUnknownResponseHeader(name, value);
}

View File

@@ -6,34 +6,30 @@
Scenario: I can create a new list
Given I have installed Orchard
And I have installed "Orchard.Lists"
When I go to "Admin/Contents/Create/List"
When I go to "Admin/ContentTypes"
And I go to "Admin/ContentTypes/Create"
And I fill in
| name | value |
| Title.Title | MyList |
And I hit "Save"
And I go to "Admin/Contents/List/List"
Then I should see "MyList"
| name | value |
| DisplayName | Event |
| Name | Event |
And I hit "Create"
And I am redirected
And I fill in
| name | value |
| PartSelections[5].IsSelected | True |
And I hit "Save"
And I go to "Admin/ContentTypes/"
Then I should see "Event"
Scenario: I can add content items to a list
Given I have installed Orchard
And I have installed "Orchard.Lists"
And I have a containable content type "MyType"
When I go to "Admin/Contents/Create/List"
And I fill in
| name | value |
| Title.Title | MyList |
| name | value |
| Title.Title | MyList |
| Container.SelectedItemContentTypes | Event |
And I hit "Save"
And I go to "Admin/Contents/List/List"
And I am redirected
Then I should see "Your List has been created"
When I go to "Admin/Lists"
Then I should see "MyList"
When I follow "Contained Items"
Then I should see "The 'MyList' List has no content items."
When I follow "Create New Content" where href has "ReturnUrl"
Then I should see "MyType"
When I follow "MyType" where href has "ReturnUrl"
And I fill in
| name | value |
| Title.Title | MyContentItem |
And I hit "Save"
And I am redirected
Then I should see "Manage MyList"
And I should see "MyContentItem"
When I follow "Contained Items (0)"
Then I should see "'MyList' has no content items"

View File

@@ -3,7 +3,7 @@
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.9.0.77
// SpecFlow Generator Version:1.9.0.0
// Runtime Version:4.0.30319.33440
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -77,83 +77,68 @@ this.ScenarioSetup(scenarioInfo);
#line 8
testRunner.And("I have installed \"Orchard.Lists\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 9
testRunner.When("I go to \"Admin/Contents/Create/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 10
testRunner.And("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table1.AddRow(new string[] {
"Title.Title",
"MyList"});
#line 10
"DisplayName",
"Event"});
table1.AddRow(new string[] {
"Name",
"Event"});
#line 11
testRunner.And("I fill in", ((string)(null)), table1, "And ");
#line 13
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 14
testRunner.And("I go to \"Admin/Contents/List/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 15
testRunner.Then("I should see \"MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("I can add content items to a list")]
public virtual void ICanAddContentItemsToAList()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can add content items to a list", ((string[])(null)));
#line 17
this.ScenarioSetup(scenarioInfo);
#line 18
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 19
testRunner.And("I have installed \"Orchard.Lists\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 20
testRunner.And("I have a containable content type \"MyType\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 21
testRunner.When("I go to \"Admin/Contents/Create/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 16
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table2.AddRow(new string[] {
"Title.Title",
"MyList"});
#line 22
"PartSelections[5].IsSelected",
"True"});
#line 17
testRunner.And("I fill in", ((string)(null)), table2, "And ");
#line 25
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 26
testRunner.And("I go to \"Admin/Contents/List/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 27
testRunner.Then("I should see \"MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 28
testRunner.When("I follow \"Contained Items\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 29
testRunner.Then("I should see \"The \'MyList\' List has no content items.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 30
testRunner.When("I follow \"Create New Content\" where href has \"ReturnUrl\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 31
testRunner.Then("I should see \"MyType\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 32
testRunner.When("I follow \"MyType\" where href has \"ReturnUrl\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 20
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 21
testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 22
testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 24
testRunner.When("I go to \"Admin/Contents/Create/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
"name",
"value"});
table3.AddRow(new string[] {
"Title.Title",
"MyContentItem"});
#line 33
"MyList"});
table3.AddRow(new string[] {
"Container.SelectedItemContentTypes",
"Event"});
#line 25
testRunner.And("I fill in", ((string)(null)), table3, "And ");
#line 36
#line 29
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 37
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 38
testRunner.Then("I should see \"Manage MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 39
testRunner.And("I should see \"MyContentItem\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 30
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 31
testRunner.Then("I should see \"Your List has been created\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 32
testRunner.When("I go to \"Admin/Lists\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 33
testRunner.Then("I should see \"MyList\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 34
testRunner.When("I follow \"Contained Items (0)\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 35
testRunner.Then("I should see \"\'MyList\' has no content items\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
}

View File

@@ -6,7 +6,8 @@
Scenario: I can edit a default layer
Given I have installed Orchard
When I go to "Admin/Widgets"
And I follow "Edit"
Then I should see "<h1[^>]*>Widgets[^>]*>"
When I follow "Edit"
Then I should see "<input[^>]*name="LayerPart.Name"[^>]*value="Default"[^>]*>"
When I fill in
| name | value |

View File

@@ -3,7 +3,7 @@
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.9.0.77
// SpecFlow Generator Version:1.9.0.0
// Runtime Version:4.0.30319.33440
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -77,8 +77,10 @@ this.ScenarioSetup(scenarioInfo);
#line 8
testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 9
testRunner.And("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.Then("I should see \"<h1[^>]*>Widgets[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 10
testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 11
testRunner.Then("I should see \"<input[^>]*name=\"LayerPart.Name\"[^>]*value=\"Default\"[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
@@ -87,17 +89,17 @@ this.ScenarioSetup(scenarioInfo);
table1.AddRow(new string[] {
"LayerPart.Description",
"This is the default layer."});
#line 11
#line 12
testRunner.When("I fill in", ((string)(null)), table1, "When ");
#line 14
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 15
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 16
testRunner.Then("I should see \"Your Layer has been saved\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 17
testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Then("I should see \"Your Layer has been saved\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 18
testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 19
testRunner.Then("I should see \"<textarea[^>]*>\\s*This is the default layer.\\s*</textarea>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
@@ -110,15 +112,15 @@ this.ScenarioSetup(scenarioInfo);
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can add a new layer and that layer is active when I\'m redirected to the widget " +
"management page", ((string[])(null)));
#line 20
this.ScenarioSetup(scenarioInfo);
#line 21
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
this.ScenarioSetup(scenarioInfo);
#line 22
testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 23
testRunner.And("I follow \"Add a new layer...\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 24
testRunner.And("I follow \"Add a new layer...\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 25
testRunner.Then("I should see \"<h1[^>]*>Add Layer</h1>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
@@ -130,15 +132,15 @@ this.ScenarioSetup(scenarioInfo);
table2.AddRow(new string[] {
"LayerPart.LayerRule",
"url \"~/awesome*\""});
#line 25
#line 26
testRunner.When("I fill in", ((string)(null)), table2, "When ");
#line 29
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 30
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 31
testRunner.Then("I should see \"Your Layer has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 32
testRunner.Then("I should see \"Your Layer has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 33
testRunner.And("I should see \"<option[^>]+selected=\"selected\"[^>]+value=\"\\d+\">For awesome stuff</" +
"option>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
@@ -150,25 +152,25 @@ this.ScenarioSetup(scenarioInfo);
public virtual void ICanDeleteALayer()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can delete a layer", ((string[])(null)));
#line 34
this.ScenarioSetup(scenarioInfo);
#line 35
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
this.ScenarioSetup(scenarioInfo);
#line 36
testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 37
testRunner.Then("I should see \"<option[^>]*>Default</option>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 38
testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Then("I should see \"<option[^>]*>Default</option>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 39
testRunner.Then("I should see \"<input[^>]*name=\"LayerPart.Name\"[^>]*value=\"Default\"[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.When("I follow \"Edit\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 40
testRunner.When("I hit \"Delete\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Then("I should see \"<input[^>]*name=\"LayerPart.Name\"[^>]*value=\"Default\"[^>]*>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 41
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.When("I hit \"Delete\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 42
testRunner.Then("I should see \"Layer was successfully deleted\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 43
testRunner.Then("I should see \"Layer was successfully deleted\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 44
testRunner.And("I should not see \"<option[^>]*>Default</option>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
this.ScenarioCleanup();
@@ -179,11 +181,11 @@ this.ScenarioSetup(scenarioInfo);
public virtual void ICanAddAWidgetToASpecificZoneInASpecificLayer()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can add a widget to a specific zone in a specific layer", ((string[])(null)));
#line 45
this.ScenarioSetup(scenarioInfo);
#line 46
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
this.ScenarioSetup(scenarioInfo);
#line 47
testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 48
testRunner.When("I go to \"Admin/Widgets\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
@@ -192,19 +194,19 @@ this.ScenarioSetup(scenarioInfo);
table3.AddRow(new string[] {
"layerId",
"Disabled"});
#line 48
#line 49
testRunner.And("I fill in", ((string)(null)), table3, "And ");
#line 51
testRunner.And("I hit \"Show\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 52
testRunner.Then("I should see \"<option[^>]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.And("I hit \"Show\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 53
testRunner.When("I follow \"Add\" where href has \"zone=Header\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Then("I should see \"<option[^>]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 54
testRunner.Then("I should see \"<h1[^>]*>Choose A Widget</h1>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.When("I follow \"Add\" where href has \"zone=Header\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 55
testRunner.When("I follow \"<h2>Html Widget</h2>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
testRunner.Then("I should see \"<h1[^>]*>Choose A Widget</h1>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 56
testRunner.When("I follow \"<h2>Html Widget</h2>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 57
testRunner.Then("I should see \"<h1[^>]*>Add Widget</h1>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
@@ -216,17 +218,17 @@ this.ScenarioSetup(scenarioInfo);
table4.AddRow(new string[] {
"Body.Text",
"<p><blink>hi</blink></p>"});
#line 57
#line 58
testRunner.When("I fill in", ((string)(null)), table4, "When ");
#line 61
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 62
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 63
testRunner.Then("I should see \"Your Html Widget has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 64
testRunner.And("I should see \"<option[^>]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.Then("I should see \"Your Html Widget has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 65
testRunner.And("I should see \"<option[^>]*selected[^>]*>Disabled\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 66
testRunner.And("I should see \"<li[^>]*class=\"[^\"]*widgets-this-layer[^\"]*\"[^>]*>\\s*<form[^>]*>\\s*" +
"<h3[^>]*>\\s*<a[^>]*>Flashy HTML Widget</a>\\s*</h3>\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden

View File

@@ -95,6 +95,8 @@ namespace Orchard.OutputCache.Filters {
var controllerAttributes = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true);
var outputCacheAttribute = actionAttributes.Concat(controllerAttributes).Cast<OutputCacheAttribute>().FirstOrDefault();
_workContext = _workContextAccessor.GetContext();
if (outputCacheAttribute != null) {
if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore) {
Logger.Debug("Request ignored based on OutputCache attribute");
@@ -128,8 +130,6 @@ namespace Orchard.OutputCache.Filters {
return;
}
_workContext = _workContextAccessor.GetContext();
// don't return any cached content, or cache any content, if the user is authenticated
if (_workContext.CurrentUser != null) {
Logger.Debug("Request ignored on Authenticated user");
@@ -290,19 +290,14 @@ namespace Orchard.OutputCache.Filters {
}
public void OnActionExecuted(ActionExecutedContext filterContext) {
// this means the cache module is not applied in this context
if (_workContext == null) {
return;
}
// handle redirections
_transformRedirect = TransformRedirect(filterContext);
}
public void OnResultExecuted(ResultExecutedContext filterContext) {
// this means the cache module is not applied in this context
if (_workContext == null) {
if (AdminFilter.IsApplied(new RequestContext(filterContext.HttpContext, new RouteData()))) {
return;
}
@@ -461,6 +456,10 @@ namespace Orchard.OutputCache.Filters {
throw new ArgumentNullException();
}
if (AdminFilter.IsApplied(new RequestContext(filterContext.HttpContext, new RouteData()))) {
return false;
}
var redirectResult = filterContext.Result as RedirectResult;
// status code can't be tested at this point, so test the result type instead
@@ -475,8 +474,7 @@ namespace Orchard.OutputCache.Filters {
if (!VirtualPathUtility.IsAbsolute(redirectUrl)) {
var applicationRoot = new UrlHelper(filterContext.HttpContext.Request.RequestContext).MakeAbsolute("/");
if (redirectUrl.StartsWith(applicationRoot, StringComparison.OrdinalIgnoreCase)) {
redirectUrl = "~/" + redirectUrl.Substring(applicationRoot.Length);
redirectUrl = VirtualPathUtility.ToAbsolute(redirectUrl);
redirectUrl = redirectUrl.Substring(applicationRoot.Length);
}
}

View File

@@ -159,7 +159,7 @@ namespace Orchard.Templates.Controllers {
public ActionResult Create(string id) {
var types = GetShapeTypes();
var typeName = String.IsNullOrWhiteSpace(id) ? types.Count() == 1 ? types.First().Name : null : id;
return String.IsNullOrEmpty(typeName) ? CreatableTypeList() : RedirectToAction("Create", "Admin", new {area = "Contents", id = typeName});
return String.IsNullOrEmpty(typeName) ? CreatableTypeList() : RedirectToAction("Create", "Admin", new { area = "Contents", id = typeName });
}
private ActionResult CreatableTypeList() {

View File

@@ -36,19 +36,19 @@ namespace Orchard.Templates.Drivers {
Template = part.Template
};
if (updater != null
if (updater != null
&& updater.TryUpdateModel(viewModel, Prefix, null, new[] { "AvailableLanguages" })
&& ValidateShapeName(part, updater)) {
part.Template = viewModel.Template;
part.Template = viewModel.Template;
try {
var processor = _processors.FirstOrDefault(x => String.Equals(x.Type, part.ProcessorName, StringComparison.OrdinalIgnoreCase)) ?? _processors.First();
processor.Verify(part.Template);
}
catch (Exception ex) {
updater.AddModelError("", T("Template processing error: {0}", ex.Message));
_transactions.Cancel();
}
try {
var processor = _processors.FirstOrDefault(x => String.Equals(x.Type, part.ProcessorName, StringComparison.OrdinalIgnoreCase)) ?? _processors.First();
processor.Verify(part.Template);
}
catch (Exception ex) {
updater.AddModelError("", T("Template processing error: {0}", ex.Message));
_transactions.Cancel();
}
}
return ContentShape("Parts_Shape_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.Shape", Model: viewModel, Prefix: Prefix));
}
@@ -60,7 +60,7 @@ namespace Orchard.Templates.Drivers {
protected override void Importing(ShapePart part, ImportContentContext context) {
var shapeElement = context.Data.Element(part.PartDefinition.Name);
if(shapeElement != null)
if (shapeElement != null)
part.Template = shapeElement.Value;
}
@@ -70,13 +70,13 @@ namespace Orchard.Templates.Drivers {
return false;
var name = titleViewModel.Title;
if (!string.IsNullOrWhiteSpace(name) &&
name[0].IsLetter() &&
name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '.' || c == '-' )) {
if (!String.IsNullOrWhiteSpace(name) &&
name[0].IsLetter() &&
name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '_')) {
return true;
}
updater.AddModelError("Title", T("{0} names can only contain alphanumerical, dot (.) or dash (-) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName));
updater.AddModelError("Title", T("{0} names can only contain alphanumerical or underscore (_) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName));
return false;
}

View File

@@ -14,8 +14,7 @@ namespace Orchard.Templates {
.WithPart("CommonPart")
.WithPart("IdentityPart")
.WithPart("TitlePart")
.WithPart("ShapePart", p => p
.WithSetting("ShapePartSettings.Processor", "Razor"))
.WithPart("ShapePart")
.Draftable());
return 1;
}

View File

@@ -4,10 +4,15 @@ Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.8.1
OrchardVersion: 1.8
Description: Provides a Template type that can be used to store Razor code and used as a shape.
Description: Provides a Template type that can be used to store template code and used as a shape.
Features:
Orchard.Templates:
Name: Templates
Description: Provides a Template type that represents a Razor template, stored as a content item.
Description: Provides a Template type that represents a shape template, stored as a content item.
Category: Content
Dependencies: Contents, Orchard.Tokens
Dependencies: Contents, Orchard.Tokens
Orchard.Templates.Razor:
Name: Razor Templates
Description: Extends Templates with Razor templates.
Category: Content
Dependencies: Orchard.Templates

View File

@@ -167,8 +167,10 @@
<Compile Include="Drivers\ShapePartDriver.cs" />
<Compile Include="Models\ShapePart.cs" />
<Compile Include="Migrations.cs" />
<Compile Include="RazorMigrations.cs" />
<Compile Include="Services\ITemplateProcessor.cs" />
<Compile Include="Services\ITemplateService.cs" />
<Compile Include="Services\NoTemplateProcessorBanner.cs" />
<Compile Include="Services\Razor\IRazorCompiler.cs" />
<Compile Include="Services\Razor\RazorCompiler.cs" />
<Compile Include="Services\Razor\RazorTemplateBase.cs" />

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Data.Migration;
using Orchard.ContentManagement.MetaData;
using Orchard.Environment.Extensions;
namespace Orchard.Templates {
[OrchardFeature("Orchard.Templates.Razor")]
public class RazorMigrations : DataMigrationImpl {
public int Create() {
ContentDefinitionManager.AlterTypeDefinition("Template", type => type
.WithPart("ShapePart", p => p
.WithSetting("ShapePartSettings.Processor", "Razor")));
return 1;
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Localization;
using Orchard.UI.Admin.Notification;
using Orchard.UI.Notify;
namespace Orchard.Templates.Services {
public class NoTemplateProcessorBanner : INotificationProvider {
private readonly IEnumerable<ITemplateProcessor> _processors;
public NoTemplateProcessorBanner(IEnumerable<ITemplateProcessor> processors) {
_processors = processors;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public IEnumerable<NotifyEntry> GetNotifications() {
if (!_processors.Any()) {
yield return new NotifyEntry { Message = T("To be able to use Templates enable a template processor like Razor Templates."), Type = NotifyType.Warning };
}
}
}
}

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
namespace Orchard.Templates.Compilation.Razor {
public interface IRazorCompiler : IDependency {
public interface IRazorCompiler : IDependency {
IRazorTemplateBase<TModel> CompileRazor<TModel>(string code, string name, IDictionary<string, object> parameters);
IRazorTemplateBase CompileRazor(string code, string name, IDictionary<string, object> parameters);
}

View File

@@ -10,10 +10,12 @@ using System.Text;
using System.Web.Razor;
using Microsoft.CSharp;
using Orchard.Caching;
using Orchard.Environment.Extensions;
using Orchard.Logging;
using Orchard.Utility.Extensions;
namespace Orchard.Templates.Compilation.Razor {
[OrchardFeature("Orchard.Templates.Razor")]
public class RazorCompiler : IRazorCompiler {
private readonly ICacheManager _cache;
private readonly ISignals _signals;
@@ -46,7 +48,7 @@ namespace Orchard.Templates.Compilation.Razor {
};
public RazorCompiler(
ICacheManager cache,
ICacheManager cache,
ISignals signals) {
_cache = cache;
_signals = signals;
@@ -56,15 +58,15 @@ namespace Orchard.Templates.Compilation.Razor {
private ILogger Logger { get; set; }
public IRazorTemplateBase<TModel> CompileRazor<TModel>(string code, string name, IDictionary<string, object> parameters) {
return (RazorTemplateBase<TModel>) Compile(code, name, typeof (TModel), parameters);
return (RazorTemplateBase<TModel>)Compile(code, name, typeof(TModel), parameters);
}
public IRazorTemplateBase CompileRazor(string code, string name, IDictionary<string, object> parameters) {
return (IRazorTemplateBase) Compile(code, name, null, parameters);
return (IRazorTemplateBase)Compile(code, name, null, parameters);
}
private object Compile(string code, string name, Type modelType, IDictionary<string, object> parameters) {
var cacheKey = (name ?? DynamicallyGeneratedClassName) + GetHash(code);
var generatedClassName = name != null ? name.Strip(c => !c.IsLetter() && !Char.IsDigit(c)) : DynamicallyGeneratedClassName;

View File

@@ -3,8 +3,7 @@ using System.Web.Mvc;
using System.Web.WebPages;
namespace Orchard.Templates.Compilation.Razor {
public interface IRazorTemplateBase
{
public interface IRazorTemplateBase {
dynamic Model { get; }
WebPageContext WebPageContext { get; set; }
ViewContext ViewContext { get; set; }
@@ -15,8 +14,7 @@ namespace Orchard.Templates.Compilation.Razor {
}
public interface IRazorTemplateBase<TModel> : IRazorTemplateBase
{
public interface IRazorTemplateBase<TModel> : IRazorTemplateBase {
new TModel Model { get; }
new ViewDataDictionary<TModel> ViewData { get; set; }
}

View File

@@ -7,9 +7,12 @@ using System.Web.Mvc;
using System.Web.UI;
using System.Web.WebPages;
using Orchard.DisplayManagement.Implementation;
using Orchard.Environment.Extensions;
using Orchard.Logging;
using Orchard.Templates.Compilation.Razor;
namespace Orchard.Templates.Services {
[OrchardFeature("Orchard.Templates.Razor")]
public class RazorTemplateProcessor : TemplateProcessorImpl {
private readonly IRazorCompiler _compiler;
private readonly HttpContextBase _httpContextBase;
@@ -19,7 +22,7 @@ namespace Orchard.Templates.Services {
}
public RazorTemplateProcessor(
IRazorCompiler compiler,
IRazorCompiler compiler,
HttpContextBase httpContextBase) {
_compiler = compiler;
_httpContextBase = httpContextBase;
@@ -58,7 +61,7 @@ namespace Orchard.Templates.Services {
obj.WebPageContext = new WebPageContext(displayContext.ViewContext.HttpContext, obj as WebPageRenderingBase, model);
obj.ViewContext = shapeViewContext;
obj.ViewData = new ViewDataDictionary(displayContext.ViewDataContainer.ViewData) {Model = model};
obj.ViewData = new ViewDataDictionary(displayContext.ViewDataContainer.ViewData) { Model = model };
obj.InitHelpers();
}
else {

View File

@@ -15,8 +15,8 @@ namespace Orchard.Templates.Services {
private IContentManager _contentManager;
private ITemplateService _templateService;
public TemplateShapeDisplayEvent (
ICacheManager cacheManager,
public TemplateShapeDisplayEvent(
ICacheManager cacheManager,
ISignals signals,
IContentManager contentManager,
ITemplateService templateService
@@ -41,7 +41,7 @@ namespace Orchard.Templates.Services {
public IDictionary<string, Func<dynamic, IHtmlString>> BuildShapeProcessors() {
return _cacheManager.Get("Template.ShapeProcessors", ctx => {
ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal));
ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal));
var allTemplates = _contentManager.Query<ShapePart>().List();

View File

@@ -35,7 +35,7 @@ namespace Orchard.Templates.Settings {
AvailableProcessors = _processors.ToArray()
};
updateModel.TryUpdateModel(model, "ShapePartSettingsViewModel", new[] {"Processor"}, null);
updateModel.TryUpdateModel(model, "ShapePartSettingsViewModel", new[] { "Processor" }, null);
builder.WithSetting("ShapePartSettings.Processor", model.Processor);
yield return DefinitionTemplate(model);
}

View File

@@ -17,7 +17,7 @@ namespace Orchard.Caching {
var entry = _entries.AddOrUpdate(key,
// "Add" lambda
k => AddEntry(k, acquire),
// "Update" lamdba
// "Update" lambda
(k, currentEntry) => UpdateEntry(currentEntry, k, acquire));
return entry.Result;