Making it so when a content item is set as the home page it's only accessible as the home page and not at its path

- current implication for blogs is that if a blog is set as the home page its posts are then all rooted (e.g. if a blog at
  /blog is set as the home page then it's available at / and a post at, say, /my-post instead of /blog/my-post). There should
  maybe be a setting to alter the paths of the posts but (1) that's a pain at the moment, (2) hacking the URL by removing
  the post slug would result in a 404 instead of redirecting to /, the path of the blog - we don't handle redirects of that
  nature - and (3) the ability to root a blog in this manner *has* been requested by some.

--HG--
branch : dev
This commit is contained in:
Nathan Heskew 2010-12-01 00:51:42 -08:00
parent 2798850a38
commit 381f70d47c
14 changed files with 292 additions and 231 deletions

View File

@ -17,7 +17,10 @@ Scenario: I can create a new blog and blog post
And I hit "Save" And I hit "Save"
And I go to "my-blog" And I go to "my-blog"
Then I should see "<h1[^>]*>.*?My Blog.*?</h1>" Then I should see "<h1[^>]*>.*?My Blog.*?</h1>"
When I go to "admin/blogs/my-blog/posts/create" When I go to "admin/blogs"
And I follow "My Blog"
Then I should see "foo"
When I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -34,7 +37,9 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
| name | value | | name | value |
| Routable.Title | My Blog | | Routable.Title | My Blog |
And I hit "Save" And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create" And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -43,7 +48,9 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
And I go to "my-blog/my-post" And I go to "my-blog/my-post"
Then I should see "<h1[^>]*>.*?My Post.*?</h1>" Then I should see "<h1[^>]*>.*?My Post.*?</h1>"
And I should see "Hi there." And I should see "Hi there."
When I go to "admin/blogs/my-blog/posts/create" When I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -52,7 +59,9 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
And I go to "my-blog/my-post-2" And I go to "my-blog/my-post-2"
Then I should see "<h1[^>]*>.*?My Post.*?</h1>" Then I should see "<h1[^>]*>.*?My Post.*?</h1>"
And I should see "Hi there, again." And I should see "Hi there, again."
When I go to "admin/blogs/my-blog/posts/create" When I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -72,7 +81,9 @@ Scenario: I can create a new blog and blog post and when I change the slug of th
And I hit "Save" And I hit "Save"
And I go to "my-blog" And I go to "my-blog"
Then I should see "<h1[^>]*>.*?My Blog.*?</h1>" Then I should see "<h1[^>]*>.*?My Blog.*?</h1>"
When I go to "admin/blogs/my-blog/posts/create" When I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -81,7 +92,8 @@ Scenario: I can create a new blog and blog post and when I change the slug of th
And I go to "my-blog/my-post" And I go to "my-blog/my-post"
Then I should see "<h1[^>]*>.*?My Post.*?</h1>" Then I should see "<h1[^>]*>.*?My Post.*?</h1>"
And I should see "Hi there." And I should see "Hi there."
When I go to "admin/blogs/my-blog" When I go to "admin/blogs"
And I follow "My Blog"
And I follow "Blog Properties" And I follow "Blog Properties"
And I fill in And I fill in
| name | value | | name | value |
@ -100,7 +112,9 @@ Scenario: When viewing a blog the user agent is given an RSS feed of the blog's
| name | value | | name | value |
| Routable.Title | My Blog | | Routable.Title | My Blog |
And I hit "Save" And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create" And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -135,7 +149,9 @@ Scenario: The virtual path of my installation when not at the root is reflected
| name | value | | name | value |
| Routable.Title | My Blog | | Routable.Title | My Blog |
And I hit "Save" And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create" And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
Then I should see "<span>http\://localhost/OrchardLocal/my-blog/</span>" Then I should see "<span>http\://localhost/OrchardLocal/my-blog/</span>"
Scenario: The virtual path of my installation when at the root is reflected in the URL example for the slug field when creating a blog or blog post Scenario: The virtual path of my installation when at the root is reflected in the URL example for the slug field when creating a blog or blog post
@ -146,10 +162,12 @@ Scenario: The virtual path of my installation when at the root is reflected in t
| name | value | | name | value |
| Routable.Title | My Blog | | Routable.Title | My Blog |
And I hit "Save" And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create" And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
Then I should see "<span>http\://localhost/my-blog/</span>" Then I should see "<span>http\://localhost/my-blog/</span>"
Scenario: I set my blog to be the content for the home page and the posts for the blog should still be at the blog path prefixed path Scenario: I set my blog to be the content for the home page and the posts for the blog be rooted to the app
Given I have installed Orchard Given I have installed Orchard
When I go to "admin/blogs/create" When I go to "admin/blogs/create"
And I fill in And I fill in
@ -157,7 +175,9 @@ Scenario: I set my blog to be the content for the home page and the posts for th
| Routable.Title | My Blog | | Routable.Title | My Blog |
| Routable.PromoteToHomePage | true | | Routable.PromoteToHomePage | true |
And I hit "Save" And I hit "Save"
And I go to "admin/blogs/my-blog/posts/create" And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I fill in And I fill in
| name | value | | name | value |
| Routable.Title | My Post | | Routable.Title | My Post |
@ -168,5 +188,5 @@ Scenario: I set my blog to be the content for the home page and the posts for th
Then I should see "<h1>My Blog</h1>" Then I should see "<h1>My Blog</h1>"
When I go to "/my-blog" When I go to "/my-blog"
Then the status should be 404 "Not Found" Then the status should be 404 "Not Found"
When I go to "/my-blog/my-post" When I go to "/my-post"
Then I should see "<h1>My Post</h1>" Then I should see "<h1>My Post</h1>"

View File

@ -97,7 +97,13 @@ this.ScenarioSetup(scenarioInfo);
#line 19 #line 19
testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\"");
#line 20 #line 20
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.When("I go to \"admin/blogs\"");
#line 21
testRunner.And("I follow \"My Blog\"");
#line 22
testRunner.Then("I should see \"foo\"");
#line 23
testRunner.When("I follow \"New Post\"");
#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",
@ -108,15 +114,15 @@ this.ScenarioSetup(scenarioInfo);
table2.AddRow(new string[] { table2.AddRow(new string[] {
"Body.Text", "Body.Text",
"Hi there."}); "Hi there."});
#line 21 #line 24
testRunner.And("I fill in", ((string)(null)), table2); testRunner.And("I fill in", ((string)(null)), table2);
#line 25
testRunner.And("I hit \"Publish Now\"");
#line 26
testRunner.And("I go to \"my-blog/my-post\"");
#line 27
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 28 #line 28
testRunner.And("I hit \"Publish Now\"");
#line 29
testRunner.And("I go to \"my-blog/my-post\"");
#line 30
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 31
testRunner.And("I should see \"Hi there.\""); testRunner.And("I should see \"Hi there.\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
@ -129,11 +135,11 @@ this.ScenarioSetup(scenarioInfo);
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can create a new blog with multiple blog posts each with the same title and uni" + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can create a new blog with multiple blog posts each with the same title and uni" +
"que slugs are generated or given for said posts", ((string[])(null))); "que slugs are generated or given for said posts", ((string[])(null)));
#line 30 #line 33
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 31 #line 34
testRunner.Given("I have installed Orchard"); testRunner.Given("I have installed Orchard");
#line 32 #line 35
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
@ -142,12 +148,16 @@ this.ScenarioSetup(scenarioInfo);
table3.AddRow(new string[] { table3.AddRow(new string[] {
"Routable.Title", "Routable.Title",
"My Blog"}); "My Blog"});
#line 33
testRunner.And("I fill in", ((string)(null)), table3);
#line 36 #line 36
testRunner.And("I fill in", ((string)(null)), table3);
#line 39
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 37 #line 40
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.And("I go to \"admin/blogs\"");
#line 41
testRunner.And("I follow \"My Blog\"");
#line 42
testRunner.And("I follow \"New Post\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
"name", "name",
@ -158,18 +168,22 @@ this.ScenarioSetup(scenarioInfo);
table4.AddRow(new string[] { table4.AddRow(new string[] {
"Body.Text", "Body.Text",
"Hi there."}); "Hi there."});
#line 38
testRunner.And("I fill in", ((string)(null)), table4);
#line 42
testRunner.And("I hit \"Publish Now\"");
#line 43 #line 43
testRunner.And("I fill in", ((string)(null)), table4);
#line 47
testRunner.And("I hit \"Publish Now\"");
#line 48
testRunner.And("I go to \"my-blog/my-post\""); testRunner.And("I go to \"my-blog/my-post\"");
#line 44 #line 49
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 45 #line 50
testRunner.And("I should see \"Hi there.\""); testRunner.And("I should see \"Hi there.\"");
#line 46 #line 51
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.When("I go to \"admin/blogs\"");
#line 52
testRunner.And("I follow \"My Blog\"");
#line 53
testRunner.And("I follow \"New Post\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
"name", "name",
@ -180,18 +194,22 @@ this.ScenarioSetup(scenarioInfo);
table5.AddRow(new string[] { table5.AddRow(new string[] {
"Body.Text", "Body.Text",
"Hi there, again."}); "Hi there, again."});
#line 47
testRunner.And("I fill in", ((string)(null)), table5);
#line 51
testRunner.And("I hit \"Publish Now\"");
#line 52
testRunner.And("I go to \"my-blog/my-post-2\"");
#line 53
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 54 #line 54
testRunner.And("I fill in", ((string)(null)), table5);
#line 58
testRunner.And("I hit \"Publish Now\"");
#line 59
testRunner.And("I go to \"my-blog/my-post-2\"");
#line 60
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 61
testRunner.And("I should see \"Hi there, again.\""); testRunner.And("I should see \"Hi there, again.\"");
#line 55 #line 62
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.When("I go to \"admin/blogs\"");
#line 63
testRunner.And("I follow \"My Blog\"");
#line 64
testRunner.And("I follow \"New Post\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
"name", "name",
@ -205,15 +223,15 @@ this.ScenarioSetup(scenarioInfo);
table6.AddRow(new string[] { table6.AddRow(new string[] {
"Body.Text", "Body.Text",
"Are you still there?"}); "Are you still there?"});
#line 56 #line 65
testRunner.And("I fill in", ((string)(null)), table6); testRunner.And("I fill in", ((string)(null)), table6);
#line 61 #line 70
testRunner.And("I hit \"Publish Now\""); testRunner.And("I hit \"Publish Now\"");
#line 62 #line 71
testRunner.And("I go to \"my-blog/my-post-3\""); testRunner.And("I go to \"my-blog/my-post-3\"");
#line 63 #line 72
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 64 #line 73
testRunner.And("I should see \"Are you still there?\""); testRunner.And("I should see \"Are you still there?\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
@ -226,11 +244,11 @@ this.ScenarioSetup(scenarioInfo);
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can create a new blog and blog post and when I change the slug of the blog the " + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can create a new blog and blog post and when I change the slug of the blog the " +
"path of the plog post is updated", ((string[])(null))); "path of the plog post is updated", ((string[])(null)));
#line 66 #line 75
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 67 #line 76
testRunner.Given("I have installed Orchard"); testRunner.Given("I have installed Orchard");
#line 68 #line 77
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
@ -239,16 +257,20 @@ this.ScenarioSetup(scenarioInfo);
table7.AddRow(new string[] { table7.AddRow(new string[] {
"Routable.Title", "Routable.Title",
"My Blog"}); "My Blog"});
#line 69 #line 78
testRunner.And("I fill in", ((string)(null)), table7); testRunner.And("I fill in", ((string)(null)), table7);
#line 72 #line 81
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 73 #line 82
testRunner.And("I go to \"my-blog\""); testRunner.And("I go to \"my-blog\"");
#line 74 #line 83
testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\"");
#line 75 #line 84
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.When("I go to \"admin/blogs\"");
#line 85
testRunner.And("I follow \"My Blog\"");
#line 86
testRunner.And("I follow \"New Post\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
"name", "name",
@ -259,19 +281,21 @@ this.ScenarioSetup(scenarioInfo);
table8.AddRow(new string[] { table8.AddRow(new string[] {
"Body.Text", "Body.Text",
"Hi there."}); "Hi there."});
#line 76 #line 87
testRunner.And("I fill in", ((string)(null)), table8); testRunner.And("I fill in", ((string)(null)), table8);
#line 80 #line 91
testRunner.And("I hit \"Publish Now\""); testRunner.And("I hit \"Publish Now\"");
#line 81 #line 92
testRunner.And("I go to \"my-blog/my-post\""); testRunner.And("I go to \"my-blog/my-post\"");
#line 82 #line 93
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 83 #line 94
testRunner.And("I should see \"Hi there.\""); testRunner.And("I should see \"Hi there.\"");
#line 84 #line 95
testRunner.When("I go to \"admin/blogs/my-blog\""); testRunner.When("I go to \"admin/blogs\"");
#line 85 #line 96
testRunner.And("I follow \"My Blog\"");
#line 97
testRunner.And("I follow \"Blog Properties\""); testRunner.And("I follow \"Blog Properties\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] {
@ -280,19 +304,19 @@ this.ScenarioSetup(scenarioInfo);
table9.AddRow(new string[] { table9.AddRow(new string[] {
"Routable.Slug", "Routable.Slug",
"my-other-blog"}); "my-other-blog"});
#line 86 #line 98
testRunner.And("I fill in", ((string)(null)), table9); testRunner.And("I fill in", ((string)(null)), table9);
#line 89 #line 101
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 90 #line 102
testRunner.And("I go to \"my-other-blog\""); testRunner.And("I go to \"my-other-blog\"");
#line 91 #line 103
testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\"");
#line 92 #line 104
testRunner.When("I go to \"my-other-blog/my-post\""); testRunner.When("I go to \"my-other-blog/my-post\"");
#line 93 #line 105
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\""); testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
#line 94 #line 106
testRunner.And("I should see \"Hi there.\""); testRunner.And("I should see \"Hi there.\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
@ -303,11 +327,11 @@ this.ScenarioSetup(scenarioInfo);
public virtual void WhenViewingABlogTheUserAgentIsGivenAnRSSFeedOfTheBlogSPosts() public virtual void WhenViewingABlogTheUserAgentIsGivenAnRSSFeedOfTheBlogSPosts()
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("When viewing a blog the user agent is given an RSS feed of the blog\'s posts", ((string[])(null))); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("When viewing a blog the user agent is given an RSS feed of the blog\'s posts", ((string[])(null)));
#line 96 #line 108
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 97 #line 109
testRunner.Given("I have installed Orchard"); testRunner.Given("I have installed Orchard");
#line 98 #line 110
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] {
@ -316,12 +340,16 @@ this.ScenarioSetup(scenarioInfo);
table10.AddRow(new string[] { table10.AddRow(new string[] {
"Routable.Title", "Routable.Title",
"My Blog"}); "My Blog"});
#line 99 #line 111
testRunner.And("I fill in", ((string)(null)), table10); testRunner.And("I fill in", ((string)(null)), table10);
#line 102 #line 114
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 103 #line 115
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.And("I go to \"admin/blogs\"");
#line 116
testRunner.And("I follow \"My Blog\"");
#line 117
testRunner.And("I follow \"New Post\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] {
"name", "name",
@ -332,15 +360,15 @@ this.ScenarioSetup(scenarioInfo);
table11.AddRow(new string[] { table11.AddRow(new string[] {
"Body.Text", "Body.Text",
"Hi there."}); "Hi there."});
#line 104 #line 118
testRunner.And("I fill in", ((string)(null)), table11); testRunner.And("I fill in", ((string)(null)), table11);
#line 108 #line 122
testRunner.And("I hit \"Publish Now\""); testRunner.And("I hit \"Publish Now\"");
#line 109 #line 123
testRunner.And("I am redirected"); testRunner.And("I am redirected");
#line 110 #line 124
testRunner.And("I go to \"my-blog/my-post\""); testRunner.And("I go to \"my-blog/my-post\"");
#line 111 #line 125
testRunner.Then("I should see \"<link rel=\"alternate\" type=\"application/rss\\+xml\" title=\"My Blog\" h" + testRunner.Then("I should see \"<link rel=\"alternate\" type=\"application/rss\\+xml\" title=\"My Blog\" h" +
"ref=\"/rss\\?containerid=\\d+\" />\""); "ref=\"/rss\\?containerid=\\d+\" />\"");
#line hidden #line hidden
@ -354,15 +382,15 @@ this.ScenarioSetup(scenarioInfo);
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Enabling remote blog publishing inserts the appropriate metaweblogapi markup into" + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Enabling remote blog publishing inserts the appropriate metaweblogapi markup into" +
" the blog\'s page", ((string[])(null))); " the blog\'s page", ((string[])(null)));
#line 114 #line 128
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 115 #line 129
testRunner.Given("I have installed Orchard"); testRunner.Given("I have installed Orchard");
#line 116 #line 130
testRunner.And("I have enabled \"XmlRpc\""); testRunner.And("I have enabled \"XmlRpc\"");
#line 117 #line 131
testRunner.And("I have enabled \"Orchard.Blogs.RemotePublishing\""); testRunner.And("I have enabled \"Orchard.Blogs.RemotePublishing\"");
#line 118 #line 132
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] {
@ -371,23 +399,23 @@ this.ScenarioSetup(scenarioInfo);
table12.AddRow(new string[] { table12.AddRow(new string[] {
"Routable.Title", "Routable.Title",
"My Blog"}); "My Blog"});
#line 119 #line 133
testRunner.And("I fill in", ((string)(null)), table12); testRunner.And("I fill in", ((string)(null)), table12);
#line 122 #line 136
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 123 #line 137
testRunner.And("I go to \"my-blog\""); testRunner.And("I go to \"my-blog\"");
#line 124 #line 138
testRunner.Then("I should see \"<link href=\"[^\"]*/XmlRpc/LiveWriter/Manifest\" rel=\"wlwmanifest\" typ" + testRunner.Then("I should see \"<link href=\"[^\"]*/XmlRpc/LiveWriter/Manifest\" rel=\"wlwmanifest\" typ" +
"e=\"application/wlwmanifest\\+xml\" />\""); "e=\"application/wlwmanifest\\+xml\" />\"");
#line 125 #line 139
testRunner.When("I go to \"/XmlRpc/LiveWriter/Manifest\""); testRunner.When("I go to \"/XmlRpc/LiveWriter/Manifest\"");
#line 126 #line 140
testRunner.Then("the content type should be \"\\btext/xml\\b\""); testRunner.Then("the content type should be \"\\btext/xml\\b\"");
#line 127 #line 141
testRunner.And("I should see \"<manifest xmlns=\"http\\://schemas\\.microsoft\\.com/wlw/manifest/weblo" + testRunner.And("I should see \"<manifest xmlns=\"http\\://schemas\\.microsoft\\.com/wlw/manifest/weblo" +
"g\">\""); "g\">\"");
#line 128 #line 142
testRunner.And("I should see \"<clientType>Metaweblog</clientType>\""); testRunner.And("I should see \"<clientType>Metaweblog</clientType>\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
@ -400,13 +428,13 @@ this.ScenarioSetup(scenarioInfo);
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when not at the root is reflected in the URL " + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when not at the root is reflected in the URL " +
"example for the slug field when creating a blog or blog post", ((string[])(null))); "example for the slug field when creating a blog or blog post", ((string[])(null)));
#line 130 #line 144
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 131 #line 145
testRunner.Given("I have installed Orchard at \"/OrchardLocal\""); testRunner.Given("I have installed Orchard at \"/OrchardLocal\"");
#line 132 #line 146
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line 133 #line 147
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/</span>\""); testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/</span>\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] {
@ -415,13 +443,17 @@ this.ScenarioSetup(scenarioInfo);
table13.AddRow(new string[] { table13.AddRow(new string[] {
"Routable.Title", "Routable.Title",
"My Blog"}); "My Blog"});
#line 134 #line 148
testRunner.When("I fill in", ((string)(null)), table13); testRunner.When("I fill in", ((string)(null)), table13);
#line 137 #line 151
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 138 #line 152
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.And("I go to \"admin/blogs\"");
#line 139 #line 153
testRunner.And("I follow \"My Blog\"");
#line 154
testRunner.And("I follow \"New Post\"");
#line 155
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/my-blog/</span>\""); testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/my-blog/</span>\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
@ -434,13 +466,13 @@ this.ScenarioSetup(scenarioInfo);
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when at the root is reflected in the URL exam" + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when at the root is reflected in the URL exam" +
"ple for the slug field when creating a blog or blog post", ((string[])(null))); "ple for the slug field when creating a blog or blog post", ((string[])(null)));
#line 141 #line 157
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 142 #line 158
testRunner.Given("I have installed Orchard at \"/\""); testRunner.Given("I have installed Orchard at \"/\"");
#line 143 #line 159
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line 144 #line 160
testRunner.Then("I should see \"<span>http\\://localhost/</span>\""); testRunner.Then("I should see \"<span>http\\://localhost/</span>\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] {
@ -449,30 +481,34 @@ this.ScenarioSetup(scenarioInfo);
table14.AddRow(new string[] { table14.AddRow(new string[] {
"Routable.Title", "Routable.Title",
"My Blog"}); "My Blog"});
#line 145 #line 161
testRunner.When("I fill in", ((string)(null)), table14); testRunner.When("I fill in", ((string)(null)), table14);
#line 148 #line 164
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 149 #line 165
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.And("I go to \"admin/blogs\"");
#line 150 #line 166
testRunner.And("I follow \"My Blog\"");
#line 167
testRunner.And("I follow \"New Post\"");
#line 168
testRunner.Then("I should see \"<span>http\\://localhost/my-blog/</span>\""); testRunner.Then("I should see \"<span>http\\://localhost/my-blog/</span>\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();
} }
[NUnit.Framework.TestAttribute()] [NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("I set my blog to be the content for the home page and the posts for the blog shou" + [NUnit.Framework.DescriptionAttribute("I set my blog to be the content for the home page and the posts for the blog be r" +
"ld still be at the blog path prefixed path")] "ooted to the app")]
public virtual void ISetMyBlogToBeTheContentForTheHomePageAndThePostsForTheBlogShouldStillBeAtTheBlogPathPrefixedPath() public virtual void ISetMyBlogToBeTheContentForTheHomePageAndThePostsForTheBlogBeRootedToTheApp()
{ {
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I set my blog to be the content for the home page and the posts for the blog shou" + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I set my blog to be the content for the home page and the posts for the blog be r" +
"ld still be at the blog path prefixed path", ((string[])(null))); "ooted to the app", ((string[])(null)));
#line 152 #line 170
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 153 #line 171
testRunner.Given("I have installed Orchard"); testRunner.Given("I have installed Orchard");
#line 154 #line 172
testRunner.When("I go to \"admin/blogs/create\""); testRunner.When("I go to \"admin/blogs/create\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] {
@ -484,12 +520,16 @@ this.ScenarioSetup(scenarioInfo);
table15.AddRow(new string[] { table15.AddRow(new string[] {
"Routable.PromoteToHomePage", "Routable.PromoteToHomePage",
"true"}); "true"});
#line 155 #line 173
testRunner.And("I fill in", ((string)(null)), table15); testRunner.And("I fill in", ((string)(null)), table15);
#line 159 #line 177
testRunner.And("I hit \"Save\""); testRunner.And("I hit \"Save\"");
#line 160 #line 178
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\""); testRunner.And("I go to \"admin/blogs\"");
#line 179
testRunner.And("I follow \"My Blog\"");
#line 180
testRunner.And("I follow \"New Post\"");
#line hidden #line hidden
TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] { TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] {
"name", "name",
@ -500,23 +540,23 @@ this.ScenarioSetup(scenarioInfo);
table16.AddRow(new string[] { table16.AddRow(new string[] {
"Body.Text", "Body.Text",
"Hi there."}); "Hi there."});
#line 161 #line 181
testRunner.And("I fill in", ((string)(null)), table16); testRunner.And("I fill in", ((string)(null)), table16);
#line 165 #line 185
testRunner.And("I hit \"Publish Now\""); testRunner.And("I hit \"Publish Now\"");
#line 166 #line 186
testRunner.And("I am redirected"); testRunner.And("I am redirected");
#line 167 #line 187
testRunner.And("I go to \"/Default.aspx\""); testRunner.And("I go to \"/Default.aspx\"");
#line 168 #line 188
testRunner.Then("I should see \"<h1>My Blog</h1>\""); testRunner.Then("I should see \"<h1>My Blog</h1>\"");
#line 169 #line 189
testRunner.When("I go to \"/my-blog\""); testRunner.When("I go to \"/my-blog\"");
#line 170 #line 190
testRunner.Then("the status should be 404 \"Not Found\""); testRunner.Then("the status should be 404 \"Not Found\"");
#line 171 #line 191
testRunner.When("I go to \"/my-blog/my-post\""); testRunner.When("I go to \"/my-post\"");
#line 172 #line 192
testRunner.Then("I should see \"<h1>My Post</h1>\""); testRunner.Then("I should see \"<h1>My Post</h1>\"");
#line hidden #line hidden
testRunner.CollectScenarioErrors(); testRunner.CollectScenarioErrors();

View File

@ -41,7 +41,7 @@ Scenario: If I create a page which gets a conflicting path generated its path is
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. 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 Given I have installed Orchard
When I go to "admin/contents/create/page" When I go to "admin/contents/create/page"
And I fill in And I fill in

View File

@ -166,11 +166,11 @@ this.ScenarioSetup(scenarioInfo);
[NUnit.Framework.TestAttribute()] [NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("A new page marked to be the home page and publish does take over the home page an" + [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.")] "d is not accessible from its own standard path")]
public virtual void ANewPageMarkedToBeTheHomePageAndPublishDoesTakeOverTheHomePageAndIsNotAccessibleFromItsOwnStandardPath_() 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" + 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))); "d is not accessible from its own standard path", ((string[])(null)));
#line 44 #line 44
this.ScenarioSetup(scenarioInfo); this.ScenarioSetup(scenarioInfo);
#line 45 #line 45

View File

@ -58,14 +58,7 @@ namespace Orchard.Core.Routable.Controllers {
throw new ApplicationException(T("Ambiguous content").Text); throw new ApplicationException(T("Ambiguous content").Text);
} }
var item = hits.Single(); dynamic model = _contentManager.BuildDisplay(hits.Single());
// primary action run for a home paged item shall not pass
if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext")
&& item.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) {
return HttpNotFound();
}
dynamic model = _contentManager.BuildDisplay(item);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }

View File

@ -16,6 +16,8 @@ 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 IContentManager _contentManager;
private readonly IWorkContextAccessor _workContextAccessor;
private readonly IHomePageProvider _routableHomePageProvider; private readonly IHomePageProvider _routableHomePageProvider;
public RoutePartHandler( public RoutePartHandler(
@ -23,11 +25,14 @@ namespace Orchard.Core.Routable.Handlers {
IRepository<RoutePartRecord> repository, IRepository<RoutePartRecord> repository,
IRoutablePathConstraint routablePathConstraint, IRoutablePathConstraint routablePathConstraint,
IRoutableService routableService, IRoutableService routableService,
IContentManager contentManager,
IWorkContextAccessor workContextAccessor, IWorkContextAccessor workContextAccessor,
IEnumerable<IHomePageProvider> homePageProviders) { IEnumerable<IHomePageProvider> homePageProviders) {
_services = services; _services = services;
_routablePathConstraint = routablePathConstraint; _routablePathConstraint = routablePathConstraint;
_routableService = routableService; _routableService = routableService;
_contentManager = contentManager;
_workContextAccessor = workContextAccessor;
_routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name); _routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
@ -47,9 +52,26 @@ namespace Orchard.Core.Routable.Handlers {
OnPublished<RoutePart>((context, route) => { OnPublished<RoutePart>((context, route) => {
FinalizePath(route, context, processSlug); FinalizePath(route, context, processSlug);
if (route.ContentItem.Id != 0 && route.PromoteToHomePage && _routableHomePageProvider != null) { if (route.Id != 0 && route.PromoteToHomePage && _routableHomePageProvider != null) {
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id); var homePageSetting = _workContextAccessor.GetContext().CurrentSite.HomePage;
_routablePathConstraint.AddPath(""); var currentHomePageId = !string.IsNullOrWhiteSpace(homePageSetting)
? _routableHomePageProvider.GetHomePageId(homePageSetting)
: 0;
if (currentHomePageId != route.Id) {
// reset the path on the current home page
var currentHomePage = _contentManager.Get(currentHomePageId);
if (currentHomePage != null)
FinalizePath(currentHomePage.As<RoutePart>(), context, processSlug);
// set the new home page
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id);
}
// readjust the constraints of the current current home page
_routablePathConstraint.RemovePath(route.Path);
route.Path = "";
_routableService.FixContainedPaths(route);
_routablePathConstraint.AddPath(route.Path);
} }
}); });

View File

@ -1,7 +1,5 @@
using System.Linq; using System.Linq;
using Orchard.Blogs.Services; using Orchard.Blogs.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Localization; using Orchard.Localization;
using Orchard.UI.Navigation; using Orchard.UI.Navigation;
@ -32,12 +30,12 @@ namespace Orchard.Blogs {
} }
else if (singleBlog != null) else if (singleBlog != null)
menu.Add(T("Manage Blog"), "1.0", menu.Add(T("Manage Blog"), "1.0",
item => item.Action("Item", "BlogAdmin", new { area = "Orchard.Blogs", blogSlug = singleBlog.As<IRoutableAspect>().Path }).Permission(Permissions.MetaListBlogs)); item => item.Action("Item", "BlogAdmin", new { area = "Orchard.Blogs", blogId = singleBlog.Id }).Permission(Permissions.MetaListBlogs));
if (singleBlog != null) if (singleBlog != null)
menu.Add(T("Create New Post"), "1.1", menu.Add(T("Create New Post"), "1.1",
item => item =>
item.Action("Create", "BlogPostAdmin", new { area = "Orchard.Blogs", blogSlug = singleBlog.As<IRoutableAspect>().Path }).Permission(Permissions.PublishBlogPost)); item.Action("Create", "BlogPostAdmin", new { area = "Orchard.Blogs", blogId = singleBlog.Id }).Permission(Permissions.PublishBlogPost));
menu.Add(T("Create New Blog"), "1.2", menu.Add(T("Create New Blog"), "1.2",
item => item =>

View File

@ -1,5 +1,4 @@
using System.Linq; using System.Linq;
using System.Reflection;
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Blogs.Extensions; using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
@ -50,7 +49,7 @@ namespace Orchard.Blogs.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs"))) if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
BlogPart blog = Services.ContentManager.New<BlogPart>("Blog"); var blog = Services.ContentManager.New<BlogPart>("Blog");
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -81,11 +80,11 @@ namespace Orchard.Blogs.Controllers {
return Redirect(Url.BlogForAdmin(blog)); return Redirect(Url.BlogForAdmin(blog));
} }
public ActionResult Edit(int id) { public ActionResult Edit(int blogId) {
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog"))) if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(id, VersionOptions.Latest); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -95,11 +94,11 @@ namespace Orchard.Blogs.Controllers {
} }
[HttpPost, ActionName("Edit")] [HttpPost, ActionName("Edit")]
public ActionResult EditPOST(int id) { public ActionResult EditPOST(int blogId) {
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog"))) if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(id, VersionOptions.DraftRequired); var blog = _blogService.Get(blogId, VersionOptions.DraftRequired);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -118,11 +117,11 @@ namespace Orchard.Blogs.Controllers {
} }
[HttpPost] [HttpPost]
public ActionResult Remove(int id) { public ActionResult Remove(int blogId) {
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog"))) if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(id, VersionOptions.Latest); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -148,8 +147,8 @@ namespace Orchard.Blogs.Controllers {
return View((object)viewModel); return View((object)viewModel);
} }
public ActionResult Item(string blogSlug, Pager pager) { public ActionResult Item(int blogId, Pager pager) {
BlogPart blogPart = _blogService.Get(blogSlug); BlogPart blogPart = _blogService.Get(blogId, VersionOptions.Latest).As<BlogPart>();
if (blogPart == null) if (blogPart == null)
return HttpNotFound(); return HttpNotFound();

View File

@ -80,11 +80,11 @@ namespace Orchard.Blogs.Controllers {
//todo: the content shape template has extra bits that the core contents module does not (remove draft functionality) //todo: the content shape template has extra bits that the core contents module does not (remove draft functionality)
//todo: - move this extra functionality there or somewhere else that's appropriate? //todo: - move this extra functionality there or somewhere else that's appropriate?
public ActionResult Edit(string blogSlug, int postId) { public ActionResult Edit(int blogId, int postId) {
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post"))) if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(blogSlug); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -99,8 +99,8 @@ namespace Orchard.Blogs.Controllers {
[HttpPost, ActionName("Edit")] [HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Save")] [FormValueRequired("submit.Save")]
public ActionResult EditPOST(string blogSlug, int postId, string returnUrl) { public ActionResult EditPOST(int blogId, int postId, string returnUrl) {
return EditPOST(blogSlug, postId, returnUrl, contentItem => { return EditPOST(blogId, postId, returnUrl, contentItem => {
if (!contentItem.Has<IPublishingControlAspect>() && !contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) if (!contentItem.Has<IPublishingControlAspect>() && !contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
Services.ContentManager.Publish(contentItem); Services.ContentManager.Publish(contentItem);
}); });
@ -108,15 +108,15 @@ namespace Orchard.Blogs.Controllers {
[HttpPost, ActionName("Edit")] [HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Publish")] [FormValueRequired("submit.Publish")]
public ActionResult EditAndPublishPOST(string blogSlug, int postId, string returnUrl) { public ActionResult EditAndPublishPOST(int blogId, int postId, string returnUrl) {
return EditPOST(blogSlug, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem)); return EditPOST(blogId, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem));
} }
public ActionResult EditPOST(string blogSlug, int postId, string returnUrl, Action<ContentItem> conditionallyPublish) { public ActionResult EditPOST(int blogId, int postId, string returnUrl, Action<ContentItem> conditionallyPublish) {
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post"))) if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(blogSlug); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -178,16 +178,16 @@ namespace Orchard.Blogs.Controllers {
ActionResult RedirectToEdit(IContent item) { ActionResult RedirectToEdit(IContent item) {
if (item == null || item.As<BlogPostPart>() == null) if (item == null || item.As<BlogPostPart>() == null)
return HttpNotFound(); return HttpNotFound();
return RedirectToAction("Edit", new { BlogSlug = item.As<IRoutableAspect>().Path, PostId = item.ContentItem.Id }); return RedirectToAction("Edit", new { BlogId = item.As<BlogPostPart>().BlogPart.Id, PostId = item.ContentItem.Id });
} }
[ValidateAntiForgeryTokenOrchard] [ValidateAntiForgeryTokenOrchard]
public ActionResult Delete(string blogSlug, int postId) { public ActionResult Delete(int blogId, int postId) {
//refactoring: test PublishBlogPost/PublishOthersBlogPost in addition if published //refactoring: test PublishBlogPost/PublishOthersBlogPost in addition if published
if (!Services.Authorizer.Authorize(Permissions.DeleteBlogPost, T("Couldn't delete blog post"))) if (!Services.Authorizer.Authorize(Permissions.DeleteBlogPost, T("Couldn't delete blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(blogSlug); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -198,15 +198,15 @@ namespace Orchard.Blogs.Controllers {
_blogPostService.Delete(post); _blogPostService.Delete(post);
Services.Notifier.Information(T("Blog post was successfully deleted")); Services.Notifier.Information(T("Blog post was successfully deleted"));
return Redirect(Url.BlogForAdmin(blog)); return Redirect(Url.BlogForAdmin(blog.As<BlogPart>()));
} }
[ValidateAntiForgeryTokenOrchard] [ValidateAntiForgeryTokenOrchard]
public ActionResult Publish(string blogSlug, int postId) { public ActionResult Publish(int blogId, int postId) {
if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't publish blog post"))) if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't publish blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(blogSlug); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -217,15 +217,15 @@ namespace Orchard.Blogs.Controllers {
_blogPostService.Publish(post); _blogPostService.Publish(post);
Services.Notifier.Information(T("Blog post successfully published.")); Services.Notifier.Information(T("Blog post successfully published."));
return Redirect(Url.BlogForAdmin(blog)); return Redirect(Url.BlogForAdmin(blog.As<BlogPart>()));
} }
[ValidateAntiForgeryTokenOrchard] [ValidateAntiForgeryTokenOrchard]
public ActionResult Unpublish(string blogSlug, int postId) { public ActionResult Unpublish(int blogId, int postId) {
if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't unpublish blog post"))) if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't unpublish blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var blog = _blogService.Get(blogSlug); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
return HttpNotFound(); return HttpNotFound();
@ -236,7 +236,7 @@ namespace Orchard.Blogs.Controllers {
_blogPostService.Unpublish(post); _blogPostService.Unpublish(post);
Services.Notifier.Information(T("Blog post successfully unpublished.")); Services.Notifier.Information(T("Blog post successfully unpublished."));
return Redirect(Url.BlogForAdmin(blog)); return Redirect(Url.BlogForAdmin(blog.As<BlogPart>()));
} }
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {

View File

@ -40,23 +40,23 @@ namespace Orchard.Blogs.Extensions {
} }
public static string BlogForAdmin(this UrlHelper urlHelper, BlogPart blogPart) { public static string BlogForAdmin(this UrlHelper urlHelper, BlogPart blogPart) {
return urlHelper.Action("Item", "BlogAdmin", new { blogSlug = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" }); return urlHelper.Action("Item", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogCreate(this UrlHelper urlHelper) { public static string BlogCreate(this UrlHelper urlHelper) {
return urlHelper.Action("Create", "BlogAdmin", new {area = "Orchard.Blogs"}); return urlHelper.Action("Create", "BlogAdmin", new { area = "Orchard.Blogs" });
} }
public static string BlogEdit(this UrlHelper urlHelper, BlogPart blogPart) { public static string BlogEdit(this UrlHelper urlHelper, BlogPart blogPart) {
return urlHelper.Action("Edit", "BlogAdmin", new { blogPart.Id, area = "Orchard.Blogs" }); return urlHelper.Action("Edit", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogRemove(this UrlHelper urlHelper, BlogPart blogPart) { public static string BlogRemove(this UrlHelper urlHelper, BlogPart blogPart) {
return urlHelper.Action("Remove", "BlogAdmin", new { blogPart.Id, area = "Orchard.Blogs" }); return urlHelper.Action("Remove", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogPostCreate(this UrlHelper urlHelper, BlogPart blogPart) { public static string BlogPostCreate(this UrlHelper urlHelper, BlogPart blogPart) {
return urlHelper.Action("Create", "BlogPostAdmin", new { blogSlug = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" }); return urlHelper.Action("Create", "BlogPostAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogPost(this UrlHelper urlHelper, BlogPostPart blogPostPart) { public static string BlogPost(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
@ -64,19 +64,19 @@ namespace Orchard.Blogs.Extensions {
} }
public static string BlogPostEdit(this UrlHelper urlHelper, BlogPostPart blogPostPart) { public static string BlogPostEdit(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
return urlHelper.Action("Edit", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" }); return urlHelper.Action("Edit", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogPostDelete(this UrlHelper urlHelper, BlogPostPart blogPostPart) { public static string BlogPostDelete(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
return urlHelper.Action("Delete", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" }); return urlHelper.Action("Delete", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogPostPublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) { public static string BlogPostPublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
return urlHelper.Action("Publish", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" }); return urlHelper.Action("Publish", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
} }
public static string BlogPostUnpublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) { public static string BlogPostUnpublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
return urlHelper.Action("Unpublish", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" }); return urlHelper.Action("Unpublish", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
} }
} }
} }

View File

@ -65,13 +65,13 @@ namespace Orchard.Blogs.Handlers {
{"Area", "Orchard.Blogs"}, {"Area", "Orchard.Blogs"},
{"Controller", "BlogAdmin"}, {"Controller", "BlogAdmin"},
{"Action", "Edit"}, {"Action", "Edit"},
{"Id", context.ContentItem.Id} {"blogId", context.ContentItem.Id}
}; };
context.Metadata.RemoveRouteValues = new RouteValueDictionary { context.Metadata.RemoveRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"}, {"Area", "Orchard.Blogs"},
{"Controller", "BlogAdmin"}, {"Controller", "BlogAdmin"},
{"Action", "Remove"}, {"Action", "Remove"},
{"Id", context.ContentItem.Id} {"blogId", context.ContentItem.Id}
}; };
} }
} }

View File

@ -30,9 +30,10 @@ namespace Orchard.Blogs.Handlers {
OnUpdateEditorShape<BlogPostPart>(SetModelProperties); OnUpdateEditorShape<BlogPostPart>(SetModelProperties);
OnInitializing<BlogPostPart>((context, bp) => { OnInitializing<BlogPostPart>((context, bp) => {
var blogSlug = requestContext.RouteData.Values.ContainsKey("blogSlug") ? requestContext.RouteData.Values["blogSlug"] as string : null; var blogId = requestContext.RouteData.Values.ContainsKey("blogId") ? requestContext.RouteData.Values["blogId"] as string : null;
if (!string.IsNullOrEmpty(blogSlug)) { if (!string.IsNullOrEmpty(blogId)) {
bp.BlogPart = blogService.Get(blogSlug); var blog = blogService.Get(int.Parse(blogId), VersionOptions.Latest);
bp.BlogPart = blog.As<BlogPart>();
return; return;
} }
@ -72,14 +73,14 @@ namespace Orchard.Blogs.Handlers {
{"Area", "Orchard.Blogs"}, {"Area", "Orchard.Blogs"},
{"Controller", "BlogPostAdmin"}, {"Controller", "BlogPostAdmin"},
{"Action", "Create"}, {"Action", "Create"},
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug} {"blogId", blogPost.BlogPart.Id}
}; };
context.Metadata.EditorRouteValues = new RouteValueDictionary { context.Metadata.EditorRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"}, {"Area", "Orchard.Blogs"},
{"Controller", "BlogPostAdmin"}, {"Controller", "BlogPostAdmin"},
{"Action", "Edit"}, {"Action", "Edit"},
{"postId", context.ContentItem.Id}, {"postId", context.ContentItem.Id},
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug} {"blogId", blogPost.BlogPart.Id}
}; };
context.Metadata.RemoveRouteValues = new RouteValueDictionary { context.Metadata.RemoveRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Blogs"}, {"Area", "Orchard.Blogs"},

View File

@ -35,7 +35,7 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{id}/Edit", "Admin/Blogs/{blogId}/Edit",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogAdmin"}, {"controller", "BlogAdmin"},
@ -49,7 +49,7 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{id}/Remove", "Admin/Blogs/{blogId}/Remove",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogAdmin"}, {"controller", "BlogAdmin"},
@ -63,15 +63,13 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{blogSlug}", "Admin/Blogs/{blogId}",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogAdmin"}, {"controller", "BlogAdmin"},
{"action", "Item"} {"action", "Item"}
}, },
new RouteValueDictionary { new RouteValueDictionary (),
{"blogSlug", _blogSlugConstraint}
},
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"} {"area", "Orchard.Blogs"}
}, },
@ -79,15 +77,13 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{blogSlug}/Posts/Create", "Admin/Blogs/{blogId}/Posts/Create",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPostAdmin"}, {"controller", "BlogPostAdmin"},
{"action", "Create"} {"action", "Create"}
}, },
new RouteValueDictionary { new RouteValueDictionary (),
{"blogSlug", _blogSlugConstraint}
},
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"} {"area", "Orchard.Blogs"}
}, },
@ -95,15 +91,13 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{blogSlug}/Posts/{postId}/Edit", "Admin/Blogs/{blogId}/Posts/{postId}/Edit",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPostAdmin"}, {"controller", "BlogPostAdmin"},
{"action", "Edit"} {"action", "Edit"}
}, },
new RouteValueDictionary { new RouteValueDictionary (),
{"blogSlug", _blogSlugConstraint}
},
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"} {"area", "Orchard.Blogs"}
}, },
@ -111,15 +105,13 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{blogSlug}/Posts/{postId}/Delete", "Admin/Blogs/{blogId}/Posts/{postId}/Delete",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPostAdmin"}, {"controller", "BlogPostAdmin"},
{"action", "Delete"} {"action", "Delete"}
}, },
new RouteValueDictionary { new RouteValueDictionary (),
{"blogSlug", _blogSlugConstraint}
},
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"} {"area", "Orchard.Blogs"}
}, },
@ -127,15 +119,13 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{blogSlug}/Posts/{postId}/Publish", "Admin/Blogs/{blogId}/Posts/{postId}/Publish",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPostAdmin"}, {"controller", "BlogPostAdmin"},
{"action", "Publish"} {"action", "Publish"}
}, },
new RouteValueDictionary { new RouteValueDictionary (),
{"blogSlug", _blogSlugConstraint}
},
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"} {"area", "Orchard.Blogs"}
}, },
@ -143,15 +133,13 @@ namespace Orchard.Blogs {
}, },
new RouteDescriptor { new RouteDescriptor {
Route = new Route( Route = new Route(
"Admin/Blogs/{blogSlug}/Posts/{postId}/Unpublish", "Admin/Blogs/{blogId}/Posts/{postId}/Unpublish",
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"}, {"area", "Orchard.Blogs"},
{"controller", "BlogPostAdmin"}, {"controller", "BlogPostAdmin"},
{"action", "Unpublish"} {"action", "Unpublish"}
}, },
new RouteValueDictionary { new RouteValueDictionary (),
{"blogSlug", _blogSlugConstraint}
},
new RouteValueDictionary { new RouteValueDictionary {
{"area", "Orchard.Blogs"} {"area", "Orchard.Blogs"}
}, },

View File

@ -281,8 +281,9 @@ namespace Orchard.Setup.Services {
// create a welcome page that's promoted to the home page // create a welcome page that's promoted to the home page
var page = contentManager.Create("Page", VersionOptions.Draft); var page = contentManager.Create("Page", VersionOptions.Draft);
page.As<RoutePart>().Title = T("Welcome to Orchard!").Text; page.As<RoutePart>().Title = T("Welcome to Orchard!").Text;
page.As<RoutePart>().Path = ""; page.As<RoutePart>().Path = "welcome-to-orchard";
page.As<RoutePart>().Slug = ""; page.As<RoutePart>().Slug = "welcome-to-orchard";
page.As<RoutePart>().PromoteToHomePage = true;
page.As<BodyPart>().Text = T( page.As<BodyPart>().Text = T(
@"<p>You've successfully setup your Orchard Site and this is the homepage of your new site. @"<p>You've successfully setup your Orchard Site and this is the homepage of your new site.
Here are a few things you can look at to get familiar with the application. Here are a few things you can look at to get familiar with the application.
@ -304,7 +305,6 @@ Modules are created by other users of Orchard just like you so if you feel up to
<p>Thanks for using Orchard The Orchard Team </p>", page.Id).Text; <p>Thanks for using Orchard The Orchard Team </p>", page.Id).Text;
contentManager.Publish(page); contentManager.Publish(page);
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;
// add a menu item for the shiny new home page // add a menu item for the shiny new home page
var menuItem = contentManager.Create("MenuItem"); var menuItem = contentManager.Create("MenuItem");